The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Chris Down <chris@chrisdown.name>
To: Mike Rapoport <rppt@kernel.org>
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] kho: Don't release incoming bootmem areas when kho_init() fails
Date: Sat, 28 Nov 2026 01:21:55 -0800	[thread overview]
Message-ID: <awqdM6WBmcGak0UV@chrisdown.name> (raw)
In-Reply-To: <avGb2Trm-C3_YC-7@kernel.org>

Hi Mike,

Mike Rapoport writes:
>On Sat, Nov 07, 2026 at 07:40:50PM -0800, Chris Down wrote:
>> kho_populate() adds the incoming bootmem areas without reserving
>> them. memblock_free_all() then hands the remainder to the buddy
>> allocator.
>
>This paragraph is confusing.
>It reads like kho_populate() should have reserved bootmem areas, but it
>didn't.

Yeah, I can see how it reads that way. v2 will say who reserves the
areas on each kind of boot instead.

>> Unfortunately however, if kho_init() fails, err_free_bootmem
>> currently frees every area with free_reserved_area(). This can free
>> pages still backing early allocations or free buddy pages a second
>> time.
>
>Is this an issue you hit in practice or it was reported by a code analysis?

Just from reading the code, same as the reservation failure one.

Actually, I did find an amusingly simple way to trigger it to
demonstrate :-) With CONFIG_KEXEC_HANDOVER_DEBUGFS=y, kho_init() fails
when debugfs is disabled, so a KHO kexec into a kernel with debugfs=off
added to its command line is enough. From a quick check I did, the new
kernel then crashes in free_pcppages_bulk() under free_reserved_area()
and never gets to userspace. I'll add the trace to the v2 changelog.

kho_init() shouldn't really fail just because debugfs is off, so let me
fix that in v2 as well.

>> +	if (!fdt) {
>
>I think using !is_kho_boot() makes this clearer.

Agreed, will do in v2.

Once the reservation failure v2 lets kho_mem_retrieve() fail and drop
the handover, is_kho_boot() will be false even though the bootmem was
inherited, so both this and the bootmem setup above it will have to
check for that instead. I'll change both in that series.

Thanks!

Chris

      reply	other threads:[~2026-11-28  9:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-08  3:40 [PATCH] kho: Don't release incoming bootmem areas when kho_init() fails Chris Down
2026-11-08 14:29 ` Pasha Tatashin
2026-11-09 10:09 ` Mike Rapoport
2026-11-28  9:21   ` Chris Down [this message]

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=awqdM6WBmcGak0UV@chrisdown.name \
    --to=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 \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox