From: Shivansh Dhiman <shivansh.dhiman@amd.com>
To: Yosry Ahmed <yosry@kernel.org>
Cc: <seanjc@google.com>, <pbonzini@redhat.com>, <tglx@linutronix.de>,
<mingo@redhat.com>, <kvm@vger.kernel.org>, <x86@kernel.org>,
<yosry.ahmed@linux.dev>, <jmattson@google.com>,
<thomas.lendacky@amd.com>, <nikunj.dadhania@amd.com>,
<ravi.bangoria@amd.com>, <santosh.shukla@amd.com>,
Shivansh Dhiman <shivansh.dhiman@amd.com>
Subject: Re: [PATCH v3 2/5] KVM: nSVM: Disable LBRV in nested control cache when unsupported
Date: Mon, 13 Jul 2026 11:58:41 +0530 [thread overview]
Message-ID: <175172b6-94d1-4552-a477-e07c202de3bb@amd.com> (raw)
In-Reply-To: <CAO9r8zMxtKYFwmMcTgedrFu2gT+SECmFJaiPFmE5iuRAkxs_jw@mail.gmail.com>
On 10-07-26 01:18, Yosry Ahmed wrote:
> On Thu, Jul 9, 2026 at 1:32 AM Shivansh Dhiman <shivansh.dhiman@amd.com> wrote:
>>
>> Clear SVM_MISC2_ENABLE_V_LBR in __nested_copy_vmcb_control_to_cache() when
>> the vCPU does not support LBR Virtualization. This lets the cached value be
>> consumed directly instead of re-checking X86_FEATURE_LBRV on every access.
>>
>> Suggested-by: Yosry Ahmed <yosry@kernel.org>
>> Signed-off-by: Shivansh Dhiman <shivansh.dhiman@amd.com>
>> ---
>> Changelog:
>> v3:
>> * New patch.
>> * Sanitize V_LBR in the cache and drop the redundant X86_FEATURE_LBRV
>> checks (Yosry Ahmed).
>>
>> ---
>> arch/x86/kvm/svm/nested.c | 9 ++++++---
>> 1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
>> index d3df6b22bfef..84248e6665cf 100644
>> --- a/arch/x86/kvm/svm/nested.c
>> +++ b/arch/x86/kvm/svm/nested.c
>> @@ -534,6 +534,11 @@ void __nested_copy_vmcb_control_to_cache(struct kvm_vcpu *vcpu,
>> if (!gmet_enabled || !guest_cpu_cap_has(vcpu, X86_FEATURE_GMET))
>> to->misc_ctl &= ~SVM_MISC_ENABLE_GMET;
>>
>> + /* Always clear misc_ctl2 bits that the guest cannot use */
>
> I think the comment here is unnecessary, the comment above for
> misc_ctl should already make this clear.
[...]
>
>> + to->misc_ctl2 = from->misc_ctl2;
>> + if (!lbrv || !guest_cpu_cap_has(vcpu, X86_FEATURE_LBRV))
>
> Do we need to check lbrv here? KVM should not set X86_FEATURE_LBRV if
> lbrv=0 anyway, right?
Makes sense on both comments. I'll remove the comment and the !lbrv check
in next version.
>
>> + to->misc_ctl2 &= ~SVM_MISC2_ENABLE_V_LBR;
>> +
>> to->iopm_base_pa = from->iopm_base_pa & PAGE_MASK;
>> to->msrpm_base_pa = from->msrpm_base_pa & PAGE_MASK;
>> to->tsc_offset = from->tsc_offset;
next prev parent reply other threads:[~2026-07-13 6:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 8:29 [PATCH v3 0/5] KVM: SVM: Add Bus Lock Detect support and refactor LBRV Shivansh Dhiman
2026-07-09 8:29 ` [PATCH v3 1/5] KVM: SVM: Refactor svm_update_lbrv() Shivansh Dhiman
2026-07-09 19:53 ` Yosry Ahmed
2026-07-13 6:25 ` Shivansh Dhiman
2026-07-09 8:29 ` [PATCH v3 2/5] KVM: nSVM: Disable LBRV in nested control cache when unsupported Shivansh Dhiman
2026-07-09 8:50 ` sashiko-bot
2026-07-09 19:42 ` Yosry Ahmed
2026-07-09 19:48 ` Yosry Ahmed
2026-07-13 6:28 ` Shivansh Dhiman [this message]
2026-07-09 8:29 ` [PATCH v3 3/5] KVM: nSVM: Sanitize nested DR6 using kvm_dr6_fixed() Shivansh Dhiman
2026-07-09 8:51 ` sashiko-bot
2026-07-13 6:47 ` Shivansh Dhiman
2026-07-09 8:29 ` [PATCH v3 4/5] KVM: SVM: Compute DEBUGCTL reserved bits dynamically Shivansh Dhiman
2026-07-09 8:44 ` sashiko-bot
2026-07-13 7:05 ` Shivansh Dhiman
2026-07-09 8:29 ` [PATCH v3 5/5] KVM: SVM: Add Bus Lock Detect support Shivansh Dhiman
2026-07-09 8:55 ` sashiko-bot
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=175172b6-94d1-4552-a477-e07c202de3bb@amd.com \
--to=shivansh.dhiman@amd.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nikunj.dadhania@amd.com \
--cc=pbonzini@redhat.com \
--cc=ravi.bangoria@amd.com \
--cc=santosh.shukla@amd.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
--cc=yosry.ahmed@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