From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] KVM: prevent spurious exit to userspace during task switch emulation. Date: Thu, 15 Apr 2010 12:36:22 +0300 Message-ID: <4BC6DE16.8040706@redhat.com> References: <20100415092810.GH18132@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, mtosatti@redhat.com To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:18741 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932099Ab0DOJg1 (ORCPT ); Thu, 15 Apr 2010 05:36:27 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o3F9aQTp019436 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 15 Apr 2010 05:36:27 -0400 In-Reply-To: <20100415092810.GH18132@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 04/15/2010 12:28 PM, Gleb Natapov wrote: > > kvm_task_switch() never requires userspace exit, so no matter what the > function returns we should not exit to userspace. > > Signed-off-by: Gleb Natapov > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index c773a46..1bd434b 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -2254,7 +2254,8 @@ static int task_switch_interception(struct vcpu_svm *svm) > (int_vec == OF_VECTOR || int_vec == BP_VECTOR))) > skip_emulated_instruction(&svm->vcpu); > > - return kvm_task_switch(&svm->vcpu, tss_selector, reason); > + kvm_task_switch(&svm->vcpu, tss_selector, reason); > + return 1; > } > > static int cpuid_interception(struct vcpu_svm *svm) > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 453f080..3e1607d 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -3306,8 +3306,7 @@ static int handle_task_switch(struct kvm_vcpu *vcpu) > type != INTR_TYPE_NMI_INTR)) > skip_emulated_instruction(vcpu); > > - if (!kvm_task_switch(vcpu, tss_selector, reason)) > - return 0; > + kvm_task_switch(vcpu, tss_selector, reason); > > Ignoring the return seems wrong. At the very least log errors in dmesg (rate-limited). -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.