From: "Ard Biesheuvel" <ardb@kernel.org>
To: "Junxiao Chang" <junxiao.chang@intel.com>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Sebastian Andrzej Siewior" <bigeasy@linutronix.de>
Subject: Re: [PATCH] mefi: add dynamic control interface for EFI runtime services
Date: Thu, 23 Jul 2026 08:37:23 +0200 [thread overview]
Message-ID: <d107385f-1c58-4aa0-beac-7d536d064600@app.fastmail.com> (raw)
In-Reply-To: <20260704003341.3923900-1-junxiao.chang@intel.com>
(cc Sebastian)
On Sat, 4 Jul 2026, at 02:33, Junxiao Chang wrote:
> 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
I'd prefer not to add a command line option for this. If the sysfs control
is useful, we can enable it unconditionally, or depend on PREEMPT_RT.
> 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);
This is racy, no?
> + 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
next prev parent reply other threads:[~2026-07-23 6:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-04 0:33 Junxiao Chang
2026-07-23 6:37 ` Ard Biesheuvel [this message]
2026-07-30 6:14 ` Chang, Junxiao
2026-08-12 14:41 ` Sebastian Andrzej Siewior
2026-08-13 8:12 ` Chang, Junxiao
2026-07-31 6:24 ` [PATCH] efi: " Junxiao Chang
2026-08-01 13:45 ` Ard Biesheuvel
2026-08-06 9:49 ` Junxiao Chang
2026-08-15 9:50 ` Junxiao Chang
2026-09-03 10:08 ` Ard Biesheuvel
2026-09-08 10:17 ` Ilias Apalodimas
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=d107385f-1c58-4aa0-beac-7d536d064600@app.fastmail.com \
--to=ardb@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=ilias.apalodimas@linaro.org \
--cc=junxiao.chang@intel.com \
--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
all inboxes | Powered by JetHome®