linux-stable/drivers/firmware
Kirill A. Shutemov 50e782a86c efi/unaccepted: Fix soft lockups caused by parallel memory acceptance
Michael reported soft lockups on a system that has unaccepted memory.
This occurs when a user attempts to allocate and accept memory on
multiple CPUs simultaneously.

The root cause of the issue is that memory acceptance is serialized with
a spinlock, allowing only one CPU to accept memory at a time. The other
CPUs spin and wait for their turn, leading to starvation and soft lockup
reports.

To address this, the code has been modified to release the spinlock
while accepting memory. This allows for parallel memory acceptance on
multiple CPUs.

A newly introduced "accepting_list" keeps track of which memory is
currently being accepted. This is necessary to prevent parallel
acceptance of the same memory block. If a collision occurs, the lock is
released and the process is retried.

Such collisions should rarely occur. The main path for memory acceptance
is the page allocator, which accepts memory in MAX_ORDER chunks. As long
as MAX_ORDER is equal to or larger than the unit_size, collisions will
never occur because the caller fully owns the memory block being
accepted.

Aside from the page allocator, only memblock and deferered_free_range()
accept memory, but this only happens during boot.

The code has been tested with unit_size == 128MiB to trigger collisions
and validate the retry codepath.

Fixes: 2053bc57f3 ("efi: Add unaccepted memory support")
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-by: Michael Roth <michael.roth@amd.com
Reviewed-by: Nikolay Borisov <nik.borisov@suse.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Tested-by: Michael Roth <michael.roth@amd.com>
[ardb: drop unnecessary cpu_relax() call]
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2023-10-20 18:10:06 +02:00
..
arm_ffa firmware: arm_ffa: Set handle field to zero in memory descriptor 2023-06-06 13:41:56 +01:00
arm_scmi ARM: SoC cleanups for 6.6 2023-08-30 16:49:40 -07:00
broadcom MIPS: BCM47XX: remove MODULE_LICENSE in non-modules 2023-04-13 13:13:51 -07:00
cirrus firmware: cs_dsp: Fix new control name check 2023-08-15 19:23:01 +01:00
efi efi/unaccepted: Fix soft lockups caused by parallel memory acceptance 2023-10-20 18:10:06 +02:00
google firmware: coreboot: framebuffer: Allow building with simpledrm 2023-08-04 16:31:32 +02:00
imx ARM: SoC cleanups for 6.6 2023-08-30 16:49:40 -07:00
meson firmware: meson_sm: fix to avoid potential NULL pointer dereference 2023-08-04 15:19:01 +02:00
psci firmware/psci: demote suspend-mode warning to info level 2023-04-14 13:48:56 +02:00
smccc firmware: smccc: Fix use of uninitialised results structure 2023-07-18 10:08:05 +01:00
tegra firmware: Explicitly include correct DT includes 2023-08-12 10:31:01 +02:00
xilinx Pin control bulk changes for the v6.6 kernel cycle: 2023-08-30 19:36:19 -07:00
arm_scpi.c
arm_sdei.c arm64: sdei: abort running SDEI handlers during crash 2023-08-04 17:35:33 +01:00
dmi-id.c
dmi-sysfs.c firmware: dmi-sysfs: handle HAS_IOPORT=n 2023-05-31 19:17:29 +01:00
dmi_scan.c
edd.c edd: make kobj_type structure constant 2023-03-09 18:07:33 +01:00
iscsi_ibft.c
iscsi_ibft_find.c iscsi_ibft: Fix finding the iBFT under Xen Dom 0 2023-06-26 07:47:11 +02:00
Kconfig
Makefile
memmap.c
mtk-adsp-ipc.c firmware: Explicitly include correct DT includes 2023-08-12 10:31:01 +02:00
pcdp.c
pcdp.h
qcom_scm-legacy.c firmware: qcom_scm: Move qcom_scm.h to include/linux/firmware/qcom/ 2023-02-08 19:15:16 -08:00
qcom_scm-smc.c firmware: qcom_scm: Move qcom_scm.h to include/linux/firmware/qcom/ 2023-02-08 19:15:16 -08:00
qcom_scm.c firmware: qcom_scm: Convert all symbols to EXPORT_SYMBOL_GPL 2023-07-27 20:29:06 -07:00
qcom_scm.h firmware: qcom: scm: Add wait-queue handling logic 2023-01-18 21:14:40 -06:00
qemu_fw_cfg.c
raspberrypi.c firmware: Explicitly include correct DT includes 2023-08-12 10:31:01 +02:00
scpi_pm_domain.c firmware: Explicitly include correct DT includes 2023-08-12 10:31:01 +02:00
stratix10-rsu.c Char/Misc driver changes for 6.6-rc1 2023-09-01 09:53:54 -07:00
stratix10-svc.c firmware: stratix10-svc: Generic Mailbox Command 2023-08-04 16:31:37 +02:00
sysfb.c drivers/firmware: Move sysfb_init() from device_initcall to subsys_initcall_sync 2023-05-15 13:36:30 +02:00
sysfb_simplefb.c firmware/sysfb: Fix VESA format selection 2023-04-21 14:27:31 +02:00
ti_sci.c firmware: ti_sci: Fixup documentation errors 2023-07-11 13:04:14 -05:00
ti_sci.h
trusted_foundations.c
turris-mox-rwtm.c firmware: turris-mox-rwtm: make kobj_type structure constant 2023-04-07 17:17:00 +02:00