This is v2 of the patch series, which adds support for memory access attributes
(secure/space) in qtest framework.
Thanks to everyone who reviewed the previous version and provided valuable
feedback.
The major changes from v1 include:
- rework the qtest protocol to use an optional attrs argument and replace with
the related libqtest APIs
- use ARMSS_* and arm_space_is_secure() for ARM security-space handling
- switch AddressSpace lookup to cpu_asidx_from_attrs()
Motivation
----------
IOMMU functional testing is always stack-heavy: for example, even for the
Non-secure Arm SMMU model, end-to-end validation can require a fairly involved
software stack. To keep the testing loop tight and reproducible, I previously
proposed using iommu-testdev + QTest to validate IOMMU/SMMU behaviour without
booting a guest [1].
[1] https://www.qemu.org/docs/master/specs/iommu-testdev.html
However, the current QTest interface cannot tag memory accesses with MemTxAttrs,
so it is hard to write targeted tests for security-sensitive paths. This becomes
a bigger issue for Secure SMMU work, which is RFCing in [2] and for future Arm
RME-DA enablement.
[2] https://lore.kernel.org/qemu-devel/20260221100250.2976287-1-tangtao1634@phytium.com.cn/
This series therefore adds qtest protocol/libqtest helpers to drive memory
transactions and introduces qtest-attrs-test to validate the new APIs on Arm
virt(Secure/NonSecure/Root/Realm spaces) and on x86 pc (SMM AddressSpace).
Compatibility
-------------
This series is strictly additive:
- Existing qtest protocol commands remain unchanged.
- The new *_attrs commands are optional extensions.
- The implementation is confined to qtest.c + libqtest, plus the new test case.
Testing
-------
The new qtest-attrs-test is registered for both x86 and aarch64 qtest lists.
# test command
meson test -C build \
"qtest-aarch64/qtest-attrs-test" \
"qtest-i386/qtest-attrs-test" \
"qtest-x86_64/qtest-attrs-test"
Future work
-----------
Once the Secure SMMU series lands, I plan to build on this qtest API to extend
iommu-testdev-based tests to cover more security contexts (Secure state and,
later, RME-DA-related paths) while still avoiding a full guest software stack.
The branch below [4] demonstrates a modified iommu-testdev using the new qtest
interfaces to exercise Secure SMMU behaviour.
[4] https://gitlab.com/TaoTang/qemu/-/tree/integration/qtest-secure-api-v2
Tao Tang (2):
tests/qtest: Add attrs argument support to memory access commands
tests/qtest: Add qtest-attrs-test for memory access with attrs
system/qtest.c | 266 +++++++++++++++++++++++++++------
tests/qtest/libqtest-single.h | 61 ++++++++
tests/qtest/libqtest.c | 148 ++++++++++++++++++
tests/qtest/libqtest.h | 25 ++++
tests/qtest/meson.build | 4 +-
tests/qtest/qtest-attrs-test.c | 229 ++++++++++++++++++++++++++++
6 files changed, 685 insertions(+), 48 deletions(-)
create mode 100644 tests/qtest/qtest-attrs-test.c
--
2.34.1