linux/drivers
Ard Biesheuvel 2dfaeac3f3 x86/efistub: Avoid legacy decompressor when doing EFI boot
From: Ard Biesheuvel <ardb@kernel.org>

[ Commit a1b87d54f4 upstream ]

The bare metal decompressor code was never really intended to run in a
hosted environment such as the EFI boot services, and does a few things
that are becoming problematic in the context of EFI boot now that the
logo requirements are getting tighter: EFI executables will no longer be
allowed to consist of a single executable section that is mapped with
read, write and execute permissions if they are intended for use in a
context where Secure Boot is enabled (and where Microsoft's set of
certificates is used, i.e., every x86 PC built to run Windows).

To avoid stepping on reserved memory before having inspected the E820
tables, and to ensure the correct placement when running a kernel build
that is non-relocatable, the bare metal decompressor moves its own
executable image to the end of the allocation that was reserved for it,
in order to perform the decompression in place. This means the region in
question requires both write and execute permissions, which either need
to be given upfront (which EFI will no longer permit), or need to be
applied on demand using the existing page fault handling framework.

However, the physical placement of the kernel is usually randomized
anyway, and even if it isn't, a dedicated decompression output buffer
can be allocated anywhere in memory using EFI APIs when still running in
the boot services, given that EFI support already implies a relocatable
kernel. This means that decompression in place is never necessary, nor
is moving the compressed image from one end to the other.

Since EFI already maps all of memory 1:1, it is also unnecessary to
create new page tables or handle page faults when decompressing the
kernel. That means there is also no need to replace the special
exception handlers for SEV. Generally, there is little need to do
any of the things that the decompressor does beyond

- initialize SEV encryption, if needed,
- perform the 4/5 level paging switch, if needed,
- decompress the kernel
- relocate the kernel

