Skip to contentSkip to conversation

i386: add some compile time checks to mem_init()

PATCH Applied Jan Beulich 2 participants 2 messages Dec 16, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i386: add some compile time checks to mem_init()

Some of the inconsistencies checked for at run time can be detected at build time already, so duplicate the checks done at run time to also be done at build time.

---
 arch/x86/mm/init_32.c |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
arch/x86/mm/init_32.c +15 -1
@@ -1040,11 +1040,25 @@ void __init mem_init(void)
 		(unsigned long)&_text, (unsigned long)&_etext,
 		((unsigned long)&_etext - (unsigned long)&_text) >> 10);
 
+	/*
+	 * Check boundaries twice: Some fundamental inconsistencies can
+	 * be detected at build time already.
+	 */
+#define __FIXADDR_TOP (-PAGE_SIZE)
+#ifdef CONFIG_HIGHMEM
+	BUILD_BUG_ON(PKMAP_BASE + LAST_PKMAP*PAGE_SIZE	> FIXADDR_START);
+	BUILD_BUG_ON(VMALLOC_END			> PKMAP_BASE);
+#endif
+#define high_memory (-128UL << 20)
+	BUILD_BUG_ON(VMALLOC_START			>= VMALLOC_END);
+#undef high_memory
+#undef __FIXADDR_TOP
+
 #ifdef CONFIG_HIGHMEM
 	BUG_ON(PKMAP_BASE + LAST_PKMAP*PAGE_SIZE	> FIXADDR_START);
 	BUG_ON(VMALLOC_END				> PKMAP_BASE);
 #endif
-	BUG_ON(VMALLOC_START				> VMALLOC_END);
+	BUG_ON(VMALLOC_START				>= VMALLOC_END);
 	BUG_ON((unsigned long)high_memory		> VMALLOC_START);
 
 	if (boot_cpu_data.wp_works_ok < 0)
Applied
#1 lore raw
Quoted 9 lines · Jan Beulich

Some of the inconsistencies checked for at run time can be detected at build time already, so duplicate the checks done at run time to also be done at build time.

---
 arch/x86/mm/init_32.c |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

applied to tip/x86/debug - thanks,

Ingo