linux/drivers/firmware
Kirill A. Shutemov c211c19e80 efi/unaccepted: Avoid load_unaligned_zeropad() stepping into unaccepted memory
load_unaligned_zeropad() can lead to unwanted loads across page boundaries.
The unwanted loads are typically harmless. But, they might be made to
totally unrelated or even unmapped memory. load_unaligned_zeropad()
relies on exception fixup (#PF, #GP and now #VE) to recover from these
unwanted loads.

But, this approach does not work for unaccepted memory. For TDX, a load
from unaccepted memory will not lead to a recoverable exception within
the guest. The guest will exit to the VMM where the only recourse is to
terminate the guest.

There are two parts to fix this issue and comprehensively avoid access
to unaccepted memory. Together these ensure that an extra "guard" page
is accepted in addition to the memory that needs to be used.

1. Implicitly extend the range_contains_unaccepted_memory(start, end)
   checks up to end+unit_size if 'end' is aligned on a unit_size
   boundary.
2. Implicitly extend accept_memory(start, end) to end+unit_size if 'end'
   is aligned on a unit_size boundary.

Side note: This leads to something strange. Pages which were accepted
	   at boot, marked by the firmware as accepted and will never
	   _need_ to be accepted might be on unaccepted_pages list
	   This is a cue to ensure that the next page is accepted
	   before 'page' can be used.

This is an actual, real-world problem which was discovered during TDX
testing.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20230606142637.5171-7-kirill.shutemov@linux.intel.com
2023-06-06 17:27:08 +02:00
..
arm_ffa firmware: arm_ffa: Set reserved/MBZ fields to zero in the memory descriptors 2023-05-08 20:40:46 +01:00
arm_scmi firmware: arm_scmi: Fix incorrect alloc_workqueue() invocation 2023-05-08 20:40:25 +01:00
broadcom MIPS: BCM47XX: remove MODULE_LICENSE in non-modules 2023-04-13 13:13:51 -07:00
cirrus firmware: cs_dsp: Add a debugfs entry containing control details 2023-04-03 12:15:28 +01:00
efi efi/unaccepted: Avoid load_unaligned_zeropad() stepping into unaccepted memory 2023-06-06 17:27:08 +02:00
google Char/Misc and other driver subsystem changes for 6.3-rc1 2023-02-24 12:47:33 -08:00
imx firmware: imx: scu-pd: add missed lvds lpi2c and pwm power domains 2023-03-06 11:12:36 +08:00
meson firmware: meson_sm: populate platform devices from sm device tree data 2023-03-27 12:07:17 +02:00
psci firmware/psci: demote suspend-mode warning to info level 2023-04-14 13:48:56 +02:00
smccc irqchip/gicv3: Workaround for NVIDIA erratum T241-FABRIC-4 2023-04-08 10:51:23 +01:00
tegra firmware: Use of_property_present() for testing DT property presence 2023-04-04 21:51:23 +02:00
xilinx Merge 6.3-rc3 into char-misc-next 2023-03-20 09:06:37 +01:00
arm_scpi.c firmware: arm_scpi: Ensure scpi_info is not assigned if the probe fails 2022-07-04 14:28:42 +01:00
arm_sdei.c firmware: arm_sdei: Fix sleep from invalid context BUG 2023-03-28 15:21:35 +01:00
dmi-id.c driver core: make struct class.dev_uevent() take a const * 2022-11-24 17:12:15 +01:00
dmi-sysfs.c firmware: dmi-sysfs: make kobj_type structures constant 2023-03-09 17:31:16 +01:00
dmi_scan.c firmware: dmi: Fortify entry point length checks 2022-09-23 14:53:14 +02:00
edd.c edd: make kobj_type structure constant 2023-03-09 18:07:33 +01:00
iscsi_ibft.c
iscsi_ibft_find.c
Kconfig sound updates for 5.19-rc1 2022-05-25 16:55:16 -07:00
Makefile Follow-up tweaks for the EFI changes in v5.19 2022-06-03 13:39:30 -07:00
memmap.c
mtk-adsp-ipc.c firmware: mediatek: Use meaningful names for mbox 2022-06-22 13:39:30 +01: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 ARM: SoC drivers for v6.4 2023-04-25 12:02:16 -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 Char/Misc driver changes for 6.2-rc1 2022-12-16 03:49:24 -08:00
scpi_pm_domain.c
stratix10-rsu.c firmware: stratix10-rsu: extend RSU driver to get DCMF status 2022-07-14 16:55:09 +02:00
stratix10-svc.c firmware: stratix10-svc: Fix an NULL vs IS_ERR() bug in probe 2023-04-20 11:45:28 +02:00
sysfb.c efi: sysfb_efi: Fix DMI quirks not working for simpledrm 2023-03-18 11:44:57 +01:00
sysfb_simplefb.c firmware/sysfb: Fix VESA format selection 2023-04-21 14:27:31 +02:00
ti_sci.c firmware: ti_sci: Use devm_bitmap_zalloc when applicable 2022-11-03 21:45:10 -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