mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-05-26 11:40:24 +02:00
KVM: SVM: Switch svm_copy_lbrs() to a macro
In preparation for using svm_copy_lbrs() with 'struct vmcb_save_area' without a containing 'struct vmcb', and later even 'struct vmcb_save_area_cached', make it a macro. Macros are generally not preferred compared to functions, mainly due to type-safety. However, in this case it seems like having a simple macro copying a few fields is better than copy-pasting the same 5 lines of code in different places. Cc: stable@vger.kernel.org Signed-off-by: Yosry Ahmed <yosry@kernel.org> Link: https://patch.msgid.link/20260303003421.2185681-3-yosry@kernel.org Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
committed by
Sean Christopherson
parent
b53ab5167a
commit
361dbe8173
@@ -710,10 +710,10 @@ static void nested_vmcb02_prepare_save(struct vcpu_svm *svm, struct vmcb *vmcb12
|
||||
* Reserved bits of DEBUGCTL are ignored. Be consistent with
|
||||
* svm_set_msr's definition of reserved bits.
|
||||
*/
|
||||
svm_copy_lbrs(vmcb02, vmcb12);
|
||||
svm_copy_lbrs(&vmcb02->save, &vmcb12->save);
|
||||
vmcb02->save.dbgctl &= ~DEBUGCTL_RESERVED_BITS;
|
||||
} else {
|
||||
svm_copy_lbrs(vmcb02, vmcb01);
|
||||
svm_copy_lbrs(&vmcb02->save, &vmcb01->save);
|
||||
}
|
||||
vmcb_mark_dirty(vmcb02, VMCB_LBR);
|
||||
svm_update_lbrv(&svm->vcpu);
|
||||
@@ -1233,9 +1233,9 @@ int nested_svm_vmexit(struct vcpu_svm *svm)
|
||||
|
||||
if (unlikely(guest_cpu_cap_has(vcpu, X86_FEATURE_LBRV) &&
|
||||
(svm->nested.ctl.virt_ext & LBR_CTL_ENABLE_MASK))) {
|
||||
svm_copy_lbrs(vmcb12, vmcb02);
|
||||
svm_copy_lbrs(&vmcb12->save, &vmcb02->save);
|
||||
} else {
|
||||
svm_copy_lbrs(vmcb01, vmcb02);
|
||||
svm_copy_lbrs(&vmcb01->save, &vmcb02->save);
|
||||
vmcb_mark_dirty(vmcb01, VMCB_LBR);
|
||||
}
|
||||
|
||||
|
||||
@@ -841,15 +841,6 @@ static void svm_recalc_msr_intercepts(struct kvm_vcpu *vcpu)
|
||||
*/
|
||||
}
|
||||
|
||||
void svm_copy_lbrs(struct vmcb *to_vmcb, struct vmcb *from_vmcb)
|
||||
{
|
||||
to_vmcb->save.dbgctl = from_vmcb->save.dbgctl;
|
||||
to_vmcb->save.br_from = from_vmcb->save.br_from;
|
||||
to_vmcb->save.br_to = from_vmcb->save.br_to;
|
||||
to_vmcb->save.last_excp_from = from_vmcb->save.last_excp_from;
|
||||
to_vmcb->save.last_excp_to = from_vmcb->save.last_excp_to;
|
||||
}
|
||||
|
||||
static void __svm_enable_lbrv(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
to_svm(vcpu)->vmcb->control.virt_ext |= LBR_CTL_ENABLE_MASK;
|
||||
|
||||
@@ -713,8 +713,16 @@ static inline void *svm_vcpu_alloc_msrpm(void)
|
||||
return svm_alloc_permissions_map(MSRPM_SIZE, GFP_KERNEL_ACCOUNT);
|
||||
}
|
||||
|
||||
#define svm_copy_lbrs(to, from) \
|
||||
do { \
|
||||
(to)->dbgctl = (from)->dbgctl; \
|
||||
(to)->br_from = (from)->br_from; \
|
||||
(to)->br_to = (from)->br_to; \
|
||||
(to)->last_excp_from = (from)->last_excp_from; \
|
||||
(to)->last_excp_to = (from)->last_excp_to; \
|
||||
} while (0)
|
||||
|
||||
void svm_vcpu_free_msrpm(void *msrpm);
|
||||
void svm_copy_lbrs(struct vmcb *to_vmcb, struct vmcb *from_vmcb);
|
||||
void svm_enable_lbrv(struct kvm_vcpu *vcpu);
|
||||
void svm_update_lbrv(struct kvm_vcpu *vcpu);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user