Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Chris Down <chris@chrisdown.name>
Cc: 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: Thu, 3 Dec 2026 13:57:04 +0200	[thread overview]
Message-ID: <axFZEDbsV_v64dze@kernel.org> (raw)
In-Reply-To: <58bd4ca045b33b71cec8509e893f4ff81e372dc7.1796126791.git.chris@chrisdown.name>

Hi Chris,

On Tue, Dec 01, 2026 at 10:32:11PM -0800, 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:

Do you mind adding a few words about how unlikely it is? :)
 
> - 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(-)

-- 
Sincerely yours,
Mike.


  parent reply	other threads:[~2026-12-03 11:57 UTC|newest]

Thread overview: 13+ 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-03  2:58     ` Chris Down
2026-12-03  6:32   ` sashiko-bot
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
2026-12-03  2:58     ` Chris Down
2026-12-03  6:32   ` sashiko-bot
2026-12-03 11:57   ` Mike Rapoport [this message]
2026-12-02 11:24 ` [PATCH v2 0/2] kho: handle failures to reserve preserved memory Mike Rapoport
2026-12-03  2:58   ` Chris Down
2026-12-03 11:58     ` 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=axFZEDbsV_v64dze@kernel.org \
    --to=rppt@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=pratyush@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