Created
July 3, 2011 09:24
-
-
Save iriina/1062097 to your computer and use it in GitHub Desktop.
Remap vmspace0 from the system kernel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
base = (void *)0x40000000; //vkernel kva start | |
error = kern_mmap(p->p_vmspace, base, 0x40000000, | |
PROT_READ|PROT_WRITE, | |
MAP_FILE|MAP_SHARED|MAP_VPAGETABLE, | |
MemImageFd, 0, &res); | |
kprintf("XXX Mapped %i\n", error); | |
if (!error) { | |
//madvise | |
tmpaddr = (vm_offset_t)base + 0x40000000; | |
start = trunc_page((vm_offset_t)base); | |
end = round_page(tmpaddr); | |
error = vm_map_madvise(&p->p_vmspace->vm_map, start, end, | |
MADV_NOSYNC, 0); | |
kprintf("XXX Madvise %i\n", error); | |
if (!error) { | |
//mcontrol | |
tmpaddr = (vm_offset_t)base + 0x40000000; | |
start = trunc_page((vm_offset_t)base); | |
end = round_page(tmpaddr); | |
error = vm_map_madvise(&p->p_vmspace->vm_map, start, end, | |
MADV_SETMAP, 0 | VPTE_R | VPTE_W | VPTE_V); | |
kprintf("XXX Mcontrol %i\n", error); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment