public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: prevent spurious exit to userspace during task switch emulation.
@ 2010-04-15  9:28 Gleb Natapov
  2010-04-15  9:36 ` Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Gleb Natapov @ 2010-04-15  9:28 UTC (permalink / raw)
  To: kvm; +Cc: avi, mtosatti

    
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 <gleb@redhat.com>
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);
 
 	/* clear all local breakpoint enable flags */
 	vmcs_writel(GUEST_DR7, vmcs_readl(GUEST_DR7) & ~55);
--
			Gleb.

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

* Re: [PATCH] KVM: prevent spurious exit to userspace during task switch emulation.
  2010-04-15  9:28 [PATCH] KVM: prevent spurious exit to userspace during task switch emulation Gleb Natapov
@ 2010-04-15  9:36 ` Avi Kivity
  0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2010-04-15  9:36 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm, mtosatti

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<gleb@redhat.com>
> 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.


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

end of thread, other threads:[~2010-04-15  9:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-15  9:28 [PATCH] KVM: prevent spurious exit to userspace during task switch emulation Gleb Natapov
2010-04-15  9:36 ` Avi Kivity

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