@@ -391,40 +391,56 @@ static const char* pagetag_cloneable_and_global(uint64_t entry)
391391}
392392
393393TINYKVM_COLD ()
394- void print_pte (const vMemory& memory, uint64_t pte_addr, uint64_t pte_mem)
394+ static const char * leaf_pagetable_bits (uint64_t entry)
395+ {
396+ if (entry & (PDE64_ACCESSED | PDE64_DIRTY) == (PDE64_ACCESSED | PDE64_DIRTY)) {
397+ return " A+D" ;
398+ } else if (entry & PDE64_ACCESSED) {
399+ return " A" ;
400+ } else if (entry & PDE64_DIRTY) {
401+ return " D" ;
402+ } else {
403+ return " " ;
404+ }
405+ }
406+ TINYKVM_COLD ()
407+ static void print_pte (const vMemory& memory, uint64_t pte_addr, uint64_t pte_mem)
395408{
396409 uint64_t * pt = memory.page_at (pte_mem);
397410 for (uint64_t i = 0 ; i < 512 ; i++) {
398411 if (pt[i] & PDE64_PRESENT) {
399- printf (" |-- 4k PT (0x%lX): 0x%lX W=%lu E=%d %s %s\n " ,
412+ printf (" |-- 4k PT (0x%lX): 0x%lX W=%lu E=%d %s %s%s \n " ,
400413 pte_addr + (i << 12 ), pt[i] & PDE64_ADDR_MASK,
401414 pt[i] & PDE64_RW, !(pt[i] & PDE64_NX),
402415 (pt[i] & PDE64_USER) ? " USER" : " KERNEL" ,
403- pagetag_cloneable_and_global (pt[i]));
416+ pagetag_cloneable_and_global (pt[i]),
417+ leaf_pagetable_bits (pt[i]));
404418 }
405419 }
406420}
407421TINYKVM_COLD ()
408- void print_pd (const vMemory& memory, uint64_t pd_addr, uint64_t pd_mem)
422+ static void print_pd (const vMemory& memory, uint64_t pd_addr, uint64_t pd_mem)
409423{
410424 uint64_t * pd = memory.page_at (pd_mem);
411425 for (uint64_t i = 0 ; i < 512 ; i++) {
412426 if (pd[i] & PDE64_PRESENT) {
413427 uint64_t addr = pd_addr + (i << 21 );
414428 uint64_t mem = pd[i] & PDE64_ADDR_MASK;
415- printf (" |-* 2MB PD (0x%lX): 0x%lX W=%lu E=%d %s %s\n " ,
429+ const bool is_leaf = (pd[i] & PDE64_PS) != 0 ;
430+ printf (" |-* 2MB PD (0x%lX): 0x%lX W=%lu E=%d %s %s%s\n " ,
416431 addr, mem,
417432 pd[i] & PDE64_RW, !(pd[i] & PDE64_NX),
418433 (pd[i] & PDE64_USER) ? " USER" : " KERNEL" ,
419- pagetag_cloneable_and_global (pd[i]));
420- if (!(pd[i] & PDE64_PS)) {
434+ pagetag_cloneable_and_global (pd[i]),
435+ is_leaf ? leaf_pagetable_bits (pd[i]) : " " );
436+ if (!is_leaf) {
421437 print_pte (memory, addr, mem);
422438 }
423439 }
424440 }
425441}
426442TINYKVM_COLD ()
427- void print_pdpt (const vMemory& memory, uint64_t pdpt_base, uint64_t pdpt_mem)
443+ static void print_pdpt (const vMemory& memory, uint64_t pdpt_base, uint64_t pdpt_mem)
428444{
429445 uint64_t * pdpt = memory.page_at (pdpt_mem);
430446 for (uint64_t i = 0 ; i < 512 ; i++) {
0 commit comments