From: Deborah Brouwer <deborah.brouwer@collabora.com>
To: Daniel Almeida <daniel.almeida@collabora.com>,
Alice Ryhl <aliceryhl@google.com>,
Danilo Krummrich <dakr@kernel.org>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org, sunke@kylinos.cn,
Deborah Brouwer <deborah.brouwer@collabora.com>
Subject: [PATCH] drm/tyr: clamp va_bits to available bits
Date: Wed, 25 Nov 2026 13:28:20 -0700 [thread overview]
Message-ID: <20261125-b4-va_bits_clamp-v1-1-07e2bb33eb50@collabora.com> (raw)
Tyr creates a virtual memory space using the number of bits supported in
virtual addresses as reported by the gpu. But the page table mapping
operations limit the width of the input virtual addresses to unsigned
long. This can result in tyr creating a virtual memory space that is
larger than a 32-bit system can support.
Check if the virtual address space bits supported by the gpu are larger
than the width of unsigned long, and if so, clamp the virtual address
space bits to this smaller size.
This reproduces the clamping that already occurs in panthor_mmu_init().
Link: https://sashiko.dev/#/patchset/20261122-tyr-ioctls-v7-0-3a2af624b992%40linux.dev
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
drivers/gpu/drm/tyr/gpu.rs | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/tyr/gpu.rs b/drivers/gpu/drm/tyr/gpu.rs
index 820de9d60c19..058863a6b70b 100644
--- a/drivers/gpu/drm/tyr/gpu.rs
+++ b/drivers/gpu/drm/tyr/gpu.rs
@@ -36,6 +36,15 @@
impl GpuInfo {
pub(crate) fn new(io: &IoMem<'_>) -> Self {
+ let mut mmu_features = io.read(MMU_FEATURES);
+
+ // In io_pgtable_ops, input virtual addresses can't exceed unsigned long.
+ // Check that the virtual address bits reported by the gpu are
+ // architecturally supported and, if not, clamp them to the available bits.
+ if mmu_features.va_bits().get() > usize::BITS {
+ mmu_features = mmu_features.with_const_va_bits::<{ usize::BITS }>();
+ }
+
Self(uapi::drm_panthor_gpu_info {
gpu_id: io.read(GPU_ID).into_raw(),
gpu_rev: io.read(REVIDR).into_raw(),
@@ -43,7 +52,7 @@ pub(crate) fn new(io: &IoMem<'_>) -> Self {
l2_features: io.read(L2_FEATURES).into_raw(),
tiler_features: io.read(TILER_FEATURES).into_raw(),
mem_features: io.read(MEM_FEATURES).into_raw(),
- mmu_features: io.read(MMU_FEATURES).into_raw(),
+ mmu_features: mmu_features.into_raw(),
thread_features: io.read(THREAD_FEATURES).into_raw(),
max_threads: io.read(THREAD_MAX_THREADS).into_raw(),
thread_max_workgroup_size: io.read(THREAD_MAX_WORKGROUP_SIZE).into_raw(),
---
base-commit: 7402dd230f4497954b465145a22cff7a5a488629
change-id: 20261125-b4-va_bits_clamp-4af5a92c1e68
Best regards,
--
Deborah Brouwer <deborah.brouwer@collabora.com>
next reply other threads:[~2026-11-25 20:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 20:28 Deborah Brouwer [this message]
2026-11-25 21:27 ` Daniel Almeida
2026-11-25 21:56 ` Alice Ryhl
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=20261125-b4-va_bits_clamp-v1-1-07e2bb33eb50@collabora.com \
--to=deborah.brouwer@collabora.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=sunke@kylinos.cn \
/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®