Avi Kivity | 7d36db3 | 2010-08-03 14:07:34 +0300 | [diff] [blame] | 1 | /* test long rmap chains */ |
| 2 | |
| 3 | #include "libcflat.h" |
Gleb Natapov | 002d183 | 2013-02-11 15:10:32 +0200 | [diff] [blame] | 4 | #include "fwcfg.h" |
Avi Kivity | 7d36db3 | 2010-08-03 14:07:34 +0300 | [diff] [blame] | 5 | #include "vm.h" |
Paolo Bonzini | dcda215 | 2017-10-23 15:00:53 +0200 | [diff] [blame] | 6 | #include "vmalloc.h" |
Avi Kivity | 7d36db3 | 2010-08-03 14:07:34 +0300 | [diff] [blame] | 7 | #include "smp.h" |
Paolo Bonzini | 5aca024 | 2017-10-22 15:19:32 +0200 | [diff] [blame] | 8 | #include "alloc_page.h" |
Avi Kivity | 7d36db3 | 2010-08-03 14:07:34 +0300 | [diff] [blame] | 9 | |
Avi Kivity | 7d36db3 | 2010-08-03 14:07:34 +0300 | [diff] [blame] | 10 | int main (void) |
| 11 | { |
| 12 | int i; |
| 13 | int nr_pages; |
| 14 | void *target_page, *virt_addr; |
| 15 | |
| 16 | setup_vm(); |
| 17 | |
Gleb Natapov | 002d183 | 2013-02-11 15:10:32 +0200 | [diff] [blame] | 18 | nr_pages = fwcfg_get_u64(FW_CFG_RAM_SIZE) / PAGE_SIZE; |
Avi Kivity | 7d36db3 | 2010-08-03 14:07:34 +0300 | [diff] [blame] | 19 | nr_pages -= 1000; |
| 20 | target_page = alloc_page(); |
| 21 | |
| 22 | virt_addr = (void *) 0xfffffa000; |
| 23 | for (i = 0; i < nr_pages; i++) { |
| 24 | install_page(phys_to_virt(read_cr3()), virt_to_phys(target_page), |
| 25 | virt_addr); |
| 26 | virt_addr += PAGE_SIZE; |
| 27 | } |
| 28 | printf("created %d mappings\n", nr_pages); |
| 29 | |
| 30 | virt_addr = (void *) 0xfffffa000; |
| 31 | for (i = 0; i < nr_pages; i++) { |
| 32 | unsigned long *touch = virt_addr; |
| 33 | |
| 34 | *touch = 0; |
| 35 | virt_addr += PAGE_SIZE; |
| 36 | } |
| 37 | printf("instantiated mappings\n"); |
| 38 | |
| 39 | virt_addr += PAGE_SIZE; |
| 40 | install_pte(phys_to_virt(read_cr3()), 1, virt_addr, |
Alexander Gordeev | d10d16e | 2016-06-06 12:25:26 +0200 | [diff] [blame] | 41 | 0 | PT_PRESENT_MASK | PT_WRITABLE_MASK, target_page); |
Avi Kivity | 7d36db3 | 2010-08-03 14:07:34 +0300 | [diff] [blame] | 42 | |
| 43 | *(unsigned long *)virt_addr = 0; |
| 44 | printf("PASS\n"); |
| 45 | |
| 46 | return 0; |
| 47 | } |