vmm: Mask NX / unused bits in guest page walks
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 22 Dec 2017 17:02:18 +0000 (12:02 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Fri, 22 Dec 2017 17:02:18 +0000 (12:02 -0500)
The guest can (and does) set the NX bit.  Similarly, bits 62:52 are ignored
and could be used in the future.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
user/vmm/vmx.c

index afc0ee0..8528958 100644 (file)
@@ -57,6 +57,8 @@ int gvatogpa(struct guest_thread *vm_thread, uint64_t va, uint64_t *pa)
 
        for (int shift = PML4_SHIFT; shift >= PML1_SHIFT; shift -= BITS_PER_PML) {
                entry = ptptr[PMLx(va, shift)];
+               /* bit 63 can be NX.  Bits 62:52 are ignored (for PML4) */
+               entry &= 0x000fffffffffffff;
 
                if (!PAGE_PRESENT(entry))
                        return -1;