2023-01-19 20:42:22

by Demi Marie Obenour

[permalink] [raw]
Subject: [PATCH v3 5/5] efi: Warn if trying to reserve memory under Xen

Doing so cannot work and should never happen.

Signed-off-by: Demi Marie Obenour <[email protected]>
Tested-by: Marek Marczykowski-Górecki <[email protected]>
---
drivers/firmware/efi/efi.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index b49fcde06ca0ff5347047666f38b9309bd9cfe26..902f323499d8acc4f2b846a78993eb201448acad 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -519,6 +519,10 @@ void __init __weak efi_arch_mem_reserve(phys_addr_t addr, u64 size) {}
*/
void __init efi_mem_reserve(phys_addr_t addr, u64 size)
{
+ /* efi_mem_reserve() does not work under Xen */
+ if (WARN_ON_ONCE(efi_enabled(EFI_PARAVIRT)))
+ return;
+
if (!memblock_is_region_reserved(addr, size))
memblock_reserve(addr, size);

--
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab