Fix DMA page lookup for IOMMU allocations - #121
Open
xiaotianxt wants to merge 1 commit into
Open
Conversation
xiaotianxt
marked this pull request as ready for review
August 11, 2026 23:55
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.
Summary
exanic_virt_to_page()to handle both direct-mapped and vmalloc-backed addressesdma_alloc_coherent()Root cause
With an IOMMU enabled, the DMA API can assemble a coherent allocation from separate pages and expose its CPU mapping through
vmap(). Such an address is in vmalloc space. On x86,virt_to_page()is only valid whenvirt_addr_valid()is true, so applying it to that mapping produces an invalidstruct page *and can fault inpage_count()orvm_insert_page().The helper follows the same split used by the Linux IOMMU DMA implementation when releasing coherent allocations:
vmalloc_to_page()for vmalloc addresses andvirt_to_page()otherwise.This addresses the IOMMU-dependent kernel faults reported in #94 and #95. A matching
vm_insert_page()fault with IOMMU enabled was also reported in #70.Impact
Avoid kernel page faults while mapping ExaNIC DMA buffers and while checking their mapping reference counts. Non-IOMMU/direct-mapped allocations keep the existing behavior.
Validation
exanic.koagainst Debian 12 x86_64 Linux 6.1.180 headersexanic.koagainst Rocky Linux 9 x86_64 Linux 5.14.0-687.36.1 headersRuntime validation still requires an ExaNIC-equipped Linux host with IOMMU enabled.