#!/usr/bin/env python3 # wall2_recscan.py - scan the guest RAM for the RM's low-aperture window # records and their memdesc PAs. # # Record layout (verified r685/r686): 0x40-byte stride # {u64 tag; u64 VA; u64 SIZE; u64 0; u32 0x7461696c ("tail" as a u32 - # on disk the BYTES are "liat"); u32 0} # The tag is NOT the byte string "tail" - searching for b'tail' finds # nothing; search for the 4-byte pattern 6c 69 61 74 (struct ' 1: want = int(sys.argv[1], 0) img = open(RAM, "rb", buffering=0) img.seek(0, 2); fsz = img.tell() recs = [] pos = 0; CH = 64 << 20 while pos < fsz: img.seek(pos); buf = img.read(min(CH, fsz - pos)) st = 0 while True: i = buf.find(TAG, st) if i < 0: break st = i + 1 if i >= 0x20: tag, va, sz, z = struct.unpack_from("