From 3b9432714a0515b89309ff2e6c1983690fb67761 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Rasmusson Date: Thu, 24 Sep 2026 01:58:15 -0400 Subject: kernel: validate learned semaphore maps and post guest GPU events - admit {GPU VA -> PA} pairs only when the preceding bytes form a valid client memory descriptor header (type 0/1, CPU+GPU mapped bits), prefer validated pairs over headerless candidates under first-wins dedup, and invalidate the translation cache on every rebuild; fixes stale identity entries shadowing live pool pages and lets the guest UVM channel bring-up complete on its own - capture OS event allocations (class 0x79) and post event records (function 0x1003) into the guest status queue when a channel's busy notification is consumed, with a broadcast fallback, serialized with replies via a queue lock - add BAR0 shadow introspection (dump_bar0/scan_bar0) and guest-side diagnostic scripts for the VM cycle --- tools/guest-diag/guest_pmap.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tools/guest-diag/guest_pmap.py (limited to 'tools/guest-diag/guest_pmap.py') diff --git a/tools/guest-diag/guest_pmap.py b/tools/guest-diag/guest_pmap.py new file mode 100644 index 0000000..96b7ddc --- /dev/null +++ b/tools/guest-diag/guest_pmap.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +# guest-side helper: translate GPU/user VAs of a process through its pagemap. +# Usage: sudo python3 guest_pmap.py [hex-va ...] +import os +import sys + +pid = int(sys.argv[1]) +vas = [int(x, 16) for x in sys.argv[2:]] + +maps = [] +try: + with open('/proc/%d/maps' % pid) as f: + for line in f: + parts = line.split() + a, b = parts[0].split('-') + maps.append((int(a, 16), int(b, 16), line.strip())) +except OSError as e: + print('MAPS_ERROR: %s' % e) + +def in_maps(va): + for a, b, line in maps: + if a <= va < b: + return line + return None + +fd = os.open('/proc/%d/pagemap' % pid, os.O_RDONLY) +try: + for va in vas: + os.lseek(fd, (va // 4096) * 8, 0) + e = int.from_bytes(os.read(fd, 8), 'little') + present = (e >> 63) & 1 + pfn = e & ((1 << 55) - 1) + pa = (pfn << 12) | (va & 0xfff) + line = in_maps(va) + print('VA=0x%x present=%d PA=0x%x map=%s' % (va, present, pa, line if line else '-')) +finally: + os.close(fd) -- cgit v1.2.3