public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Fix immediate_exit handling for uninitialized AP
@ 2017-09-06 16:34 Jan H. Schönherr
  2017-09-13 15:33 ` Radim Krčmář
  0 siblings, 1 reply; 2+ messages in thread
From: Jan H. Schönherr @ 2017-09-06 16:34 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Jan H. Schönherr, David Hildenbrand, kvm

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.

Fixes: 460df4c1fc7c008 ("KVM: race-free exit from KVM_RUN without POSIX signals")
Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de>
---
compile-time tested only
---
 arch/x86/kvm/x86.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 40039cd..a69a948 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -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);
-- 
2.3.1.dirty

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: x86: Fix immediate_exit handling for uninitialized AP
  2017-09-06 16:34 [PATCH] KVM: x86: Fix immediate_exit handling for uninitialized AP Jan H. Schönherr
@ 2017-09-13 15:33 ` Radim Krčmář
  0 siblings, 0 replies; 2+ messages in thread
From: Radim Krčmář @ 2017-09-13 15:33 UTC (permalink / raw)
  To: Jan H. Schönherr; +Cc: Paolo Bonzini, David Hildenbrand, kvm

2017-09-06 18:34+0200, Jan H. Schönherr:
> 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.
> 
> Fixes: 460df4c1fc7c008 ("KVM: race-free exit from KVM_RUN without POSIX signals")
> Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de>
> ---
> compile-time tested only
> ---
>  arch/x86/kvm/x86.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 40039cd..a69a948 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -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.

>  		kvm_apic_accept_events(vcpu);
>  		kvm_clear_request(KVM_REQ_UNHALT, vcpu);
> -- 
> 2.3.1.dirty
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-13 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-06 16:34 [PATCH] KVM: x86: Fix immediate_exit handling for uninitialized AP Jan H. Schönherr
2017-09-13 15:33 ` Radim Krčmář

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox