[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20150327215308.85354CFD@viggo.jf.intel.com>
Date: Fri, 27 Mar 2015 14:53:08 -0700
From: Dave Hansen <dave@...1.net>
To: linux-kernel@...r.kernel.org
Cc: x86@...nel.org, tglx@...utronix.de, Dave Hansen <dave@...1.net>,
dave.hansen@...ux.intel.com
Subject: [PATCH 10/17] x86: make __VIRTUAL_MASK safe to use on 32 bit
From: Dave Hansen <dave.hansen@...ux.intel.com>
We are going to do some calculations in a moment that are based on the
size of the virtual address space. __VIRTUAL_MASK is currently unsafe
to use on 32-bit since it overflows an unsigned long with its shift.
The current version will emit a warning if used at all on 32-bit
kernels.
Add a version which is safe on 32-bit and consequently does not spit
out a warning.
Signed-off-by: Dave Hansen <dave.hansen@...ux.intel.com>
---
b/arch/x86/include/asm/page_types.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff -puN arch/x86/include/asm/page_types.h~x86-make-__VIRTUAL_MASK-safe-to-use-on-32-bit arch/x86/include/asm/page_types.h
--- a/arch/x86/include/asm/page_types.h~x86-make-__VIRTUAL_MASK-safe-to-use-on-32-bit 2015-03-27 14:35:07.648891831 -0700
+++ b/arch/x86/include/asm/page_types.h 2015-03-27 14:35:07.652892012 -0700
@@ -10,7 +10,15 @@
#define PAGE_MASK (~(PAGE_SIZE-1))
#define __PHYSICAL_MASK ((phys_addr_t)((1ULL << __PHYSICAL_MASK_SHIFT) - 1))
+#ifdef CONFIG_X86_64
+/*
+ * This version doesn't work on 32-bit because __VIRTUAL_MASK_SHIFT=32
+ * overflows the unsigned long we're trying to shift.
+ */
#define __VIRTUAL_MASK ((1UL << __VIRTUAL_MASK_SHIFT) - 1)
+#else
+#define __VIRTUAL_MASK (~0UL)
+#endif
/* Cast PAGE_MASK to a signed type so that it is sign-extended if
virtual addresses are 32-bits but physical addresses are larger
_
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists