[PATCH 3/9] x86, 64bit: set extra ident page table for whole kernel range

Yinghai Lu
2012-11-16T08:53:40Z

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 with [_text, _end] for all text/data/bss/brk...

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
---
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