[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201007195351.776555-5-nivedita@alum.mit.edu>
Date: Wed, 7 Oct 2020 15:53:50 -0400
From: Arvind Sankar <nivedita@...m.mit.edu>
To: x86@...nel.org, Joerg Roedel <jroedel@...e.de>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH 4/5] x86/boot/64: Explicitly map boot_params and command line
Commits
ca0e22d4f011 ("x86/boot/compressed/64: Always switch to own page table")
8570978ea030 ("x86/boot/compressed/64: Don't pre-map memory in KASLR code")
set up a new page table in the decompressor stub, but without explicit
mappings for boot_params and the kernel command line, relying on the #PF
handler instead.
This is fragile, as boot_params and the command line mappings are
required for the main kernel. If EARLY_PRINTK and RANDOMIZE_BASE are
disabled, a QEMU/OVMF boot never accesses the command line in the
decompressor stub, and so it never gets mapped. The main kernel accesses
it from the identity mapping if AMD_MEM_ENCRYPT is enabled, and will
crash.
Fix this by adding back the explicit mapping of boot_params and the
command line.
Note: the changes also removed the explicit mapping of the main kernel,
with the result that .bss and .brk may not be in the identity mapping,
but those don't get accessed by the main kernel before it switches to
its own page tables.
Signed-off-by: Arvind Sankar <nivedita@...m.mit.edu>
---
arch/x86/boot/compressed/ident_map_64.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/x86/boot/compressed/ident_map_64.c b/arch/x86/boot/compressed/ident_map_64.c
index 070cda70aef3..8edeff0d9324 100644
--- a/arch/x86/boot/compressed/ident_map_64.c
+++ b/arch/x86/boot/compressed/ident_map_64.c
@@ -150,10 +150,13 @@ void initialize_identity_maps(void)
}
/*
- * New page-table is set up - map the kernel image and load it
- * into cr3.
+ * New page-table is set up - map the kernel image, boot_params and the
+ * command line, and load the new page-table into cr3.
*/
add_identity_map((unsigned long)_head, (unsigned long)_end - (unsigned long)_head);
+ add_identity_map((unsigned long)boot_params, sizeof(*boot_params));
+ add_identity_map(get_cmd_line_ptr(), COMMAND_LINE_SIZE);
+
write_cr3(top_level_pgt);
}
--
2.26.2
Powered by blists - more mailing lists