blob: 3433dda8c7a07d77fa83f6c862df22f0e489feef [file] [log] [blame]
Avi Kivity7d36db32010-08-03 14:07:34 +03001/* test long rmap chains */
2
3#include "libcflat.h"
Gleb Natapov002d1832013-02-11 15:10:32 +02004#include "fwcfg.h"
Avi Kivity7d36db32010-08-03 14:07:34 +03005#include "vm.h"
Paolo Bonzinidcda2152017-10-23 15:00:53 +02006#include "vmalloc.h"
Avi Kivity7d36db32010-08-03 14:07:34 +03007#include "smp.h"
Paolo Bonzini5aca0242017-10-22 15:19:32 +02008#include "alloc_page.h"
Avi Kivity7d36db32010-08-03 14:07:34 +03009
Avi Kivity7d36db32010-08-03 14:07:34 +030010int main (void)
11{
12 int i;
13 int nr_pages;
14 void *target_page, *virt_addr;
15
16 setup_vm();
17
Gleb Natapov002d1832013-02-11 15:10:32 +020018 nr_pages = fwcfg_get_u64(FW_CFG_RAM_SIZE) / PAGE_SIZE;
Avi Kivity7d36db32010-08-03 14:07:34 +030019 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 Gordeevd10d16e2016-06-06 12:25:26 +020041 0 | PT_PRESENT_MASK | PT_WRITABLE_MASK, target_page);
Avi Kivity7d36db32010-08-03 14:07:34 +030042
43 *(unsigned long *)virt_addr = 0;
44 printf("PASS\n");
45
46 return 0;
47}