mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Cong Wang <cwang@multikernel.io>
Cc: Cong Wang <xiyou.wangcong@gmail.com>,
	linux-kernel@vger.kernel.org,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Andy Lutomirski <luto@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Oscar Salvador <osalvador@suse.de>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] x86/mm: Split a 1G direct mapping that hot-remove only partly covers
Date: Tue, 20 Oct 2026 10:56:34 +0200	[thread overview]
Message-ID: <91eb0dca-773a-4906-b8fb-9ed6854966ec@kernel.org> (raw)
In-Reply-To: <CAGHCLaTe9h0JACdhgAiUw851veDWX=y6KxUPLU1NzHzut3QE4A@mail.gmail.com>

On 10/19/26 22:32, Cong Wang wrote:
> On Mon, Oct 19, 2026 at 3:26 AM David Hildenbrand (Arm)
> <david@kernel.org> wrote:
>>
>> On 10/19/26 06:16, Cong Wang wrote:
>>> From: Cong Wang <cwang@multikernel.io>
>>>
>>> Hot-remove works on memory blocks, 128M and up, while the kernel maps
>>> boot memory with 1G pages where it can. Removing a block that sits in
>>> such a 1G page covers only part of it, and remove_pud_table() then
>>> walks the memory that 1G page maps as if it were a PMD table. The
>>> removal succeeds, but it corrupts the first page of the 1G region, may
>>> free that page while still in use, and leaves the removed memory
>>> mapped.
>>>
>>> Map the 1G leaf through 2M leaves first, under pgd_lock as
>>> set_memory_*() may change it for the rest of the 1G meanwhile.
>>>
>>> Reproduced in a 3G QEMU guest booted with movablecore=1280M. We used a
>>> test module fills the first page of a 1G-mapped region with a known
>>> pattern, then calls offline_and_remove_memory() on one 128M block in
>>> that region. Before this patch, part of the pattern is zeroed and the
>>> 1G page stays. After this patch, the pattern is intact, the block is
>>> unmapped, the rest stays mapped through 2M pages, and adding the block
>>> back works.
>>
>> Which in-tree mechanism can trigger this?
>>
>> I would imagine only DIMM hotremove on bare metal. But let's be real, that is
>> never going to be < 1 GiB.
>>
>> All other mechanisms (including DIMMs in virtual environments) get removed in
>> the same granularity they were added.
> 
> You're right.
> 
> The only in-tree path I can see is ACPI hot-remove of boot memory,
> where the direct map was built over contiguous E820 RAM and a 1G page
> can straddle DIMM boundaries that are not 1G aligned. I agree that is
> unlikely on real firmware.
> 
> Where I actually hit it is removing 128M blocks of boot memory
> (offline_and_remove_memory()) for the multikernel work, which is not
> upstream. Happy to carry this patch downstream.

It should definitely not be tagged as a fix. Given that we don't expect in-tree
users (and also don't endorse ones that remove arbitrary boot memory they don't
actually own), I'm not sure if we want this at this point.

I'll leave it up to x86 folks.

(IMHO we should, however, definitely warn if we would run into this situation)

-- 
Cheers,

David

      reply	other threads:[~2026-10-20  8:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19  4:16 Cong Wang
2026-10-19 10:26 ` David Hildenbrand (Arm)
2026-10-19 20:32   ` Cong Wang
2026-10-20  8:56     ` David Hildenbrand (Arm) [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=91eb0dca-773a-4906-b8fb-9ed6854966ec@kernel.org \
    --to=david@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=cwang@multikernel.io \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=osalvador@suse.de \
    --cc=peterz@infradead.org \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    --cc=xiyou.wangcong@gmail.com \
    /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

all inboxes | Powered by JetHome®