Skip to content

Instantly share code, notes, and snippets.

@iriina
Created July 3, 2011 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iriina/1062102 to your computer and use it in GitHub Desktop.
Save iriina/1062102 to your computer and use it in GitHub Desktop.
Remap vmspace0 from the vkernel
static void
recreate_kva(void)
{
void *base;
void *try;
try = (void *)KvaStart;
base = try;
base = mmap(try, KERNEL_KVA_SIZE, PROT_READ|PROT_WRITE,
MAP_FILE|MAP_SHARED|MAP_VPAGETABLE,
MemImageFd, 0);
if (base != try) {
err(1, "Unable to mmap() kernel virtual memory!");
/* NOT REACHED */
}
madvise(base, KERNEL_KVA_SIZE, MADV_NOSYNC);
printf("XXX KVM mapped at %p-%p\n", (void *)KvaStart, (void *)KvaEnd);
mcontrol(base, KERNEL_KVA_SIZE, MADV_SETMAP,
0 | VPTE_R | VPTE_W | VPTE_V);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment