From: Junxiao Chang <junxiao.chang@intel.com>
To: ardb@kernel.org, ilias.apalodimas@linaro.org,
linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: -cc=junxiao.chang@intel.com
Subject: [PATCH] mefi: add dynamic control interface for EFI runtime services
Date: Sat, 4 Jul 2026 08:33:41 +0800 [thread overview]
Message-ID: <20260704003341.3923900-1-junxiao.chang@intel.com> (raw)
Add an interface to dynamically enable or disable EFI runtime
services at runtime. By default, EFI runtime services remain
enabled, but they can be temporarily disabled to improve real-time
latency.
Currently, EFI runtime services are typically disabled on RT
systems using kernel parameters such as "noefi" or "efi=disable".
However, this permanently disables EFI services, preventing use
cases such as UEFI firmware updates.
With this change, EFI runtime services can be disabled during
execution of real-time workloads and re-enabled afterwards,
allowing better balance between real-time performance and firmware
service availability.
Signed-off-by: Junxiao Chang <junxiao.chang@intel.com>
---
.../admin-guide/kernel-parameters.txt | 5 ++-
drivers/firmware/efi/efi.c | 39 +++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index b5493a7f8f228..533213101f808 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1595,7 +1595,8 @@ Kernel parameters
efi= [EFI,EARLY]
Format: { "debug", "disable_early_pci_dma",
"nochunk", "noruntime", "nosoftreserve",
- "novamap", "no_disable_early_pci_dma" }
+ "novamap", "no_disable_early_pci_dma",
+ "dynamic" }
debug: enable misc debug output.
disable_early_pci_dma: disable the busmaster bit on all
PCI bridges while in the EFI boot stub.
@@ -1612,6 +1613,8 @@ Kernel parameters
novamap: do not call SetVirtualAddressMap().
no_disable_early_pci_dma: Leave the busmaster bit set
on all PCI bridges while in the EFI boot stub
+ dynamic: enable EFI runtime services, which can be
+ disabled via /sys/firmware/efi/dynamic_enable.
efi_no_storage_paranoia [EFI,X86,EARLY]
Using this parameter you can use more than 50% of
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 0327a39d31fa5..18d5d99fab821 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -81,6 +81,7 @@ struct mm_struct efi_mm = {
struct workqueue_struct *efi_rts_wq;
+static bool efi_in_dynamic __initdata;
static bool disable_runtime = IS_ENABLED(CONFIG_EFI_DISABLE_RUNTIME);
static int __init setup_noefi(char *arg)
{
@@ -115,6 +116,11 @@ static int __init parse_efi_cmdline(char *str)
if (parse_option_str(str, "runtime"))
disable_runtime = false;
+ if (parse_option_str(str, "dynamic")) {
+ disable_runtime = false;
+ efi_in_dynamic = true;
+ }
+
if (parse_option_str(str, "nosoftreserve"))
set_bit(EFI_MEM_NO_SOFT_RESERVE, &efi.flags);
@@ -401,6 +407,34 @@ static void __init efi_debugfs_init(void)
static inline void efi_debugfs_init(void) {}
#endif
+static ssize_t efi_dynamic_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%d\n", efi_enabled(EFI_RUNTIME_SERVICES));
+}
+
+static ssize_t efi_dynamic_store(struct kobject *kobj, struct kobj_attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret;
+ bool enable;
+
+ ret = kstrtobool(buf, &enable);
+ if (ret)
+ return ret;
+
+ if (enable)
+ set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
+ else {
+ clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
+ if (efi_rts_wq)
+ flush_workqueue(efi_rts_wq);
+ }
+
+ return count;
+}
+static struct kobj_attribute efi_dynamic_attr =
+ __ATTR(dynamic_enable, 0644, efi_dynamic_show, efi_dynamic_store);
+
static int __init efipostcore_init(void)
{
if (!efi_enabled(EFI_RUNTIME_SERVICES))
@@ -446,6 +480,11 @@ static int __init efisubsys_init(void)
goto err_destroy_wq;
}
+ if (efi_in_dynamic && efi.runtime_supported_mask) {
+ if (sysfs_create_file(efi_kobj, &efi_dynamic_attr.attr))
+ pr_warn("unable to register efi dynamic sysfs interface\n");
+ }
+
if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE |
EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME)) {
error = generic_ops_register();
--
2.43.0
reply other threads:[~2026-07-03 0:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260704003341.3923900-1-junxiao.chang@intel.com \
--to=junxiao.chang@intel.com \
--cc=-cc=junxiao.chang@intel.com \
--cc=ardb@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.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