summaryrefslogtreecommitdiffstats
path: root/tools/guest-diag/pmap_va.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/guest-diag/pmap_va.sh')
-rwxr-xr-xtools/guest-diag/pmap_va.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/guest-diag/pmap_va.sh b/tools/guest-diag/pmap_va.sh
new file mode 100755
index 0000000..e5bcef4
--- /dev/null
+++ b/tools/guest-diag/pmap_va.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+# pmap_va.sh <pid|name> <hex-va> [hex-va ...]
+# Push guest_pmap.py to the running VM and translate the VAs of the named
+# process through the guest's own pagemap (root in the guest).
+set -u
+cd "$(dirname "$0")/../.."
+
+TARGET="$1"; shift
+VAS="$*"
+
+B64=$(base64 -w0 tools/guest-diag/guest_pmap.py)
+timeout 30 ./scripts/vgpu_vm.py exec --timeout 25 \
+ "echo '$B64' | base64 -d > /tmp/pmap.py" >/dev/null 2>&1
+
+if ! [[ "$TARGET" =~ ^[0-9]+$ ]]; then
+ PID=$(timeout 20 ./scripts/vgpu_vm.py exec --timeout 15 "pgrep -x $TARGET | head -1" 2>/dev/null | tail -1)
+ [ -n "$PID" ] && TARGET="$PID"
+fi
+[ -n "$TARGET" ] || { echo "no pid found"; exit 1; }
+
+timeout 60 ./scripts/vgpu_vm.py exec --timeout 55 "sudo python3 /tmp/pmap.py $TARGET $VAS" 2>/dev/null | grep -E '^VA='