[PATCH] drm/tyr: clamp va_bits to available bits
From: Deborah Brouwer
Date: Wed Nov 25 2026 - 15:29:05 EST
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@xxxxxxxxxxxxx>
---
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@xxxxxxxxxxxxx>