From: Pratyush Yadav <pratyush@kernel.org>
To: Chris Down <chris@chrisdown.name>
Cc: rppt@kernel.org, pasha.tatashin@soleen.com,
pratyush@kernel.org, graf@amazon.com,
kexec@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH v2 2/2] kho: drop the handover if preserved memory can't be reserved
Date: Wed, 02 Dec 2026 11:14:08 +0000 [thread overview]
Message-ID: <2vxzfqwgue7z.fsf@kernel.org> (raw)
In-Reply-To: <58bd4ca045b33b71cec8509e893f4ff81e372dc7.1796126791.git.chris@chrisdown.name> (Chris Down's message of "Tue, 01 Dec 2026 22:32:11 -0800")
On Tue, Dec 01 2026, Chris Down wrote:
> kho_preserved_memory_reserve() reserves each range of preserved memory
> in memblock and marks it noinit, but ignores both return values. Either
> can fail when memblock has to grow its reserved array and can't find
> room for the new one, which is unlikely but possible. The boot then
> goes on as if the range were reserved, and two things can follow:
>
> - If the reservation failed, memblock_free_all() hands the range to the
> page allocator with the previous kernel's data still in it, while its
> KHO user still expects to restore it. A memfd preserved through LUO
> can then get back pages that belong to someone else. Oh dear!
> - If only the noinit marking failed, the struct pages can be
> initialised later, wiping the KHO magic, so restoring the range fails.
>
> Let's return the error instead. The walk then stops, and
> kho_mem_retrieve() logs the failure and drops the handover. The boot
> carries on without it. Ranges that the walk had already reserved stay
> reserved, since freeing them would need the same array growth that
> just failed. The rest of the preserved memory is released like any
> other free memory.
>
> reserve_mem= revives its regions from the handover before
> mm_core_init(), and relies on the walk to reserve them. They have to
> stay reserved when the handover is dropped, so make
> reserve_mem_kho_revive() reserve its region itself.
>
> Fixes: fc33e4b44b27 ("kexec: enable KHO support for memory preservation")
> Signed-off-by: Chris Down <chris@chrisdown.name>
> ---
> kernel/liveupdate/kho_core.c | 18 +++++++++++++++---
> mm/memblock.c | 8 ++++++++
> 2 files changed, 23 insertions(+), 3 deletions(-)
>
[...]
> diff --git a/mm/memblock.c b/mm/memblock.c
> index a450092a80fb..7b29b657a348 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -2746,6 +2746,14 @@ static bool __init reserve_mem_kho_revive(const char *name, phys_addr_t size,
> return false;
> }
>
> + /* KHO reserves preserved memory, but not if it drops the handover. */
Nit: I find this comment hard to read.
Perhaps:
KHO reserves the preserved memory, but that happens later. Handover
failures can leave it unreserved.
Or something to the tune of this?
Other than this,
Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
> + err = memblock_reserve(*p_start, size);
> + if (err) {
> + pr_warn("KHO reserve-mem '%s' could not be reserved: %d\n",
> + name, err);
> + return false;
> + }
> +
> reserved_mem_add(*p_start, size, name);
> pr_info("Revived memory reservation '%s' from KHO\n", name);
--
Regards,
Pratyush Yadav
next prev parent reply other threads:[~2026-12-02 11:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 6:32 [PATCH v2 0/2] kho: handle failures to reserve preserved memory Chris Down
2026-12-02 6:32 ` [PATCH v2 1/2] kho: skip bootmem setup in kho_init() if bootmem was inherited Chris Down
2026-12-02 10:59 ` Pratyush Yadav
2026-12-02 6:32 ` [PATCH v2 2/2] kho: drop the handover if preserved memory can't be reserved Chris Down
2026-12-02 11:14 ` Pratyush Yadav [this message]
2026-12-02 11:24 ` [PATCH v2 0/2] kho: handle failures to reserve preserved memory Mike Rapoport
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=2vxzfqwgue7z.fsf@kernel.org \
--to=pratyush@kernel.org \
--cc=chris@chrisdown.name \
--cc=graf@amazon.com \
--cc=kernel-team@meta.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=rppt@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.