Skip to contentSkip to conversation

x86: fix double definition for __VIRTUAL_MASK_SHIFT

PATCH New Yury Norov 2 participants 4 messages May 8, 2019 – May 9, 2019 x86

lore
Share & tools
lore

Yury Norov

author
#0 lore raw

PATCH 1/1 x86: fix double definition for __VIRTUAL_MASK_SHIFT

__VIRTUAL_MASK_SHIFT is defined twice to the same valie in arch/x86/include/asm/page_32_types.h. Fix it.

---
 arch/x86/include/asm/page_32_types.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/include/asm/page_32_types.h +2 -3
index 0d5c739eebd7..9bfac5c80d89 100644
@@ -28,6 +28,8 @@
 #define MCE_STACK 0
 #define N_EXCEPTION_STACKS 1
 
+#define __VIRTUAL_MASK_SHIFT	32
+
 #ifdef CONFIG_X86_PAE
 /*
  * This is beyond the 44 bit limit imposed by the 32bit long pfns,
@@ -36,11 +38,8 @@
  * The real limit is still 44 bits.
  */
 #define __PHYSICAL_MASK_SHIFT	52
-#define __VIRTUAL_MASK_SHIFT	32
-
 #else  /* !CONFIG_X86_PAE */
 #define __PHYSICAL_MASK_SHIFT	32
-#define __VIRTUAL_MASK_SHIFT	32
 #endif	/* CONFIG_X86_PAE */
 
 /*
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 x86/mm: Clean up the __[PHYSICAL/VIRTUAL]_MASK_SHIFT definitions a bit

Quoted 22 lines · Yury Norov

__VIRTUAL_MASK_SHIFT is defined twice to the same valie in arch/x86/include/asm/page_32_types.h. Fix it.

---
 arch/x86/include/asm/page_32_types.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/include/asm/page_32_types.h +2 -0
index 0d5c739eebd7..9bfac5c80d89 100644
@@ -28,6 +28,8 @@
 #define MCE_STACK 0
 #define N_EXCEPTION_STACKS 1
 
+#define __VIRTUAL_MASK_SHIFT	32
+
 #ifdef CONFIG_X86_PAE
 /*
  * This is beyond the 44 bit limit imposed by the 32bit long pfns,

arch/x86/include/asm/page_32_types.h line 43

Quoted 9 lines
arch/x86/include/asm/page_32_types.h +0 -3
@@ -36,11 +38,8 @@
  * The real limit is still 44 bits.
  */
 #define __PHYSICAL_MASK_SHIFT	52
-#define __VIRTUAL_MASK_SHIFT	32
-
 #else  /* !CONFIG_X86_PAE */
 #define __PHYSICAL_MASK_SHIFT	32
-#define __VIRTUAL_MASK_SHIFT	32
 #endif	/* CONFIG_X86_PAE */

I think it's clearer to see them defined where the physical mask shift is defined.

How about the patch below? It does away with the weird formatting and cleans up both the comments and the style of the definition:

/*
* 52 bits on PAE is beyond the 44-bit limit imposed by the
* 32-bit long PFNs, but we need the full mask to make sure
* inverted PROT_NONE entries have all the host bits set
* in a guest. The real limit is still 44 bits.
*/
#ifdef CONFIG_X86_PAE

# define __PHYSICAL_MASK_SHIFT	52
# define __VIRTUAL_MASK_SHIFT	32
#else
# define __PHYSICAL_MASK_SHIFT	32
# define __VIRTUAL_MASK_SHIFT	32
#endif

?

Thanks,

Ingo

===============>
From: Ingo Molnar <[email protected]>
Date: Thu, 9 May 2019 10:59:44 +0200
Subject: [PATCH] x86/mm: Clean up the __[PHYSICAL/VIRTUAL]_MASK_SHIFT definitions a bit

---
 arch/x86/include/asm/page_32_types.h | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
arch/x86/include/asm/page_32_types.h +11 -12
index 565ad755c785..009e96d4b6d4 100644
@@ -26,20 +26,19 @@
 
 #define N_EXCEPTION_STACKS	1
 
