From: sashiko-bot@kernel.org
To: "Manuel Andreas" <manuel.andreas@tum.de>, kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: nSVM: Reject EVENTINJ of #BR/#OF into a 64-bit L2
Date: Wed, 18 Nov 2026 13:55:13 +0000 [thread overview]
Message-ID: <sashiko-outbox-221100@kernel.org> (raw)
In-Reply-To: <20261118133741.1185904-1-manuel.andreas@tum.de>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] KVM: nSVM: missing EFER.LMA normalization in
nested_vmcb02_prepare_save() [1]
--
commit bd07241cd6a52030415a707aa3b0f77f55f74c7c
Author: Manuel Andreas <manuel.andreas@tum.de>
KVM: nSVM: Reject EVENTINJ of #BR/#OF into a 64-bit L2
This commit rejects VMCB12 EVENTINJ of #BR or #OF into a 64-bit L2 guest in
nested_svm_check_cached_vmcb12(), deriving 64-bit mode from EFER.LME,
CR0.PG, CR4.PAE, and CS.L.
> diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
> index 1cecb82702e2c..c69d334e3c3c5 100644
> --- a/arch/x86/kvm/svm/nested.c
> +++ b/arch/x86/kvm/svm/nested.c
[ ... ]
> @@ -398,6 +400,31 @@ static bool nested_svm_check_event_inj(struct kvm_vcpu *vcpu, u32 event_inj)
> return true;
> }
>
> +/*
> + * #BR and #OF are invalid in 64-bit mode, but not in compatibility mode,
> + * hence the CS.L check. VMRUN ignores EFER.LMA and derives
> + * long mode from EFER.LME, CR0.PG and CR4.PAE, so do the same.
> + */
> +static bool nested_svm_check_event_inj_mode(u32 event_inj,
> + struct vmcb_save_area_cached *save)
> +{
> + u32 type = event_inj & SVM_EVTINJ_TYPE_MASK;
> + u8 vector = event_inj & SVM_EVTINJ_VEC_MASK;
> +
> + if (!(event_inj & SVM_EVTINJ_VALID))
> + return true;
> +
> + if (!((save->efer & EFER_LME) && (save->cr0 & X86_CR0_PG) &&
> + (save->cr4 & X86_CR4_PAE) && (save->cs.attrib & SVM_SELECTOR_L_MASK)))
> + return true;
[Severity: High]
This problem wasn't introduced by this patch, but since VMRUN ignores
EFER.LMA, can nested_vmcb02_prepare_save() leave EFER_LMA clear in
vcpu->arch.efer [1] when entering a 64-bit L2 whose VMCB12 save area
has EFER_LME=1, X86_CR0_PG=1, and EFER_LMA=0?
arch/x86/kvm/svm/nested.c:nested_vmcb02_prepare_save() {
...
/* SVM ignores EFER.LMA if EFER.LME=0 (instead of failing VMRUN). */
if (!(svm->nested.save.efer & EFER_LME))
svm->nested.save.efer &= ~EFER_LMA;
svm_set_efer(vcpu, svm->nested.save.efer);
svm_set_cr0(vcpu, svm->nested.save.cr0);
...
}
arch/x86/kvm/svm/svm.c:svm_set_cr0() {
...
if (vcpu->arch.efer & EFER_LME) {
if (!is_paging(vcpu) && (cr0 & X86_CR0_PG)) {
vcpu->arch.efer |= EFER_LMA;
...
}
nested_vmcb02_prepare_save() only clears EFER_LMA when EFER_LME is clear,
and svm_set_cr0() only sets EFER_LMA when transitioning from !is_paging().
Because L1 already has paging enabled on VMRUN, is_paging(vcpu) is true
when svm_set_cr0() runs, leaving vcpu->arch.efer with EFER_LMA=0.
As a result, KVM miscomputes L2's long mode and MMU role state, and a
subsequent MSR_EFER write via set_efer() triggers WARN_ON_ONCE((efer &
EFER_LMA) != (vcpu->arch.efer & EFER_LMA)) and injects a spurious #GP into
L2.
[1] https://sashiko.dev/#/bug/linux-d0314b95-e275-4bc2-be19-05c208604a98
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118133741.1185904-1-manuel.andreas@tum.de?part=1
prev parent reply other threads:[~2026-11-18 13:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 13:37 [PATCH] KVM: nSVM: Reject EVENTINJ of #BR/#OF into a 64-bit L2 Manuel Andreas
2026-11-18 13:55 ` sashiko-bot [this message]
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-221100@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=manuel.andreas@tum.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox