[PATCH RFC v3 00/12] target/arm: add support for MTE4

Gabriel Brookman posted 12 patches 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260105-feat-mte4-v3-0-86a0d99ef2e4@gmail.com
Maintainers: Laurent Vivier <laurent@vivier.eu>, Peter Maydell <peter.maydell@linaro.org>
docs/system/arm/emulation.rst        |   5 ++
linux-user/aarch64/mte_user_helper.h |   3 +
linux-user/aarch64/target_prctl.h    |  11 +++
target/arm/cpu-features.h            |  10 +++
target/arm/cpu.h                     |   4 +
target/arm/helper.c                  |  27 ++++++-
target/arm/internals.h               |  31 ++++++++
target/arm/ptw.c                     |  45 ++++++++++-
target/arm/tcg/cpu64.c               |   8 ++
target/arm/tcg/helper-a64.c          |   9 +--
target/arm/tcg/hflags.c              |  25 +++++--
target/arm/tcg/mte_helper.c          | 140 +++++++++++++++++++++++++++++++----
target/arm/tcg/translate-a64.c       |   8 +-
target/arm/tcg/translate.h           |   2 +
tests/tcg/aarch64/Makefile.target    |   2 +-
tests/tcg/aarch64/mte-10.c           |  49 ++++++++++++
tests/tcg/aarch64/mte-9.c            |  48 ++++++++++++
tests/tcg/aarch64/mte.h              |  15 ++++
18 files changed, 401 insertions(+), 41 deletions(-)
[PATCH RFC v3 00/12] target/arm: add support for MTE4
Posted by Gabriel Brookman 1 month ago
This patch implements ARM's Enhanced Memory Tagging Extension (MTE4).
MTE4 implies the presence of several subfeatures:
FEAT_MTE_CANONICAL_TAGS, FEAT_MTE_TAGGED_FAR, FEAT_MTE_STORE_ONLY,
FEAT_MTE_NO_ADDRESS_TAGS, and FEAT_MTE_PERM, none of which are
currently implemented in QEMU. This patch implements all five.

Testing:
  - Included for FAR and STORE_ONLY.
  - The MTE_CANONICAL/NAT test from the previous email, modified so
    MTE_CANONICAL is enabled in user mode.
  - A bare-metal testsuite that sets up page tables for S1 and S2
    translation, to test the features that rely on those. Didn't include
    it because it's unwieldy.
  - The bare-metal testsuite also was used to test LDGM and similar
    instructions not permitted in user-mode.

Thanks,
Gabriel Brookman

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3116
Signed-off-by: Gabriel Brookman <brookmangabriel@gmail.com>
---
Changes in v3:
- Added prctl for MTE_STORE_ONLY to linux-user
- mte_check is no longer generated on read when STORE_ONLY enabled
- Implemented LDGM instruction
- Removed "long" datatype as per Richard's suggestion
- Implemented masking for VA range checks when MTX bit enabled
- Implemented MTE_PERM, with NoTagAccess attribute
- Removed user-mode test for MTE_CANONICAL, since can't enable in
  user-mode.
- Removed TBI from mte_check generation logic
- Link to v2: https://lore.kernel.org/qemu-devel/20251116-feat-mte4-v2-0-9a7122b7fa76@gmail.com

Changes in v2:
- Added tests for STORE_ONLY.
- Refined commit messages.
- Added FEAT_MTE_CANONICAL_TAGS and FEAT_MTE_NO_ADDRESS_TAGS + tests.
- fixed TCSO bit macro names.
- Link to v1: https://lore.kernel.org/qemu-devel/20251111-feat-mte4-v1-0-72ef5cf276f9@gmail.com

---
Gabriel Brookman (12):
      target/arm: implement MTE_PERM
      target/arm: add TCSO bitmasks to SCTLR
      target/arm: mte_check unemitted on STORE_ONLY load
      linux-user: add MTE_STORE_ONLY to prctl
      target/arm: removed TBI bits from MTE check logic
      target/arm: add canonical and no-address tag logic
      target/arm: ldg on canonical tag loads the tag
      target/arm: storing to canonical tags faults
      target/arm: added mtx to translation logic
      docs: add MTE4 features to docs
      tests/tcg: add test for MTE FAR
      tests/tcg: add test for MTE_STORE_ONLY

 docs/system/arm/emulation.rst        |   5 ++
 linux-user/aarch64/mte_user_helper.h |   3 +
 linux-user/aarch64/target_prctl.h    |  11 +++
 target/arm/cpu-features.h            |  10 +++
 target/arm/cpu.h                     |   4 +
 target/arm/helper.c                  |  27 ++++++-
 target/arm/internals.h               |  31 ++++++++
 target/arm/ptw.c                     |  45 ++++++++++-
 target/arm/tcg/cpu64.c               |   8 ++
 target/arm/tcg/helper-a64.c          |   9 +--
 target/arm/tcg/hflags.c              |  25 +++++--
 target/arm/tcg/mte_helper.c          | 140 +++++++++++++++++++++++++++++++----
 target/arm/tcg/translate-a64.c       |   8 +-
 target/arm/tcg/translate.h           |   2 +
 tests/tcg/aarch64/Makefile.target    |   2 +-
 tests/tcg/aarch64/mte-10.c           |  49 ++++++++++++
 tests/tcg/aarch64/mte-9.c            |  48 ++++++++++++
 tests/tcg/aarch64/mte.h              |  15 ++++
 18 files changed, 401 insertions(+), 41 deletions(-)
---
base-commit: 159107e390609f71b78268a4888563dcdce6ac65
change-id: 20251109-feat-mte4-6740a6202e83

Best regards,
-- 
Gabriel Brookman <brookmangabriel@gmail.com>