Hi all,
This 2-patch series extends the qtest protocol/libqtest memory-access commands
so QTests can drive memory transactions with selected MemTxAttrs. In particular,
it adds support for:
- MemTxAttrs.secure (Available on Arm/x86)
- MemTxAttrs.space (Arm security space selector)
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 with:
- MemTxAttrs.secure via *_secure commands (Arm + x86)
- MemTxAttrs.space via *_space commands (Arm-only)
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 *_secure / *_space 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 secure/space attributes on Arm
QTEST_QEMU_BINARY=build/qemu-system-aarch64 ./build/tests/qtest/qtest-attrs-test
# test secure attribute on x86
QTEST_QEMU_BINARY=build/qemu-system-x86_64 ./build/tests/qtest/qtest-attrs-test
CI is all green [3]:
[3] https://gitlab.com/TaoTang/qemu/-/pipelines/2341872040
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
secure/space qtest interfaces to exercise Secure SMMU behaviour.
[4] https://github.com/hnusdr/qemu/commits/qtest-arm-secure-api
Tao Tang (2):
tests/qtest: Support for memory access with secure/space attr
tests/qtest: Add qtest-attrs-test to verify memory access with attr
system/qtest.c | 482 ++++++++++++++++++++++++
tests/qtest/libqtest-single.h | 133 +++++++
tests/qtest/libqtest.c | 249 ++++++++++++
tests/qtest/libqtest.h | 281 ++++++++++++++
tests/qtest/meson.build | 4 +-
tests/qtest/qtest-attrs-test.c | 669 +++++++++++++++++++++++++++++++++
6 files changed, 1817 insertions(+), 1 deletion(-)
create mode 100644 tests/qtest/qtest-attrs-test.c
--
2.34.1