[PATCH v6 05/27] x86, 64bit: clear ident mapping when kernel is above 512G

From: Yinghai Lu
Date: Thu Dec 13 2012 - 17:03:46 EST


After following patch:
x86, 64bit: Set extra ident mapping for whole kernel range

We have extra ident mapping for kernel that is loaded above 1G.

So need to clear extra pgd entry when kernel is loaded above 512g.

Signed-off-by: Yinghai Lu <yinghai@xxxxxxxxxx>
---
arch/x86/kernel/head64.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 037df57..3ef9ce6 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -29,7 +29,17 @@
static void __init zap_identity_mappings(void)
{
pgd_t *pgd = pgd_offset_k(0UL);
+ unsigned long pa_text = __pa_symbol(_text);
+ unsigned long pa_end = __pa_symbol(_end);
+
pgd_clear(pgd);
+
+ /* When kernel is loaded above 512G */
+ if (pa_text >= PGDIR_SIZE)
+ pgd_clear(pgd + pgd_index(pa_text));
+ if (pa_end - 1 >= PGDIR_SIZE)
+ pgd_clear(pgd + pgd_index(pa_end - 1));
+
__flush_tlb_all();
}

--
1.7.10.4

--
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/