summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/guest-diag/memprobe.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/tools/guest-diag/memprobe.py b/tools/guest-diag/memprobe.py
index 96dd40b..c2bab9f 100644
--- a/tools/guest-diag/memprobe.py
+++ b/tools/guest-diag/memprobe.py
@@ -72,12 +72,24 @@ def scan_qwords(pid, fd, lo, hi, needle_lo=None, needle_hi=None, needle_set=None
return hits
def sem_objs(pid, fd, lo, hi):
- # qword in [lo,hi) at address A -> a sem object holds it at +0x10
+ # A real sem object stores its GPU VA three times, at so+0x08, so+0x10 and
+ # so+0x18. Requiring a duplicated neighbour keeps the scan selective: a
+ # bare qword in the window matches thousands of unrelated pointers once
+ # the ring/pushbuffer windows are part of the range.
first = scan_qwords(pid, fd, None, None, needle_lo=lo, needle_hi=hi)
- out = {}
+ cand = {}
for addr, val in first:
- so = addr - 0x10
- out.setdefault(val, set()).add(so)
+ cand.setdefault(val, set()).add(addr)
+ out = {}
+ for val, addrs in cand.items():
+ for a in addrs:
+ buf = rd(fd, a - 8, 0x20)
+ if not buf or len(buf) < 0x20:
+ continue
+ q0, q1, q2, q3 = (r64(buf, i) for i in (0, 8, 0x10, 0x18))
+ if q1 == val and (q0 == val or q2 == val) and \
+ (q2 == val or q3 == val):
+ out.setdefault(val, set()).add(a - 0x10)
return out
def find_trackers(pid, fd, lo, hi, limit=8):