diff mbox

[kvm-unit-tests,v3,3/6] x86: vmx: Named constant: EPT_ADDR_MASK

Message ID 1456938657-20850-4-git-send-email-pfeiner@google.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Feiner March 2, 2016, 5:10 p.m. UTC
Signed-off-by: Peter Feiner <pfeiner@google.com>
---
 x86/vmx.c | 6 +++---
 x86/vmx.h | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/x86/vmx.c b/x86/vmx.c
index 3fa1a73..9811a28 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -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;
diff --git a/x86/vmx.h b/x86/vmx.h
index 8b79191..459dd13 100644
--- a/x86/vmx.h
+++ b/x86/vmx.h
@@ -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))