From 969bbd2e08bf5a02bba2efae4a3ee37aee3e69fe Mon Sep 17 00:00:00 2001 From: Jonathan Goyvaerts Date: Tue, 1 Dec 2026 16:26:29 -0300 Subject: [PATCH] drm/asahi: g17: stop aliasing the render context at low addresses On a G17P client's first compute bind the driver mapped the first 64 KiB of the render context, which userspace binds at 0x10_0000_0000, a second time at VA 0, GPU-writable. It also refused the bind unless userspace had bound six more ranges of that object a second time at 0x18000..0x74000. A per-VM registry tracked the canonical binds for that check, on every bind, unmap and object close. Nothing reads those copies. The hardware adds the 0x10_0000_0000 base itself: the HwData words at 0x10 and 0x18 hold it, the tiling and VDM registers are offsets from it, and the compute registers carry full addresses. Measured on the M4 Pro (T6040, firmware 25G83) with the aliases skipped and with userspace not binding the low ranges at all: GPU VA 0..0x74000 reads zero, 39,372 dEQP-VK cases (compute, SSBO, robustness, line rasterization, texturing, draw, graphicsfuzz) and 1,393 GLES3 and GLES3.1 cases (including compute, SSBO and images) give the same results as with the aliases, with no fault or GPU recovery. The writable copy at VA 0 also let a shader's null-pointer store overwrite the context's Bind0 image. VA 0..0x10000 stays reserved and is now unmapped, so a load there reads zero and a store is dropped. Remove the aliases, the registry and its hooks, CONTEXT_VIEWS, and the G17 note in the SOFT_FAULTS documentation. Userspace that still binds the low ranges keeps working: those are ordinary binds of its own. Signed-off-by: Jonathan Goyvaerts --- drivers/gpu/drm/asahi/file.rs | 1 - drivers/gpu/drm/asahi/g17/mod.rs | 4 +- drivers/gpu/drm/asahi/g17/queue/compute.rs | 1 - drivers/gpu/drm/asahi/hw/t8140.rs | 28 -- drivers/gpu/drm/asahi/mmu.rs | 58 +++- drivers/gpu/drm/asahi/mmu/bind.rs | 23 +- drivers/gpu/drm/asahi/mmu/context.rs | 336 --------------------- drivers/gpu/drm/asahi/mmu/lifetime.rs | 24 +- include/uapi/drm/asahi_drm.h | 4 - 9 files changed, 55 insertions(+), 424 deletions(-) delete mode 100644 drivers/gpu/drm/asahi/mmu/context.rs diff --git a/drivers/gpu/drm/asahi/file.rs b/drivers/gpu/drm/asahi/file.rs index 37387915a9e7a..f6b8f0ae4ee22 100644 --- a/drivers/gpu/drm/asahi/file.rs +++ b/drivers/gpu/drm/asahi/file.rs @@ -1302,7 +1302,6 @@ impl File { if op.offset.checked_add(accessed).ok_or(EINVAL)? > u64::try_from(object.size())? { return Err(EINVAL); } - vm.validate_context_binding(op.addr, op.range, single_page)?; batch.push_map(vm.prepare_bind_object( &object, op.addr, diff --git a/drivers/gpu/drm/asahi/g17/mod.rs b/drivers/gpu/drm/asahi/g17/mod.rs index aba213381f5e5..306c294ebe19b 100644 --- a/drivers/gpu/drm/asahi/g17/mod.rs +++ b/drivers/gpu/drm/asahi/g17/mod.rs @@ -3127,9 +3127,7 @@ impl gpu::Gpu for Gpu { /// with no fault reported (measured on the M4 Pro, firmware 25G83). The driver gives every /// queue of the family the same fault setting, 1 in `QueueConfig::unk_66`, the word the M5 /// firmware names soft_fault_enabled, so this is not a per-SoC property. Advertise it unless - /// fault_control asks for anything else. The first 0x74000 bytes of a client VM are mapped, - /// not unmapped memory: they hold the execution context's views (`CONTEXT_VIEWS`, the null - /// view at address 0). + /// fault_control asks for anything else. fn supports_soft_faults(&self) -> bool { crate::module_parameters::fault_control.value() == 0xb } diff --git a/drivers/gpu/drm/asahi/g17/queue/compute.rs b/drivers/gpu/drm/asahi/g17/queue/compute.rs index f19ba2c5b86f4..66dc87d5aa07e 100644 --- a/drivers/gpu/drm/asahi/g17/queue/compute.rs +++ b/drivers/gpu/drm/asahi/g17/queue/compute.rs @@ -286,7 +286,6 @@ impl Graph { return Err(EFAULT); } let vm = context.vm(); - if !self.m5 { vm.install_job_context_aliases()?; } let descriptors = self.descriptor_alias(vm)?; let prot = if self.m5 { mmu::PROT_GPU_SHARED_RW } else { mmu::PROT_GPU_FW_SHARED_RW }; let page = mmu::UAT_PGSZ as u64; diff --git a/drivers/gpu/drm/asahi/hw/t8140.rs b/drivers/gpu/drm/asahi/hw/t8140.rs index c0b99b3857ecc..5c5ed4dac49ad 100644 --- a/drivers/gpu/drm/asahi/hw/t8140.rs +++ b/drivers/gpu/drm/asahi/hw/t8140.rs @@ -406,34 +406,6 @@ pub(crate) mod resources { } } -/// Canonical userspace resource and its presentation in an execution context. -#[derive(Clone, Copy)] -pub(crate) struct ContextView { - pub(crate) source: u64, - pub(crate) low: u64, - pub(crate) size: usize, - pub(crate) write: bool, -} - -const fn context_view(low: u64, size: usize, write: bool) -> ContextView { - ContextView { - source: 0x10_0000_0000 + low, - low, - size, - write, - } -} - -pub(crate) const CONTEXT_VIEWS: [ContextView; 7] = [ - context_view(0, 0x10000, false), - context_view(0x18000, 0x8000, false), - context_view(0x28000, 0x8000, false), - context_view(0x38000, 0x8000, false), - context_view(0x48000, 0x8000, false), - context_view(0x58000, 0x8000, true), - context_view(0x68000, 0xc000, true), -]; - /// Scheduler accounting policy and its firmware clock domain. pub(crate) mod qos { pub(crate) const CLASS: u8 = 0x0f; diff --git a/drivers/gpu/drm/asahi/mmu.rs b/drivers/gpu/drm/asahi/mmu.rs index ae4a95da16b87..79fd5de709d30 100644 --- a/drivers/gpu/drm/asahi/mmu.rs +++ b/drivers/gpu/drm/asahi/mmu.rs @@ -111,7 +111,6 @@ pub(crate) use pgtable::{ const DEBUG_CLASS: DebugFlags = DebugFlags::Mmu; mod bind; -mod context; mod layout; mod lifetime; @@ -1346,7 +1345,6 @@ pub(crate) struct Vm { bind_sequence: Arc, lifetime: Option>, residency: Option>, - context_bindings: Option>, shared_bindings: Option>, status: Option>, /// The memory accounting of the client that created this VM, which kernel memory sized @@ -2692,7 +2690,6 @@ impl Vm { bind_sequence, lifetime: None, residency: None, - context_bindings: None, shared_bindings: None, status: None, memory: None, @@ -2723,13 +2720,12 @@ impl Vm { )?); self.lifetime = Some(lifetime::VmLifetime::new()?); self.residency = Some(residency::Gate::new()?); - self.context_bindings = Some(context::ContextBindings::new()?); self.shared_bindings = Some(shared::SharedBindings::new()?); Ok(self) } /// Attach a status and job lifetime tracking before sharing a newly created user VM with - /// queues, without the G17 canonical context views, shared-object footprints and idle + /// queues, without the G17 shared-object footprints and idle /// residency reclaim of [`Self::with_status`]. Used by G15, whose user objects stay pinned. #[cfg(any(CONFIG_DRM_ASAHI_UAT_ADOPTION, CONFIG_DRM_ASAHI_G16))] pub(crate) fn with_tracked_status(mut self) -> Result { @@ -3448,7 +3444,6 @@ impl Vm { if result.is_ok() { // The close callback or deferred object list retains this GEM, // so clearing its candidate cannot release its final reference. - self.untrack_context_object(gem); self.untrack_shared_object(gem); } mod_dev_dbg!(self.dev, "MMU: bo_unmap done\n"); @@ -3493,7 +3488,6 @@ impl Vm { mod_dev_dbg!(self.dev, "MMU: deferred bo_unmap\n"); let result = vm_exec.unique_gpuvm.bo_unmap(&mut ctx, &bo); if result.is_ok() { - self.untrack_context_object_before(gem, sequence); self.untrack_shared_object_before(gem, sequence); } drop(vm_exec); @@ -3514,7 +3508,6 @@ impl Vm { VmInner::unmap_gpuva, ); if result.is_ok() { - self.untrack_context_object_before(gem, sequence); self.untrack_shared_object_before(gem, sequence); } drop(inner); @@ -3528,7 +3521,6 @@ impl Vm { let mut inner = self.gpuvm.lock_inner(); let result = inner.unmap_object(gem, VmInner::unmap_gpuva); if result.is_ok() { - self.untrack_context_object(gem); self.untrack_shared_object(gem); } drop(inner); @@ -3536,6 +3528,54 @@ impl Vm { result } + pub(crate) fn translate_iova(&self, address: u64) -> Result { + // SAFETY: See `lock_vm()`. A page-table read needs only the VM's own reservation, not + // every external object's: G18 translates each page of a job's mappings on every + // submission, and locking all external objects made each translation cost O(external + // objects). + let mut vm_exec = unsafe { self.gpuvm.exec_lock_vm(None, false)? }; + vm_exec.unique_gpuvm.data().page_table.translate_iova(address) + } + + /// [`Self::translate_iova`] of `address + k * UAT_PGSZ` for each `k` below + /// `bytes.div_ceil(UAT_PGSZ)`, under one lock and one page-table walk. + pub(crate) fn translate_pages(&self, address: u64, bytes: usize) -> Result> { + let offset = address & UAT_PGMSK as u64; + let start = address - offset; + let pages = bytes.div_ceil(UAT_PGSZ); + let end = start.checked_add((pages as u64) << UAT_PGBIT).ok_or(EINVAL)?; + let mut physical = KVec::from_elem(0u64, pages, GFP_KERNEL)?; + if pages == 0 { + return Ok(physical); + } + { + // SAFETY: See `lock_vm()`, and `translate_iova()` for why the VM's reservation + // suffices. + let mut vm_exec = unsafe { self.gpuvm.exec_lock_vm(None, false)? }; + vm_exec + .unique_gpuvm + .data() + .page_table + .translate_pages(start..end, &mut physical)?; + } + for frame in physical.iter_mut() { + *frame |= offset; + } + Ok(physical) + } + + /// [`Self::translate_iova`] for each of `addresses`, under one lock. + pub(crate) fn translate_each(&self, addresses: &[u64]) -> Result> { + let mut physical = KVec::with_capacity(addresses.len(), GFP_KERNEL)?; + // SAFETY: As in `translate_pages()`. + let mut vm_exec = unsafe { self.gpuvm.exec_lock_vm(None, false)? }; + let page_table = &mut vm_exec.unique_gpuvm.data().page_table; + for &address in addresses { + physical.push(page_table.translate_iova(address)?, GFP_KERNEL)?; + } + Ok(physical) + } + /// Returns the dummy GEM object used to hold the shared DMA reservation locks pub(crate) fn get_resv_obj(&self) -> ARef { self.dummy_obj.clone() diff --git a/drivers/gpu/drm/asahi/mmu/bind.rs b/drivers/gpu/drm/asahi/mmu/bind.rs index 84f7d0fcd8127..0980426121a61 100644 --- a/drivers/gpu/drm/asahi/mmu/bind.rs +++ b/drivers/gpu/drm/asahi/mmu/bind.rs @@ -16,7 +16,6 @@ pub(crate) struct PreparedUserMap { offset: u64, single_page: bool, sparse_tile: bool, - context: context::PreparedBinding, _residency: Option, _sg_lease: kernel::drm::gem::shmem::SGLease, } @@ -91,7 +90,6 @@ impl Vm { } gem::validate_vm_binding(gem, self)?; let residency = self.enter_residency_metadata()?; - let context = self.prepare_context_binding(addr, size, offset)?; let resources = VmOpResources::with_gpuvas(self.memory_client())?; // SAFETY: As in `Vm::bind_object()`, the device is bound while its file can issue binds. let dev = unsafe { self.dev.as_bound() }; @@ -119,7 +117,6 @@ impl Vm { offset, single_page, sparse_tile, - context, }) } @@ -176,12 +173,7 @@ impl Vm { context: &mut ctx, flags, }); - let retired = result.is_ok().then(|| { - let retired = self.commit_context_binding( - &map.gem, - &map.context, - ctx.bind_sequence, - ); + if result.is_ok() { self.track_shared_binding( &map.gem, map.addr, @@ -190,11 +182,9 @@ impl Vm { map.single_page, ctx.bind_sequence, ); - retired - }); + } drop(inner); drop(commit); - drop(retired); Some(result) } Err(error) if error == EIO => { @@ -215,16 +205,11 @@ impl Vm { inner .unique_gpuvm .sm_unmap(unmap.iova, unmap.size, &mut ctx); - let retired = result.is_ok().then(|| { - let retired = self.untrack_context_ranges(core::iter::once( - unmap.iova..unmap.iova + unmap.size, - )); + if result.is_ok() { self.untrack_shared_range(unmap.iova, unmap.size); - retired - }); + } drop(inner); drop(commit); - drop(retired); Some(result) } Err(error) if error == EIO => { diff --git a/drivers/gpu/drm/asahi/mmu/context.rs b/drivers/gpu/drm/asahi/mmu/context.rs deleted file mode 100644 index 5870ad8c07dc0..0000000000000 --- a/drivers/gpu/drm/asahi/mmu/context.rs +++ /dev/null @@ -1,336 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only OR MIT - -//! Tracks canonical context resources and retains their fixed low presentation. -//! -//! Userspace owns low views 1 through 6. Only the reserved null view is created -//! here. Its installation is serialized per VM and retained through VM teardown. -//! Commits take bindings after the GPUVM exec lock; deferred unmaps take it -//! after the VM lifetime lock. Readers release bindings before taking either. - -use super::*; -use crate::hw::t8140::CONTEXT_VIEWS; -use kernel::drm::gem::BaseObject; - -struct Binding { - gem: ARef, - offset: usize, - bind_sequence: u64, -} -struct Bindings { - generation: u64, - slots: [Option; CONTEXT_VIEWS.len()], -} -/// All arithmetic for a canonical map is checked before its page-table commit. -pub(super) struct PreparedBinding { - address: u64, - object_offset: u64, - touched: u8, - covered: u8, -} - -/// Final GEM release can acquire DMA reservations. Keep replaced references -/// until the caller has released its GPUVM and mapping-admission locks. -pub(super) struct RetiredBindings([Option; CONTEXT_VIEWS.len()]); - -impl RetiredBindings { - fn new() -> Self { - Self(core::array::from_fn(|_| None)) - } -} - -#[pin_data] -pub(super) struct ContextBindings { - #[pin] - bindings: Mutex, - #[pin] - install: Mutex<()>, -} -impl ContextBindings { - pub(super) fn new() -> Result> { - Arc::pin_init( - pin_init!(Self { - bindings <- new_mutex!(Bindings { generation: 0, - slots: core::array::from_fn(|_| None) }, "VM context resources"), - install <- new_mutex!((), "VM context alias installation"), - }), - GFP_KERNEL, - ) - } -} - -impl Vm { - pub(crate) fn validate_context_binding( - &self, - address: u64, - size: u64, - single_page: bool, - ) -> Result { - if self.context_bindings.is_none() || !single_page { - return Ok(()); - } - let end = address.checked_add(size).ok_or(EOVERFLOW)?; - if CONTEXT_VIEWS - .iter() - .any(|view| address < view.source + view.size as u64 && view.source < end) - { - return Err(EINVAL); - } - Ok(()) - } - - pub(super) fn prepare_context_binding( - &self, - address: u64, - size: u64, - object_offset: u64, - ) -> Result { - let mut update = PreparedBinding { - address, - object_offset, - touched: 0, - covered: 0, - }; - if self.context_bindings.is_none() { - return Ok(update); - } - let end = address.checked_add(size).ok_or(EOVERFLOW)?; - for (index, view) in CONTEXT_VIEWS.iter().enumerate() { - if address < view.source + view.size as u64 && view.source < end { - update.touched |= 1 << index; - } - if address <= view.source && view.source + view.size as u64 <= end { - update.covered |= 1 << index; - usize::try_from( - object_offset - .checked_add(view.source - address) - .ok_or(EOVERFLOW)?, - )?; - } - } - Ok(update) - } - - /// Called after a successful leaf commit, while its exec lock still orders - /// mapping changes. The prepared update cannot fail after visibility. - pub(super) fn commit_context_binding( - &self, - gem: &ARef, - update: &PreparedBinding, - bind_sequence: u64, - ) -> RetiredBindings { - let mut retired = RetiredBindings::new(); - if update.touched == 0 { - return retired; - } - let Some(context) = self.context_bindings.as_ref() else { - return retired; - }; - let mut bindings = context.bindings.lock(); - for (index, slot) in bindings.slots.iter_mut().enumerate() { - if update.touched & (1 << index) != 0 { - retired.0[index] = slot.take(); - } - if update.covered & (1 << index) != 0 { - // Coverage proves source >= address. Preparation checked this - // exact sum and its usize conversion against the same view. - let offset = (update.object_offset - + (CONTEXT_VIEWS[index].source - update.address)) as usize; - *slot = Some(Binding { - gem: gem.clone(), - offset, - bind_sequence, - }); - } - } - bindings.generation = bindings.generation.wrapping_add(1); - retired - } - - /// Successful user unmaps and accepted deferred unmaps invalidate the - /// matching candidates. Returning their owners avoids destruction under - /// the caller's exec or lifetime lock. - pub(super) fn untrack_context_ranges( - &self, - ranges: impl Iterator>, - ) -> RetiredBindings { - let mut retired = RetiredBindings::new(); - let Some(context) = self.context_bindings.as_ref() else { - return retired; - }; - let mut bindings = context.bindings.lock(); - for range in ranges { - let mut touched = false; - for (index, view) in CONTEXT_VIEWS.iter().enumerate() { - if range.start < view.source + view.size as u64 && view.source < range.end { - if let Some(binding) = bindings.slots[index].take() { - retired.0[index] = Some(binding); - } - touched = true; - } - } - if touched { - bindings.generation = bindings.generation.wrapping_add(1); - } - } - retired - } - - pub(crate) fn untrack_context_object(&self, gem: &gem::Object) { - self.untrack_context_object_before(gem, u64::MAX); - } - - pub(super) fn untrack_context_object_before(&self, gem: &gem::Object, sequence: u64) { - let Some(context) = self.context_bindings.as_ref() else { - return; - }; - let mut bindings = context.bindings.lock(); - let mut touched = false; - for slot in &mut bindings.slots { - if slot - .as_ref() - .is_some_and(|binding| core::ptr::eq(&*binding.gem, gem) - && binding.bind_sequence <= sequence) - { - *slot = None; - touched = true; - } - } - if touched { - bindings.generation = bindings.generation.wrapping_add(1); - } - } - - pub(crate) fn translate_iova(&self, address: u64) -> Result { - // SAFETY: See `lock_vm()`. A page-table read needs only the VM's own reservation, not - // every external object's: G18 translates each page of a job's mappings on every - // submission, and locking all external objects made each translation cost O(external - // objects). - let mut vm_exec = unsafe { self.gpuvm.exec_lock_vm(None, false)? }; - vm_exec.unique_gpuvm.data().page_table.translate_iova(address) - } - - /// [`Self::translate_iova`] of `address + k * UAT_PGSZ` for each `k` below - /// `bytes.div_ceil(UAT_PGSZ)`, under one lock and one page-table walk. - pub(crate) fn translate_pages(&self, address: u64, bytes: usize) -> Result> { - let offset = address & UAT_PGMSK as u64; - let start = address - offset; - let pages = bytes.div_ceil(UAT_PGSZ); - let end = start.checked_add((pages as u64) << UAT_PGBIT).ok_or(EINVAL)?; - let mut physical = KVec::from_elem(0u64, pages, GFP_KERNEL)?; - if pages == 0 { - return Ok(physical); - } - { - // SAFETY: See `lock_vm()`, and `translate_iova()` for why the VM's reservation - // suffices. - let mut vm_exec = unsafe { self.gpuvm.exec_lock_vm(None, false)? }; - vm_exec - .unique_gpuvm - .data() - .page_table - .translate_pages(start..end, &mut physical)?; - } - for frame in physical.iter_mut() { - *frame |= offset; - } - Ok(physical) - } - - /// [`Self::translate_iova`] for each of `addresses`, under one lock. - pub(crate) fn translate_each(&self, addresses: &[u64]) -> Result> { - let mut physical = KVec::with_capacity(addresses.len(), GFP_KERNEL)?; - // SAFETY: As in `translate_pages()`. - let mut vm_exec = unsafe { self.gpuvm.exec_lock_vm(None, false)? }; - let page_table = &mut vm_exec.unique_gpuvm.data().page_table; - for &address in addresses { - physical.push(page_table.translate_iova(address)?, GFP_KERNEL)?; - } - Ok(physical) - } - - /// Requires a job mapping guard before validating or installing these views. - pub(crate) fn install_job_context_aliases(&self) -> Result { - let context = self.context_bindings.as_ref().ok_or(EINVAL)?; - let (generation, snapshot) = { - let bindings = context.bindings.lock(); - let mut snapshot = KVec::with_capacity(CONTEXT_VIEWS.len(), GFP_KERNEL)?; - for slot in &bindings.slots { - let binding = slot.as_ref().ok_or(ENOENT)?; - snapshot.push((binding.gem.clone(), binding.offset), GFP_KERNEL)?; - } - (bindings.generation, snapshot) - }; - for (index, (gem, offset)) in snapshot.iter().enumerate().skip(1) { - let view = CONTEXT_VIEWS[index]; - if !self.covers_range(view.source, view.size as u64, true, view.write) - || !self.covers_range(view.low, view.size as u64, true, view.write) - { - return Err(EFAULT); - } - if offset.checked_add(view.size).ok_or(EOVERFLOW)? > gem.size() { - return Err(ERANGE); - } - for page in (0..view.size).step_by(UAT_PGSZ) { - if self.translate_iova(view.source + page as u64)? - != self.translate_iova(view.low + page as u64)? - { - return Err(EFAULT); - } - } - } - let _install = context.install.lock(); - let view = CONTEXT_VIEWS[0]; - let (gem, offset) = &snapshot[0]; - // Null presentation requires writes in addition to the canonical view's - // ordinary read requirement. - if !self.covers_range(view.source, view.size as u64, true, true) { - return Err(EFAULT); - } - let end = offset.checked_add(view.size).ok_or(EOVERFLOW)?; - if end > gem.size() { - return Err(ERANGE); - } - let mut existing = 0; - for page in (0..view.size).step_by(UAT_PGSZ) { - if self.covers_range(view.low + page as u64, UAT_PGSZ as u64, true, true) { - existing += 1; - if self.translate_iova(view.source + page as u64)? - != self.translate_iova(view.low + page as u64)? - { - return Err(EFAULT); - } - } - } - if existing != 0 { - if existing != view.size / UAT_PGSZ { - return Err(EFAULT); - } - return if context.bindings.lock().generation == generation { - Ok(()) - } else { - Err(EAGAIN) - }; - } - let mut mappings = KVec::with_capacity(1, GFP_KERNEL)?; - let mapping = self.map_in_range( - gem, - *offset..end, - UAT_PGSZ as u64, - view.low..view.low + view.size as u64, - PROT_GPU_SHARED_RW, - false, - )?; - for page in (0..view.size).step_by(UAT_PGSZ) { - if self.translate_iova(view.source + page as u64)? - != self.translate_iova(view.low + page as u64)? - { - return Err(EFAULT); - } - } - mappings.push(mapping, GFP_KERNEL)?; - if context.bindings.lock().generation != generation { - return Err(EAGAIN); - } - self.append_driver_mappings(mappings) - } -} diff --git a/drivers/gpu/drm/asahi/mmu/lifetime.rs b/drivers/gpu/drm/asahi/mmu/lifetime.rs index 214f6cfa3c3e3..5ef8d0629f56a 100644 --- a/drivers/gpu/drm/asahi/mmu/lifetime.rs +++ b/drivers/gpu/drm/asahi/mmu/lifetime.rs @@ -177,17 +177,6 @@ impl Vm { Ok(()) } - /// Reserves the complete append before moving aliases into VM ownership. - pub(crate) fn append_driver_mappings(&self, mappings: KVec) -> Result { - let lifetime = self.lifetime.as_ref().ok_or(EINVAL)?; - let mut driver = lifetime.driver.lock(); - let driver = Option::as_mut(&mut *driver).ok_or(EINVAL)?; - driver.mappings.reserve(mappings.len(), GFP_KERNEL)?; - for mapping in mappings { - driver.mappings.push(mapping, GFP_KERNEL)?; - } - Ok(()) - } /// Keeps fixed kernel aliases alive while accepted work can still reference them. pub(crate) fn retain_mapping(&self, mapping: KernelMapping) -> Result { let lifetime = self.lifetime.as_ref().ok_or(EINVAL)?; @@ -651,14 +640,8 @@ impl Vm { if state.quarantine_gen != gen { continue; } - // Reserve before accepting any range; a partial deferred batch must - // not leave canonical metadata ahead of the accepted cleanup. + // Reserve before accepting any range, so a deferred batch is accepted whole. state.unmaps.reserve(batch.ops.len() - start, GFP_KERNEL)?; - let retired = - self.untrack_context_ranges(batch.ops.iter().skip(start).filter_map(|op| match op { - PreparedUserBindOp::Unmap(unmap) => Some(unmap.iova..unmap.iova + unmap.size), - PreparedUserBindOp::Map(_) => None, - })); // Transfer the preallocated split nodes (and any reserved split charge) // along with each accepted range. Already-committed prefix operations // must not be replayed: their nodes may have been consumed and another @@ -675,7 +658,6 @@ impl Vm { } } drop(state); - drop(retired); return Ok(true); } } @@ -763,10 +745,6 @@ impl Vm { }, GFP_KERNEL)?; } if state.active != 0 || state.draining { - // Stop new jobs from selecting this accepted cleanup candidate. - // The queued object retains its GEM while the candidate is removed. - // Preserve a context view installed by a later bind. - self.untrack_context_object_before(gem, bind_sequence); return Ok(()); } state.draining = true; diff --git a/include/uapi/drm/asahi_drm.h b/include/uapi/drm/asahi_drm.h index a568e33b507af..5bb3c41573ba7 100644 --- a/include/uapi/drm/asahi_drm.h +++ b/include/uapi/drm/asahi_drm.h @@ -291,10 +291,6 @@ enum drm_asahi_feature { * toggled. Therefore, it is exposed as a feature bit and not a * userspace-settable flag on the VM. When soft fault is enabled, * userspace can speculate memory accesses more aggressively. - * - * On G17 GPUs the first 0x74000 bytes of a VM are not unmapped memory: - * they hold the views of the execution context, which the kernel and - * userspace map there. Loads from them return the context's data. */ DRM_ASAHI_FEATURE_SOFT_FAULTS = (1UL) << 0,