From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH] KVM: x86: Convert INIT and SIPI signals into synchronously handled events Date: Tue, 12 Mar 2013 15:37:39 +0200 Message-ID: <20130312133739.GD11223@redhat.com> References: <513F1529.3040309@siemens.com> <513F1A63.9070107@redhat.com> <513F2688.2080902@siemens.com> <513F273F.5020108@siemens.com> <513F2A11.7030904@redhat.com> <513F2AAD.4050008@siemens.com> <20130312132517.GC11223@redhat.com> <513F2D2F.9040103@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Paolo Bonzini , Marcelo Tosatti , kvm To: Jan Kiszka Return-path: Received: from mx1.redhat.com ([209.132.183.28]:6458 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755112Ab3CLNhn (ORCPT ); Tue, 12 Mar 2013 09:37:43 -0400 Content-Disposition: inline In-Reply-To: <513F2D2F.9040103@siemens.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Mar 12, 2013 at 02:27:11PM +0100, Jan Kiszka wrote: > On 2013-03-12 14:25, Gleb Natapov wrote: > > On Tue, Mar 12, 2013 at 02:16:29PM +0100, Jan Kiszka wrote: > >> On 2013-03-12 14:13, Paolo Bonzini wrote: > >>> Il 12/03/2013 14:01, Jan Kiszka ha scritto: > >>>>>>>> For example, should kvm_arch_interrupt_allowed return zero if the VCPU > >>>>>>>> is in the INIT_RECEIVED state? > >>>>>> > >>>>>> Yeah, that probably makes sense beyond async_pf. > >>>> Wait: If you perform a proper reset on INIT already, we would clear IF > >>>> thus prevent also async_pf injections. On the other hand, > >>>> kvm_arch_can_inject_async_page_present returns true if apf.msr_val & > >>>> KVM_ASYNC_PF_ENABLED is not set - shouldn't that be cleared on reset as > >>>> well? Hmm... > >>> > >>> So if you split the reset (which is done on INIT) from setting up CS on > >>> SIPI, you kill two birds with a stone, or at least one and a half: you > >>> clear IF as you wrote above, and INIT on BSP almost works (the only > >>> missing bit should be setting the mp_state to KVM_MP_STATE_RUNNABLE). > >> > >> ...unless the async_pf MSR is cleared on reset as well. > >> > > It is: > > vcpu->arch.apf.msr_val = 0; > > Can you explain the "if !(apf.msr_val & KVM_ASYNC_PF_ENABLED) return > true;" in kvm_arch_can_inject_async_page_present? > APF works even with non-PV guests. If non PV guest access swapped out page the page is swapped in asynchronously and vcpu enters apf.halted state. In this sate it can still receive interrupt. Completion of apf cause vcpu exit apf.halted state. On vcpu reset we call kvm_clear_async_pf_completion_queue() so vcpu->async_pf.done will be empty and kvm_check_async_pf_completion() will be nop if vcpu is properly reset on INIT. -- Gleb.