]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
KVM: x86: add kvm_leave_nested
authorMaxim Levitsky <mlevitsk@redhat.com>
Thu, 3 Nov 2022 14:13:45 +0000 (16:13 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 14 Dec 2022 13:00:29 +0000 (14:00 +0100)
commit f9697df251438b0798780900e8b43bdb12a56d64 upstream.

add kvm_leave_nested which wraps a call to nested_ops->leave_nested
into a function.

Cc: stable@vger.kernel.org
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20221103141351.50662-4-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 27550a5930bbed6e8847a0a1fac8079b61afb920)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
arch/x86/kvm/svm/nested.c
arch/x86/kvm/vmx/nested.c
arch/x86/kvm/x86.c

index 6747c7c5b64bedd6345df3e1e6de6e47889e1708..e0b4f88b04b3e114dde787703c429929fda61ae4 100644 (file)
@@ -940,9 +940,6 @@ void svm_free_nested(struct vcpu_svm *svm)
        svm->nested.initialized = false;
 }
 
-/*
- * Forcibly leave nested mode in order to be able to reset the VCPU later on.
- */
 void svm_leave_nested(struct kvm_vcpu *vcpu)
 {
        struct vcpu_svm *svm = to_svm(vcpu);
index 91b182fafb43d2420ea10a0dc43a304fd8256ccf..817632d5a1189106fe947bab25616008402f2abb 100644 (file)
@@ -6276,9 +6276,6 @@ out:
        return kvm_state.size;
 }
 
-/*
- * Forcibly leave nested mode in order to be able to reset the VCPU later on.
- */
 void vmx_leave_nested(struct kvm_vcpu *vcpu)
 {
        if (is_guest_mode(vcpu)) {
index 0f934b7d3eba02ffeadf31af73bab926f5b0ac2f..a6c96f6f9257fa75e41e8b3e8e7dc25e1a3de943 100644 (file)
@@ -608,6 +608,12 @@ void kvm_deliver_exception_payload(struct kvm_vcpu *vcpu)
 }
 EXPORT_SYMBOL_GPL(kvm_deliver_exception_payload);
 
+/* Forcibly leave the nested mode in cases like a vCPU reset */
+static void kvm_leave_nested(struct kvm_vcpu *vcpu)
+{
+       kvm_x86_ops.nested_ops->leave_nested(vcpu);
+}
+
 static void kvm_multiple_exception(struct kvm_vcpu *vcpu,
                unsigned nr, bool has_error, u32 error_code,
                bool has_payload, unsigned long payload, bool reinject)
@@ -4775,7 +4781,7 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
 
        if (events->flags & KVM_VCPUEVENT_VALID_SMM) {
                if (!!(vcpu->arch.hflags & HF_SMM_MASK) != events->smi.smm) {
-                       kvm_x86_ops.nested_ops->leave_nested(vcpu);
+                       kvm_leave_nested(vcpu);
                        kvm_smm_changed(vcpu, events->smi.smm);
                }