Re: [PATCH v2 04/16] x86/compressed: efi-mixed: move efi32_pe_entry into .text section

From: Borislav Petkov
Date: Thu Nov 17 2022 - 10:57:37 EST


On Wed, Sep 21, 2022 at 04:54:10PM +0200, Ard Biesheuvel wrote:
> /*
> * We need to set the image_offset variable here since startup_32() will
> * use it before we get to the 64-bit efi_pe_entry() in C code.
> */
> - subl %esi, %ebx
> - movl %ebx, rva(image_offset)(%ebp) // save image_offset
> + subl %esi, %ebp // calculate image_offset
> + movl %ebp, (image_offset - 1b)(%ebx) // save image_offset

All looks ok, just one question: what was the reason for that
image_offset thing?

I see:

1887c9b653f9 ("efi/x86: Decompress at start of PE image load address")

It says that if the kernel is loaded as a PE executable using
LoadImage() we don't know where that image will be loaded each time so
we're saving that offset for later when relocating (or not) the kernel?

All part of those improvements:

https://lore.kernel.org/all/20200301230537.2247550-1-nivedita@xxxxxxxxxxxx/

Am I close?

I.e., that image_offset is purely a kernel thing and not something EFI
LoadImage's inner workings mandate...? It doesn't seem so from where I'm
standing but lemme doublecheck still.

Thx.

--
Regards/Gruss,
Boris.

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