Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yosry Ahmed" <yosry@kernel.org>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 1/3] KVM: nSVM: Update virtual LBR state/intercepts on KVM_SET_NESTED_STATE
Date: Sat, 05 Dec 2026 01:35:05 +0000	[thread overview]
Message-ID: <sashiko-outbox-250898@kernel.org> (raw)
In-Reply-To: <20261205011107.2050815-2-yosry@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] KVM: nSVM: svm_set_nested_state() calls svm_update_lbrv() on
  SEV-ES vCPUs
--

commit 24710e2ee8b01dff28f27148759c38c44f7b5221
Author: Yosry Ahmed <yosry@kernel.org>

KVM: nSVM: Update virtual LBR state/intercepts on KVM_SET_NESTED_STATE

This commit calls svm_update_lbrv() in svm_set_nested_state() after
preparing vmcb02's control area so virtual LBR state and intercepts are
recomputed when MSR_IA32_DEBUGCTLMSR is restored before nested state.

> diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
> index 81d768ec82419..c5a572b58be07 100644
> --- a/arch/x86/kvm/svm/nested.c
> +++ b/arch/x86/kvm/svm/nested.c
> @@ -2091,6 +2091,12 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu,
>  
>  	nested_vmcb02_prepare_control(svm);
>  
> +	/*
> +	 * Update virtual LBR state after setting up vmcb02's control area in
> +	 * case DEBUGCTLMSR was already restored.
> +	 */
> +	svm_update_lbrv(vcpu);

[Severity: High]
Can this svm_update_lbrv() call hit KVM_BUG_ON(is_sev_es_guest(vcpu),
vcpu->kvm) and corrupt LBR MSR intercepts on SEV-ES/SEV-SNP vCPUs?

svm_set_nested_state() does not reject SEV-ES vCPUs, and
svm_need_lbr_virtualization() does not check is_sev_es_guest(vcpu).
Two KVM_SET_NESTED_STATE(KVM_STATE_NESTED_GUEST_MODE) calls (first with
SVM_MISC2_ENABLE_V_LBR set, then cleared) reach __svm_disable_lbrv().

While commit "KVM: nSVM: Explicitly initialize misc_ctl2 in vmcb02" avoids
that direct trigger, calling KVM_SET_NESTED_STATE after LAUNCH_UPDATE_VMSA
with ctl->misc_ctl2 = 0 still runs svm_recalc_lbr_msr_intercepts() and
re-enables intercepts for MSR_IA32_DEBUGCTLMSR and the LBR MSRs.

Leaving guest mode via KVM_SET_NESTED_STATE(0) then leaves
MSR_IA32_DEBUGCTLMSR intercepted on vmcb01, bypassing
sev_es_prevent_msr_access() so unprivileged userspace can call
KVM_SET_MSRS(MSR_IA32_DEBUGCTLMSR, 0) to trigger KVM_BUG_ON().

Should svm_set_nested_state() reject SEV-ES guests, or should
svm_need_lbr_virtualization() return true for is_sev_es_guest(vcpu)?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205011107.2050815-1-yosry@kernel.org?part=1

  reply	other threads:[~2026-12-05  1:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  1:11 [PATCH 0/3] KVM: nSVM: Nested virtual LBR fix and cleanups Yosry Ahmed
2026-12-05  1:11 ` [PATCH 1/3] KVM: nSVM: Update virtual LBR state/intercepts on KVM_SET_NESTED_STATE Yosry Ahmed
2026-12-05  1:35   ` sashiko-bot [this message]
2026-12-05  1:11 ` [PATCH 2/3] KVM: nSVM: Call svm_update_lbrv() outside nested_vmcb02_prepare_save() Yosry Ahmed
2026-12-05  1:11 ` [PATCH 3/3] KVM: nSVM: Explicitly initialize misc_ctl2 in vmcb02 Yosry Ahmed

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-250898@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yosry@kernel.org \
    /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