Skip to content

Commit f9697df

Browse files
Maxim Levitskybonzini
authored andcommitted
KVM: x86: add kvm_leave_nested
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>
1 parent 16ae56d commit f9697df

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

arch/x86/kvm/svm/nested.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,9 +1146,6 @@ void svm_free_nested(struct vcpu_svm *svm)
11461146
svm->nested.initialized = false;
11471147
}
11481148

1149-
/*
1150-
* Forcibly leave nested mode in order to be able to reset the VCPU later on.
1151-
*/
11521149
void svm_leave_nested(struct kvm_vcpu *vcpu)
11531150
{
11541151
struct vcpu_svm *svm = to_svm(vcpu);

arch/x86/kvm/vmx/nested.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6440,9 +6440,6 @@ static int vmx_get_nested_state(struct kvm_vcpu *vcpu,
64406440
return kvm_state.size;
64416441
}
64426442

6443-
/*
6444-
* Forcibly leave nested mode in order to be able to reset the VCPU later on.
6445-
*/
64466443
void vmx_leave_nested(struct kvm_vcpu *vcpu)
64476444
{
64486445
if (is_guest_mode(vcpu)) {

arch/x86/kvm/x86.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,12 @@ static void kvm_queue_exception_vmexit(struct kvm_vcpu *vcpu, unsigned int vecto
628628
ex->payload = payload;
629629
}
630630

631+
/* Forcibly leave the nested mode in cases like a vCPU reset */
632+
static void kvm_leave_nested(struct kvm_vcpu *vcpu)
633+
{
634+
kvm_x86_ops.nested_ops->leave_nested(vcpu);
635+
}
636+
631637
static void kvm_multiple_exception(struct kvm_vcpu *vcpu,
632638
unsigned nr, bool has_error, u32 error_code,
633639
bool has_payload, unsigned long payload, bool reinject)
@@ -5195,7 +5201,7 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
51955201

51965202
if (events->flags & KVM_VCPUEVENT_VALID_SMM) {
51975203
if (!!(vcpu->arch.hflags & HF_SMM_MASK) != events->smi.smm) {
5198-
kvm_x86_ops.nested_ops->leave_nested(vcpu);
5204+
kvm_leave_nested(vcpu);
51995205
kvm_smm_changed(vcpu, events->smi.smm);
52005206
}
52015207

0 commit comments

Comments
 (0)