svm_switch_vmcb() is only used outside of nested.c to initialize svm->current_vmcb and svm->vmcb. Open-code the initialization (which is arguably not a "switch" to begin with) in the vCPU creation path, and move svm_switch_vmcb() to nested.c in preparation for adding more nested logic. No fcuntional change intended. Signed-off-by: Yosry Ahmed --- arch/x86/kvm/svm/nested.c | 6 ++++++ arch/x86/kvm/svm/svm.c | 10 +++------- arch/x86/kvm/svm/svm.h | 2 -- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index eb56c2fbf2832..24a52aefe94ee 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -705,6 +705,12 @@ static void nested_svm_transition_tlb_flush(struct kvm_vcpu *vcpu) kvm_make_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu); } +static void svm_switch_vmcb(struct vcpu_svm *svm, struct kvm_vmcb_info *target_vmcb) +{ + svm->current_vmcb = target_vmcb; + svm->vmcb = target_vmcb->ptr; +} + /* * Load guest's/host's cr3 on nested vmentry or vmexit. @nested_npt is true * if we are emulating VM-Entry into a guest with NPT enabled. diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 4f13c3456a5d7..14733ff8bcd19 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1300,12 +1300,6 @@ static void svm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) __svm_vcpu_reset(vcpu); } -void svm_switch_vmcb(struct vcpu_svm *svm, struct kvm_vmcb_info *target_vmcb) -{ - svm->current_vmcb = target_vmcb; - svm->vmcb = target_vmcb->ptr; -} - static int svm_vcpu_precreate(struct kvm *kvm) { return avic_alloc_physical_id_table(kvm); @@ -1353,7 +1347,9 @@ static int svm_vcpu_create(struct kvm_vcpu *vcpu) svm->vmcb01.ptr = page_address(vmcb01_page); svm->vmcb01.pa = __sme_set(page_to_pfn(vmcb01_page) << PAGE_SHIFT); - svm_switch_vmcb(svm, &svm->vmcb01); + + svm->current_vmcb = &svm->vmcb01; + svm->vmcb = svm->vmcb01.ptr; svm->guest_state_loaded = false; diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 6e98e02f7b8d5..4dcfd56882da5 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -922,8 +922,6 @@ void nested_copy_vmcb_control_to_cache(struct vcpu_svm *svm, void nested_copy_vmcb_save_to_cache(struct vcpu_svm *svm, struct vmcb_save_area *save); void nested_sync_control_from_vmcb02(struct vcpu_svm *svm); -void svm_switch_vmcb(struct vcpu_svm *svm, struct kvm_vmcb_info *target_vmcb); - static inline void __svm_pmu_handle_nested_transition(struct vcpu_svm *svm, bool defer) -- 2.54.0.1136.gdb2ca164c4-goog