Re: [PATCH v7 03/26] KVM: SVM: Add missing save/restore handling of LBR MSRs
From: Yosry Ahmed
Date: Tue Mar 03 2026 - 19:49:05 EST
> > There's so much repeated code here.
>
> Ya :-(
>
> > We can use gotos to share code, but I am not sure if that's a strict
> > improvement. We can also use a helper, perhaps?
>
>
> Where's your sense of adventure?
>
> case MSR_IA32_LASTBRANCHFROMIP:
> case MSR_IA32_LASTBRANCHTOIP:
> case MSR_IA32_LASTINTFROMIP:
> case MSR_IA32_LASTINTTOIP:
> if (!lbrv)
> return KVM_MSR_RET_UNSUPPORTED;
> if (!msr->host_initiated)
> return 1;
> *(&svm->vmcb->save.br_from + (ecx - MSR_IA32_LASTBRANCHFROMIP)) = data;
> vmcb_mark_dirty(svm->vmcb, VMCB_LBR);
> break;
>
> Jokes aside, maybe this, to dedup get() at the same time?
Looks good to me!