From 50c9683d36fa103faf14d0c4770c8e5d97e4f74c Mon Sep 17 00:00:00 2001 From: Jonathan Goyvaerts Date: Mon, 16 Nov 2026 11:12:51 -0300 Subject: [PATCH] drm/asahi: g17: advertise soft faults Commit 6f7faeecea0e ("drm/asahi: g17: do not advertise soft faults") stopped advertising DRM_ASAHI_FEATURE_SOFT_FAULTS on G17, after every robustness2 rgba32 vertex_attribute_fetch case read non-zero data with the bit set. Its explanation was wrong. Mesa pointed the out-of-bounds vec3/vec4 vertex fetches at address 0 plus index times stride, and that range is not unmapped on G17: once a client runs compute work, the first 64 KiB of its VM hold the execution context's null view (CONTEXT_VIEWS[0], the render context presented at its fixed low address, as macOS presents it), and userspace maps the other context views up to 0x74000. Mesa no longer redirects robust fetches there on G17 (the Mesa change "asahi: explicitly bound robust native vector vertex fetches", 4115628b637f in aurora-wip). The G17 firmware takes no fault_control, but its own fault mode gives soft faults. Measured on the M4 Pro (T6040, firmware 25G83) with the bit clear and nothing else changed: - shader loads from unmapped client addresses return zero, whether the missing translation is at the leaf, at level 1 or at the root; - shader stores to unmapped or read-only pages, and atomics on read-only pages, are dropped; - none of these reports a fault or causes a recovery. This is a property of the firmware family, not of the SoC: the driver gives every G17 queue the same fault setting (QueueConfig::unk_66 = 1, the word the M5 firmware names soft_fault_enabled). Advertise soft faults on every GPU the G17 backend drives, with fault_control at its 0xb default as on the other generations. Say in the driver and in the uAPI that the context views are mapped memory. With the bit set on the M4 Pro, unmapped addresses read zero, stores and atomics to them are dropped without a fault, and all 98,776 dEQP-VK.robustness.* cases give the same results as without it (47,933 pass, 50,843 not supported, 0 fail), with no GPU recovery. The other G17 SoCs (T6041, T8140, T8142, T6050) have not been measured. Signed-off-by: Jonathan Goyvaerts Assisted-by: LLM --- drivers/gpu/drm/asahi/g17/mod.rs | 15 +++++++++------ include/uapi/drm/asahi_drm.h | 4 ++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/asahi/g17/mod.rs b/drivers/gpu/drm/asahi/g17/mod.rs index b2c0aa5e0c4b2..434a97b486fd0 100644 --- a/drivers/gpu/drm/asahi/g17/mod.rs +++ b/drivers/gpu/drm/asahi/g17/mod.rs @@ -2561,13 +2561,16 @@ impl gpu::Gpu for Gpu { true } - /// The G17 runtime never programs fault_control into the firmware, so unmapped reads are not - /// guaranteed to return zero. Advertising soft faults made Mesa point out-of-bounds vec3/vec4 - /// vertex fetches at address 0 and skip bounds checks on bounded loads; on T6040 those reads - /// returned non-zero data (2026-10-19: every robustness2 rgba32 vertex_attribute_fetch case - /// failed; all pass with soft faults off). + /// The G17 firmware takes no fault_control. Its own fault mode gives soft faults: a shader + /// load of an unmapped client address returns zero and a store or atomic to one is dropped, + /// 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). fn supports_soft_faults(&self) -> bool { - false + crate::module_parameters::fault_control.value() == 0xb } fn queue_limits(&self) -> Option { diff --git a/include/uapi/drm/asahi_drm.h b/include/uapi/drm/asahi_drm.h index fc3b32a63b470..f963089017c40 100644 --- a/include/uapi/drm/asahi_drm.h +++ b/include/uapi/drm/asahi_drm.h @@ -291,6 +291,10 @@ 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,