From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH] KVM: x86: Fix immediate_exit handling for uninitialized AP Date: Wed, 13 Sep 2017 17:33:08 +0200 Message-ID: <20170913153308.GF2673@flask> References: <1504715646-29879-1-git-send-email-jschoenh@amazon.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: Paolo Bonzini , David Hildenbrand , kvm@vger.kernel.org To: Jan =?utf-8?Q?H=2E_Sch=C3=B6nherr?= Return-path: Received: from mx1.redhat.com ([209.132.183.28]:48516 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751010AbdIMPdO (ORCPT ); Wed, 13 Sep 2017 11:33:14 -0400 Content-Disposition: inline In-Reply-To: <1504715646-29879-1-git-send-email-jschoenh@amazon.de> Sender: kvm-owner@vger.kernel.org List-ID: 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 > --- > 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 >