Re: [PATCH] KVM: SVM: Add a helper to get LBR field pointer to dedup MSR accesses
From: Yosry Ahmed
Date: Fri Mar 13 2026 - 18:26:07 EST
On Fri, Mar 13, 2026 at 3:17 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> On Fri, Mar 13, 2026, Yosry Ahmed wrote:
> > > Hrm, I was assuming the compiler would be smart to understand the other cases
> > > are unreachable. What clang version, and are you doing anything special with
> > > your config?
> >
> > Debian clang version 18.1.8 (20+build1)
> >
> > Nothing special with my config AFAICT.
>
> Lame. Given that it's Friday and I'm about to become a pumpkin, and it doesn't
> really matter if it's compile-timer assert or not, I'm going to sqaush it to this:
>
> static u64 *svm_vmcb_lbr(struct vcpu_svm *svm, u32 msr)
> {
> switch (msr) {
> case MSR_IA32_LASTBRANCHFROMIP:
> return &svm->vmcb->save.br_from;
> case MSR_IA32_LASTBRANCHTOIP:
> return &svm->vmcb->save.br_to;
> case MSR_IA32_LASTINTFROMIP:
> return &svm->vmcb->save.last_excp_from;
> case MSR_IA32_LASTINTTOIP:
> return &svm->vmcb->save.last_excp_to;
> default:
> break;
> }
> KVM_BUG_ON(1, svm->vcpu.kvm);
> return &svm->vmcb->save.br_from;
> }
>
> Can you double check that kvm-x86/nested builds for you? In the process of
> rebuilding kvm-x86/next...
It builds. Thanks for taking care of this.