HomeFreeBSD

AMD IOMMU: fix per-device IOMMU bypass when IR is enabled

Description

AMD IOMMU: fix per-device IOMMU bypass when IR is enabled

When interrupt remapping (IR) is enabled, the device table entry
(DTE) for a given device will likely be initialized by
amdiommu_ir_find() during MSI configuration. This function directly
calls amdiommu_get_ctx_for_dev() with id_mapped=false, which means that
any attempt to disable DMA remapping for the device (e.g. by setting
hw.busdma.pciD.B.S.F='bounce' in the loader tunables) will effectively
be ignored as the paging mode field in the DTE will not be set to
0 as required for identity mapping. This will ultimately produce
an unusable device, because busdma will later observe the bounce
configuration through iommu_instantiate_ctx() and will employ the
non-translated 'bounce' busdma methods for the device, while the DTE
remains configured to enable translation.

Fix this by tweaking iommu_instantiate_ctx() to always return the
relevant per-device context object even if translation is disabled,
and adopt it in amdiommu_ir_find() instead of directly calling
amdiommu_get_ctx_for_dev().

Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53209

Details

Provenance
jahAuthored on Oct 20 2025, 1:53 AM
Reviewer
kib
Differential Revision
D53209: AMD IOMMU: fix per-device IOMMU bypass when IR is enabled
Parents
rG2b5c62494df9: release: Add pkg .conf to METALOG on dvd
Branches
Unknown
Tags
Unknown