On Tue, May 25, 2021 at 12:24 PM Reiji Watanabe <reijiw@xxxxxxxxxx> wrote: > > > @@ -9880,11 +9888,16 @@ 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 r = 0; > > + > > vcpu_load(vcpu); > > if (kvm_mpx_supported()) > > kvm_load_guest_fpu(vcpu); > > > > - kvm_apic_accept_events(vcpu); > > + r = kvm_apic_accept_events(vcpu); > > + if (r < 0) > > + goto out; > > + > > if ((vcpu->arch.mp_state == KVM_MP_STATE_HALTED || > > vcpu->arch.mp_state == KVM_MP_STATE_AP_RESET_HOLD) && > > vcpu->arch.pv.pv_unhalted) > > @@ -9892,6 +9905,7 @@ int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, > > else > > mp_state->mp_state = vcpu->arch.mp_state; > > > > +out: > > if (kvm_mpx_supported()) > > kvm_put_guest_fpu(vcpu); > > vcpu_put(vcpu); > > With the change, if the return value from kvm_apic_accept_events() > is < 0, kvm_arch_vcpu_ioctl_get_mpstate(), which is called from > KVM_GET_MP_STATE ioctl, doesn't set mp_state returning 0 (success). > It leads KVM_GET_MP_STATE ioctl to return an undefined mp_state for > the success case. Yikes! I think I intended to return 'r' when it is less than 0 (e.g. the -ENXIO I introduce later in the series). However, I'm not quite sure what to do with values of r > 0. I'll look into it and send out v2.