From: Ard Biesheuvel <ardb+git@google.com>
To: linux-efi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Ard Biesheuvel <ardb@kernel.org>, Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>
Subject: [RFC PATCH 3/7] efi/runtime: Deal with arch_efi_call_virt_setup() returning failure
Date: Wed, 14 May 2025 19:43:43 +0200 [thread overview]
Message-ID: <20250514174339.1834871-12-ardb+git@google.com> (raw)
In-Reply-To: <20250514174339.1834871-9-ardb+git@google.com>
From: Ard Biesheuvel <ardb@kernel.org>
Deal with arch_efi_call_virt_setup() returning failure, by giving up and
returning an appropriate error code to the caller.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/x86/platform/uv/bios_uv.c | 3 ++-
drivers/firmware/efi/runtime-wrappers.c | 20 +++++++++++++-------
include/linux/efi.h | 8 ++++----
3 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/arch/x86/platform/uv/bios_uv.c b/arch/x86/platform/uv/bios_uv.c
index bf31af3d32d6..a442bbe5b1c2 100644
--- a/arch/x86/platform/uv/bios_uv.c
+++ b/arch/x86/platform/uv/bios_uv.c
@@ -32,7 +32,8 @@ static s64 __uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3,
*/
return BIOS_STATUS_UNIMPLEMENTED;
- ret = efi_call_virt_pointer(tab, function, (u64)which, a1, a2, a3, a4, a5);
+ ret = efi_call_virt_pointer(tab, function, BIOS_STATUS_UNIMPLEMENTED,
+ (u64)which, a1, a2, a3, a4, a5);
return ret;
}
diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c
index 708b777857d3..82a27b414485 100644
--- a/drivers/firmware/efi/runtime-wrappers.c
+++ b/drivers/firmware/efi/runtime-wrappers.c
@@ -219,7 +219,10 @@ static void __nocfi efi_call_rts(struct work_struct *work)
efi_status_t status = EFI_NOT_FOUND;
unsigned long flags;
- arch_efi_call_virt_setup();
+ if (!arch_efi_call_virt_setup()) {
+ status = EFI_NOT_READY;
+ goto out;
+ }
flags = efi_call_virt_save_flags();
switch (efi_rts_work.efi_rts_id) {
@@ -308,6 +311,7 @@ static void __nocfi efi_call_rts(struct work_struct *work)
efi_call_virt_check_flags(flags, efi_rts_work.caller);
arch_efi_call_virt_teardown();
+out:
efi_rts_work.status = status;
complete(&efi_rts_work.efi_rts_comp);
}
@@ -444,8 +448,8 @@ virt_efi_set_variable_nb(efi_char16_t *name, efi_guid_t *vendor, u32 attr,
if (down_trylock(&efi_runtime_lock))
return EFI_NOT_READY;
- status = efi_call_virt_pointer(efi.runtime, set_variable, name, vendor,
- attr, data_size, data);
+ status = efi_call_virt_pointer(efi.runtime, set_variable, EFI_NOT_READY,
+ name, vendor, attr, data_size, data);
up(&efi_runtime_lock);
return status;
}
@@ -481,9 +485,9 @@ virt_efi_query_variable_info_nb(u32 attr, u64 *storage_space,
if (down_trylock(&efi_runtime_lock))
return EFI_NOT_READY;
- status = efi_call_virt_pointer(efi.runtime, query_variable_info, attr,
- storage_space, remaining_space,
- max_variable_size);
+ status = efi_call_virt_pointer(efi.runtime, query_variable_info,
+ EFI_NOT_READY, attr, storage_space,
+ remaining_space, max_variable_size);
up(&efi_runtime_lock);
return status;
}
@@ -509,12 +513,14 @@ virt_efi_reset_system(int reset_type, efi_status_t status,
return;
}
- arch_efi_call_virt_setup();
+ if (!arch_efi_call_virt_setup())
+ goto out;
efi_rts_work.efi_rts_id = EFI_RESET_SYSTEM;
arch_efi_call_virt(efi.runtime, reset_system, reset_type, status,
data_size, data);
arch_efi_call_virt_teardown();
+out:
up(&efi_runtime_lock);
}
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 7d63d1d75f22..13aff30be3a9 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -1179,19 +1179,19 @@ static inline void efi_check_for_embedded_firmwares(void) { }
* Restores the usual kernel environment once the call has returned.
*/
-#define efi_call_virt_pointer(p, f, args...) \
+#define efi_call_virt_pointer(p, f, busy, args...) \
({ \
- typeof((p)->f(args)) __s; \
+ typeof((p)->f(args)) __s = (busy); \
unsigned long __flags; \
\
- arch_efi_call_virt_setup(); \
+ if (!arch_efi_call_virt_setup()) goto __out; \
\
__flags = efi_call_virt_save_flags(); \
__s = arch_efi_call_virt(p, f, args); \
efi_call_virt_check_flags(__flags, NULL); \
\
arch_efi_call_virt_teardown(); \
- \
+__out: \
__s; \
})
--
2.49.0.1101.gccaa498523-goog
next prev parent reply other threads:[~2025-05-14 17:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-14 17:43 [RFC PATCH 0/7] arm64: Make EFI calls preemptible Ard Biesheuvel
2025-05-14 17:43 ` [RFC PATCH 1/7] efi: Add missing static initializer for efi_mm::cpus_allowed_lock Ard Biesheuvel
2025-05-14 17:43 ` [RFC PATCH 2/7] efi/runtime: Return success/failure from arch_efi_call_virt_setup() Ard Biesheuvel
2025-05-14 17:43 ` Ard Biesheuvel [this message]
2025-05-14 17:43 ` [RFC PATCH 4/7] arm64/fpsimd: Don't warn when EFI execution context is preemptible Ard Biesheuvel
2025-05-14 17:43 ` [RFC PATCH 5/7] arm64/efi: Use a semaphore to protect the EFI stack and FP/SIMD state Ard Biesheuvel
2025-05-14 17:43 ` [RFC PATCH 6/7] arm64/efi: Move uaccess en/disable out of efi_set_pgd() Ard Biesheuvel
2025-07-11 13:41 ` Will Deacon
2025-07-14 6:38 ` Ard Biesheuvel
2025-05-14 17:43 ` [RFC PATCH 7/7] arm64/efi: Call EFI runtime services without disabling preemption Ard Biesheuvel
2025-07-11 13:48 ` Peter Zijlstra
2025-07-14 2:20 ` Ard Biesheuvel
2025-07-14 10:55 ` Peter Zijlstra
2025-07-15 0:46 ` Ard Biesheuvel
2025-07-11 13:44 ` [RFC PATCH 0/7] arm64: Make EFI calls preemptible Will Deacon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250514174339.1834871-12-ardb+git@google.com \
--to=ardb+git@google.com \
--cc=ardb@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=peterz@infradead.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).