Skip to contentSkip to conversation

kmemcheck: (finally) use 4k pages for identity mapping

PATCH In review Vegard Nossum 2 participants 2 messages Oct 19, 2008 – Oct 20, 2008

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

PATCH 1/1 kmemcheck: (finally) use 4k pages for identity mapping

Quoted 1 line

From 760932c8607b736504a134ed6feec25e90e089ac Mon Sep 17 00:00:00 2001

From: Vegard Nossum <[email protected]>
Date: Sun, 19 Oct 2008 15:28:04 +0200
Subject: [PATCH] kmemcheck: (finally) use 4k pages for identity mapping

At last I found the right hooks for doing this properly. DEBUG_PAGEALLOC has the exact same requirement: Kernel pages must be mapped with 4k physical pages (since that's the size of pages returned by the page allocator).

Now we finally get rid of the need to do set_memory_4k() or try to work around TLB flushing from interrupt context. Yay!

Has been tested on both 32- and 64-bit on a P4 and a Dual Core.

---
 arch/x86/kernel/cpu/common.c      |    7 -------
 arch/x86/mm/init_32.c             |    2 +-
 arch/x86/mm/init_64.c             |    2 +-
 arch/x86/mm/kmemcheck/kmemcheck.c |    4 ----
 mm/kmemcheck.c                    |    8 --------
 5 files changed, 2 insertions(+), 21 deletions(-)
arch/x86/kernel/cpu/common.c +0 -7
index 5613afb..ff26d87 100644
@@ -575,13 +575,6 @@ void __init early_cpu_init(void)
 	}
 
 	early_identify_cpu(&boot_cpu_data);
-
-#ifdef CONFIG_KMEMCHECK
-	/*
-	 * We need 4K granular PTEs for kmemcheck:
-	 */
-	setup_clear_cpu_cap(X86_FEATURE_PSE);
-#endif
 }
 
 /*
arch/x86/mm/init_32.c +1 -1
index 39e6a93..6ef3ef8 100644
@@ -825,7 +825,7 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
 	pgd_t *pgd_base = swapper_pg_dir;
 	unsigned long start_pfn, end_pfn;
 	unsigned long big_page_start;
-#ifdef CONFIG_DEBUG_PAGEALLOC
+#if defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KMEMCHECK)
 	/*
 	 * For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages.
 	 * This will simplify cpa(), which otherwise needs to support splitting
arch/x86/mm/init_64.c +1 -1
index b8e461d..99d7791 100644
@@ -682,7 +682,7 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
 	if (!after_bootmem)
 		init_gbpages();
 
-#ifdef CONFIG_DEBUG_PAGEALLOC
+#if defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KMEMCHECK)
 	/*
 	 * For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages.
 	 * This will simplify cpa(), which otherwise needs to support splitting
arch/x86/mm/kmemcheck/kmemcheck.c +0 -4
index bd739a4..056b4f1 100644
@@ -295,10 +295,6 @@ void kmemcheck_hide_pages(struct page *p, unsigned int n)
 {
 	unsigned int i;
 
-#ifdef CONFIG_X86_64
-	set_memory_4k((unsigned long) page_address(p), n);
-#endif
-
 	for (i = 0; i < n; ++i) {
 		unsigned long address;
 		pte_t *pte;
mm/kmemcheck.c +0 -8
index ffe5a8c..eaa41b8 100644
@@ -10,14 +10,6 @@ void kmemcheck_alloc_shadow(struct kmem_cache *s, gfp_t flags, int node,
 	int pages;
 	int i;
 
-#ifdef CONFIG_X86_64
-	/* XXX: x86_64 doesn't honour PSE capabilities, so we need the call
-	 * to set_memory_4k(). However, that one wants to flush all CPUs,
-	 * which doesn't work when irqs are disabled. Temporary hack: */
-	if (irqs_disabled())
-		return;
-#endif
-
 	pages = 1 << order;
 
 	/*
Signature · 1 line
1.5.5.1
#1 lore raw
Quoted 15 lines · Vegard Nossum
Quoted 1 line

From 760932c8607b736504a134ed6feec25e90e089ac Mon Sep 17 00:00:00 2001

From: Vegard Nossum <[email protected]>
Date: Sun, 19 Oct 2008 15:28:04 +0200
Subject: [PATCH] kmemcheck: (finally) use 4k pages for identity mapping

At last I found the right hooks for doing this properly. DEBUG_PAGEALLOC has the exact same requirement: Kernel pages must be mapped with 4k physical pages (since that's the size of pages returned by the page allocator).

Now we finally get rid of the need to do set_memory_4k() or try to work around TLB flushing from interrupt context. Yay!

Has been tested on both 32- and 64-bit on a P4 and a Dual Core.

Quoted 8 lines
---
 arch/x86/kernel/cpu/common.c      |    7 -------
 arch/x86/mm/init_32.c             |    2 +-
 arch/x86/mm/init_64.c             |    2 +-
 arch/x86/mm/kmemcheck/kmemcheck.c |    4 ----
 mm/kmemcheck.c                    |    8 --------
 5 files changed, 2 insertions(+), 21 deletions(-)

nice! Pulled into tip/kmemcheck-v2, thanks Vegard.

Ingo