Re: [PATCH v1 0/2] firmware: dmi_scan: Make it work in kexec'ed kernel

From: Dave Young
Date: Sat Jun 12 2021 - 00:41:12 EST


> Probably it is doable to have kexec on 32bit efi working
> without runtime service support, that means no need the trick of fixed
> mapping.
>
> If I can restore my vm to boot 32bit efi on this weekend then I may provide some draft
> patches for test.

Unfortunately I failed to setup a 32bit efi guest, here are some
untested draft patches, please have a try.

========= kernel draft patch ==============

---
arch/x86/boot/header.S | 2 +-
arch/x86/platform/efi/efi.c | 6 +++---
arch/x86/platform/efi/quirks.c | 3 ---
3 files changed, 4 insertions(+), 7 deletions(-)

--- linux-x86.orig/arch/x86/boot/header.S
+++ linux-x86/arch/x86/boot/header.S
@@ -416,7 +416,7 @@ xloadflags:
# define XLF23 0
#endif

-#if defined(CONFIG_X86_64) && defined(CONFIG_EFI) && defined(CONFIG_KEXEC_CORE)
+#if defined(CONFIG_EFI) && defined(CONFIG_KEXEC_CORE)
# define XLF4 XLF_EFI_KEXEC
#else
# define XLF4 0
--- linux-x86.orig/arch/x86/platform/efi/efi.c
+++ linux-x86/arch/x86/platform/efi/efi.c
@@ -710,10 +710,10 @@ static void __init kexec_enter_virtual_m
unsigned int num_pages;

/*
- * We don't do virtual mode, since we don't do runtime services, on
- * non-native EFI.
+ * We don't do virtual mode, since we don't do runtime services
+ * on non-native or IA32 EFI.
*/
- if (efi_is_mixed()) {
+ if (!efi_enabled(EFI_64BIT)) {
efi_memmap_unmap();
clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
return;
--- linux-x86.orig/arch/x86/platform/efi/quirks.c
+++ linux-x86/arch/x86/platform/efi/quirks.c
@@ -524,9 +524,6 @@ int __init efi_reuse_config(u64 tables,
if (!efi_setup)
return 0;

- if (!efi_enabled(EFI_64BIT))
- return 0;
-
data = early_memremap(efi_setup, sizeof(*data));
if (!data) {
ret = -ENOMEM;


========= kexec-tools draft patch =========

---
kexec/arch/i386/kexec-bzImage.c | 5 +++++
1 file changed, 5 insertions(+)

--- kexec-tools.orig/kexec/arch/i386/kexec-bzImage.c
+++ kexec-tools/kexec/arch/i386/kexec-bzImage.c
@@ -83,6 +83,11 @@ int bzImage_probe(const char *buf, off_t
if (probe_debug) {
fprintf(stderr, "It's a bzImage\n");
}
+
+#define XLF_EFI_KEXEC (1 << 4)
+ if ((header->xloadflags & XLF_EFI_KEXEC) == XLF_EFI_KEXEC)
+ bzImage_support_efi_boot = 1;
+
return 0;
}