Patch "x86/kexec: Add EFI config table identity mapping for kexec kernel" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    x86/kexec: Add EFI config table identity mapping for kexec kernel

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     x86-kexec-add-efi-config-table-identity-mapping-for-.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d6cbe5b6ceaddf2b9cdf02c8912d69247198ed28
Author: Tao Liu <ltao@xxxxxxxxxx>
Date:   Wed Jul 17 16:31:20 2024 -0500

    x86/kexec: Add EFI config table identity mapping for kexec kernel
    
    [ Upstream commit 5760929f6545c651682de3c2c6c6786816b17bb1 ]
    
    A kexec kernel boot failure is sometimes observed on AMD CPUs due to an
    unmapped EFI config table array.  This can be seen when "nogbpages" is on
    the kernel command line, and has been observed as a full BIOS reboot rather
    than a successful kexec.
    
    This was also the cause of reported regressions attributed to Commit
    7143c5f4cf20 ("x86/mm/ident_map: Use gbpages only where full GB page should
    be mapped.") which was subsequently reverted.
    
    To avoid this page fault, explicitly include the EFI config table array in
    the kexec identity map.
    
    Further explanation:
    
    The following 2 commits caused the EFI config table array to be
    accessed when enabling sev at kernel startup.
    
        commit ec1c66af3a30 ("x86/compressed/64: Detect/setup SEV/SME features
                              earlier during boot")
        commit c01fce9cef84 ("x86/compressed: Add SEV-SNP feature
                              detection/setup")
    
    This is in the code that examines whether SEV should be enabled or not, so
    it can even affect systems that are not SEV capable.
    
    This may result in a page fault if the EFI config table array's address is
    unmapped. Since the page fault occurs before the new kernel establishes its
    own identity map and page fault routines, it is unrecoverable and kexec
    fails.
    
    Most often, this problem is not seen because the EFI config table array
    gets included in the map by the luck of being placed at a memory address
    close enough to other memory areas that *are* included in the map created
    by kexec.
    
    Both the "nogbpages" command line option and the "use gpbages only where
    full GB page should be mapped" change greatly reduce the chance of being
    included in the map by luck, which is why the problem appears.
    
    Signed-off-by: Tao Liu <ltao@xxxxxxxxxx>
    Signed-off-by: Steve Wahl <steve.wahl@xxxxxxx>
    Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
    Tested-by: Pavin Joseph <me@xxxxxxxxxxxxxxx>
    Tested-by: Sarah Brofeldt <srhb@xxxxxx>
    Tested-by: Eric Hagberg <ehagberg@xxxxxxxxx>
    Reviewed-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
    Link: https://lore.kernel.org/all/20240717213121.3064030-2-steve.wahl@xxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index d287fe290c9ab..2fa12d1dc6760 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -28,6 +28,7 @@
 #include <asm/setup.h>
 #include <asm/set_memory.h>
 #include <asm/cpu.h>
+#include <asm/efi.h>
 
 #ifdef CONFIG_ACPI
 /*
@@ -90,6 +91,8 @@ map_efi_systab(struct x86_mapping_info *info, pgd_t *level4p)
 {
 #ifdef CONFIG_EFI
 	unsigned long mstart, mend;
+	void *kaddr;
+	int ret;
 
 	if (!efi_enabled(EFI_BOOT))
 		return 0;
@@ -105,6 +108,30 @@ map_efi_systab(struct x86_mapping_info *info, pgd_t *level4p)
 	if (!mstart)
 		return 0;
 
+	ret = kernel_ident_mapping_init(info, level4p, mstart, mend);
+	if (ret)
+		return ret;
+
+	kaddr = memremap(mstart, mend - mstart, MEMREMAP_WB);
+	if (!kaddr) {
+		pr_err("Could not map UEFI system table\n");
+		return -ENOMEM;
+	}
+
+	mstart = efi_config_table;
+
+	if (efi_enabled(EFI_64BIT)) {
+		efi_system_table_64_t *stbl = (efi_system_table_64_t *)kaddr;
+
+		mend = mstart + sizeof(efi_config_table_64_t) * stbl->nr_tables;
+	} else {
+		efi_system_table_32_t *stbl = (efi_system_table_32_t *)kaddr;
+
+		mend = mstart + sizeof(efi_config_table_32_t) * stbl->nr_tables;
+	}
+
+	memunmap(kaddr);
+
 	return kernel_ident_mapping_init(info, level4p, mstart, mend);
 #endif
 	return 0;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux