KVM: x86: Fix immediate_exit handling for uninitialized AP
PATCH 1/1 KVM: x86: Fix immediate_exit handling for uninitialized AP
When user space sets kvm_run->immediate_exit, KVM is supposed to return quickly. However, when a vCPU is in KVM_MP_STATE_UNINITIALIZED, the value is not considered and the vCPU blocks.
Fix that oversight.
---
compile-time tested only
--- arch/x86/kvm/x86.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kvm/x86.c +4 -0
@@ -7199,6 +7199,10 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)sigprocmask (SIG_SETMASK , &vcpu->sigset, &sigsaved);if (unlikely (vcpu->arch.mp_state ==KVM_MP_STATE_UNINITIALIZED )) { +if (kvm_run->immediate_exit) { + r = -EINTR ; + goto out; + }kvm_vcpu_block (vcpu);kvm_apic_accept_events (vcpu);kvm_clear_request (KVM_REQ_UNHALT , vcpu);
Signature · 1 line
2.3.1.dirty
2017-09-06 18:34+0200, Jan H. Schönherr:
Quoted 19 lines
When user space sets
kvm_run->immediate_exit, KVM is supposed to return quickly. However, when a vCPU is inKVM_MP_STATE_UNINITIALIZED, the value is not considered and the vCPU blocks.Fix that oversight.
Fixes 460df4c1fc7c008 ("KVM: race-free exit from KVM_RUN without POSIX signals")Signed-off-by Jan H. Schönherr <[email protected]>---
compile-time tested only--- arch/x86/kvm/x86.c | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/kvm/x86.c +0
-0
arch/x86/kvm/x86.c int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) · line 7206
Quoted 8 lines
arch/x86/kvm/x86.c +4
-0@@ -7199,6 +7199,10 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)sigprocmask (SIG_SETMASK , &vcpu->sigset, &sigsaved);if (unlikely (vcpu->arch.mp_state ==KVM_MP_STATE_UNINITIALIZED )) { +if (kvm_run->immediate_exit) { + r = -EINTR ; + goto out; + }kvm_vcpu_block (vcpu);
Without immediate_exit, we would also execute the following code, but I think it's ok not to ... queued, thanks.
Quoted 5 lines
arch/x86/kvm/x86.c +0
-0kvm_apic_accept_events (vcpu);kvm_clear_request (KVM_REQ_UNHALT , vcpu);Signature · 1 line
2.3.1.dirty