* [PATCH] drm/tyr: clamp va_bits to available bits
@ 2026-11-25 20:28 Deborah Brouwer
2026-11-25 21:27 ` Daniel Almeida
2026-11-25 21:56 ` Alice Ryhl
0 siblings, 2 replies; 3+ messages in thread
From: Deborah Brouwer @ 2026-11-25 20:28 UTC (permalink / raw)
To: Daniel Almeida, Alice Ryhl, Danilo Krummrich, David Airlie,
Simona Vetter
Cc: dri-devel, rust-for-linux, linux-kernel, sunke, Deborah Brouwer
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/tyr: clamp va_bits to available bits
2026-11-25 20:28 [PATCH] drm/tyr: clamp va_bits to available bits Deborah Brouwer
@ 2026-11-25 21:27 ` Daniel Almeida
2026-11-25 21:56 ` Alice Ryhl
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Almeida @ 2026-11-25 21:27 UTC (permalink / raw)
To: Deborah Brouwer
Cc: Alice Ryhl, Danilo Krummrich, David Airlie, Simona Vetter,
dri-devel, rust-for-linux, linux-kernel, sunke
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/tyr: clamp va_bits to available bits
2026-11-25 20:28 [PATCH] drm/tyr: clamp va_bits to available bits Deborah Brouwer
2026-11-25 21:27 ` Daniel Almeida
@ 2026-11-25 21:56 ` Alice Ryhl
1 sibling, 0 replies; 3+ messages in thread
From: Alice Ryhl @ 2026-11-25 21:56 UTC (permalink / raw)
To: Deborah Brouwer
Cc: Daniel Almeida, Danilo Krummrich, David Airlie, Simona Vetter,
dri-devel, rust-for-linux, linux-kernel, sunke
On Wed, Nov 25, 2026 at 01:28:20PM -0700, Deborah Brouwer wrote:
> 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().
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Alice
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-25 21:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 20:28 [PATCH] drm/tyr: clamp va_bits to available bits Deborah Brouwer
2026-11-25 21:27 ` Daniel Almeida
2026-11-25 21:56 ` Alice Ryhl
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®