In preparation for unifying the VMRUN failure code paths, move calling nested_svm_merge_msrpm() into enter_svm_guest_mode() next to the nested_svm_load_cr3() call (the other failure path in enter_svm_guest_mode()).
Adding more uses of the from_vmrun parameter is not pretty, but it is plumbed all the way to nested_svm_load_cr3() so it's not going away soon anyway.
No functional change intended.
Cc: stable@vger.kernel.org Signed-off-by: Yosry Ahmed yosry.ahmed@linux.dev --- arch/x86/kvm/svm/nested.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index f46e97008492..2ee9d8bef5ba 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -911,6 +911,12 @@ int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb12_gpa, if (ret) return ret;
+ if (from_vmrun) { + ret = nested_svm_merge_msrpm(vcpu); + if (ret) + return ret; + } + if (!from_vmrun) kvm_make_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu);
@@ -990,23 +996,18 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu)
svm->nested.nested_run_pending = 1;
- if (enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12, true)) - goto out_exit_err; - - if (!nested_svm_merge_msrpm(vcpu)) - goto out; - -out_exit_err: - svm->nested.nested_run_pending = 0; - svm->nmi_l1_to_l2 = false; - svm->soft_int_injected = false; + if (enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12, true)) { + svm->nested.nested_run_pending = 0; + svm->nmi_l1_to_l2 = false; + svm->soft_int_injected = false;
- svm->vmcb->control.exit_code = SVM_EXIT_ERR; - svm->vmcb->control.exit_code_hi = -1u; - svm->vmcb->control.exit_info_1 = 0; - svm->vmcb->control.exit_info_2 = 0; + svm->vmcb->control.exit_code = SVM_EXIT_ERR; + svm->vmcb->control.exit_code_hi = -1u; + svm->vmcb->control.exit_info_1 = 0; + svm->vmcb->control.exit_info_2 = 0;
- nested_svm_vmexit(svm); + nested_svm_vmexit(svm); + }
out: kvm_vcpu_unmap(vcpu, &map);