kernel/vm: Add sanity check for page_num in "page" KDL command.

On some rare memory-corruption KDLs, I have seen pages with
"0" for all fields including page_num. So now we compute the
expected page number from the page's offset into sPages
and print an additional line if it doesn't match what's in the
page structure.
This commit is contained in:
Augustin Cavalier 2024-05-28 17:04:18 -04:00
parent d12b3a0e1d
commit 56c6878258
1 changed files with 5 additions and 2 deletions

View File

@ -955,11 +955,14 @@ dump_page_long(int argc, char **argv)
page = vm_lookup_page(pageAddress / B_PAGE_SIZE);
}
const page_num_t expected = sPhysicalPageOffset + (page - sPages);
kprintf("PAGE: %p\n", page);
kprintf("queue_next,prev: %p, %p\n", page->queue_link.next,
page->queue_link.previous);
kprintf("physical_number: %#" B_PRIxPHYSADDR "\n",
page->physical_page_number);
kprintf("physical_number: %#" B_PRIxPHYSADDR "\n", page->physical_page_number);
if (page->physical_page_number != expected)
kprintf("\t(expected %#" B_PRIxSIZE ")!\n", expected);
kprintf("cache: %p\n", page->Cache());
kprintf("cache_offset: %" B_PRIuPHYSADDR "\n", page->cache_offset);
kprintf("cache_next: %p\n", page->cache_next);