All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC v5 0/5] tests/qtest: Add memory-access attributes (secure/space)
@ 2026-08-14  3:56 Tao Tang
  2026-08-14  3:56 ` [RFC v5 1/5] tests/qtest: Add attrs support to qtest server memory commands Tao Tang
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Tao Tang @ 2026-08-14  3:56 UTC (permalink / raw)
  To: Fabiano Rosas, Laurent Vivier, Paolo Bonzini
  Cc: qemu-devel, qemu-arm, Peter Maydell, Chen Baozi, Chao Liu,
	Jim MacArthur, Tao Tang

This is v5 of the qtest memory-access attributes series. Thanks to everyone who
reviewed v4 and provided feedback.

Since v4:
- server-side attrs handling has been simplified
- raw response handling has been split into a preparatory patch, and reusable
libqtest assertions and typed failure helpers have been added
- raw commands are now used only for malformed protocol forms.

This series is also available in a branch below:
https://gitlab.com/TaoTang/qemu/tree/qtest-secure-v5

CI is all green:
https://gitlab.com/TaoTang/qemu/-/pipelines/2757894685


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/20260813161515.2788900-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"


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 while still avoiding
a full guest software stack. There is an experimental branch that already uses
this API to validate secure/non-secure SMMU behaviour:

https://gitlab.com/TaoTang/qemu/tree/integration/secure-smmu-v5-qtest


Tao Tang (5):
  tests/qtest: Add attrs support to qtest server memory commands
  tests/qtest: Add libqtest attrs helpers for memory accesses
  tests/qtest: Add raw command response helper
  tests/qtest: Add qtest-attrs-test for memory access attrs
  [NOT-MERGE] tests/qtest: add q35 SMM-only x86 attrs coverage

 hw/pci-host/q35.c                  |  27 ++
 include/hw/pci-host/q35.h          |   8 +
 system/qtest.c                     | 349 +++++++++++++++++++++----
 tests/qtest/libqtest-single.h      | 156 +++++++++++
 tests/qtest/libqtest.c             | 402 +++++++++++++++++++++++++----
 tests/qtest/libqtest.h             | 288 +++++++++++++++++++++
 tests/qtest/meson.build            |   8 +-
 tests/qtest/qtest-attrs-test.c     | 305 ++++++++++++++++++++++
 tests/qtest/qtest-x86-attrs-test.c | 170 ++++++++++++
 9 files changed, 1600 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



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-08-19 14:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14  3:56 [RFC v5 0/5] tests/qtest: Add memory-access attributes (secure/space) Tao Tang
2026-08-14  3:56 ` [RFC v5 1/5] tests/qtest: Add attrs support to qtest server memory commands Tao Tang
2026-08-19 13:32   ` Fabiano Rosas
2026-08-14  3:56 ` [RFC v5 2/5] tests/qtest: Add libqtest attrs helpers for memory accesses Tao Tang
2026-08-14  3:56 ` [RFC v5 3/5] tests/qtest: Add raw command response helper Tao Tang
2026-08-19 14:06   ` Fabiano Rosas
2026-08-14  3:56 ` [RFC v5 4/5] tests/qtest: Add qtest-attrs-test for memory access attrs Tao Tang
2026-08-19 14:14   ` Fabiano Rosas
2026-08-14  3:56 ` [RFC v5 5/5] [NOT-MERGE] tests/qtest: add q35 SMM-only x86 attrs coverage Tao Tang

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.