[Devel] [PATCH hci-8.2 6/7] ms/KVM: SVM: Triple fault L1 on unintercepted EFER.SVME clear by L2
no-reply at sashiko.virtuozzo.com
no-reply at sashiko.virtuozzo.com
Tue Dec 1 03:49:01 MSK 2026
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] kvm/svm: comment typo and commit message omits wants_to_run
gating
--
commit 241f9fb2c8d3d5ea8f0d77081ce249af0f7abd5b
Author: Yosry Ahmed <yosry.ahmed at linux.dev>
ms/KVM: SVM: Triple fault L1 on unintercepted EFER.SVME clear by L2
When L2 clears EFER.SVME and L1 does not intercept the write, svm_set_efer() now requests a triple fault for L1 before tearing down the nested state. Previously KVM left guest mode and kept running L1 without injecting a #VMEXIT.
Link: https://patch.msgid.link/20260209195142.2554532-2-yosry.ahmed@linux.dev
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 385b6db1698af..f4e581d35c88b 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -222,6 +222,19 @@ int svm_set_efer(struct kvm_vcpu *vcpu, u64 efer)
>
> if ((old_efer & EFER_SVME) != (efer & EFER_SVME)) {
> if (!(efer & EFER_SVME)) {
> + /*
> + * Architecturally, clearing EFER.SVME while a guest is
> + * running yields undefined behavior, i.e. KVM can do
> + * literally anything. Force the vCPU back into L1 as
> + * that is the safest option for KVM, but synthesize a
> + * triple fault (for L1!) so that KVM at least doesn't
> + * run random L2 code in the context of L1. Do so if
> + * and only if the vCPU is actively running, e.g. to
> + * avoid positives if userspace is stuffing state.
> + */
> + if (is_guest_mode(vcpu) && vcpu->wants_to_run)
> + kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu);
[Severity: Low]
This isn't a bug, but the comment says "to avoid positives" where it
presumably means "to avoid false positives".
Also, the commit message does not mention the vcpu->wants_to_run condition.
Because wants_to_run is only set inside KVM_RUN, host-initiated EFER writes
outside KVM_RUN (KVM_SET_SREGS, KVM_SET_NESTED_STATE) do not trigger the
triple fault. Could the changelog say so?
Carry the trailer below into the next revision and Sashiko will not review this patch again.
Reviewed-by: Sashiko <no-reply at sashiko.virtuozzo.com>
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157390-kvm-fixes-v1-0-ea4024e03c63@virtuozzo.com?part=6
More information about the Devel
mailing list