-#ifdef CONFIG_X86_PAE
 /*
- * This is beyond the 44 bit limit imposed by the 32bit long pfns,
- * but we need the full mask to make sure inverted PROT_NONE
- * entries have all the host bits set in a guest.
- * The real limit is still 44 bits.
+ * 52 bits on PAE is beyond the 44-bit limit imposed by the
+ * 32-bit long PFNs, but we need the full mask to make sure
+ * inverted PROT_NONE entries have all the host bits set
+ * in a guest. The real limit is still 44 bits.
  */
-#define __PHYSICAL_MASK_SHIFT	52
-#define __VIRTUAL_MASK_SHIFT	32
-
-#else  /* !CONFIG_X86_PAE */
-#define __PHYSICAL_MASK_SHIFT	32
-#define __VIRTUAL_MASK_SHIFT	32
-#endif	/* CONFIG_X86_PAE */
+#ifdef CONFIG_X86_PAE
+# define __PHYSICAL_MASK_SHIFT	52
+# define __VIRTUAL_MASK_SHIFT	32
+#else
+# define __PHYSICAL_MASK_SHIFT	32
+# define __VIRTUAL_MASK_SHIFT	32
+#endif
 
 /*
  * Kernel image size is limited to 512 MB (see in arch/x86/kernel/head_32.S)
author
#2 lore raw

Re: [PATCH] x86/mm: Clean up the __[PHYSICAL/VIRTUAL]_MASK_SHIFT definitions a bit

Quoted 48 lines · Ingo Molnar
Quoted 22 lines · Yury Norov

__VIRTUAL_MASK_SHIFT is defined twice to the same valie in arch/x86/include/asm/page_32_types.h. Fix it.

---
 arch/x86/include/asm/page_32_types.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/include/asm/page_32_types.h +2 -0
index 0d5c739eebd7..9bfac5c80d89 100644
@@ -28,6 +28,8 @@
 #define MCE_STACK 0
 #define N_EXCEPTION_STACKS 1
 
+#define __VIRTUAL_MASK_SHIFT	32
+
 #ifdef CONFIG_X86_PAE
 /*
  * This is beyond the 44 bit limit imposed by the 32bit long pfns,

arch/x86/include/asm/page_32_types.h line 43

Quoted 9 lines
arch/x86/include/asm/page_32_types.h +0 -3
@@ -36,11 +38,8 @@
  * The real limit is still 44 bits.
  */
 #define __PHYSICAL_MASK_SHIFT	52
-#define __VIRTUAL_MASK_SHIFT	32
-
 #else  /* !CONFIG_X86_PAE */
 #define __PHYSICAL_MASK_SHIFT	32
-#define __VIRTUAL_MASK_SHIFT	32
 #endif	/* CONFIG_X86_PAE */

I think it's clearer to see them defined where the physical mask shift is defined.

How about the patch below? It does away with the weird formatting and cleans up both the comments and the style of the definition:

/*
* 52 bits on PAE is beyond the 44-bit limit imposed by the
* 32-bit long PFNs, but we need the full mask to make sure
* inverted PROT_NONE entries have all the host bits set
* in a guest. The real limit is still 44 bits.
*/
#ifdef CONFIG_X86_PAE

Quoted 8 lines
# define __PHYSICAL_MASK_SHIFT	52
# define __VIRTUAL_MASK_SHIFT	32
#else
# define __PHYSICAL_MASK_SHIFT	32
# define __VIRTUAL_MASK_SHIFT	32
#endif

?

My main concern was about double definition. It pretty looks like a bug. But if it's intentional, I'm OK. In the patch below, could you please add some note to the comment that __VIRTUAL_MASK_SHIFT defined twice intentionally?

Thanks,
Yury

Quoted 50 lines

Thanks,

Ingo

===============>
From: Ingo Molnar <[email protected]>
Date: Thu, 9 May 2019 10:59:44 +0200
Subject: [PATCH] x86/mm: Clean up the __[PHYSICAL/VIRTUAL]_MASK_SHIFT definitions a bit

---
 arch/x86/include/asm/page_32_types.h | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
