diff mbox

[kvm-unit-tests,v7,08/11] x86: Cleanup PAGE_* constants

Message ID 802aa7dd0a31ea847e59f84a7bf31a0f5011bb2d.1462457467.git.agordeev@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alexander Gordeev May 5, 2016, 2:26 p.m. UTC
Cc: Andrew Jones <drjones@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Radim Kr?má? <rkrcmar@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 lib/x86/asm/page.h | 10 +++++++++-
 x86/access.c       |  4 +---
 x86/vmx.h          |  2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/lib/x86/asm/page.h b/lib/x86/asm/page.h
index d4580b4..916462d 100644
--- a/lib/x86/asm/page.h
+++ b/lib/x86/asm/page.h
@@ -7,7 +7,14 @@ 
  */
 
 
-#define PAGE_SIZE	4096ul
+#include <linux/const.h>
+
+#define PAGE_SHIFT	12
+#define PAGE_SIZE	(_AC(1,UL) << PAGE_SHIFT)
+#define PAGE_MASK	(~(PAGE_SIZE-1))
+
+#ifndef __ASSEMBLY__
+
 #ifdef __x86_64__
 #define LARGE_PAGE_SIZE	(512 * PAGE_SIZE)
 #else
@@ -30,4 +37,5 @@ 
 #define	PGDIR_MASK	1023
 #endif
 
+#endif /* !__ASSEMBLY__ */
 #endif
diff --git a/x86/access.c b/x86/access.c
index 4acaee5..aaf805d 100644
--- a/x86/access.c
+++ b/x86/access.c
@@ -2,6 +2,7 @@ 
 #include "libcflat.h"
 #include "desc.h"
 #include "processor.h"
+#include "asm/page.h"
 
 #define smp_id() 0
 
@@ -15,9 +16,6 @@  static int cpuid_7_ebx;
 static int cpuid_7_ecx;
 static int invalid_mask;
 
-#define PAGE_SIZE ((pt_element_t)4096)
-#define PAGE_MASK (~(PAGE_SIZE-1))
-
 #define PT_BASE_ADDR_MASK ((pt_element_t)((((pt_element_t)1 << 40) - 1) & PAGE_MASK))
 #define PT_PSE_BASE_ADDR_MASK (PT_BASE_ADDR_MASK & ~(1ull << 21))
 
diff --git a/x86/vmx.h b/x86/vmx.h
index d6bc217..27f3451 100644
--- a/x86/vmx.h
+++ b/x86/vmx.h
@@ -4,6 +4,7 @@ 
 #include "libcflat.h"
 #include "processor.h"
 #include "bitops.h"
+#include "asm/page.h"
 
 struct vmcs {
 	u32 revision_id; /* vmcs revision identifier */
@@ -476,7 +477,6 @@  enum Ctrl1 {
 #define EPT_PGDIR_ENTRIES	(1 << EPT_PGDIR_WIDTH)
 #define EPT_LEVEL_SHIFT(level)	(((level)-1) * EPT_PGDIR_WIDTH + 12)
 #define EPT_ADDR_MASK		GENMASK_ULL(51, 12)
-#define PAGE_MASK		(~(PAGE_SIZE-1))
 #define PAGE_MASK_2M		(~(PAGE_SIZE_2M-1))
 
 #define EPT_VLT_RD		1