From: Alexandre Ghiti <alex@ghiti.fr>
To: Alexandre Ghiti <alexghiti@rivosinc.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Mike Rapoport <rppt@kernel.org>,
linux-mm@kvack.org, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 0/2] riscv: Fix set_memory_XX() and set_direct_map_XX()
Date: Fri, 3 Nov 2023 11:02:36 +0100 [thread overview]
Message-ID: <7fa25a76-4e4e-49c3-b0d1-fc34ed73a19a@ghiti.fr> (raw)
In-Reply-To: <20231027143222.115588-1-alexghiti@rivosinc.com>
On 27/10/2023 16:32, Alexandre Ghiti wrote:
> Those 2 patches fix the set_memory_XX() and set_direct_map_XX() APIs, which
> in turn fix STRICT_KERNEL_RWX and memfd_secret(). Those were broken since the
> permission changes were not applied to the linear mapping because the linear
> mapping is mapped using hugepages and walk_page_range_novma() does not split
> such mappings.
>
> To fix that, patch 1 disables PGD mappings in the linear mapping as it is
> hard to propagate changes at this level in *all* the page tables, this has the
> downside of disabling PMD mapping for sv32 and PUD (1GB) mapping for sv39 in
> the linear mapping (for specific kernels, we could add a Kconfig to enable
> ARCH_HAS_SET_DIRECT_MAP and STRICT_KERNEL_RWX if needed, I'm pretty sure we'll
> discuss that).
>
> patch 2 implements the split of the huge linear mappings so that
> walk_page_range_novma() can properly apply the permissions. The whole split is
> protected with mmap_sem in write mode, but I'm wondering if that's enough,
> any opinion on that is appreciated.
>
> Changes in v2:
> - Fix rv32 build
> - Rebase on top of 6.6-rc6
> - Move the flush_tlb_all outside the mmap_lock
>
> Alexandre Ghiti (2):
> riscv: Don't use PGD entries for the linear mapping
> riscv: Fix set_memory_XX() and set_direct_map_XX() by splitting huge
> linear mappings
>
> arch/riscv/mm/init.c | 12 +-
> arch/riscv/mm/pageattr.c | 270 +++++++++++++++++++++++++++++++++------
> 2 files changed, 236 insertions(+), 46 deletions(-)
>
Any feedback from anyone? That's a fix I'd like to see merged in 6.7, if
no objection, I'll ask for Palmer to take it.
Thanks,
Alex
parent reply other threads:[~2023-11-03 10:02 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20231027143222.115588-1-alexghiti@rivosinc.com>]
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=7fa25a76-4e4e-49c3-b0d1-fc34ed73a19a@ghiti.fr \
--to=alex@ghiti.fr \
--cc=alexghiti@rivosinc.com \
--cc=aou@eecs.berkeley.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--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