1 /* test long rmap chains */ 2 3 #include "libcflat.h" 4 #include "fwcfg.h" 5 #include "vm.h" 6 #include "smp.h" 7 #include "alloc_page.h" 8 9 int main (void) 10 { 11 int i; 12 int nr_pages; 13 void *target_page, *virt_addr; 14 15 setup_vm(); 16 17 nr_pages = fwcfg_get_u64(FW_CFG_RAM_SIZE) / PAGE_SIZE; 18 nr_pages -= 1000; 19 target_page = alloc_page(); 20 21 virt_addr = (void *) 0xfffffa000; 22 for (i = 0; i < nr_pages; i++) { 23 install_page(phys_to_virt(read_cr3()), virt_to_phys(target_page), 24 virt_addr); 25 virt_addr += PAGE_SIZE; 26 } 27 printf("created %d mappings\n", nr_pages); 28 29 virt_addr = (void *) 0xfffffa000; 30 for (i = 0; i < nr_pages; i++) { 31 unsigned long *touch = virt_addr; 32 33 *touch = 0; 34 virt_addr += PAGE_SIZE; 35 } 36 printf("instantiated mappings\n"); 37 38 virt_addr += PAGE_SIZE; 39 install_pte(phys_to_virt(read_cr3()), 1, virt_addr, 40 0 | PT_PRESENT_MASK | PT_WRITABLE_MASK, target_page); 41 42 *(unsigned long *)virt_addr = 0; 43 printf("PASS\n"); 44 45 return 0; 46 } 47