diff options
| author | Arthur Hanson Rasmusson <arthur@vgpu.io> | 2026-09-30 03:20:38 -0400 |
|---|---|---|
| committer | Arthur Hanson Rasmusson <arthur@vgpu.io> | 2026-09-30 03:20:38 -0400 |
| commit | 54aa7aa028276bf2e11a77757e43289330a9785f (patch) | |
| tree | ad92631cf91b9b56c0348717f2aea7b1fc0474ce /tools | |
| parent | fe9297d33fa495996f6ac1609a52c8091dc4d110 (diff) | |
| download | open-iov-54aa7aa028276bf2e11a77757e43289330a9785f.tar.gz open-iov-54aa7aa028276bf2e11a77757e43289330a9785f.zip | |
guest-diag: bpz19 - attach-mode path trace through FUN_0042aec0
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/guest-diag/bpz19.py | 77 | ||||
| -rwxr-xr-x | tools/guest-diag/push_guest_tools.sh | 1 |
2 files changed, 78 insertions, 0 deletions
diff --git a/tools/guest-diag/bpz19.py b/tools/guest-diag/bpz19.py new file mode 100644 index 0000000..9dfed68 --- /dev/null +++ b/tools/guest-diag/bpz19.py @@ -0,0 +1,77 @@ +# gdb script: trace the path through FUN_0042aec0 (GPU arch/config init) by +# attaching to a running cdt at the CDT_PAUSE (bpz18 variant). +# +# Host: c48=6 c4c=0x27 c50=7 c54=5 e94=0x18. Guest reaches same c48..c54 but +# e94=0, so some branch inside FUN_0042aec0 diverges. This logs hits on: +# 0x32aec0 FUN_0042aec0 entry +# 0x32b0b7 after chip-info store +# 0x32c911 the 0xc4c dispatch +# 0x32e8be case index 1 body (sets e94=0x18) +# 0x32e46a default target of the dispatch +# 0x2e3e80 FUN_003e3e80 (terminator; dumps ds fields) +import gdb +import time + +gdb.execute("set pagination off") +gdb.execute("set confirm off") +out = gdb.execute("info proc mappings", to_string=True) +base = None +for line in out.splitlines(): + if "libcuda" in line and "r-xp" in line: + f = line.split() + base = int(f[0], 16) - int(f[3], 16) + break +print("BASE=0x%x" % (base or 0)) +if base is None: + raise SystemExit + +SITES = [ + (0x32aec0, "F42AEC0_ENTRY"), + (0x32b0b7, "AFTER_CHIPINFO"), + (0x32c911, "C4C_DISPATCH"), + (0x32e8be, "CASE1_e94_0x18"), + (0x32e46a, "DISPATCH_DEFAULT"), +] +for off, name in SITES: + gdb.execute("break *0x%x" % (base + off)) +CALLER_RET = base + 0xd0eae1 +gdb.execute("break *0x%x" % (base + 0x2e3e80)) + +def rd(addr, n=4, fmt="unsigned int"): + try: + return int(gdb.parse_and_eval("*(%s*)0x%x" % (fmt, addr))) & ((1 << (8 * n)) - 1) + except Exception: + return None + +t0 = time.time() +for hit in range(120): + try: + gdb.execute("continue") + except gdb.error as e: + print("CONTINUE_END %s" % e) + break + rip = int(gdb.parse_and_eval("$rip")) & 0xffffffffffffffff + off = rip - base + if off == 0x2e3e80: + ret = rd(int(gdb.parse_and_eval("$rsp")), 8, "unsigned long") + if ret != CALLER_RET: + continue + rdi = int(gdb.parse_and_eval("$rdi")) & 0xffffffffffffffff + ds = rd(rdi + 0x40, 8, "unsigned long") + print("TERMINATOR FUN_003e3e80 dev=0x%x ds=0x%x t=%.3f" % (rdi, ds or 0, time.time() - t0)) + for o in [0xc48, 0xc4c, 0xc50, 0xc54, 0xe94, 0x4354, 0x426c]: + print(" ds+0x%x = 0x%x" % (o, rd(ds + o) or 0)) + break + name = dict((o, n) for o, n in SITES).get(off, "?") + rcx = int(gdb.parse_and_eval("$rcx")) & 0xffffffffffffffff + eax = rd("$eax") if False else (int(gdb.parse_and_eval("$eax")) & 0xffffffff) + extra = "" + if off == 0x32c911: + extra = " c4c=0x%x arch=0x%x" % (rd(rcx + 0xc4c) or 0, rd(rcx + 0xc50) or 0) + print("HIT t=%.3f +0x%x %s eax=0x%x rcx=0x%x%s" % + (time.time() - t0, off, name, eax, rcx, extra)) + +try: + gdb.execute("detach") +except Exception: + pass diff --git a/tools/guest-diag/push_guest_tools.sh b/tools/guest-diag/push_guest_tools.sh index ffb9b29..873a7fc 100755 --- a/tools/guest-diag/push_guest_tools.sh +++ b/tools/guest-diag/push_guest_tools.sh @@ -43,6 +43,7 @@ push_b64 "$HERE/bpz12.py" /tmp/bpz12.py push_b64 "$HERE/bpz13.py" /tmp/bpz13.py push_b64 "$HERE/bpz14.py" /tmp/bpz14.py push_b64 "$HERE/bpz16.py" /tmp/bpz16.py +push_b64 "$HERE/bpz19.py" /tmp/bpz19.py push_b64 "$HERE/invd.py" /tmp/invd.py push_b64 "$HERE/bpwait.py" /tmp/bpwait.py push_b64 "$HERE/ctx999.py" /tmp/ctx999.py |