So do all of this from the EFI stub code, and avoid the bare metal
decompressor altogether.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20230807162720.545787-24-ardb@kernel.org
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2024-03-06 14:45:18 +00:00
..
accessibility tty: fix possible null-ptr-defer in spk_ttyio_release 2023-01-24 07:24:37 +01:00
acpi ACPI: APEI: set memory failure flags as MF_ACTION_REQUIRED on synchronous events 2024-02-05 20:12:47 +00:00
amba amba: bus: fix refcount leak 2023-09-13 09:42:56 +02:00
android binder: signal epoll threads of self-work 2024-02-23 09:12:39 +01:00
ata ahci: Extend ASM1061 43-bit DMA address quirk to other ASM106x parts 2024-03-01 13:26:39 +01:00
atm atm: idt77252: fix a memleak in open_card_ubr0 2024-02-16 19:06:26 +01:00
auxdisplay auxdisplay: hd44780: move cursor home after clear display command 2023-12-08 08:51:16 +01:00
base pmdomain: core: Move the unused cleanup to a _sync initcall 2024-02-23 09:12:47 +01:00
bcma Interrupt subsystem updates: 2022-10-12 10:23:24 -07:00
block virtio-blk: Ensure no requests in virtqueues before deleting vqs. 2024-03-01 13:26:30 +01:00
bluetooth Bluetooth: hci_qca: Set BDA quirk bit if fwnode exists in DT 2024-03-06 14:45:08 +00:00
bus bus: moxtet: Add spi device table 2024-02-23 09:12:48 +01:00
cdrom block: remove blk_cleanup_disk 2022-06-28 06:33:15 -06:00
char hwrng: core - Fix page fault dead lock on mmap-ed hwrng 2024-01-31 16:16:58 -08:00
clk clk: tegra20: fix gcc-7 constant overflow warning 2024-03-06 14:45:05 +00:00
clocksource clocksource/drivers/timer-ti-dm: Fix make W=n kerneldoc warnings 2024-01-25 15:27:39 -08:00
comedi comedi: adv_pci1760: Fix PWM instruction handling 2023-01-24 07:24:35 +01:00
connector connector/cn_proc: Use task_is_in_init_pid_ns() 2022-01-26 18:57:09 -08:00
counter counter: microchip-tcb-capture: Fix the use of internal GCLK logic 2023-10-19 23:08:58 +02:00
cpufreq cpufreq: intel_pstate: fix pstate limits enforcement for adjust_perf call back 2024-03-06 14:45:06 +00:00
cpuidle powerpc/pseries: Rework lppaca_shared_proc() to avoid DEBUG_PREEMPT 2023-09-13 09:42:48 +02:00
crypto crypto: virtio/akcipher - Fix stack overflow on memcpy 2024-03-01 13:26:32 +01:00
cxl cxl/pci: Fix disabling memory if DVSEC CXL Range does not match a CFMWS window 2024-03-01 13:26:31 +01:00
dax dax/kmem: Pass valid argument to memory_group_register_static 2023-07-19 16:21:43 +02:00
dca dca: Use PTR_ERR_OR_ZERO() to simplify code 2020-05-15 16:25:20 +02:00
devfreq PM / devfreq: Synchronize devfreq_monitor_[start/stop] 2024-02-05 20:12:47 +00:00
dio drivers: dio: fix possible memory leak in dio_init() 2022-12-31 13:32:38 +01:00
dma dmaengine: fsl-qdma: init irq after reg initialization 2024-03-06 14:45:10 +00:00
dma-buf dma-buf: fix check in dma_resv_add_fence 2023-12-08 08:51:15 +01:00
edac EDAC/thunderx: Fix possible out-of-bounds string access 2024-01-25 15:27:18 -08:00
eisa EISA: use DEVICE_ATTR_RO() helper macro 2021-06-04 15:28:34 +02:00
extcon extcon: cht_wc: add POWER_SUPPLY dependency 2023-09-13 09:42:53 +02:00
firewire firewire: core: send bus reset promptly on gap count error 2024-03-01 13:26:30 +01:00
firmware x86/efistub: Avoid legacy decompressor when doing EFI boot 2024-03-06 14:45:18 +00:00
fpga fpga: bridge: fix kernel-doc parameter description 2023-05-11 23:03:27 +09:00
fsi fsi: aspeed: Reset master errors after CFAM reset 2023-09-13 09:42:54 +02:00
gnss gnss: replace ida_simple API 2022-06-21 09:30:36 +02:00
gpio gpio: eic-sprd: Clear interrupt after set the interrupt type 2024-01-31 16:17:11 -08:00
gpu drm/amd/display: Increase frame warning limit with KASAN or KCSAN in dml 2024-03-06 14:45:14 +00:00
greybus greybus: svc: clean up link configuration hack at hello 2022-02-04 15:27:44 +01:00
hid HID: wacom: Do not register input devices until after hid_hw_start 2024-02-23 09:12:33 +01:00
hsi HSI: omap_ssi_core: Fix error handling in ssi_init() 2022-12-31 13:32:45 +01:00
hte hte: tegra: Fix missing error code in tegra_hte_test_probe() 2023-11-20 11:51:58 +01:00
hv Drivers: hv: vmbus: Don't dereference ACPI root object handle 2023-09-13 09:42:59 +02:00
hwmon hwmon: (coretemp) Enlarge per package core count limit 2024-03-01 13:26:29 +01:00
hwspinlock hwspinlock: qcom: add missing regmap config for SFPB MMIO implementation 2023-09-19 12:28:05 +02:00
hwtracing coresight: etm4x: Fix width of CCITMIN field 2024-01-20 11:50:11 +01:00
i2c i2c: imx: when being a target, mark the last read as processed 2024-03-01 13:26:38 +01:00
i3c i3c: master: cdns: Update maximum prescaler value for i2c clock 2024-02-05 20:12:58 +00:00
idle intel_idle: add Emerald Rapids Xeon support 2023-10-10 22:00:44 +02:00
iio iio: imu: bno055: serdev requires REGMAP 2024-02-23 09:12:41 +01:00
infiniband trace: Relocate event helper files 2024-03-06 14:45:17 +00:00
input Input: xpad - add constants for GIP interface numbers 2024-03-06 14:45:05 +00:00
interconnect interconnect: qcom: sc8180x: Mark CO0 BCM keepalive 2024-02-23 09:12:34 +01:00
iommu iommu/arm-smmu-qcom: Limit the SMR groups to 128 2024-03-06 14:45:06 +00:00
ipack Char/Misc and other driver changes for 6.1-rc1 2022-10-08 08:56:37 -07:00
irqchip irqchip/sifive-plic: Enable interrupt if needed before EOI 2024-03-01 13:26:32 +01:00
isdn mISDN: Update parameter type of dsp_cmx_send() 2023-08-16 18:27:26 +02:00
leds leds: trigger: panic: Don't register panic notifier if creating the trigger failed 2024-02-05 20:12:57 +00:00
macintosh macintosh: via-pmu-led: requires ATA to be set 2023-05-11 23:03:31 +09:00
mailbox mailbox: arm_mhuv2: Fix a bug for mhuv2_sender_interrupt 2024-02-05 20:12:58 +00:00
mcb mcb: fix error handling for different scenarios when parsing 2023-11-28 17:07:13 +00:00
md dm-integrity, dm-verity: reduce stack usage for recheck 2024-03-01 13:26:33 +01:00
media media: rc: bpf attach/detach requires write permission 2024-02-23 09:12:41 +01:00
memory memory: brcmstb_dpfe: fix testing array offset after use 2023-07-19 16:21:24 +02:00
memstick memstick r592: make memstick_debug_get_tpc_name() static 2023-07-19 16:21:08 +02:00
message scsi: message: mptlan: Fix use after free bug in mptlan_remove() due to race condition 2023-05-24 17:32:37 +01:00
mfd mfd: ti_am335x_tscadc: Fix TI SoC dependencies 2024-02-05 20:12:58 +00:00
misc misc: open-dice: Fix spurious lockdep warning 2024-03-01 13:26:27 +01:00
mmc mmc: sdhci-xenon: fix PHY init clock stability 2024-03-06 14:45:11 +00:00
most most: usb: replace snprintf in show functions with sysfs_emit 2021-11-26 17:03:47 +01:00
mtd mtd: spinand: gigadevice: Fix the get ecc status issue 2024-03-06 14:45:06 +00:00
mux mux: Fix struct mux_state kernel-doc comment 2022-02-04 15:47:12 +01:00
net gtp: fix use-after-free and null-ptr-deref in gtp_newlink() 2024-03-06 14:45:10 +00:00
nfc nfcsim.c: Fix error checking for debugfs_create_dir 2023-06-28 11:12:36 +02:00
ntb ntb: Fix calculation ntb_transport_tx_free_entry() 2023-09-13 09:43:02 +02:00
nubus nubus: Partially revert proc_create_single_data() conversion 2023-07-05 18:27:37 +01:00
nvdimm nd_btt: Make BTT lanes preemptible 2023-11-20 11:52:05 +01:00
nvme nvmet-fc: take ref count on tgtport before delete assoc 2024-03-01 13:26:28 +01:00
nvmem nvmem: imx: correct nregs for i.MX6UL 2023-11-02 09:35:31 +01:00
of of: property: fw_devlink: Fix stupid bug in remote-endpoint parsing 2024-03-06 14:45:09 +00:00
opp OPP: Pass rounded rate to _set_opp() 2024-01-31 16:16:58 -08:00
parisc parisc/power: Fix power soft-off button emulation on qemu 2024-01-31 16:16:59 -08:00
parport parport: parport_serial: Add Brainboxes device IDs and geometry 2024-01-20 11:50:11 +01:00
pci PCI: layerscape: Add workaround for lost link capabilities during reset 2024-03-06 14:45:05 +00:00
pcmcia pcmcia: ds: fix possible name leak in error path in pcmcia_device_add() 2023-11-20 11:52:13 +01:00
peci peci: cpu: Fix use-after-free in adev_release() 2022-08-15 20:31:35 +02:00
perf perf: hisi: Fix use-after-free when register pmu fails 2023-11-20 11:52:01 +01:00
phy phy: ti: phy-omap-usb2: Fix NULL pointer dereference for SRP 2024-02-16 19:06:25 +01:00
pinctrl pinctrl: cy8c95x0: Fix get_pincfg 2024-01-20 11:50:09 +01:00
platform platform/x86: thinkpad_acpi: Only update profile if successfully converted 2024-03-01 13:26:37 +01:00
pnp PNP: ACPI: fix fortify warning 2024-02-05 20:12:47 +00:00
power power: supply: bq27xxx-i2c: Do not free non existing IRQ 2024-03-06 14:45:09 +00:00
powercap powercap: DTPM: Fix missing cpufreq_cpu_put() calls 2023-12-13 18:39:21 +01:00
pps pps: generators: pps_gen_parport: Switch to use module_parport_driver() 2022-03-18 14:01:19 +01:00
ps3 powerpc/ps3: Warn on PS3 device errors 2021-06-10 21:44:58 +10:00
ptp ptp: annotate data-race around q->head and q->tail 2023-11-28 17:07:05 +00:00
pwm pwm: Fix out-of-bounds access in of_pwm_single_xlate() 2024-01-25 15:27:42 -08:00
rapidio rapidio: devices: fix missing put_device in mport_cdev_open 2022-12-31 13:32:00 +01:00
ras RAS/CEC: Reduce offline page threshold for Intel systems 2022-08-22 19:30:02 +02:00
regulator regulator: pwm-regulator: Add validity checks in continuous .get_voltage 2024-03-01 13:26:26 +01:00
remoteproc remoteproc: imx_dsp_rproc: Fix kernel test robot sparse warning 2023-05-24 17:32:53 +01:00
reset reset: hisilicon: hi6220: fix Wvoid-pointer-to-enum-cast warning 2024-01-20 11:50:07 +01:00
rpmsg rpmsg: virtio: Free driver_override when rpmsg_remove() 2024-01-31 16:16:59 -08:00
rtc rtc: Extend timeout for waiting for UIP to clear to 1s 2024-01-31 16:17:01 -08:00
s390 s390/cio: fix invalid -EBUSY on ccw_device_start 2024-03-01 13:26:31 +01:00
sbus module: remove never implemented MODULE_SUPPORTED_DEVICE 2021-03-17 13:16:18 -07:00
scsi scsi: sd: usb_storage: uas: Access media prior to querying device properties 2024-03-06 14:45:04 +00:00
sh genirq: Add and use an irq_data_update_affinity helper 2022-07-07 09:38:04 +01:00
siox siox: fix possible memory leak in siox_device_add() 2022-11-09 15:40:14 +01:00
slimbus slimbus: qcom-ngd: Fix build error when CONFIG_SLIM_QCOM_NGD_CTRL=y && CONFIG_QCOM_RPROC_COMMON=m 2022-11-10 18:45:40 +01:00
soc pmdomain: qcom: rpmhpd: Fix enabled_corner aggregation 2024-03-06 14:45:11 +00:00
soundwire soundwire: stream: fix NULL pointer dereference for multi_link 2023-12-20 17:00:25 +01:00
spi spi: sh-msiof: avoid integer overflow in constants 2024-03-01 13:26:27 +01:00
spmi spmi: mediatek: Fix UAF on device remove 2024-02-05 20:12:58 +00:00
ssb ssb: gpio: Use generic_handle_irq_safe() 2022-09-19 15:08:38 +02:00
staging staging: iio: ad5933: fix type mismatch regression 2024-02-23 09:12:40 +01:00
target scsi: target: pscsi: Fix bio_put() for error case 2024-03-01 13:26:31 +01:00
tc The main MIPS changes for 5.6: 2020-01-31 11:28:31 -08:00
tee tee: optee: Fix supplicant based device enumeration 2023-12-13 18:39:12 +01:00
thermal thermal: intel: hfi: Add syscore callbacks for system-wide PM 2024-01-31 16:17:09 -08:00
thunderbolt thunderbolt: Fix memory leak in margining_port_remove() 2024-01-01 12:39:08 +00:00
tty serial: amba-pl011: Fix DMA transmission in RS485 mode 2024-03-01 13:26:33 +01:00
ufs scsi: ufs: core: Remove the ufshcd_release() in ufshcd_err_handling_prepare() 2024-03-01 13:26:30 +01:00
uio uio: Fix use-after-free in uio_open 2024-01-20 11:50:10 +01:00
usb usb: gadget: Properly configure the device for remote wakeup 2024-03-06 14:45:05 +00:00
vdpa vdpa: Fix an error handling path in eni_vdpa_probe() 2024-01-25 15:27:47 -08:00
vfio iommufd/iova_bitmap: Consider page offset for the pages to be pinned 2024-03-01 13:26:35 +01:00
vhost vhost: use kzalloc() instead of kmalloc() followed by memset() 2024-02-16 19:06:31 +01:00
video fbcon: always restore the old font data in fbcon_do_set_font() 2024-03-06 14:45:09 +00:00
virt virt: sevguest: Fix passing a stack buffer as a scatterlist target 2023-11-20 11:52:13 +01:00
virtio virtio_pci: fix the common cfg map size 2023-11-02 09:35:23 +01:00
vlynq bus: Make remove callback return void 2021-07-21 11:53:42 +02:00
w1 w1: fix loop in w1_fini() 2023-07-19 16:21:48 +02:00
watchdog watchdog: it87_wdt: Keep WDTCTRL bit 3 unmodified for IT8784/IT8786 2024-02-05 20:12:56 +00:00
xen xen/gntdev: Fix the abuse of underlying struct page in DMA-buf import 2024-02-05 20:12:58 +00:00
zorro proc: remove PDE_DATA() completely 2022-01-22 08:33:37 +02:00
Kconfig vme: move back to staging 2022-06-10 15:38:14 +02:00
Makefile hwtracing: hisi_ptt: Add trace function support for HiSilicon PCIe Tune and Trace device 2022-09-08 16:26:17 -06:00