#!/usr/bin/env python3 """Did programming VM context 1 actually take effect? Read the registers back. `vmid_proof.py conf` configured MM VM context 1 with context 0's root page table and vmid=1 still failed. Before concluding anything about the mechanism, verify the configuration was actually applied -- an unapplied write would make that negative meaningless. Prints context 0 vs context 1 for every register `enable_vm_addressing` writes, on each MM instance, so a mismatch is visible rather than assumed. """ import sys sys.path.insert(0,'/root/psp/hw') from tinygrad import Device adev=Device["AMD"].iface.dev_impl g=adev.gmc print('mm_insts=%s vmhubs=%s'%(g.mm_insts, getattr(g,'vmhubs','?')), flush=True) def dump(tag): for inst in g.mm_insts: row=[] for c in (0,1): vals={} for nm in ('PAGE_TABLE_START_ADDR_LO32','PAGE_TABLE_END_ADDR_LO32', 'PAGE_TABLE_BASE_ADDR_LO32','CNTL'): try: vals[nm]=adev.reg(f"regMMVM_CONTEXT{c}_{nm}").read(inst=inst) except Exception as e: vals[nm]='ERR' row.append(vals) print(' %-10s inst%d ctx0 base=%#-12x cntl=%#-10x | ctx1 base=%#-12x cntl=%#x' %(tag,inst,row[0]['PAGE_TABLE_BASE_ADDR_LO32'],row[0]['CNTL'], row[1]['PAGE_TABLE_BASE_ADDR_LO32'],row[1]['CNTL']), flush=True) print(' ctx0 start=%#-12x end=%#-12x | ctx1 start=%#-12x end=%#x' %(row[0]['PAGE_TABLE_START_ADDR_LO32'],row[0]['PAGE_TABLE_END_ADDR_LO32'], row[1]['PAGE_TABLE_START_ADDR_LO32'],row[1]['PAGE_TABLE_END_ADDR_LO32']), flush=True) dump('before') for inst in g.mm_insts: g.enable_vm_addressing(adev.mm.root_page_table, "MM", vmid=1, inst=inst) g.flush_tlb(ip="MM", vmid=1) dump('after')