[PATCH] iommufd: fix selftest link dependency on amdv1 driver

From: Arnd Bergmann

Date: Tue Dec 23 2025 - 16:51:32 EST


From: Arnd Bergmann <arnd@xxxxxxxx>

When CONFIG_AMD_IOMMU is disabled, the selftest runs into a link failure:

aarch64-linux-ld: drivers/iommu/iommufd/selftest.o: in function `mock_domain_alloc_pgtable.isra.0':
selftest.c:(.text+0x1590): undefined reference to `pt_iommu_amdv1_init'
aarch64-linux-ld: drivers/iommu/iommufd/selftest.o:(.rodata+0x280): undefined reference to `pt_iommu_amdv1_map_pages'
aarch64-linux-ld: drivers/iommu/iommufd/selftest.o:(.rodata+0x288): undefined reference to `pt_iommu_amdv1_unmap_pages'
aarch64-linux-ld: drivers/iommu/iommufd/selftest.o:(.rodata+0x2b0): undefined reference to `pt_iommu_amdv1_iova_to_phys'
aarch64-linux-ld: drivers/iommu/iommufd/selftest.o:(.rodata+0x2d8): undefined reference to `pt_iommu_amdv1_read_and_clear_dirty'

Change the top-level function to skip all the amdv1 tests in this configuration.

Fixes: e93d5945ed5b ("iommufd: Change the selftest to use iommupt instead of xarray")
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---
drivers/iommu/iommufd/selftest.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
index 550ff36dec3a..4d04d7642b1b 100644
--- a/drivers/iommu/iommufd/selftest.c
+++ b/drivers/iommu/iommufd/selftest.c
@@ -479,6 +479,11 @@ mock_domain_alloc_pgtable(struct device *dev,
}

case MOCK_IOMMUPT_AMDV1: {
+ if (!IS_ENABLED(CONFIG_AMD_IOMMU)) {
+ rc = -EOPNOTSUPP;
+ goto err_free;
+ }
+
struct pt_iommu_amdv1_cfg cfg = {};

cfg.common.hw_max_vasz_lg2 = 64;
--
2.39.5