This is v6 of the qtest memory-access attributes series. Many thanks to whom
reviewed previous versions and provided feedback.
Changes since v5
----------------
- Move the raw command response helper before the attrs helpers patch.
- Move the generic response assertions and typed failure helpers from the test
patch into the libqtest attrs helpers patch.
- Check for TCG availability before running either attrs test program,
and return early when TCG is unavailable.
This series is also available in a branch below:
https://gitlab.com/TaoTang/qemu/-/tree/series/qtest-secure-v6
The CI passed with warnings from two jobs, which also occured in upstream CI.
https://gitlab.com/TaoTang/qemu/-/pipelines/3065518609
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 [2], and for future Arm
RME-DA enablement.
[2] https://lore.kernel.org/qemu-devel/20261114154623.3599750-1-tangtao1634@phytium.com.cn/
This series therefore extends qtest memory access commands with an optional
attrs argument, adds matching libqtest helpers, and introduces tests that
exercise the new APIs against address spaces that actually differ by security
context.
In particular:
- on Arm virt,secure=on, the test now uses the secure-only RAM window so the
requested attrs must select the correct AddressSpace
- on x86 q35,smm=on, the API series covers normal RAM, and an extra NOT-MERGE
validation patch adds an SMM-only RAM window so the secure path can be
cross-checked against a location not visible from the default address space
Compatibility
-------------
This series is additive for existing qtest users:
- Existing qtest memory commands keep their current forms; attrs is an optional
extra argument
- Existing libqtest memory helpers remain available and are kept as wrappers
passing NULL attrs
- The first 4 patches are the upstreamable API and test additions
- The 5th patch is explicitly marked NOT-MERGE and only provides extra x86
RFC coverage by wiring in a q35 test-only SMM RAM window
One behavioural improvement is that memory access failures on the new paths are
now reported consistently as ERR, which lets tests validate address-space
selection failures directly.
Testing
-------
The API series was exercised with:
meson test -C build \
"qtest-aarch64/qtest-attrs-test" \
"qtest-i386/qtest-attrs-test" \
"qtest-x86_64/qtest-attrs-test"
The extra x86 cross-check from the NOT-MERGE patch was exercised with:
meson test -C build \
"qtest-i386/qtest-x86-attrs-test" \
"qtest-x86_64/qtest-x86-attrs-test"
Tao Tang (5):
tests/qtest: Add attrs support to qtest server memory commands
tests/qtest: Add raw command response helper
tests/qtest: Add libqtest attrs helpers for memory accesses
tests/qtest: Add qtest-attrs-test for memory access attrs
[NOT-MERGE] tests/qtest: add q35 SMM-only x86 attrs coverage
include/hw/pci-host/q35.h | 8 +
tests/qtest/libqtest-single.h | 156 +++++++++++
tests/qtest/libqtest.h | 288 +++++++++++++++++++++
hw/pci-host/q35.c | 27 ++
system/qtest.c | 349 +++++++++++++++++++++----
tests/qtest/libqtest.c | 402 +++++++++++++++++++++++++----
tests/qtest/qtest-attrs-test.c | 310 ++++++++++++++++++++++
tests/qtest/qtest-x86-attrs-test.c | 175 +++++++++++++
tests/qtest/meson.build | 8 +-
9 files changed, 1610 insertions(+), 113 deletions(-)
create mode 100644 tests/qtest/qtest-attrs-test.c
create mode 100644 tests/qtest/qtest-x86-attrs-test.c
--
2.34.1