arch/x86/include/asm/page_32_types.h +11 -12
index 565ad755c785..009e96d4b6d4 100644
@@ -26,20 +26,19 @@
 
 #define N_EXCEPTION_STACKS	1
 
-#ifdef CONFIG_X86_PAE
 /*
- * This is beyond the 44 bit limit imposed by the 32bit long pfns,
- * but we need the full mask to make sure inverted PROT_NONE
- * entries have all the host bits set in a guest.
- * The real limit is still 44 bits.
+ * 52 bits on PAE is beyond the 44-bit limit imposed by the
+ * 32-bit long PFNs, but we need the full mask to make sure
+ * inverted PROT_NONE entries have all the host bits set
+ * in a guest. The real limit is still 44 bits.
  */
-#define __PHYSICAL_MASK_SHIFT	52
-#define __VIRTUAL_MASK_SHIFT	32
-
-#else  /* !CONFIG_X86_PAE */
-#define __PHYSICAL_MASK_SHIFT	32
-#define __VIRTUAL_MASK_SHIFT	32
-#endif	/* CONFIG_X86_PAE */
+#ifdef CONFIG_X86_PAE
+# define __PHYSICAL_MASK_SHIFT	52
+# define __VIRTUAL_MASK_SHIFT	32
+#else
+# define __PHYSICAL_MASK_SHIFT	32
+# define __VIRTUAL_MASK_SHIFT	32
+#endif
 
 /*
  * Kernel image size is limited to 512 MB (see in arch/x86/kernel/head_32.S)
#3 lore raw

Re: [PATCH] x86/mm: Clean up the __[PHYSICAL/VIRTUAL]_MASK_SHIFT definitions a bit

Quoted 56 lines · Yury Norov
Quoted 55 lines · Ingo Molnar
Quoted 22 lines · Yury Norov

__VIRTUAL_MASK_SHIFT is defined twice to the same valie in arch/x86/include/asm/page_32_types.h. Fix it.

---
 arch/x86/include/asm/page_32_types.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/include/asm/page_32_types.h +2 -0
index 0d5c739eebd7..9bfac5c80d89 100644
@@ -28,6 +28,8 @@
 #define MCE_STACK 0
 #define N_EXCEPTION_STACKS 1
 
+#define __VIRTUAL_MASK_SHIFT	32
+
 #ifdef CONFIG_X86_PAE
 /*
  * This is beyond the 44 bit limit imposed by the 32bit long pfns,

arch/x86/include/asm/page_32_types.h line 43

Quoted 9 lines
arch/x86/include/asm/page_32_types.h +0 -3
@@ -36,11 +38,8 @@
  * The real limit is still 44 bits.
  */
 #define __PHYSICAL_MASK_SHIFT	52
-#define __VIRTUAL_MASK_SHIFT	32
-
 #else  /* !CONFIG_X86_PAE */
 #define __PHYSICAL_MASK_SHIFT	32
-#define __VIRTUAL_MASK_SHIFT	32
 #endif	/* CONFIG_X86_PAE */

I think it's clearer to see them defined where the physical mask shift is defined.

How about the patch below? It does away with the weird formatting and cleans up both the comments and the style of the definition:

/*
* 52 bits on PAE is beyond the 44-bit limit imposed by the
* 32-bit long PFNs, but we need the full mask to make sure
* inverted PROT_NONE entries have all the host bits set
* in a guest. The real limit is still 44 bits.
*/
#ifdef CONFIG_X86_PAE

# define __PHYSICAL_MASK_SHIFT	52
# define __VIRTUAL_MASK_SHIFT	32
#else
# define __PHYSICAL_MASK_SHIFT	32
# define __VIRTUAL_MASK_SHIFT	32
#endif
Quoted 6 lines
Quoted 1 line

?

My main concern was about double definition. It pretty looks like a bug. But if it's intentional, I'm OK. In the patch below, could you please add some note to the comment that __VIRTUAL_MASK_SHIFT defined twice intentionally?

It's not defined "twice", it has values set in the PAE and the non-PAE branch - just like __PHYSICAL_MASK_SHIFT.

__VIRTUAL_MASK_SHIFT happens to have the same value in both branches, but that's OK and pretty standard and happens in other headers too.

Thanks,

Ingo