@@ -246,7 +246,7 @@ void install_ept_entry(unsigned long *pml4,
| EPT_RA | EPT_WA | EPT_EA;
} else
pt[offset] &= ~EPT_LARGE_PAGE;
- pt = phys_to_virt(pt[offset] & 0xffffffffff000ull);
+ pt = phys_to_virt(pt[offset] & EPT_ADDR_MASK);
}
offset = ((unsigned long)guest_addr >> ((level-1) *
EPT_PGDIR_WIDTH + 12)) & EPT_PGDIR_MASK;
@@ -334,7 +334,7 @@ unsigned long get_ept_pte(unsigned long *pml4,
break;
if (l < 4 && (pte & EPT_LARGE_PAGE))
return pte;
- pt = (unsigned long *)(pte & 0xffffffffff000ull);
+ pt = (unsigned long *)(pte & EPT_ADDR_MASK);
}
offset = (guest_addr >> (((l-1) * EPT_PGDIR_WIDTH) + 12))
& EPT_PGDIR_MASK;
@@ -378,7 +378,7 @@ int set_ept_pte(unsigned long *pml4, unsigned long guest_addr,
break;
if (!(pt[offset] & (EPT_PRESENT)))
return -1;
- pt = (unsigned long *)(pt[offset] & 0xffffffffff000ull);
+ pt = (unsigned long *)(pt[offset] & EPT_ADDR_MASK);
}
offset = (guest_addr >> (((l-1) * EPT_PGDIR_WIDTH) + 12))
& EPT_PGDIR_MASK;
@@ -3,6 +3,7 @@
#include "libcflat.h"
#include "processor.h"
+#include "bitops.h"
struct vmcs {
u32 revision_id; /* vmcs revision identifier */
@@ -466,6 +467,7 @@ enum Ctrl1 {
#define EPT_PAGE_LEVEL 4
#define EPT_PGDIR_WIDTH 9
#define EPT_PGDIR_MASK 511
+#define EPT_ADDR_MASK GENMASK_ULL(51, 12)
#define PAGE_MASK (~(PAGE_SIZE-1))
#define PAGE_MASK_2M (~(PAGE_SIZE_2M-1))
Signed-off-by: Peter Feiner <pfeiner@google.com> --- x86/vmx.c | 6 +++--- x86/vmx.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-)