From f04367d79322f6cf301d1984932a9a94c96782a8 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Thu, 26 Nov 2026 07:15:42 -0500 Subject: [PATCH] drm/asahi: g17: map the fragment status page and parameter-buffer graph firmware-only Two more kernel objects in the upper half every execution context includes still gave the GPU write access: - the G17P fragment status page of each render generation. The firmware reads the status there; the GPU writes it through the client alias that register 0x14080 names. - the parameter-buffer graph of each render pair, on G17P and M5. The firmware takes its state, scene and trailer addresses from the descriptors; the GPU reaches its page list through the client alias. GPU work from any client could rewrite another client's render status or parameter-buffer state through them. Map them firmware-only. The client aliases keep their access. M5's fragment status page is already firmware-only. Signed-off-by: DjDeveloperr --- drivers/gpu/drm/asahi/g17/buffer.rs | 5 ++++- drivers/gpu/drm/asahi/g17/queue/render/memory.rs | 5 ++++- tools/asahi/neo-auxiliary-tests.py | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/asahi/g17/buffer.rs b/drivers/gpu/drm/asahi/g17/buffer.rs index 0d9bdd33ba1ed..886e212e1b168 100644 --- a/drivers/gpu/drm/asahi/g17/buffer.rs +++ b/drivers/gpu/drm/asahi/g17/buffer.rs @@ -818,10 +818,13 @@ impl Manager { if metrics.scene_stride != layout.metric_stride { return Err(EINVAL); } + // The parameter-buffer graph's kernel mapping, in the upper half every execution context + // includes, is the firmware's alone. The GPU reaches its page list only through the + // client alias below. let mut graph = alloc.kernel( layout.bytes, cfg::TVB_PAGE, - mmu::PROT_GPU_FW_SHARED_RW, + mmu::PROT_FW_SHARED_RW, CpuMap::WriteCombined, )?; let source = layout.pages..layout.pages + layout.page_bytes; diff --git a/drivers/gpu/drm/asahi/g17/queue/render/memory.rs b/drivers/gpu/drm/asahi/g17/queue/render/memory.rs index dd9cf808544f7..0c683b0d7c9c3 100644 --- a/drivers/gpu/drm/asahi/g17/queue/render/memory.rs +++ b/drivers/gpu/drm/asahi/g17/queue/render/memory.rs @@ -431,10 +431,13 @@ impl NeoGeneration { mmu::PROT_GPU_FW_SHARED_RW, mmu::UAT_PGSZ, )?; + // The fragment status page's kernel mapping, in the upper half every execution context + // includes, is the firmware's alone: the firmware reads the status there, and the GPU + // writes it through the client alias below. let fragment = alloc.kernel( mmu::UAT_PGSZ, mmu::UAT_PGSZ as u64, - mmu::PROT_GPU_FW_SHARED_RW, + mmu::PROT_FW_SHARED_RW, CpuMap::WriteCombined, )?; let fragment_client = buffer::compact_alias( diff --git a/tools/asahi/neo-auxiliary-tests.py b/tools/asahi/neo-auxiliary-tests.py index 2fc8ada61d93a..a1e96acc231ef 100644 --- a/tools/asahi/neo-auxiliary-tests.py +++ b/tools/asahi/neo-auxiliary-tests.py @@ -20,6 +20,7 @@ impl Deref for KBox{type Target=T;fn deref(&self)->&T{&self.0}} mod mmu { pub const UAT_PGSZ:usize=0x4000; + pub const PROT_FW_SHARED_RW:u32=1; pub const PROT_GPU_FW_SHARED_RW:u32=3; pub const PROT_GPU_SHARED_RW:u32=2; pub struct Vm; @@ -35,7 +36,7 @@ fn map_range(&self,_v:&mmu::Vm,_r:Range,_a:Range,_align:u64,_p:u32,_g:u32)->Result{Err(-28)} } struct Allocator<'a>{_p:std::marker::PhantomData<&'a ()>} -impl Allocator<'_>{fn kernel(&self,size:usize,align:u64,p:u32,_c:CpuMap)->Result{assert_eq!(size,mmu::UAT_PGSZ);assert_eq!(align,0x4000);assert_eq!(p,3);Ok(KernelObject{va:0x40000000,size})}} +impl Allocator<'_>{fn kernel(&self,size:usize,align:u64,p:u32,_c:CpuMap)->Result{assert_eq!(size,mmu::UAT_PGSZ);assert_eq!(align,0x4000);assert_eq!(p,mmu::PROT_FW_SHARED_RW,"the fragment status page's kernel mapping is firmware-only");Ok(KernelObject{va:0x40000000,size})}} mod buffer{ use super::*; pub fn compact_alias(o:&KernelObject,_v:&mmu::Vm,r:Range,align:u64,p:u32,guard:usize)->Result{assert!(r.end<=o.size);assert_eq!(align,0x4000);assert_eq!(guard,0x4000);assert!(p==2||p==3);Ok(mmu::KernelMapping{va:o.va+r.start as u64})}