bianbu-linux-6.6/arch/x86/kernel
Tao Liu ddd52c9fe9 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 ec1c66af3a ("x86/compressed/64: Detect/setup SEV/SME features
                          earlier during boot")
    commit c01fce9cef ("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@redhat.com>
Signed-off-by: Steve Wahl <steve.wahl@hpe.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Pavin Joseph <me@pavinjoseph.com>
Tested-by: Sarah Brofeldt <srhb@dbc.dk>
Tested-by: Eric Hagberg <ehagberg@gmail.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/all/20240717213121.3064030-2-steve.wahl@hpe.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-10-10 11:57:30 +02:00
..
acpi xen: allow mapping ACPI data using a different physical address 2024-10-04 16:29:43 +02:00
apic x86/ioapic: Handle allocation failures gracefully 2024-10-10 11:57:28 +02:00
cpu x86/sgx: Fix deadlock in SGX NUMA node search 2024-10-04 16:28:55 +02:00
fpu x86/pkeys: Add PKRU as a parameter in signal handling functions 2024-10-10 11:57:29 +02:00
kprobes kprobe/ftrace: bail out if ftrace was killed 2024-06-27 13:49:03 +02:00
.gitignore
alternative.c x86/alternatives: Disable interrupts and sync when optimizing NOPs in place 2024-01-01 12:42:47 +00:00
amd_gart_64.c Revert "change alloc_pages name in dma_map_ops to avoid name conflicts" 2024-09-04 13:28:24 +02:00
amd_nb.c x86/amd_nb: Check for invalid SMN reads 2024-06-21 14:38:39 +02:00
aperture_64.c x86: Fix various duplicate-word comment typos 2022-08-15 19:17:52 +02:00
apm_32.c x86/APM: drop the duplicate APM_MINOR_DEV macro 2023-07-30 14:00:32 +02:00
asm-offsets.c x86/smpboot: Remove initial_stack on 64-bit 2023-03-21 13:35:53 +01:00
asm-offsets_32.c
asm-offsets_64.c x86: Fixup asm-offsets duplicate 2022-10-17 16:41:06 +02:00
audit_64.c x86/audit: Fix -Wmissing-variable-declarations warning for ia32_xyz_class 2023-08-30 10:11:16 +02:00
bootflag.c
callthunks.c x86,static_call: Fix static-call vs return-thunk 2023-09-22 18:58:24 +02:00
cet.c x86/ibt: Convert IBT selftest to asm 2023-08-17 17:07:09 +02:00
cfi.c x86: Add support for CONFIG_CFI_CLANG 2022-09-26 10:13:16 -07:00
check.c
cpuid.c x86/cpuid: make cpuid_class a static const structure 2023-08-05 08:31:41 +02:00
crash.c ARM: 2023-09-07 13:52:20 -07:00
crash_core_32.c
crash_core_64.c
crash_dump_32.c vmcore: convert copy_oldmem_page() to take an iov_iter 2022-04-29 14:37:59 -07:00
crash_dump_64.c use less confusing names for iov_iter direction initializers 2022-11-25 13:01:55 -05:00
devicetree.c x86/of: Return consistent error type from x86_of_pci_irq_enable() 2024-08-03 08:53:21 +02:00
doublefault_32.c x86: Avoid missing-prototype warnings for doublefault code 2023-05-18 11:56:18 -07:00
dumpstack.c x86/show_trace_log_lvl: Ensure stack pointer is aligned, again 2023-05-16 06:31:04 -07:00
dumpstack_32.c x86/percpu: Move irq_stack variables next to current_task 2022-10-17 16:41:05 +02:00
dumpstack_64.c x86/percpu: Move irq_stack variables next to current_task 2022-10-17 16:41:05 +02:00
e820.c x86/e820: Don't reserve SETUP_RNG_SEED in e820 2024-03-06 14:48:42 +00:00
early-quirks.c drm/i915/rpl-p: Add PCI IDs 2022-04-19 17:14:09 -07:00
early_printk.c x86/earlyprintk: Clean up pciserial 2022-08-29 12:19:25 +02:00
ebda.c
eisa.c x86/sev: Skip ROM range scans and validation for SEV-SNP guests 2024-04-03 15:29:03 +02:00
espfix_64.c x86/espfix: Use get_random_long() rather than archrandom 2022-10-31 20:12:50 +01:00
ftrace.c x86/ftrace: Remove unsued extern declaration ftrace_regs_caller_ret() 2023-07-10 21:38:13 -04:00
ftrace_32.S x86/ftrace: Enable HAVE_FUNCTION_GRAPH_RETVAL 2023-06-20 18:38:38 -04:00
ftrace_64.S x86/ftrace: Enable HAVE_FUNCTION_GRAPH_RETVAL 2023-06-20 18:38:38 -04:00
head32.c x86: Add dummy prototype for mk_early_pgtbl_32() 2023-05-18 11:56:16 -07:00
head64.c x86/head/64: Move the __head definition to <asm/init.h> 2024-04-10 16:36:07 +02:00
head_32.S x86/smpboot: Restrict soft_restart_cpu() to SEV 2023-05-15 13:44:50 +02:00
head_64.S x86/smpboot/64: Handle X2APIC BIOS inconsistency gracefully 2024-01-01 12:42:47 +00:00
hpet.c rtc: Add support for configuring the UIP timeout for RTC reads 2024-01-31 16:18:56 -08:00
hw_breakpoint.c x86/amd: Cache debug register values in percpu variables 2023-01-31 20:09:26 +01:00
i8237.c
i8253.c
i8259.c x86/i8259: Skip probing when ACPI/MADT advertises PCAT compatibility 2023-10-27 20:36:49 +02:00
ibt_selftest.S x86/ibt: Convert IBT selftest to asm 2023-08-17 17:07:09 +02:00
idt.c x86/entry: Convert INT 0x80 emulation to IDTENTRY 2023-12-13 18:45:02 +01:00
io_delay.c
ioport.c
irq.c x86/apic: Nuke ack_APIC_irq() 2023-08-09 11:58:34 -07:00
irq_32.c x86/percpu: Move irq_stack variables next to current_task 2022-10-17 16:41:05 +02:00
irq_64.c x86/percpu: Move irq_stack variables next to current_task 2022-10-17 16:41:05 +02:00
irq_work.c x86/apic: Wrap IPI calls into helper functions 2023-08-09 12:00:55 -07:00
irqflags.S x86: Prepare asm files for straight-line-speculation 2021-12-08 12:25:37 +01:00
irqinit.c x86/i8259: Mark legacy PIC interrupts with IRQ_LEVEL 2023-01-16 17:24:56 +01:00
itmt.c x86/sched/itmt: Give all SMT siblings of a core the same priority 2023-05-08 10:58:38 +02:00
jailhouse.c xen: allow mapping ACPI data using a different physical address 2024-10-04 16:29:43 +02:00
jump_label.c jump_label: make initial NOP patching the special case 2022-06-24 09:48:55 +02:00
kdebugfs.c x86/boot: Fix memremap of setup_indirect structures 2022-03-09 12:49:44 +01:00
kexec-bzimage64.c docs: move x86 documentation into Documentation/arch/ 2023-03-30 12:58:51 -06:00
kgdb.c x86/kgdb: Fix a kerneldoc warning when build with W=1 2023-09-24 11:00:13 +02:00
ksysfs.c x86/boot: Fix memremap of setup_indirect structures 2022-03-09 12:49:44 +01:00
kvm.c * Rework apic callbacks, getting rid of unnecessary ones and 2023-08-30 10:44:46 -07:00
kvmclock.c x86/kvm: Do not try to disable kvmclock if it was not enabled 2024-01-25 15:35:48 -08:00
ldt.c x86: allow get_locked_pte() to fail 2023-06-19 16:19:10 -07:00
machine_kexec_32.c x86/kexec: Set_[gi]dt() -> native_[gi]dt_invalidate() in machine_kexec_*.c 2021-05-21 12:36:45 +02:00
machine_kexec_64.c x86/kexec: Add EFI config table identity mapping for kexec kernel 2024-10-10 11:57:30 +02:00
Makefile Add x86 shadow stack support 2023-08-31 12:20:12 -07:00
mmconf-fam10h_64.c xen: allow mapping ACPI data using a different physical address 2024-10-04 16:29:43 +02:00
module.c x86/alternative: Rename apply_ibt_endbr() 2023-07-10 09:52:23 +02:00
mpparse.c Revert "x86/mpparse: Register APIC address only once" 2024-04-10 16:36:06 +02:00
msr.c x86/MSR: make msr_class a static const structure 2023-08-05 08:31:42 +02:00
nmi.c x86/nmi: Fix the inverse "in NMI handler" check 2024-04-03 15:28:21 +02:00
nmi_selftest.c x86/apic: Wrap IPI calls into helper functions 2023-08-09 12:00:55 -07:00
paravirt-spinlocks.c
paravirt.c x86/paravirt: Fix incorrect virt spinlock setting on bare metal 2024-08-14 13:58:59 +02:00
pci-dma.c x86: always initialize xen-swiotlb when xen-pcifront is enabling 2023-07-31 17:54:27 +02:00
pcspeaker.c
perf_regs.c
platform-quirks.c x86/quirks: Include linux/pnp.h for arch_pnpbios_disabled() 2023-05-18 11:56:18 -07:00
pmem.c x86/pmem: Fix platform-device leak in error path 2022-06-20 18:01:16 +02:00
probe_roms.c x86/sev: Skip ROM range scans and validation for SEV-SNP guests 2024-04-03 15:29:03 +02:00
process.c x86: Increase brk randomness entropy for 64-bit systems 2024-08-29 17:33:35 +02:00
process.h x86: Snapshot thread flags 2021-12-01 00:06:43 +01:00
process_32.c x86/resctl: fix scheduler confusion with 'current' 2023-03-08 11:48:11 -08:00
process_64.c x86/mm: Use IPIs to synchronize LAM enablement 2024-10-04 16:29:04 +02:00
ptrace.c x86: Add PTRACE interface for shadow stack 2023-08-02 15:01:51 -07:00
pvclock.c locking/atomic: treewide: use raw_atomic*_<op>() 2023-06-05 09:57:20 +02:00
quirks.c
reboot.c x86/reboot: Expose VMCS crash hooks if and only if KVM_{INTEL,AMD} is enabled 2023-08-03 15:37:14 -07:00
reboot_fixups_32.c
relocate_kernel_32.S x86/kexec: Disable RET on kexec 2022-07-09 13:12:32 +02:00
relocate_kernel_64.S x86,objtool: Split UNWIND_HINT_EMPTY in two 2023-03-23 23:18:58 +01:00
resource.c x86/PCI: Tidy E820 removal messages 2022-12-10 10:33:11 -06:00
rethook.c x86,rethook: Fix arch_rethook_trampoline() to generate a complete pt_regs 2022-03-28 19:38:51 -07:00
rtc.c rtc: Extend timeout for waiting for UIP to clear to 1s 2024-01-31 16:18:56 -08:00
setup.c x86/coco: Require seeding RNG with RDRAND on CoCo systems 2024-04-10 16:36:03 +02:00
setup_percpu.c x86/apic/32: Remove x86_cpu_to_logical_apicid 2023-08-09 11:58:23 -07:00
sev-shared.c x86/sev: Move early startup code into .head.text section 2024-04-10 16:36:07 +02:00
sev.c x86/sev: Move early startup code into .head.text section 2024-04-10 16:36:07 +02:00
sev_verify_cbit.S x86: Prepare asm files for straight-line-speculation 2021-12-08 12:25:37 +01:00
shstk.c x86/shstk: Make return uprobe work with shadow stack 2024-08-03 08:53:48 +02:00
signal.c x86/pkeys: Add PKRU as a parameter in signal handling functions 2024-10-10 11:57:29 +02:00
signal_32.c x86/shstk: Add user control-protection fault handler 2023-08-02 15:01:50 -07:00
signal_64.c x86/pkeys: Restore altstack access in sigreturn() 2024-10-10 11:57:29 +02:00
smp.c Revert "x86/smp: Put CPUs into INIT on shutdown if possible" 2023-10-15 12:02:02 -07:00
smpboot.c xen: allow mapping ACPI data using a different physical address 2024-10-04 16:29:43 +02:00
stacktrace.c x86: remove __range_not_ok() 2022-02-25 09:36:05 +01:00
static_call.c x86/static_call: Fix __static_call_fixup() 2023-08-17 13:24:09 +02:00
step.c ptrace: Reimplement PTRACE_KILL by always sending SIGKILL 2022-05-11 14:34:28 -05:00
sys_ia32.c
sys_x86_64.c x86/mm: Introduce MAP_ABOVE4G 2023-07-11 14:12:19 -07:00
tboot.c mm: remove rb tree. 2022-09-26 19:46:16 -07:00
time.c x86: stop playing stack games in profile_pc() 2024-07-05 09:33:54 +02:00
tls.c x86/gsseg: Move load_gs_index() to its own new header file 2023-01-12 13:06:36 +01:00
tls.h
topology.c cpu-hotplug: Provide prototypes for arch CPU registration 2023-10-11 14:27:37 +02:00
trace.c trace/osnoise: Fix an ifdef comment 2021-10-25 23:02:36 -04:00
trace_clock.c
tracepoint.c x86/traceponit: Fix comment about irq vector tracepoints 2022-05-26 22:03:52 -04:00
traps.c Add x86 shadow stack support 2023-08-31 12:20:12 -07:00
tsc.c x86/tsc: Extend watchdog check exemption to 4-Sockets platform 2023-07-14 15:17:09 -07:00
tsc_msr.c
tsc_sync.c x86/tsc: Trust initial offset in architectural TSC-adjust MSRs 2024-06-12 11:11:17 +02:00
umip.c x86/umip: Downgrade warning messages to debug loglevel 2021-09-25 13:23:28 +02:00
unwind_frame.c x86: kmsan: don't instrument stack walking functions 2022-10-03 14:03:25 -07:00
unwind_guess.c x86/unwind: Recover kretprobe trampoline entry 2021-09-30 21:24:07 -04:00
unwind_orc.c objtool changes for v6.5: 2023-06-27 15:05:41 -07:00
uprobes.c x86/shstk: Make return uprobe work with shadow stack 2024-08-03 08:53:48 +02:00
verify_cpu.S x86: Prepare asm files for straight-line-speculation 2021-12-08 12:25:37 +01:00
vm86_32.c x86/32: Remove lazy GS macros 2022-04-14 14:09:43 +02:00
vmlinux.lds.S x86/srso: Disentangle rethunk-dependent options 2024-04-10 16:35:50 +02:00
vsmp_64.c x86/apic: Get rid of hard_smp_processor_id() 2023-08-09 11:58:17 -07:00
x86_init.c xen: allow mapping ACPI data using a different physical address 2024-10-04 16:29:43 +02:00