From: Shivansh Dhiman <shivansh.dhiman@amd.com>
To: Sean Christopherson <seanjc@google.com>
Cc: <pbonzini@redhat.com>, <tglx@linutronix.de>, <mingo@redhat.com>,
<kvm@vger.kernel.org>, <x86@kernel.org>, <yosry@kernel.org>,
<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 v4 1/5] KVM: SVM: Refactor svm_update_lbrv()
Date: Thu, 1 Oct 2026 03:46:06 +0530 [thread overview]
Message-ID: <cc237101-8b1d-413c-80a0-87dee6edc6a4@amd.com> (raw)
In-Reply-To: <arav9aN48nEZTv7V@google.com>
Hi Sean,
Thanks for reviewing my series. Replying to v4.
On 25-09-26 23:01, Sean Christopherson wrote:
> The shortlog is effectively "do work". Be more precise.
Ack.
>
> On Tue, Jul 21, 2026, Shivansh Dhiman wrote:
>> Rewrite the enable_lbrv computation in svm_update_lbrv() as a series of
>> 'if' statements. Rename nested_vmcb12_has_lbrv() to nested_lbrv_enabled(),
>> expose it, and use it instead of open-coding the nested LBRV check.
>
> This is super duper obviously two separate and *barely* related patches.
Makes sense.
>
>> No functional change intended.
>>
>> Suggested-by: Yosry Ahmed <yosry@kernel.org>
>> Signed-off-by: Shivansh Dhiman <shivansh.dhiman@amd.com>
>> Reviewed-by: Yosry Ahmed <yosry@kernel.org>
>> ---
>> Changelog:
>> v3 -> v4:
>> * Rename nested_vmcb12_has_lbrv() to nested_lbrv_enabled() (Yosry).
>
> I don't like this change. Unlike nested_vgif_enabled(), this is *only* checking
> the effective vmcb12. Once the guest_cpu_cap_has() code is moved elsewhere, I
> don't see any point in keeping the helper.
Ack.
>
>> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
>> index ef69a51ab27f..e9f2456982d4 100644
>> --- a/arch/x86/kvm/svm/svm.c
>> +++ b/arch/x86/kvm/svm/svm.c
>> @@ -880,9 +880,13 @@ void svm_update_lbrv(struct kvm_vcpu *vcpu)
>> {
>> struct vcpu_svm *svm = to_svm(vcpu);
>> bool current_enable_lbrv = svm->vmcb->control.misc_ctl2 & SVM_MISC2_ENABLE_V_LBR;
>> - bool enable_lbrv = (svm->vmcb->save.dbgctl & DEBUGCTLMSR_LBR) ||
>> - (is_guest_mode(vcpu) && guest_cpu_cap_has(vcpu, X86_FEATURE_LBRV) &&
>> - (svm->nested.ctl.misc_ctl2 & SVM_MISC2_ENABLE_V_LBR));
>> + bool enable_lbrv = false;
>> +
>> + if (svm->vmcb->save.dbgctl & DEBUGCTLMSR_LBR)
>> + enable_lbrv = true;
>> +
>> + if (is_guest_mode(vcpu) && nested_lbrv_enabled(vcpu))
>> + enable_lbrv = true;
>
> This is begging for short-circuit logic (which was kinda the point of the existing
> code). An if-elif is silly, and I agree that squeezing everything into variable
> initialization is hard to read, so I think we should do:
>
> static bool svm_need_lbr_virtualization(struct kvm_vcpu *vcpu)
> {
> struct vcpu_svm *svm = to_svm(vcpu);
>
> if (svm->vmcb->save.dbgctl & (DEBUGCTLMSR_LBR | DEBUGCTLMSR_BUS_LOCK_DETECT))
> return true;
>
> return is_guest_mode(vcpu) &&
> (svm->nested.ctl.misc_ctl2 & SVM_MISC2_ENABLE_V_LBR);
> }
>
>
> bool enable_lbrv = svm_need_lbr_virtualization(vcpu);
That looks cleaner. There's another series I've posted on SVM vLBRv2 which will
benefit from this refactor. Thanks.
-Shivansh
next prev parent reply other threads:[~2026-09-30 22:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 5:05 [PATCH v4 0/5] KVM: SVM: Add Bus Lock Detect support and refactor LBRV Shivansh Dhiman
2026-07-21 5:05 ` [PATCH v4 1/5] KVM: SVM: Refactor svm_update_lbrv() Shivansh Dhiman
2026-07-21 6:40 ` Nikunj A. Dadhania
2026-07-21 9:16 ` Shivansh Dhiman
2026-09-25 17:31 ` Sean Christopherson
2026-09-30 22:16 ` Shivansh Dhiman [this message]
2026-07-21 5:05 ` [PATCH v4 2/5] KVM: nSVM: Disable LBRV in nested control cache when unsupported Shivansh Dhiman
2026-07-21 5:05 ` [PATCH v4 3/5] KVM: nSVM: Sanitize nested DR6 using kvm_dr6_fixed() Shivansh Dhiman
2026-07-21 5:21 ` sashiko-bot
2026-09-25 17:26 ` Sean Christopherson
2026-09-25 17:39 ` Sean Christopherson
2026-09-30 22:16 ` Shivansh Dhiman
2026-07-21 5:05 ` [PATCH v4 4/5] KVM: SVM: Turn DEBUGCTL_RESERVED_BITS into a helper Shivansh Dhiman
2026-09-25 17:43 ` Sean Christopherson
2026-09-30 22:29 ` Shivansh Dhiman
2026-07-21 5:06 ` [PATCH v4 5/5] KVM: SVM: Add Bus Lock Detect support Shivansh Dhiman
2026-09-25 17:45 ` [PATCH v4 0/5] KVM: SVM: Add Bus Lock Detect support and refactor LBRV Sean Christopherson
2026-09-25 23:01 ` Sean Christopherson
2026-09-28 18:38 ` Shivansh Dhiman
2026-10-01 20:18 ` Shivansh Dhiman
2026-10-01 23:11 ` Sean Christopherson
2026-09-30 23:05 ` Shivansh Dhiman
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=cc237101-8b1d-413c-80a0-87dee6edc6a4@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@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 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.