From: sashiko-bot@kernel.org
To: "Chris Down" <chris@chrisdown.name>,
rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org
Cc: graf@amazon.com, kexec@lists.infradead.org, linux-mm@kvack.org,
kernel-team@meta.com
Subject: Re: [PATCH v2 2/2] kho: drop the handover if preserved memory can't be reserved
Date: Thu, 03 Dec 2026 06:32:23 +0000 [thread overview]
Message-ID: <sashiko-outbox-247237@kernel.org> (raw)
In-Reply-To: <58bd4ca045b33b71cec8509e893f4ff81e372dc7.1796126791.git.chris@chrisdown.name>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] kho: kho_init() uses is_kho_boot() instead of
kho_in.bootmem_phys
--
commit 43513d95ccfc673fefadf352275abd473f3def20
Author: Chris Down <chris@chrisdown.name>
kho: drop the handover if preserved memory can't be reserved
This commit checks the return values of memblock_reserve() and
memblock_reserved_mark_noinit() in kho_preserved_memory_reserve(), drops
the KHO handover in kho_mem_retrieve() if either fails, and makes
reserve_mem_kho_revive() reserve its own region in memblock.
> diff --git a/kernel/liveupdate/kho_core.c b/kernel/liveupdate/kho_core.c
> index 43ecef317cfdf..a0429e85132bc 100644
> --- a/kernel/liveupdate/kho_core.c
> +++ b/kernel/liveupdate/kho_core.c
[ ... ]
> @@ -1731,13 +1738,18 @@ static void __init kho_mem_retrieve(void)
> const struct kho_radix_walk_cb cb = {
> .leaf = kho_preserved_memory_reserve,
> };
> + int err;
>
> - if (kho_radix_walk_tree(&kho_in.radix_tree, &cb, NULL))
> + err = kho_radix_walk_tree(&kho_in.radix_tree, &cb, NULL);
> + if (err)
> goto err;
>
> return;
>
> err:
> + pr_warn("failed to reserve preserved memory: %pe, disabling KHO revival\n",
> + ERR_PTR(err));
> +
> /*
> * Failed to initialize preserved memory. Clear FDT and radix so KHO
> * users don't treat it as a KHO boot.
[Severity: High]
When kho_mem_retrieve() drops the handover by clearing kho_in.fdt_phys
while leaving kho_in.bootmem_phys set, is_kho_boot() becomes false even
though the kernel is running out of inherited bootmem. Does that cause
kho_init() to mishandle kho_bootmem in two places that still check
is_kho_boot() instead of kho_in.bootmem_phys?
kernel/liveupdate/kho_core.c:kho_init() {
if (is_kho_boot())
kho_account_incoming_bootmem();
...
if (kho_in.bootmem_phys)
return 0;
...
err_free_bootmem:
kho_out.fdt = NULL;
if (!is_kho_boot()) {
for (int i = 0; i < kho_bootmem_cnt; i++) {
void *start = __va(kho_bootmem[i].addr);
void *end = start + kho_bootmem[i].size;
free_reserved_area(start, end, -1, "");
}
}
}
First, if kho_init() fails and jumps to err_free_bootmem after the
handover was dropped, !is_kho_boot() is true and free_reserved_area() is
called on the inherited kho_bootmem ranges, which are actively in use by
the running kernel and already released to the buddy allocator by
memblock_free_all(). Second, on the normal path, kho_init() skips
kho_account_incoming_bootmem() because is_kho_boot() is false and then
returns early at if (kho_in.bootmem_phys), leaving zone->cma_pages and
totalcma_pages uncounted for the inherited MIGRATE_CMA bootmem
pageblocks.
Checking kho_in.bootmem_phys in both places would match the early return
in kho_init().
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796126791.git.chris@chrisdown.name?part=2
next prev parent reply other threads:[~2026-12-03 6:32 UTC|newest]
Thread overview: 11+ 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 [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
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=sashiko-outbox-247237@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=chris@chrisdown.name \
--cc=graf@amazon.com \
--cc=kernel-team@meta.com \
--cc=kexec@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=rppt@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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