From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
To: Linux-MM <linux-mm@kvack.org>,
linux-riscv <linux-riscv@lists.infradead.org>,
device-tree <devicetree-discuss@lists.ozlabs.org>,
Linux-Renesas <linux-renesas-soc@vger.kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
Arnd Bergmann <arnd@arndb.de>, Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Jessica Clarke <jrtc27@jrtc27.com>,
Geert Uytterhoeven <geert.uytterhoeven@gmail.com>,
Fabrizio Castro <fabrizio.castro.jz@renesas.com>,
Biju Das <biju.das.jz@bp.renesas.com>,
Chris Paterson <Chris.Paterson2@renesas.com>
Subject: [QUERY]: Block region to mmap
Date: Wed, 25 Jan 2023 12:30:13 +0000 [thread overview]
Message-ID: <CA+V-a8tR1KiLSs=Psa=w7kf0zT=yU5_Ekr6-3V1MR==Wtzmksg@mail.gmail.com> (raw)
Hi All,
Renesas RZ/Five RISC-V SoC has Instruction local memory and Data local
memory (ILM & DLM) mapped between region 0x30000 - 0x4FFFF. When a
virtual address falls within this range, the MMU doesn't trigger a
page fault; it assumes the virtual address is a physical address which
can cause undesired behaviours.
To avoid this the ILM/DLM memory regions are now added to the root
domain region of the PMPU with permissions set to 0x0 for S/U modes so
that any access to these regions gets blocked and for M-mode we grant
full access (R/W/X). This prevents any users from accessing these
regions by triggering an unhandled signal 11 in S/U modes.
This works as expected but for applications say for example when doing
mmap to this region would still succeed and later down the path when
doing a read/write to this location would cause unhandled signal 11.
To handle this case gracefully we might want mmap() itself to fail if
the addr/offset falls in this local memory region.
Tracing through the mmap call we have arch_mmap_check() if implemented
by architectures this callback gets called and it can be used as a
validator to make sure mmap() to the local memory region fails. (Note
maybe this callback can be implemented using ALTERNATIVX() macro so
that other RISC-V SoCs do nop() to this callback). This approach seems
reasonable but isn't a generic approach. For other platforms with
similar issues will have to go through similar implementation. Instead
if we define the memory regions in the device tree that aren't to be
allowed to be mmaped with this approach the implementation can be
generic and can be used on other archs/platforms.
Looking at the kernel code SPARC architecture (UltraSPARC T1) also has
a hole in the virtual memory address space (relevant commit-id to fix
this issue 8bcd17411643beb9a601e032d0cf1016909a81d3).
As this VA hole “support” has been added a long time ago now, and
maybe simply replicating their approach is not acceptable anymore
hence the proposed approach.
Is there any better approach which I am missing, any pointers comments welcome.
Cheers,
Prabhakar
next reply other threads:[~2023-01-25 12:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-25 12:30 Lad, Prabhakar [this message]
2023-01-26 14:37 ` Matthew Wilcox
2023-01-30 10:53 ` Lad, Prabhakar
2023-01-30 15:24 ` Matthew Wilcox
2023-02-01 6:31 ` Christoph Hellwig
2023-02-01 7:05 ` Jessica Clarke
2023-02-01 8:05 ` Arnd Bergmann
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='CA+V-a8tR1KiLSs=Psa=w7kf0zT=yU5_Ekr6-3V1MR==Wtzmksg@mail.gmail.com' \
--to=prabhakar.csengg@gmail.com \
--cc=Chris.Paterson2@renesas.com \
--cc=arnd@arndb.de \
--cc=biju.das.jz@bp.renesas.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=fabrizio.castro.jz@renesas.com \
--cc=geert.uytterhoeven@gmail.com \
--cc=jrtc27@jrtc27.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-mm@kvack.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=robh+dt@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