Skip to content

Commit

Permalink
efi/x86: Add kernel preferred address to PE header
Browse files Browse the repository at this point in the history
Store the kernel's link address as ImageBase in the PE header. Note that
the PE specification requires the ImageBase to be 64k aligned. The
preferred address should almost always satisfy that, except for 32-bit
kernel if the configuration has been customized.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20200303221205.4048668-4-nivedita@alum.mit.edu
Link: https://lore.kernel.org/r/20200308080859.21568-18-ardb@kernel.org
  • Loading branch information
Arvind Sankar authored and Ingo Molnar committed Mar 8, 2020
1 parent 1887c9b commit 2672519
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions arch/x86/boot/header.S
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ optional_header:
#endif

extra_header_fields:
# PE specification requires ImageBase to be 64k aligned
.set image_base, (LOAD_PHYSICAL_ADDR + 0xffff) & ~0xffff
#ifdef CONFIG_X86_32
.long 0 # ImageBase
.long image_base # ImageBase
#else
.quad 0 # ImageBase
.quad image_base # ImageBase
#endif
.long 0x20 # SectionAlignment
.long 0x20 # FileAlignment
Expand Down

0 comments on commit 2672519

Please sign in to comment.