From: "Jasmeet (Jazz) Bhatia" <jasmeet.bhatia.us@gmail.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>,
rafael@kernel.org, Pavel Machek <pavel@ucw.cz>,
linux-efi@vger.kernel.org, linux-pm@vger.kernel.org,
x86@kernel.org, linux-kernel@vger.kernel.org,
"Jasmeet (Jazz) Bhatia" <jasmeet.bhatia.us@gmail.com>
Subject: [PATCH v1 1/2] efi/libstub: Install memreserve table on x86
Date: Tue, 1 Sep 2026 04:34:07 -0700 [thread overview]
Message-ID: <08dea57d1e1190a3dab0f6cd424c07a07b0760b8.1788259938.git.jasmeet.bhatia.us@gmail.com> (raw)
In-Reply-To: <cover.1788259938.git.jasmeet.bhatia.us@gmail.com>
The generic EFI stub installs the Linux EFI memreserve configuration
table from efi_stub_common(), but x86 uses a separate EFI stub path.
Consequently, efi_mem_reserve_persistent() cannot be used on x86 when
no memreserve root has been installed.
Move install_memreserve_table() to the common stub helper code, expose
it through efistub.h, and invoke it from the x86 stub before exiting
boot services.
This allows x86 kernels to add persistent EFI memory reservations that
are carried across kexec.
Signed-off-by: Jasmeet (Jazz) Bhatia <jasmeet.bhatia.us@gmail.com>
---
.../firmware/efi/libstub/efi-stub-helper.c | 23 +++++++++++++++++++
drivers/firmware/efi/libstub/efi-stub.c | 23 -------------------
drivers/firmware/efi/libstub/efistub.h | 1 +
drivers/firmware/efi/libstub/x86-stub.c | 2 ++
4 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index f27f2e1f0019..9ea0ed0ed7d1 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -27,6 +27,29 @@ static bool efi_disable_pci_dma = IS_ENABLED(CONFIG_EFI_DISABLE_PCI_DMA);
int efi_mem_encrypt;
+void install_memreserve_table(void)
+{
+ struct linux_efi_memreserve *rsv;
+ efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID;
+ efi_status_t status;
+
+ status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, sizeof(*rsv),
+ (void **)&rsv);
+ if (status != EFI_SUCCESS) {
+ efi_err("Failed to allocate memreserve entry!\n");
+ return;
+ }
+
+ rsv->next = 0;
+ rsv->size = 0;
+ atomic_set(&rsv->count, 0);
+
+ status = efi_bs_call(install_configuration_table,
+ &memreserve_table_guid, rsv);
+ if (status != EFI_SUCCESS)
+ efi_err("Failed to install memreserve config table!\n");
+}
+
bool __pure __efi_soft_reserve_enabled(void)
{
return !efi_nosoftreserve;
diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
index 42d6073bcd06..e378dd7db682 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -77,29 +77,6 @@ static struct sysfb_display_info *setup_primary_display(void)
return NULL;
}
-static void install_memreserve_table(void)
-{
- struct linux_efi_memreserve *rsv;
- efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID;
- efi_status_t status;
-
- status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, sizeof(*rsv),
- (void **)&rsv);
- if (status != EFI_SUCCESS) {
- efi_err("Failed to allocate memreserve entry!\n");
- return;
- }
-
- rsv->next = 0;
- rsv->size = 0;
- atomic_set(&rsv->count, 0);
-
- status = efi_bs_call(install_configuration_table,
- &memreserve_table_guid, rsv);
- if (status != EFI_SUCCESS)
- efi_err("Failed to install memreserve config table!\n");
-}
-
static u32 get_supported_rt_services(void)
{
const efi_rt_properties_table_t *rt_prop_table;
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index fd91fc15ec81..8656d6a545e5 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -1168,6 +1168,7 @@ efi_enable_reset_attack_mitigation(void) { }
#endif
void efi_retrieve_eventlog(void);
+void install_memreserve_table(void);
struct sysfb_display_info *alloc_primary_display(void);
struct sysfb_display_info *__alloc_primary_display(void);
diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
index cef32e2c82d8..4a24126ccfd9 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -1015,6 +1015,8 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
efi_retrieve_eventlog();
+ install_memreserve_table();
+
setup_graphics(boot_params);
setup_efi_pci(boot_params);
--
2.55.0
next prev parent reply other threads:[~2026-09-01 11:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 11:34 [PATCH v1 0/2] efi/tpm: Preserve event log without changing x86 E820 Jasmeet (Jazz) Bhatia
2026-09-01 11:34 ` Jasmeet (Jazz) Bhatia [this message]
2026-09-01 11:34 ` [PATCH v1 2/2] efi/tpm: Persistently reserve the TPM event log Jasmeet (Jazz) Bhatia
2026-09-03 14:18 ` [PATCH v1 0/2] efi/tpm: Preserve event log without changing x86 E820 Ard Biesheuvel
2026-09-04 15:45 ` Jasmeet (Jazz) Bhatia
2026-09-04 16:38 ` Ard Biesheuvel
2026-09-07 15:57 ` Ilias Apalodimas
2026-09-11 3:03 ` Jasmeet (Jazz) Bhatia
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=08dea57d1e1190a3dab0f6cd424c07a07b0760b8.1788259938.git.jasmeet.bhatia.us@gmail.com \
--to=jasmeet.bhatia.us@gmail.com \
--cc=ardb@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rafael@kernel.org \
--cc=x86@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®