Hi Eric,
On 2026/1/17 18:04, Eric Auger wrote:
Hi Tao,
On 12/24/25 4:46 AM, Tao Tang wrote:
Add a qtest suite that validates ARM SMMUv3 translation without guest
firmware or OS. The tests leverage iommu-testdev to trigger DMA
operations and the qos-smmuv3 library to configure IOMMU translation
structures.
This test suite targets the virt machine and covers:
- Stage 1 only translation (VA -> PA via CD page tables)
- Stage 2 only translation (IPA -> PA via STE S2 tables)
- Nested translation (VA -> IPA -> PA, Stage 1 + Stage 2)
- Design to extended to support multiple security spaces
(Non-Secure, Secure, Root, Realm)
Each test case follows this sequence:
1. Initialize SMMUv3 with appropriate command/event queues
2. Build translation tables (STE/CD/PTE) for the target scenario
3. Configure iommu-testdev with IOVA and DMA attributes via MMIO
4. Trigger DMA and validate successful translation
5. Verify data integrity through a deterministic write-read pattern
This bare-metal approach provides deterministic IOMMU testing with
minimal dependencies, making failures directly attributable to the SMMU
translation path.
Signed-off-by: Tao Tang <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
---
tests/qtest/iommu-smmuv3-test.c | 121 ++++++++++++++++++++++++++++++++
tests/qtest/meson.build | 1 +
2 files changed, 122 insertions(+)
create mode 100644 tests/qtest/iommu-smmuv3-test.c
------------------------------<snip>------------------------------
------------------------------<snip>------------------------------
+
+int main(int argc, char **argv)
+{
+ g_test_init(&argc, &argv, NULL);
+ qtest_add_func("/iommu-testdev/translation/ns-s1-only",
+ test_smmuv3_ns_s1_only);
+ qtest_add_func("/iommu-testdev/translation/ns-s2-only",
+ test_smmuv3_ns_s2_only);
+ qtest_add_func("/iommu-testdev/translation/ns-nested",
+ test_smmuv3_ns_nested);
+ return g_test_run();
+}
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 669d07c06b..e2d2e68092 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -263,6 +263,7 @@ qtests_aarch64 = \
config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] :
[]) + \
(config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed64 : []) + \
(config_all_devices.has_key('CONFIG_NPCM8XX') ? qtests_npcm8xx : []) + \
+ (config_all_devices.has_key('CONFIG_IOMMU_TESTDEV') ? ['iommu-smmuv3-test']
: []) + \
One question: since it can only run along with VIRT machine, how do we
make sure this only runs with that machine enabled?
Thanks for the catch. I'll address this in two places:
- Build-time: the test is now added only when both CONFIG_IOMMU_TESTDEV
and CONFIG_ARM_VIRT are enabled in meson.build.
- Run-time: the test checks qtest_has_machine("virt") and calls
g_test_skip() if the virt machine is not available.
This ensures the test is only built/selected when virt is present and
also skips cleanly if the machine isn’t supported at runtime.
Best regards,
Tao