Re: [PATCH 0/3] Resolve problems with kexec identity mapping
From: Ard Biesheuvel
Date: Wed Jul 03 2024 - 12:18:56 EST
On Wed, 3 Jul 2024 at 18:15, Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> 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.
>
It won't fire because the code where this handler is being added is
never even called by EFI boot - it decompresses the kernel from the
EFI stub and jumps straight to its entrypoint.
> So we could try to wire in a #PF handler in stage1, see below.
>
Looks fine to me from EFI boot pov, for the reasons given above.
> 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