From: sashiko-bot@kernel.org
To: "Oliver Upton" <oupton@kernel.org>, kvmarm@lists.linux.dev
Cc: "Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH 1/8] KVM: arm64: nv: Disallow KVM_CAP_ARM_MTE + FEAT_EL2
Date: Wed, 04 Nov 2026 19:37:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-197967@kernel.org> (raw)
In-Reply-To: <20261104192124.3932743-2-oupton@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] KVM: arm64: rejecting MTE with EL2 breaks set_id_regs selftest on NV+MTE hosts
--
commit 6863183ae448414619eb0267884e7d66bfaf521c
Author: Oliver Upton <oupton@kernel.org>
KVM: arm64: nv: Disallow KVM_CAP_ARM_MTE + FEAT_EL2
This commit updates kvm_vcpu_init_check_features() to return -EINVAL when
KVM_ARM_VCPU_HAS_EL2 is requested on a VM that has KVM_CAP_ARM_MTE enabled.
> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
> index 157bf4b812020..a750413c684be 100644
> --- a/arch/arm64/kvm/arm.c
> +++ b/arch/arm64/kvm/arm.c
> @@ -1793,13 +1793,15 @@ static int kvm_vcpu_init_check_features(struct kvm_vcpu *vcpu,
> !test_bit(KVM_ARM_VCPU_PMU_V3, &features))
> return -EINVAL;
>
> + /* MTE is incompatible with AArch32 and nested virt */
> + if (kvm_has_mte(vcpu->kvm) &&
> + (test_bit(KVM_ARM_VCPU_EL1_32BIT, &features) ||
> + test_bit(KVM_ARM_VCPU_HAS_EL2, &features)))
> + return -EINVAL;
[Severity: Medium]
Does rejecting KVM_ARM_VCPU_HAS_EL2 when kvm_has_mte(vcpu->kvm) is true break
the arm64 set_id_regs selftest on hosts that support both MTE and nested
virtualization?
In tools/testing/selftests/kvm/arm64/set_id_regs.c, main() enables MTE and
then creates a default vCPU:
tools/testing/selftests/kvm/arm64/set_id_regs.c:main() {
...
test_wants_mte();
vm = vm_create(1);
vm_enable_cap(vm, KVM_CAP_ARM_WRITABLE_IMP_ID_REGS, 0);
vcpu = vm_vcpu_add(vm, 0, guest_code);
...
}
During vm_create(), kvm_arch_vm_post_create() in
tools/testing/selftests/kvm/lib/arm64/processor.c enables KVM_CAP_ARM_MTE on
the VM when request_mte is set:
if (request_mte && vm_check_cap(vm, KVM_CAP_ARM_MTE))
vm_enable_cap(vm, KVM_CAP_ARM_MTE, 0);
Then during vm_vcpu_add() -> aarch64_vcpu_setup() ->
kvm_get_default_vcpu_target(), the selftest library checks vm_supports_el2()
and sets KVM_ARM_VCPU_HAS_EL2 by default on NV-capable hosts:
tools/testing/selftests/kvm/lib/arm64/processor.c:vm_supports_el2() {
return vm_check_cap(vm, KVM_CAP_ARM_EL2) && vm->arch.has_gic;
}
tools/testing/selftests/kvm/lib/arm64/processor.c:kvm_get_default_vcpu_target() {
...
vm_ioctl(vm, KVM_ARM_PREFERRED_TARGET, &preferred);
if (vm_supports_el2(vm))
preferred.features[0] |= BIT(KVM_ARM_VCPU_HAS_EL2);
...
}
Because kvm_vm_ioctl_check_extension() in arch/arm64/kvm/arm.c still reports
KVM_CAP_ARM_EL2 as supported on a VM fd where KVM_CAP_ARM_MTE was enabled:
case KVM_CAP_ARM_EL2:
r = cpus_have_final_cap(ARM64_HAS_NESTED_VIRT);
break;
and vm_supports_el2() does not check !request_mte, aarch64_vcpu_setup() passes
KVM_ARM_VCPU_HAS_EL2 to KVM_ARM_VCPU_INIT, which now fails with -EINVAL unless
the test is run with NV=0.
Should kvm_vm_ioctl_check_extension() gate KVM_CAP_ARM_EL2 on
!kvm_has_mte(kvm) (or vm_supports_el2() check !request_mte) so userspace and
selftests do not request EL2 on MTE-enabled VMs?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261104192124.3932743-1-oupton@kernel.org?part=1
next prev parent reply other threads:[~2026-11-04 19:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 19:21 [PATCH 0/8] KVM: arm64: Prefix of fixes from HAFDBS series (for 7.4) Oliver Upton
2026-11-04 19:21 ` [PATCH 1/8] KVM: arm64: nv: Disallow KVM_CAP_ARM_MTE + FEAT_EL2 Oliver Upton
2026-11-04 19:37 ` sashiko-bot [this message]
2026-11-04 20:17 ` Oliver Upton
2026-11-04 19:21 ` [PATCH 2/8] KVM: arm64: nv: Add CGT description for FEAT_PoPS instructions Oliver Upton
2026-11-05 18:12 ` Leonardo Bras
2026-11-04 19:21 ` [PATCH 3/8] KVM: arm64: Separate user / guest visibility flags Oliver Upton
2026-11-04 19:21 ` [PATCH 4/8] KVM: arm64: nv: Treat the VNCR GICv3 registers as hidden from user Oliver Upton
2026-11-04 19:21 ` [PATCH 5/8] KVM: arm64: Use ->visibility() to filter MTE CMO instructions Oliver Upton
2026-11-04 19:21 ` [PATCH 6/8] KVM: arm64: Add sys_reg_descs for remaining " Oliver Upton
2026-11-04 19:21 ` [PATCH 7/8] KVM: arm64: nv: Enforce sysreg visibility before evaulating guest traps Oliver Upton
2026-11-04 19:21 ` [PATCH 8/8] KVM: arm64: Stop leaning on __kvm_inject_sea() for abort injection Oliver Upton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-197967@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.