Skip to content

Commit eac9563

Browse files
ardbiesheuvelIngo Molnar
authored and
Ingo Molnar
committed
x86/boot: Set EFI handover offset directly in header asm
The offsets of the EFI handover entrypoints are available to the assembler when constructing the header, so there is no need to set them from the build tool afterwards. This change has no impact on the resulting bzImage binary. Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2e765c0 commit eac9563

File tree

2 files changed

+17
-25
lines changed

2 files changed

+17
-25
lines changed

arch/x86/boot/header.S

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,24 @@ pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
524524
# define INIT_SIZE VO_INIT_SIZE
525525
#endif
526526

527+
.macro __handover_offset
528+
#ifndef CONFIG_EFI_HANDOVER_PROTOCOL
529+
.long 0
530+
#elif !defined(CONFIG_X86_64)
531+
.long ZO_efi32_stub_entry
532+
#else
533+
/* Yes, this is really how we defined it :( */
534+
.long ZO_efi64_stub_entry - 0x200
535+
#ifdef CONFIG_EFI_MIXED
536+
.if ZO_efi32_stub_entry != ZO_efi64_stub_entry - 0x200
537+
.error "32-bit and 64-bit EFI entry points do not match"
538+
.endif
539+
#endif
540+
#endif
541+
.endm
542+
527543
init_size: .long INIT_SIZE # kernel initialization size
528-
handover_offset: .long 0 # Filled in by build.c
544+
handover_offset: __handover_offset
529545
kernel_info_offset: .long ZO_kernel_info
530546

531547
# End of setup header #####################################################

arch/x86/boot/tools/build.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ u8 buf[SETUP_SECT_MAX*512];
5555
#define PECOFF_COMPAT_RESERVE 0x0
5656
#endif
5757

58-
static unsigned long efi32_stub_entry;
59-
static unsigned long efi64_stub_entry;
6058
static unsigned long efi_pe_entry;
6159
static unsigned long efi32_pe_entry;
6260
static unsigned long _end;
@@ -265,31 +263,12 @@ static void efi_stub_defaults(void)
265263
#endif
266264
}
267265

268-
static void efi_stub_entry_update(void)
269-
{
270-
unsigned long addr = efi32_stub_entry;
271-
272-
#ifdef CONFIG_EFI_HANDOVER_PROTOCOL
273-
#ifdef CONFIG_X86_64
274-
/* Yes, this is really how we defined it :( */
275-
addr = efi64_stub_entry - 0x200;
276-
#endif
277-
278-
#ifdef CONFIG_EFI_MIXED
279-
if (efi32_stub_entry != addr)
280-
die("32-bit and 64-bit EFI entry points do not match\n");
281-
#endif
282-
#endif
283-
put_unaligned_le32(addr, &buf[0x264]);
284-
}
285-
286266
#else
287267

288268
static inline void update_pecoff_setup_and_reloc(unsigned int size) {}
289269
static inline void update_pecoff_text(unsigned int text_start,
290270
unsigned int file_sz) {}
291271
static inline void efi_stub_defaults(void) {}
292-
static inline void efi_stub_entry_update(void) {}
293272

294273
static inline int reserve_pecoff_reloc_section(int c)
295274
{
@@ -332,8 +311,6 @@ static void parse_zoffset(char *fname)
332311
p = (char *)buf;
333312

334313
while (p && *p) {
335-
PARSE_ZOFS(p, efi32_stub_entry);
336-
PARSE_ZOFS(p, efi64_stub_entry);
337314
PARSE_ZOFS(p, efi_pe_entry);
338315
PARSE_ZOFS(p, efi32_pe_entry);
339316
PARSE_ZOFS(p, _end);
@@ -416,7 +393,6 @@ int main(int argc, char ** argv)
416393

417394
update_pecoff_text(setup_sectors * 512, i + (sys_size * 16));
418395

419-
efi_stub_entry_update();
420396

421397
crc = partial_crc32(buf, i, crc);
422398
if (fwrite(buf, 1, i, dest) != i)

0 commit comments

Comments
 (0)