From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/3] KVM: VMX: Short circuit STI; HLT while an interrupt is pending Date: Sun, 20 Feb 2011 11:04:55 +0200 Message-ID: <4D60D937.5020808@redhat.com> References: <1297694537-9268-1-git-send-email-avi@redhat.com> <1297694537-9268-3-git-send-email-avi@redhat.com> <20110215203654.GA16010@amt.cnet> <4D5B927B.50903@redhat.com> <20110216165101.GA15973@amt.cnet> <4D5CE68B.6000709@redhat.com> <20110217161634.GA10918@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:64250 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751914Ab1BTJFB (ORCPT ); Sun, 20 Feb 2011 04:05:01 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1K951HM029085 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 20 Feb 2011 04:05:01 -0500 In-Reply-To: <20110217161634.GA10918@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On 02/17/2011 06:16 PM, Marcelo Tosatti wrote: > On Thu, Feb 17, 2011 at 11:12:43AM +0200, Avi Kivity wrote: > > >> >> index ee1cd1a..541da0e 100644 > > >> >> --- a/arch/x86/kvm/vmx.c > > >> >> +++ b/arch/x86/kvm/vmx.c > > >> >> @@ -3437,6 +3437,15 @@ static int handle_interrupt_window(struct kvm_vcpu *vcpu) > > >> >> static int handle_halt(struct kvm_vcpu *vcpu) > > >> >> { > > >> >> skip_emulated_instruction(vcpu); > > >> >> + /* > > >> >> + * Short-circuit an STI; HLT sequence while an interrupt is pending: > > >> >> + * instead of halting, re-entering the guest, and exiting immediately > > >> >> + * on an interrupt window exit, go directly to the last step. > > >> >> + */ > > >> >> + if ((to_vmx(vcpu)->cpu_based_vm_exec_control > > >> >> + & CPU_BASED_VIRTUAL_INTR_PENDING) > > >> >> + && (kvm_get_rflags(vcpu)& X86_EFLAGS_IF)) > > >> >> + return handle_interrupt_window(vcpu); > > >> >> return kvm_emulate_halt(vcpu); > > >> >> } > > >> > > > >> >Why does the normal vcpu entry path fails to inject the interrupt? Because after halt, > > >> >KVM_REQ_EVENT is not set? > > >> > > >> Yes. Also, we want to clear CPU_BASED_VIRTUAL_INTR_PENDING. > > > > > >Is there a reason why it cannot be handled in the main loop? > > > > Don't follow. What are you suggesting? > > That vcpu main loop (inject_pending_events etc) should be able to inject > the interrupt and clear interrupt exiting, instead of a short circuit > in specific exit handlers, as an improvement on top of the current > patchset. Yes, it makes sense to make move virtual interrupt pending logic into x86.c. On the other hand, it may conflict with using the hardware interrupt queue on svm (which we don't make use of yet). > Any numbers, BTW? Not yet. -- error compiling committee.c: too many arguments to function