Hi,
I'm playing with page tables again. This time in guest context. (emulation.c)
To unmap a page from guest's address space, I try
int
unmap_page_from_guest(vm_t *vm, Bit32u page)
{
Bit32u pdi, pti;
pageEntry_t pte;
for (pdi=0; pdi<(vm->common.pages.guest_n_megs >> 2); pdi++)
{
/* browse through all entries in page directory */
for (pti=0; pti<1024; pti++)
{
/* look into all entries of the page table */
pte = vm->guest.addr.page_tbl[pdi].u.pte[pti];
if(pte.base == page)
{
pte.P = 0; // mark as not present in page table
asm volatile("invlpg %0" : : "m" (page << 12)); // remove from TLB
}
return 1;
}
}
return 0;
}
Parameter page is a "real" page frame I got from vm->common.pages.guest.
But it doesn't work. Any hints, why?
Page is found, so pte.P=0 executed - in the wrong page table? Or is invlpg wrong?
jens