diff options
author | Jan Janssen <medhefgo@web.de> | 2022-09-21 12:23:36 +0200 |
---|---|---|
committer | Jan Janssen <medhefgo@web.de> | 2022-10-17 14:47:42 +0200 |
commit | dcde6ae16551d126f8cd0c3fb9851bb11ac1b938 (patch) | |
tree | edff80ee7ef6a0e475e4616d8b702c6e7d24578a /src/boot | |
parent | stub: Use LoadImage/StartImage to start the kernel (diff) | |
download | systemd-dcde6ae16551d126f8cd0c3fb9851bb11ac1b938.tar.xz systemd-dcde6ae16551d126f8cd0c3fb9851bb11ac1b938.zip |
boot: Remove unused parameters from pe_kernel_info
Only the compat entry address is used now. This also now only returns
the compat entry address. If the image is native we do not need to try
calling into the entry address again as we would already have done so
from StartImage (and failed).
Diffstat (limited to 'src/boot')
-rw-r--r-- | src/boot/efi/boot.c | 11 | ||||
-rw-r--r-- | src/boot/efi/linux.c | 9 | ||||
-rw-r--r-- | src/boot/efi/pe.c | 38 | ||||
-rw-r--r-- | src/boot/efi/pe.h | 6 |
4 files changed, 24 insertions, 40 deletions
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index 6b3d29ba3b..e1a5e861c5 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -2416,21 +2416,22 @@ static EFI_STATUS image_start( /* Try calling the kernel compat entry point if one exists. */ if (err == EFI_UNSUPPORTED && entry->type == LOADER_LINUX) { - uint32_t kernel_entry_address; + uint32_t compat_address; - err = pe_kernel_info(loaded_image->ImageBase, &kernel_entry_address, NULL, NULL); + err = pe_kernel_info(loaded_image->ImageBase, &compat_address); if (err != EFI_SUCCESS) { if (err != EFI_UNSUPPORTED) return log_error_status_stall(err, L"Error finding kernel compat entry address: %r", err); - } else { + } else if (compat_address > 0) { EFI_IMAGE_ENTRY_POINT kernel_entry = - (EFI_IMAGE_ENTRY_POINT) ((uint8_t *) loaded_image->ImageBase + kernel_entry_address); + (EFI_IMAGE_ENTRY_POINT) ((uint8_t *) loaded_image->ImageBase + compat_address); err = kernel_entry(image, ST); graphics_mode(false); if (err == EFI_SUCCESS) return EFI_SUCCESS; - } + } else + err = EFI_UNSUPPORTED; } return log_error_status_stall(err, L"Failed to execute %s (%s): %r", entry->title_show, entry->loader, err); diff --git a/src/boot/efi/linux.c b/src/boot/efi/linux.c index 5b062d409a..622869e36c 100644 --- a/src/boot/efi/linux.c +++ b/src/boot/efi/linux.c @@ -59,7 +59,7 @@ EFI_STATUS linux_exec( const void *linux_buffer, UINTN linux_length, const void *initrd_buffer, UINTN initrd_length) { - uint32_t kernel_alignment, kernel_size_of_image, kernel_entry_address = 0; + uint32_t compat_address; EFI_STATUS err; assert(parent); @@ -67,8 +67,7 @@ EFI_STATUS linux_exec( assert(linux_buffer && linux_length > 0); assert(initrd_buffer || initrd_length == 0); - /* get the necessary fields from the PE header */ - err = pe_kernel_info(linux_buffer, &kernel_entry_address, &kernel_size_of_image, &kernel_alignment); + err = pe_kernel_info(linux_buffer, &compat_address); #if defined(__i386__) || defined(__x86_64__) if (err == EFI_UNSUPPORTED) /* Kernel is too old to support LINUX_INITRD_MEDIA_GUID, try the deprecated EFI handover @@ -108,9 +107,9 @@ EFI_STATUS linux_exec( err = BS->StartImage(kernel_image, NULL, NULL); /* Try calling the kernel compat entry point if one exists. */ - if (err == EFI_UNSUPPORTED && kernel_entry_address > 0) { + if (err == EFI_UNSUPPORTED && compat_address > 0) { EFI_IMAGE_ENTRY_POINT compat_entry = - (EFI_IMAGE_ENTRY_POINT) ((uint8_t *) loaded_image->ImageBase + kernel_entry_address); + (EFI_IMAGE_ENTRY_POINT) ((uint8_t *) loaded_image->ImageBase + compat_address); err = compat_entry(kernel_image, ST); } diff --git a/src/boot/efi/pe.c b/src/boot/efi/pe.c index 051ea74d42..3d5da14d10 100644 --- a/src/boot/efi/pe.c +++ b/src/boot/efi/pe.c @@ -215,23 +215,15 @@ static uint32_t get_compatibility_entry_address(const DosFileHeader *dos, const return 0; } -EFI_STATUS pe_kernel_info( - const void *base, - uint32_t *ret_entry_point_address, - uint32_t *ret_size_of_image, - uint32_t *ret_section_alignment) { - - const DosFileHeader *dos; - const PeFileHeader *pe; - +EFI_STATUS pe_kernel_info(const void *base, uint32_t *ret_compat_address) { assert(base); - assert(ret_entry_point_address); + assert(ret_compat_address); - dos = (const DosFileHeader *) base; + const DosFileHeader *dos = (const DosFileHeader *) base; if (!verify_dos(dos)) return EFI_LOAD_ERROR; - pe = (const PeFileHeader *) ((const uint8_t *) base + dos->ExeHeader); + const PeFileHeader *pe = (const PeFileHeader *) ((const uint8_t *) base + dos->ExeHeader); if (!verify_pe(pe, /* allow_compatibility= */ true)) return EFI_LOAD_ERROR; @@ -239,21 +231,17 @@ EFI_STATUS pe_kernel_info( if (pe->OptionalHeader.MajorImageVersion < 1) return EFI_UNSUPPORTED; - uint32_t entry_address = pe->OptionalHeader.AddressOfEntryPoint; - - /* Look for a compat entry point. */ - if (pe->FileHeader.Machine != TARGET_MACHINE_TYPE) { - entry_address = get_compatibility_entry_address(dos, pe); - if (entry_address == 0) - /* Image type not supported and no compat entry found. */ - return EFI_UNSUPPORTED; + if (pe->FileHeader.Machine == TARGET_MACHINE_TYPE) { + *ret_compat_address = 0; + return EFI_SUCCESS; } - *ret_entry_point_address = entry_address; - if (ret_size_of_image) - *ret_size_of_image = pe->OptionalHeader.SizeOfImage; - if (ret_section_alignment) - *ret_section_alignment = pe->OptionalHeader.SectionAlignment; + uint32_t compat_address = get_compatibility_entry_address(dos, pe); + if (compat_address == 0) + /* Image type not supported and no compat entry found. */ + return EFI_UNSUPPORTED; + + *ret_compat_address = compat_address; return EFI_SUCCESS; } diff --git a/src/boot/efi/pe.h b/src/boot/efi/pe.h index ead2ba01cc..ff7ff479ec 100644 --- a/src/boot/efi/pe.h +++ b/src/boot/efi/pe.h @@ -17,8 +17,4 @@ EFI_STATUS pe_file_locate_sections( UINTN *offsets, UINTN *sizes); -EFI_STATUS pe_kernel_info( - const void *base, - uint32_t *ret_entry_point_address, - uint32_t *ret_size_of_image, - uint32_t *ret_section_alignment); +EFI_STATUS pe_kernel_info(const void *base, uint32_t *ret_compat_address); |