Re: [PATCH 0/3] Resolve problems with kexec identity mapping

From: Borislav Petkov
Date: Wed Jul 03 2024 - 12:15:31 EST


On Tue, Jul 02, 2024 at 08:32:22PM +0200, Ard Biesheuvel wrote:
> For kexec on a 64-bit system, I would expect the high-level support
> code to be capable of simply mapping all of DRAM 1:1, rather than
> playing these games with #PF handlers and on-demand mapping.

Yeah, apparently we can't do that on SGI, as Steve said.

I like the aspect that the #PF handler won't fire in the first kernel because
of EFI mapping all RAM. That's good.

So we could try to wire in a #PF handler in stage1, see below.

Steve, I don't have a good idea how to test that. Maybe some of those
reporters you were talking about, would be willing to...

---
diff --git a/arch/x86/boot/compressed/idt_64.c b/arch/x86/boot/compressed/idt_64.c
index d100284bbef4..a258587c8949 100644
--- a/arch/x86/boot/compressed/idt_64.c
+++ b/arch/x86/boot/compressed/idt_64.c
@@ -32,6 +32,7 @@ void load_stage1_idt(void)
{
boot_idt_desc.address = (unsigned long)boot_idt;

+ set_idt_entry(X86_TRAP_PF, boot_page_fault);

if (IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT))
set_idt_entry(X86_TRAP_VC, boot_stage1_vc);

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette