#!/bin/bash # pin_client_sems.sh - bridge the CUDA client's device mappings into the # emulation for the live cdt process. # # Two things are pinned, both per-process (a new cdt maps new physical pages # at the same VAs, so re-run this for every cdt run): # 1. the /dev/nvidia0 window: the driver's channel rings/USERDs (the GR # channels' GPFIFO VAs live here), so the pump can run their pushes; # 2. the semaphore pages libcuda's trackers poll (found by scanning the # client's memory for sem references, then translated through the guest # pagemap). # # Usage: tools/guest-diag/pin_client_sems.sh [iterations] [sleep-secs] set -u cd "$(dirname "$(readlink -f "$0")")/../.." VMEXEC=./scripts/vgpu_vm.py ITER=${1:-1} SLEEP=${2:-10} PID=$(timeout 20 $VMEXEC exec --timeout 15 'pgrep -x cdt | head -1' 2>/dev/null | tail -1) [ -n "$PID" ] || { echo "no cdt pid"; exit 1; } echo "cdt pid=$PID" B64=$(gzip -9 < tools/guest-diag/sempages.py | base64 -w0) timeout 30 $VMEXEC exec --timeout 25 "echo '$B64' | base64 -d | gunzip > /tmp/sempages.py" >/dev/null 2>&1 B64=$(gzip -9 < tools/guest-diag/memprobe.py | base64 -w0) timeout 30 $VMEXEC exec --timeout 25 "echo '$B64' | base64 -d | gunzip > /tmp/memprobe.py" >/dev/null 2>&1 B64=$(base64 -w0 tools/guest-diag/guest_pmap_all.py) timeout 30 $VMEXEC exec --timeout 25 "echo '$B64' | base64 -d > /tmp/pmapall.py" >/dev/null 2>&1 pin_range() { # pin_range