[PATCH v3 03/12] x86, 64bit: set extra ident page table for whole kernel range

From: Yinghai Lu
Date: Wed Nov 21 2012 - 02:16:25 EST


Current when kernel is loaded above 1G, only [_text, _text+2M]
is set up with extra ident page table.
That is not enough, some variables that could be used early are
out of that range. (like gdt...)

Just set map for [_text, _end] include text/data/bss/brk...

Signed-off-by: Yinghai Lu <yinghai@xxxxxxxxxx>
Cc: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>
---
arch/x86/kernel/head_64.S | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 94bf9cc..efc0c08 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -115,7 +115,16 @@ startup_64:
andq $(PTRS_PER_PMD - 1), %rax
leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
leaq level2_spare_pgt(%rip), %rbx
- movq %rdx, 0(%rbx, %rax, 8)
+ leaq _end(%rip), %r8
+ decq %r8
+ shrq $PMD_SHIFT, %r8
+ andq $(PTRS_PER_PMD - 1), %r8
+1: movq %rdx, 0(%rbx, %rax, 8)
+ addq $PMD_SIZE, %rdx
+ incq %rax
+ cmp %r8, %rax
+ jle 1b
+
ident_complete:

/*
--
1.7.7

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