Skip to content

KVM: arm64: Enforce MTE disablement at EL2

Fuad Tabba kvmarm linux-arm-kernel 3 versions – Applied

Status from this message: Applied to next, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest4 patches 1 replyApplied
  2. v25 patches 3 repliesSuperseded
  3. v15 patches 7 repliesSuperseded

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/4KVM: arm64: Remove dead code resetting HCR_EL2 for pKVMarch/arm64/kvm/hyp/nvhe/hyp-init.S+0 -50 replies
2/4KVM: arm64: Trap MTE access and discovery when MTE is disabledarch/arm64/include/asm/kvm_arm.h arch/arm64/kernel/head.S arch/arm64/kvm/arm.c+8 -20 replies
3/4KVM: arm64: Inject UNDEF when accessing MTE sysregs with MTE disabledarch/arm64/kvm/hyp/nvhe/hyp-main.c+67 -00 replies
4/4KVM: arm64: Use kvm_has_mte() in pKVM trap initializationarch/arm64/kvm/hyp/nvhe/pkvm.c+1 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/4] KVM: arm64: Enforce MTE disablement at EL2

Changes since v2 [1]:
- Trap accesses to GMID_EL1 by setting HCR_EL2.TID5 when MTE is disabled (Marc)
- Dropped patch refactoring enter_exception64() in favor of open-coded logic in inject_undef64() in patch 3/4 (Marc)
- Based on Linux 6.19-rc6

pKVM never exposes MTE to protected guests (pVM), but we must also ensure that a malicious host cannot use MTE to attack the hypervisor or a protected VM.

If MTE is supported by the hardware (and is enabled at EL3), it remains available to lower exception levels by default. Disabling it in the host kernel (e.g., via 'arm64.nomte') only stops the kernel from advertising the feature; it does not physically disable MTE in the hardware.

The ability to disable MTE in the host kernel is used by some systems, such as Android, so that the physical memory otherwise used as tag storage can be used for other things (i.e. treated just like the rest of memory). In this scenario, a malicious host could still access tags in pages donated to a guest using MTE instructions (e.g., STG and LDG), bypassing the kernel's configuration.

To prevent this, explicitly disable MTE at EL2 (by clearing HCR_EL2.ATA and setting HCR_EL2.TID5) when the host has MTE disabled. This causes MTE instructions to trap to the hypervisor.

Cheers,
/fuad

[1] https://lore.kernel.org/all/[email protected]/

Fuad Tabba (4):
KVM: arm64: Remove dead code resetting HCR_EL2 for pKVM
KVM: arm64: Trap MTE access and discovery when MTE is disabled
KVM: arm64: Inject UNDEF when accessing MTE sysregs with MTE disabled
KVM: arm64: Use kvm_has_mte() in pKVM trap initialization

 arch/arm64/include/asm/kvm_arm.h   |  2 +-
 arch/arm64/kernel/head.S           |  2 +-
 arch/arm64/kvm/arm.c               |  6 +++
 arch/arm64/kvm/hyp/nvhe/hyp-init.S |  5 ---
 arch/arm64/kvm/hyp/nvhe/hyp-main.c | 67 ++++++++++++++++++++++++++++++
 arch/arm64/kvm/hyp/nvhe/pkvm.c     |  2 +-
 6 files changed, 76 insertions(+), 8 deletions(-)

base-commit: 24d479d26b25bce5faea3ddd9fa8f3a6c3129ea7

Signature · 1 line
2.52.0.457.g6b5491de43-goog