linux/arch/arm64/kvm
Alexandru Elisei 679d7201c1 KVM: arm64: Reject guest_memfd memslots when the VM has MTE
The user cannot use MTE on VMAs created by mapping a guest_memfd file,
as arch_calc_vm_flag_bits() does not set VM_MTE_ALLOWED.

When creating a guest_memfd backed memslot,
kvm_arch_prepare_memory_region() rejects the memslot if MTE is enabled for
the VM and if guest_memfd has been mapped in a VMA that intersects the
memslot.

However, the documentation for KVM_SET_USER_MEMORY_REGION2 explicitly
states that the only condition for userspace_addr is for it to be a legal
userspace address, but the mapping is not required to be valid nor
populated at memslot creation.

If userspace sets userspace_addr to an address that hasn't been mapped, or
if userspace_addr belongs to a VMA that isn't backed by the guest_memfd
file, or if the VMA doesn't intersect the memslot, memslot creation is
successful and KVM ends up with a VM with MTE and guest_memfd-backed
memslots.

The same happens if the order is reversed: when userspace enables MTE, KVM
does not check if memslots backed by guest_memfd are already present.

Fix both issues by rejecting guest_memfd-backed memslots when MTE is
enabled, and by rejecting MTE when guest_memfd-backed memslots are already
present.

Fixes: 32e200bd6e ("KVM: arm64: Enable support for guest_memfd backed memory")
Tested-by: Fuad Tabba <fuad.tabba@linux.dev>
Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev>
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Link: https://patch.msgid.link/20260722090354.94245-1-alexandru.elisei@arm.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
2026-07-23 09:57:06 +01:00
..
hyp KVM: arm64: Add missing hyp_enter when trapping sysreg 2026-07-23 09:56:57 +01:00
vgic KVM: arm64: vgic: Mitigate potential LPI registration failure 2026-07-23 09:56:57 +01:00
.gitignore KVM: arm64: Generate hyp_constants.h for the host 2021-12-06 08:37:03 +00:00
arch_timer.c Merge branch kvm-arm64/vgic-v5-PPI-fixes into kvmarm-master/next 2026-06-12 09:08:31 +01:00
arm.c KVM: arm64: Reject guest_memfd memslots when the VM has MTE 2026-07-23 09:57:06 +01:00
at.c KVM/arm64 fixes for 7.2, take #1 2026-07-15 12:12:37 +02:00
config.c KVM: arm64: Fix FEAT_SPE_FnE to use PMSIDR_EL1.FnE, not PMSVer 2026-04-24 12:03:57 +01:00
debug.c KVM: arm64: Read PMUVer as unsigned 2026-03-24 12:33:48 +00:00
emulate-nested.c KVM: arm64: Set IL for nested SError injection 2026-06-22 10:44:08 +01:00
fpsimd.c KVM: arm64: nv: Don't save/restore FP register during a nested ERET or exception 2026-05-21 07:42:54 +01:00
guest.c arm64: fpsimd: Use opaque type for SVE state 2026-06-03 16:50:49 +01:00
handle_exit.c KVM: arm64: Add PKVM_DISABLE_STAGE2_ON_PANIC 2026-03-11 08:51:16 +00:00
hyp_trace.c KVM: arm64: Add missing hyp_enter when trapping sysreg 2026-07-23 09:56:57 +01:00
hyp_trace.h KVM: arm64: Add trace remote for the nVHE/pKVM hyp 2026-03-11 08:51:16 +00:00
hypercalls.c KVM: arm64: Use ktime_get_snapshot_id() to snapshot CLOCK_REALTIME 2026-06-04 11:04:16 +02:00
inject_fault.c KVM: arm64: Set IL for emulated SError injection 2026-06-22 10:44:08 +01:00
Kconfig KVM: arm64: tracing: add ftrace dependency 2026-03-12 15:19:30 +00:00
Makefile KVM: arm64: Add trace remote for the nVHE/pKVM hyp 2026-03-11 08:51:16 +00:00
mmio.c KVM: arm64: Fix sign-extension of MMIO loads 2026-07-06 17:18:34 +01:00
mmu.c KVM: arm64: Reject guest_memfd memslots when the VM has MTE 2026-07-23 09:57:06 +01:00
nested.c KVM/arm64 fixes for 7.2, take #1 2026-07-15 12:12:37 +02:00
pauth.c KVM: arm64: nv: Work around lack of pauth support in old toolchains 2024-04-23 19:27:11 +01:00
pkvm.c KVM: arm64: account pKVM reclaim against the VM mm 2026-06-22 10:48:08 +01:00
pmu-emul.c KVM/arm64 updates for 7.2 2026-06-12 10:51:42 +02:00
pmu.c KVM: arm64: Use a cpucap to determine if system supports FEAT_PMUv3 2025-03-11 12:54:23 -07:00
psci.c KVM: arm64: Add support for PSCI v1.2 and v1.3 2024-10-24 16:38:07 -07:00
ptdump.c KVM: arm64: ptdump: Initialize parser_state before pgtable walk 2026-03-28 10:02:55 +00:00
pvtime.c KVM: MMU: Make the definition of 'INVALID_GPA' common 2023-01-19 21:48:38 +00:00
reset.c KVM: arm64: Discard PC update state on vcpu reset 2026-03-15 15:11:22 +00:00
stacktrace.c KVM: arm64: Add PKVM_DISABLE_STAGE2_ON_PANIC 2026-03-11 08:51:16 +00:00
sys_regs.c KVM/arm64 updates for 7.2 2026-06-12 10:51:42 +02:00
sys_regs.h KVM: arm64: Handle FEAT_IDST for sysregs without specific handlers 2026-01-15 11:58:57 +00:00
trace_arm.h KVM: arm64: Replace ternary flags with str_on_off() helper 2025-05-06 09:38:37 +01:00
trace_handle_exit.h arm64: kvm: trace_handle_exit: use string choices helper 2025-07-23 23:36:55 -07:00
trace.h
trng.c
va_layout.c KVM: arm64: Calculate hyp VA size only once 2026-01-14 10:40:11 +00:00
vgic-sys-reg-v3.c KVM: arm64: Enforce the sorting of the GICv3 system register table 2025-07-26 08:36:58 -07:00
vmid.c KVM: arm64: Ensure a VMID is allocated before programming VTTBR_EL2 2025-02-20 16:29:28 +00:00