forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 199
soc: apple: sep: unmap the firmware IOVA, not the physical address - #592
Open
brentkearney wants to merge 1 commit into
Open
soc: apple: sep: unmap the firmware IOVA, not the physical address #592brentkearney wants to merge 1 commit into
brentkearney wants to merge 1 commit into
Conversation
Author
Runtime results from the patched kernel on the j316s (MacBook Pro 16-inch, 2021, apple,t6000):
apple_sepbinds at boot, SEPOS completes the boot handshake and advertises its endpoints as before.echo 396400000.sep > /sys/bus/platform/drivers/apple_sep/unbindcompletes with no kernel output at all.dmesg | grep -c WARNING→ 0,dmesg | grep -c dart_unmap→ 0./proc/sys/kernel/taintedkeeps theWbit (512) clear; on the stock kernel this same unbind emits the two WARNs in apple_sep: unbinding warns twice and leaks the firmware IOMMU mapping #591 and taints the kernel./sys/bus/platform/devices/396400000.sep/driveris gone after the unbind, soremove()ran to completion.
load_fw_and_shmem() maps the SEP firmware region with dma_map_resource(), which returns an IOVA, but keeps only the shifted copy needed for the MSG_BOOT_IMG4 message and discards the IOVA itself. remove() then calls dma_unmap_resource() with region_params.addr, the physical address of the reserved region. The two are unrelated, so the unmap tears down page table entries that were never present, and the real mapping is leaked. On t6000 the region sits at 0x10006340000, far outside the device's DART address space, and unbinding the driver warns twice: WARNING: drivers/iommu/io-pgtable-dart.c:308 at dart_unmap_pages+0x11c/0x140 dart_unmap_pages+0x11c/0x140 apple_dart_unmap_pages+0x24/0x30 __iommu_dma_unmap+0x94/0x140 iommu_dma_unmap_phys+0xf8/0x118 ...3sep9SepDriverEE20post_unbind_callback+0x34/0x70 WARNING: drivers/iommu/dma-iommu.c:844 at __iommu_dma_unmap+0x128/0x140 __iommu_dma_unmap+0x128/0x140 iommu_dma_unmap_phys+0xf8/0x118 ...3sep9SepDriverEE20post_unbind_callback+0x34/0x70 Keep the IOVA alongside the existing fw_mapped flag and unmap that instead. Reproduced on an Apple MacBook Pro (16-inch, 2021), t6000/j316s, by enabling the sep node and unbinding the driver.
brentkearney
force-pushed
the
sep-unmap-iova
branch
from
September 3, 2026 02:19
1bd6844 to
92b6e80
Compare
ElectricS01
pushed a commit
to ElectricS01/linux
that referenced
this pull request
Sep 7, 2026
@borkmann
Alexei Starovoitov
Extend the verifier_direct_packet_access BPF selftests to exercise the verifier code paths which ensure that the pkt range is cleared after add/sub alu with a known scalar. The tests reject the invalid access. # LDLIBS=-static PKG_CONFIG='pkg-config --static' ./vmtest.sh -- ./test_progs -t verifier_direct [...] AsahiLinux#592/35 verifier_direct_packet_access/direct packet access: pkt_range cleared after sub with known scalar:OK AsahiLinux#592/36 verifier_direct_packet_access/direct packet access: pkt_range cleared after add with known scalar:OK AsahiLinux#592/37 verifier_direct_packet_access/direct packet access: test3:OK AsahiLinux#592/38 verifier_direct_packet_access/direct packet access: test3 @unpriv:OK AsahiLinux#592/39 verifier_direct_packet_access/direct packet access: test34 (non-linear, cgroup_skb/ingress, too short eth):OK AsahiLinux#592/40 verifier_direct_packet_access/direct packet access: test35 (non-linear, cgroup_skb/ingress, too short 1):OK AsahiLinux#592/41 verifier_direct_packet_access/direct packet access: test36 (non-linear, cgroup_skb/ingress, long enough):OK AsahiLinux#592 verifier_direct_packet_access:OK [...] Summary: 2/47 PASSED, 0 SKIPPED, 0 FAILED Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/r/20260409155016.536608-2-daniel@iogearbox.net Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
Unmap the IOVA that
dma_map_resource()returned instead of the region's physical address, so unbindingapple_sepstops warning twice in the IOMMU and stops leaking the SEP firmware mapping. Closes #591.Changes
fw_iova: Atomic<u64>toSepData, storing the return value ofdma_map_resource()next to the existingfw_mappedflag.fw_iovainstead ofregion_params.addrtodma_unmap_resource()in the unbind path.Testing
Compile-tested against
asahi-7.1.6-1with rustc 1.93.1, and runtime-tested on a MacBook Pro 16-inch 2021 (apple,j316s/apple,t6000) with thesepnode enabled:drivers/soc/apple/sep.obuilds before and after,CLIPPY=1introduces no new warnings, andrustfmt --checkpasses.echo 396400000.sep > /sys/bus/platform/drivers/apple_sep/unbindproduces the two WARNs in apple_sep: unbinding warns twice and leaks the firmware IOMMU mapping #591 and sets theWtaint bit.dmesg | grep -c WARNINGanddmesg | grep -c dart_unmapboth return 0, and theWtaint bit (512) stays clear.driverlink is gone afterwards, soremove()ran to completion.