From: Mike Rapoport <rppt@kernel.org>
To: "Adrian Barnaś" <abarnas@google.com>
Cc: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
David Hildenbrand <david@kernel.org>,
Ard Biesheuvel <ardb@kernel.org>,
Christoph Lameter <cl@gentwo.org>,
Yang Shi <yang@os.amperecomputing.com>,
Brendan Jackman <jackmanb@google.com>,
Ryan Roberts <ryan.roberts@arm.com>
Subject: Re: [RFC PATCH 6/6] arm64: mm: support PMD page coalescing in the linear map
Date: Mon, 6 Jul 2026 17:33:50 +0300 [thread overview]
Message-ID: <aku8zidRtXPe_Rle@kernel.org> (raw)
In-Reply-To: <akuieSDlbYdHnkCV@google.com>
On Mon, Jul 06, 2026 at 12:41:29PM +0000, Adrian Barnaś wrote:
> Hi Mike,
>
> On Fri, Jun 19, 2026 at 02:40:40PM +0100, Ryan Roberts wrote:
>
> > I don't think this is safe in general. Let's say we have a 2M region split into
> > 512 x 4K PTEs. It's possible that the first 1M is one object and the second 1M
> > is another object. Different CPUs could set_memory_*() on those 2 objects
> > concurrently. If one of them then calls this function, we could end up
> > collapsing the whole 2M while the other is trying to modify the PTEs and they
> > will race.
> >
> > Note that splitting _is_ safe (and protected by this lock) because you'd have 2
> > objects backed by the same PMD, so they would both have to split before
> > modifying the PTEs.
> >
> > I think you'd need to ensure mutual exclusion at a higher level if doing this;
> > probably execmem is the place that can ensure that no objects within a 2M region
> > are racily trying to modify their permissions?
> >
> > Thanks,
> > Ryan
>
> I wonder what do you think about enforcing mutual exclusion for permission
> changes to the ROX_CACHE block as Ryan sugest?
>
> Would it be appropriate to add locks (over `&execmem_cache.mutex`) to
> `execmem_force_rw` and `execmem_restore_rox`?
> I
> see that x86 has a lock that wraps entire process of updating attributes
> (including spliting and collapsing pages):
> ```
> spin_lock(&cpa_lock);
> ret = __change_page_attr(cpa, primary);
> spin_unlock(&cpa_lock); ```
> As I understand it makes it safe already.
> However, on ARM64 there is a split lock (which works fine for spliting) but
> for collapsing at least on my implementation it is not sufficient as
> Ryan pointed out.
I think the lock should be at set_memory level so that set_memory callers
shouldn't care about the differences in arch implementations.
I also suspect that the lockless page table walk in update_range_prot()
isn't safe today.
> Best regards
> Adrian
--
Sincerely yours,
Mike.
prev parent reply other threads:[~2026-07-06 14:34 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 13:01 [RFC PATCH 0/6] arm64: mm: Introducing ROX CACHE to ARM64 systems with bbml2 no abort Adrian Barnaś
2026-06-11 13:01 ` [RFC PATCH 1/6] arm64: mm: explicitly declare module and ftrace execmem regions Adrian Barnaś
2026-06-11 13:36 ` Brendan Jackman
2026-06-11 13:01 ` [RFC PATCH 2/6] arm64: mm: allow huge vmap permission adjustments with bbml2_no_abort Adrian Barnaś
2026-06-18 14:21 ` Ryan Roberts
2026-06-24 13:54 ` Adrian Barnaś
2026-06-11 13:01 ` [RFC PATCH 3/6] arm64: mm: fix restoring linear map permissions on execmem cache clean Adrian Barnaś
2026-06-11 13:54 ` Brendan Jackman
2026-06-12 7:17 ` Mike Rapoport
2026-06-17 15:18 ` Adrian Barnaś
2026-06-17 18:40 ` Mike Rapoport
2026-06-24 13:57 ` Adrian Barnaś
2026-07-06 11:35 ` Mike Rapoport
2026-07-06 12:47 ` Adrian Barnaś
2026-06-18 15:05 ` Ryan Roberts
2026-06-19 8:33 ` Ryan Roberts
2026-06-24 13:52 ` Adrian Barnaś
2026-06-11 13:01 ` [RFC PATCH 4/6] arm64: mm: add helper to fill execmem with trapping instructions Adrian Barnaś
2026-06-19 10:54 ` Ryan Roberts
2026-06-19 10:58 ` Mike Rapoport
2026-06-11 13:01 ` [RFC PATCH 5/6] arm64: execmem: enable EXECMEM_ROX_CACHE on supported CPUs Adrian Barnaś
2026-06-19 12:09 ` Ryan Roberts
2026-06-11 13:01 ` [RFC PATCH 6/6] arm64: mm: support PMD page coalescing in the linear map Adrian Barnaś
2026-06-19 13:40 ` Ryan Roberts
2026-06-24 14:32 ` Adrian Barnaś
2026-07-06 12:41 ` Adrian Barnaś
2026-07-06 14:33 ` Mike Rapoport [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=aku8zidRtXPe_Rle@kernel.org \
--to=rppt@kernel.org \
--cc=abarnas@google.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=cl@gentwo.org \
--cc=david@kernel.org \
--cc=jackmanb@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=ryan.roberts@arm.com \
--cc=will@kernel.org \
--cc=yang@os.amperecomputing.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