* [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot
@ 2026-07-06 16:37 Sang-Heon Jeon
2026-07-06 16:37 ` [PATCH v2 5/5] Revert "tpm: do not ignore memblock_reserve return value" Sang-Heon Jeon
2026-07-07 6:17 ` [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot Mike Rapoport
0 siblings, 2 replies; 3+ messages in thread
From: Sang-Heon Jeon @ 2026-07-06 16:37 UTC (permalink / raw)
To: rppt, Ard Biesheuvel, Borislav Petkov, Chris Zankel, Dave Hansen,
Ingo Molnar, John Paul Adrian Glaubitz, Madhavan Srinivasan,
Max Filippov, Michael Ellerman, Rich Felker, Thomas Gleixner,
Yoshinori Sato
Cc: linux-mm, Sang-Heon Jeon, Christophe Leroy (CS GROUP),
H. Peter Anvin, Ilias Apalodimas, linux-efi, linux-kernel,
linuxppc-dev, linux-sh, Nicholas Piggin, x86
memblock_reserve() can only return an error after memblock_allow_resize()
has been called. Before that it either succeeds or panics, never returning
an error.
Before memblock_allow_resize() is called, the return value checks of
memblock_reserve() are unreachable and can be removed.
All the call sites are in different trees, so I split the change into one
patch per arch/subsystem. The patches are independent and can be applied
separately.
---
Changes from v1 [1]
- add reviewed-by tag
- rebased onto latest memblock for-next
[1] https://lore.kernel.org/all/20260616182959.2429774-1-ekffu200098@gmail.com/
---
Hello Mike,
Like the previous memblock cleanup series, could you review and take this patch series to the memblock tree?
Thank you for taking valuable time.
Best Regards,
Sang-Heon Jeon
---
Sang-Heon Jeon (5):
x86/setup: remove unreachable memblock_reserve() return value check
sh: remove unreachable memblock_reserve() return value check
powerpc/fadump: remove unreachable memblock_reserve() return value
checks
xtensa: remove unreachable memblock_reserve() return value checks
Revert "tpm: do not ignore memblock_reserve return value"
arch/powerpc/kernel/fadump.c | 14 +++-----------
arch/sh/kernel/machine_kexec.c | 7 +------
arch/x86/kernel/setup.c | 7 ++-----
arch/xtensa/kernel/setup.c | 13 +++++++------
drivers/firmware/efi/tpm.c | 7 +------
5 files changed, 14 insertions(+), 34 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH v2 5/5] Revert "tpm: do not ignore memblock_reserve return value"
2026-07-06 16:37 [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot Sang-Heon Jeon
@ 2026-07-06 16:37 ` Sang-Heon Jeon
2026-07-07 6:17 ` [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot Mike Rapoport
1 sibling, 0 replies; 3+ messages in thread
From: Sang-Heon Jeon @ 2026-07-06 16:37 UTC (permalink / raw)
To: rppt, Ard Biesheuvel
Cc: linux-mm, Sang-Heon Jeon, Borislav Petkov, Chris Zankel,
Dave Hansen, Ilias Apalodimas, Ingo Molnar,
John Paul Adrian Glaubitz, linux-efi, linux-kernel,
Madhavan Srinivasan, Max Filippov, Michael Ellerman, Rich Felker,
Thomas Gleixner, Yoshinori Sato
This reverts commit c33c28f9f6e017702374e1ab907dfa5a63db5301.
efi_tpm_eventlog_init() runs from efi_config_parse_tables() during early
EFI initialization, before memblock_allow_resize(). At that point
memblock_reserve() either succeeds or panics, never returning an error.
Therefore the return value check is unreachable, so restore the original
unconditional memblock_reserve().
No functional change.
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
drivers/firmware/efi/tpm.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c
index cdd431027065..288bcf7a5b99 100644
--- a/drivers/firmware/efi/tpm.c
+++ b/drivers/firmware/efi/tpm.c
@@ -61,12 +61,7 @@ int __init efi_tpm_eventlog_init(void)
}
tbl_size = sizeof(*log_tbl) + log_tbl->size;
- if (memblock_reserve(efi.tpm_log, tbl_size)) {
- pr_err("TPM Event Log memblock reserve fails (0x%lx, 0x%x)\n",
- efi.tpm_log, tbl_size);
- ret = -ENOMEM;
- goto out;
- }
+ memblock_reserve(efi.tpm_log, tbl_size);
if (efi.tpm_final_log == EFI_INVALID_TABLE_ADDR) {
pr_info("TPM Final Events table not present\n");
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot
2026-07-06 16:37 [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot Sang-Heon Jeon
2026-07-06 16:37 ` [PATCH v2 5/5] Revert "tpm: do not ignore memblock_reserve return value" Sang-Heon Jeon
@ 2026-07-07 6:17 ` Mike Rapoport
1 sibling, 0 replies; 3+ messages in thread
From: Mike Rapoport @ 2026-07-07 6:17 UTC (permalink / raw)
To: Sang-Heon Jeon
Cc: Ard Biesheuvel, Borislav Petkov, Chris Zankel, Dave Hansen,
Ingo Molnar, John Paul Adrian Glaubitz, Madhavan Srinivasan,
Max Filippov, Michael Ellerman, Rich Felker, Thomas Gleixner,
Yoshinori Sato, linux-mm, Christophe Leroy (CS GROUP),
H. Peter Anvin, Ilias Apalodimas, linux-efi, linux-kernel,
linuxppc-dev, linux-sh, Nicholas Piggin, x86
Hi Sang-Heon,
On Tue, Jul 07, 2026 at 01:37:48AM +0900, Sang-Heon Jeon wrote:
> memblock_reserve() can only return an error after memblock_allow_resize()
> has been called. Before that it either succeeds or panics, never returning
> an error.
>
> Before memblock_allow_resize() is called, the return value checks of
> memblock_reserve() are unreachable and can be removed.
I'd rather keep these checks.
Removing them relies on internal details of memblock_reserve() implementation
and the existing event sequence. If the code would move around relying on
panic in memblock_reserve() may not be correct.
And the few bytes and cycles the change saves do not worth the churn.
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-07 6:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06 16:37 [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot Sang-Heon Jeon
2026-07-06 16:37 ` [PATCH v2 5/5] Revert "tpm: do not ignore memblock_reserve return value" Sang-Heon Jeon
2026-07-07 6:17 ` [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot Mike Rapoport
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox