public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/boot/compressed: Exclude 'top_pgtable' from relocation
@ 2018-05-02 16:08 Kirill A. Shutemov
  2018-05-03  3:42 ` Hugh Dickins
  0 siblings, 1 reply; 8+ messages in thread
From: Kirill A. Shutemov @ 2018-05-02 16:08 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H. Peter Anvin
  Cc: Hugh Dickins, linux-kernel, Kirill A. Shutemov

startup_64() copies kernel (including .data section) to the new place.
It's required for safe in-place decompression.

This is a problem if the original place is referenced: by mistake I've
put 'top_pgtable' into .data section and the address is loaded into CR3.
If the original place gets overwritten during image decompression the
kernel will crash and the machine will be rebooted.

Move 'top_pgtable' into .pgtable section where the rest of page tables
are. This section is not subject for relocation.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Fixes: e9d0e6330eb8 ("x86/boot/compressed/64: Prepare new top-level page table for trampoline")
---
 arch/x86/boot/compressed/head_64.S    | 8 ++++++++
 arch/x86/boot/compressed/pgtable_64.c | 4 +---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index fca012baba19..c433c21703e6 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -649,3 +649,11 @@ boot_stack_end:
 	.balign 4096
 pgtable:
 	.fill BOOT_PGT_SIZE, 1, 0
+
+/*
+ * The page table is going to be used instead of page table in the trampoline
+ * memory.
+ */
+	.global top_pgtable
+top_pgtable:
+	.fill PAGE_SIZE, 1, 0
diff --git a/arch/x86/boot/compressed/pgtable_64.c b/arch/x86/boot/compressed/pgtable_64.c
index 32af1cbcd903..3a0578f54550 100644
--- a/arch/x86/boot/compressed/pgtable_64.c
+++ b/arch/x86/boot/compressed/pgtable_64.c
@@ -25,10 +25,8 @@ static char trampoline_save[TRAMPOLINE_32BIT_SIZE];
 /*
  * The page table is going to be used instead of page table in the trampoline
  * memory.
- *
- * It must not be in BSS as BSS is cleared after cleanup_trampoline().
  */
-static char top_pgtable[PAGE_SIZE] __aligned(PAGE_SIZE) __section(.data);
+extern char *top_pgtable;
 
 /*
  * Trampoline address will be printed by extract_kernel() for debugging
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-06-21 16:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-02 16:08 [PATCH] x86/boot/compressed: Exclude 'top_pgtable' from relocation Kirill A. Shutemov
2018-05-03  3:42 ` Hugh Dickins
2018-05-03  8:38   ` Kirill A. Shutemov
2018-05-03 10:52     ` Kirill A. Shutemov
2018-05-03 17:19       ` Hugh Dickins
2018-06-21 15:18         ` Ingo Molnar
2018-06-21 15:27           ` Kirill A. Shutemov
2018-06-21 16:06             ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox