[PATCH CPA] [28/28] Make kernel_text test match boot mapping initialization

From: Andi Kleen
Date: Thu Jan 03 2008 - 10:32:46 EST



The boot direct mapping initialization used a different test to check if a
page was part of the kernel mapping than c_p_a(). Fix that. Also
round up to a large page size to be sure.

Signed-off-by: Andi Kleen <ak@xxxxxxx>

---
arch/x86/mm/pageattr_32.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

Index: linux/arch/x86/mm/pageattr_32.c
===================================================================
--- linux.orig/arch/x86/mm/pageattr_32.c
+++ linux/arch/x86/mm/pageattr_32.c
@@ -183,6 +183,12 @@ static int cache_attr_changed(pte_t pte,
return a != (pgprot_val(prot) & _PAGE_CACHE);
}

+static int text_address(unsigned long addr)
+{
+ unsigned long end = ((unsigned long)__init_end & LARGE_PAGE_MASK);
+ return addr < end + LARGE_PAGE_SIZE;
+}
+
/*
* Mark the address for flushing later in global_tlb_flush().
*
@@ -237,7 +243,7 @@ __change_page_attr(struct page *page, pg
set_tlb_flush(address, cache_attr_changed(*kpte, prot, level),
level < 3);

- if ((address & LARGE_PAGE_MASK) < (unsigned long)&_etext)
+ if (text_address(address))
ref_prot = PAGE_KERNEL_EXEC;

if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL)) {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/