linux/efi: Perform efi_memmap_size=0 workaround for 32 on 64 as well
diff --git a/common/protos/linux.c b/common/protos/linux.c
index 5671a395..0fb37232 100644
--- a/common/protos/linux.c
+++ b/common/protos/linux.c
@@ -30,6 +30,8 @@ noreturn void linux_spinup(void *entry, void *boot_params);
#define E820_MAX_ENTRIES_ZEROPAGE 128
#define EDDMAXNR 6
+#define XLF_KERNEL_64 (1 << 0)
+
struct setup_header {
uint8_t setup_sects;
uint16_t root_flags;
@@ -591,13 +593,18 @@ set_textmode:;
boot_params->efi_info.efi_memmap = (uint32_t)(uint64_t)(uintptr_t)efi_mmap;
boot_params->efi_info.efi_memmap_hi = (uint32_t)((uint64_t)(uintptr_t)efi_mmap >> 32);
#if defined (__x86_64__)
- boot_params->efi_info.efi_memmap_size = efi_mmap_size;
+ if ((setup_header->xloadflags & XLF_KERNEL_64) == 0) {
#elif defined (__i386__)
- // A memmap size of 0 will cause Linux to force bail out of trying to use
- // 32-bit EFI runtime services without ignoring other EFI info.
- // XXX: Figure out why 64-bit Linux hangs if trying to use 32-bit boot services.
- boot_params->efi_info.efi_memmap_size = 0;
+ if ((setup_header->xloadflags & XLF_KERNEL_64) != 0) {
#endif
+ // A memmap size of 0 will cause Linux to force bail out of trying to use
+ // mismatched bitness EFI runtime services without ignoring other EFI info.
+ // XXX: Figure out why 64-bit Linux hangs if trying to use 32-bit boot services,
+ // and vice versa.
+ boot_params->efi_info.efi_memmap_size = 0;
+ } else {
+ boot_params->efi_info.efi_memmap_size = efi_mmap_size;
+ }
boot_params->efi_info.efi_memdesc_size = efi_desc_size;
boot_params->efi_info.efi_memdesc_version = efi_desc_ver;
#endif
