@@ -2853,9 +2853,18 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
struct kvm_mp_state *mp_state)
{
+ int ret;
+
+ ret = vcpu_load(vcpu);
+ if (ret)
+ return ret;
+
/* CHECK_STOP and LOAD are not supported yet */
- return is_vcpu_stopped(vcpu) ? KVM_MP_STATE_STOPPED :
- KVM_MP_STATE_OPERATING;
+ ret = is_vcpu_stopped(vcpu) ? KVM_MP_STATE_STOPPED :
+ KVM_MP_STATE_OPERATING;
+
+ vcpu_put(vcpu);
+ return ret;
}
int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
@@ -7426,6 +7426,12 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
struct kvm_mp_state *mp_state)
{
+ int ret;
+
+ ret = vcpu_load(vcpu);
+ if (ret)
+ return ret;
+
kvm_apic_accept_events(vcpu);
if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED &&
vcpu->arch.pv.pv_unhalted)
@@ -7433,6 +7439,7 @@ int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
else
mp_state->mp_state = vcpu->arch.mp_state;
+ vcpu_put(vcpu);
return 0;
}
@@ -381,11 +381,18 @@ static void vcpu_power_off(struct kvm_vcpu *vcpu)
int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
struct kvm_mp_state *mp_state)
{
+ int ret;
+
+ ret = vcpu_load(vcpu);
+ if (ret)
+ return ret;
+
if (vcpu->arch.power_off)
mp_state->mp_state = KVM_MP_STATE_STOPPED;
else
mp_state->mp_state = KVM_MP_STATE_RUNNABLE;
+ vcpu_put(vcpu);
return 0;
}
@@ -2611,11 +2611,7 @@ static long kvm_vcpu_ioctl(struct file *filp,
case KVM_GET_MP_STATE: {
struct kvm_mp_state mp_state;
- r = vcpu_load(vcpu);
- if (r)
- goto out;
r = kvm_arch_vcpu_ioctl_get_mpstate(vcpu, &mp_state);
- vcpu_put(vcpu);
if (r)
goto out;
r = -EFAULT;
Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_get_mpstate(). Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org> --- arch/s390/kvm/kvm-s390.c | 13 +++++++++++-- arch/x86/kvm/x86.c | 7 +++++++ virt/kvm/arm/arm.c | 7 +++++++ virt/kvm/kvm_main.c | 4 ---- 4 files changed, 25 insertions(+), 6 deletions(-)