* [PATCH] iommufd: fix selftest link dependency on amdv1 driver
@ 2025-12-23 21:51 Arnd Bergmann
2025-12-24 1:52 ` Jason Gunthorpe
0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2025-12-23 21:51 UTC (permalink / raw)
To: Jason Gunthorpe, Kevin Tian, Joerg Roedel, Will Deacon,
Samiullah Khawaja
Cc: Arnd Bergmann, Robin Murphy, Nicolin Chen, Lu Baolu,
Pranjal Shrivastava, Yi Liu, iommu, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
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@arndb.de>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iommufd: fix selftest link dependency on amdv1 driver
2025-12-23 21:51 [PATCH] iommufd: fix selftest link dependency on amdv1 driver Arnd Bergmann
@ 2025-12-24 1:52 ` Jason Gunthorpe
2025-12-24 10:17 ` Arnd Bergmann
0 siblings, 1 reply; 4+ messages in thread
From: Jason Gunthorpe @ 2025-12-24 1:52 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Kevin Tian, Joerg Roedel, Will Deacon, Samiullah Khawaja,
Arnd Bergmann, Robin Murphy, Nicolin Chen, Lu Baolu,
Pranjal Shrivastava, Yi Liu, iommu, linux-kernel
On Tue, Dec 23, 2025 at 10:51:22PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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.
kconfig shouldn't let this build happen:
config IOMMUFD_TEST
bool "IOMMU Userspace API Test support"
depends on DEBUG_KERNEL
depends on FAULT_INJECTION
depends on RUNTIME_TESTING_MENU
depends on IOMMU_PT_AMDV1
select IOMMUFD_DRIVER
I think this is more fall out from Geert's change to make GENERIC_PT
unselectable, the 'depends on' is no longer enough??
I guess the right fix is to add a "select GENERIC_PT" above, does that
work for you?
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommufd: fix selftest link dependency on amdv1 driver
2025-12-24 1:52 ` Jason Gunthorpe
@ 2025-12-24 10:17 ` Arnd Bergmann
2026-01-02 19:36 ` Jason Gunthorpe
0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2025-12-24 10:17 UTC (permalink / raw)
To: Jason Gunthorpe, Arnd Bergmann
Cc: Kevin Tian, Joerg Roedel, Will Deacon, Samiullah Khawaja,
Robin Murphy, Nicolin Chen, Baolu Lu, Pranjal Shrivastava, Yi Liu,
iommu, linux-kernel
On Wed, Dec 24, 2025, at 02:52, Jason Gunthorpe wrote:
> On Tue, Dec 23, 2025 at 10:51:22PM +0100, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>>
>> 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.
>
> kconfig shouldn't let this build happen:
>
> config IOMMUFD_TEST
> bool "IOMMU Userspace API Test support"
> depends on DEBUG_KERNEL
> depends on FAULT_INJECTION
> depends on RUNTIME_TESTING_MENU
> depends on IOMMU_PT_AMDV1
> select IOMMUFD_DRIVER
>
> I think this is more fall out from Geert's change to make GENERIC_PT
> unselectable, the 'depends on' is no longer enough??
>
> I guess the right fix is to add a "select GENERIC_PT" above, does that
> work for you?
No, it's already set.
The configuration that had the build failure contains
CONFIG_ARM64=y
# CONFIG_AMD_IOMMU is not set
CONFIG_GENERIC_PT=y
CONFIG_IOMMU_PT=m
CONFIG_IOMMU_PT_AMDV1=m
CONFIG_IOMMUFD=y
CONFIG_IOMMUFD_TEST=y
I suspect this is because IOMMUFD_TEST is 'bool' and can be enabled
even when its dependencies are =m, but if the test code is built-in,
it can't actually link.
This should be fixable using
depends on IOMMU_PT_AMDV1=y || IOMMUFD=IOMMU_PT_AMDV1
or by forcing the iommufd code to be a loadable module when
IOMMU_PT_AMDV=m, e.g. through
config IOMMUFD
depends on IOMMU_PT_AMDV1 || !IOMMU_PT_AMDV1 || !RUNTIME_TESTING_MENU
A cleaner approach might be to split out IOMMUFD_TEST into a separate
module rather than including it inside of the IOMMUFD module,
but that is likely much more work.
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommufd: fix selftest link dependency on amdv1 driver
2025-12-24 10:17 ` Arnd Bergmann
@ 2026-01-02 19:36 ` Jason Gunthorpe
0 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2026-01-02 19:36 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Arnd Bergmann, Kevin Tian, Joerg Roedel, Will Deacon,
Samiullah Khawaja, Robin Murphy, Nicolin Chen, Baolu Lu,
Pranjal Shrivastava, Yi Liu, iommu, linux-kernel
On Wed, Dec 24, 2025 at 11:17:13AM +0100, Arnd Bergmann wrote:
> On Wed, Dec 24, 2025, at 02:52, Jason Gunthorpe wrote:
> > On Tue, Dec 23, 2025 at 10:51:22PM +0100, Arnd Bergmann wrote:
> >> From: Arnd Bergmann <arnd@arndb.de>
> >>
> >> 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.
> >
> > kconfig shouldn't let this build happen:
> >
> > config IOMMUFD_TEST
> > bool "IOMMU Userspace API Test support"
> > depends on DEBUG_KERNEL
> > depends on FAULT_INJECTION
> > depends on RUNTIME_TESTING_MENU
> > depends on IOMMU_PT_AMDV1
> > select IOMMUFD_DRIVER
> >
> > I think this is more fall out from Geert's change to make GENERIC_PT
> > unselectable, the 'depends on' is no longer enough??
> >
> > I guess the right fix is to add a "select GENERIC_PT" above, does that
> > work for you?
>
> No, it's already set.
>
> The configuration that had the build failure contains
>
> CONFIG_ARM64=y
> # CONFIG_AMD_IOMMU is not set
> CONFIG_GENERIC_PT=y
> CONFIG_IOMMU_PT=m
> CONFIG_IOMMU_PT_AMDV1=m
> CONFIG_IOMMUFD=y
> CONFIG_IOMMUFD_TEST=y
>
> I suspect this is because IOMMUFD_TEST is 'bool' and can be enabled
> even when its dependencies are =m, but if the test code is built-in,
> it can't actually link.
Okay, that makes more sense..
> This should be fixable using
>
> depends on IOMMU_PT_AMDV1=y || IOMMUFD=IOMMU_PT_AMDV1
This is probably the best option, can you check it with the
problematic .config?
> or by forcing the iommufd code to be a loadable module when
> IOMMU_PT_AMDV=m, e.g. through
>
> config IOMMUFD
> depends on IOMMU_PT_AMDV1 || !IOMMU_PT_AMDV1 || !RUNTIME_TESTING_MENU
Because we don't want this restriction for production builds..
> A cleaner approach might be to split out IOMMUFD_TEST into a separate
> module rather than including it inside of the IOMMUFD module,
> but that is likely much more work.
I think there are cross calls that would make that difficult :\
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-02 19:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-23 21:51 [PATCH] iommufd: fix selftest link dependency on amdv1 driver Arnd Bergmann
2025-12-24 1:52 ` Jason Gunthorpe
2025-12-24 10:17 ` Arnd Bergmann
2026-01-02 19:36 ` Jason Gunthorpe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.