From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoffer Dall Subject: Re: [PATCH] arm64: KVM: export current vcpu->pause state via pseudo regs Date: Mon, 4 Aug 2014 14:11:31 +0200 Message-ID: <20140804121131.GC524@cbox> References: <1404914112-7298-1-git-send-email-alex.bennee@linaro.org> <20140731143538.GI11610@cbox> <87mwbpimgz.fsf@linaro.org> <20140731163805.GK11610@cbox> <20140731165006.GL11610@cbox> <87egx0ilkg.fsf@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Peter Maydell , kvm-devel , Catalin Marinas , Will Deacon , open list , Gleb Natapov , Paolo Bonzini , "kvmarm@lists.cs.columbia.edu" , arm-mail-list To: Alex =?iso-8859-1?Q?Benn=E9e?= Return-path: Received: from mail-lb0-f172.google.com ([209.85.217.172]:38559 "EHLO mail-lb0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751132AbaHDML0 (ORCPT ); Mon, 4 Aug 2014 08:11:26 -0400 Received: by mail-lb0-f172.google.com with SMTP id z11so5238432lbi.17 for ; Mon, 04 Aug 2014 05:11:24 -0700 (PDT) Content-Disposition: inline In-Reply-To: <87egx0ilkg.fsf@linaro.org> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, Aug 01, 2014 at 10:48:36AM +0100, Alex Benn=E9e wrote: >=20 > Christoffer Dall writes: >=20 > > On Thu, Jul 31, 2014 at 05:45:28PM +0100, Peter Maydell wrote: > >> On 31 July 2014 17:38, Christoffer Dall wrote: > >> >> > If we are not complaining when setting the pause value to fal= se if it > >> >> > was true before, then we probably also need to wake up the th= read in > >> >> > case this is called from another thread, right? > >> >> > > >> >> > or perhaps we should just return an error if you're trying to= un-pause a > >> >> > CPU through this interface, hmmmm. > >> >> > >> >> Wouldn't it be an error to mess with any register when the syst= em is not > >> >> in a quiescent state? I was assuming that the wake state is dea= lt with > >> >> when the run loop finally restarts. > >> >> > >> > > >> > The ABI doesn't really define it as an error (the ABI doesn't en= force > >> > anything right now) so the question is, does it ever make sense = to clear > >> > the pause flag through this ioctl? If not, I think we should ju= st err > >> > on the side of caution and specify in the docs that this is not > >> > supported and return an error. > >>=20 > >> Consider the case where the reset state of the system is > >> "CPU 0 running, CPUs 1..N stopped", and we're doing an > >> incoming migration to a state where all CPUs are running. > >> In that case we'll be using this ioctl to clear the pause flag, > >> right? (We'll also obviously need to set the PC and other > >> register state correctly before resuming the guest.) > >>=20 > > Doh, you're right, I somehow had it in my mind that when you send t= he > > thread a signal, the pause flag would be cleared, but that goes aga= inst > > the whole idea of a CPU being turned off for KVM. > > > > But wouldn't we then have to also wake up the thread when clearing = the > > pause flag? It feels strange that the ioctl can clear the pause fl= ag, > > but keep the thread on a wake-queue, and then userspace has to send= the > > thread a signal of some sort to wake it up? > >=20 > Isn't the vCPU off the wait-queue by definition if the ioctl exits an= d > you go through the KVM_SET_ONE_REG stuff? >=20 > Once you re-enter the KVM_RUN ioctl it sees the pause_flag as cleared > and falls straight through into kvm_guest_enter() otherwise it will > again wait on wait_event_interruptible(*wq, !vcpu->arch.pause). >=20 Yeah, you're right, I forgot we grab the vcpu->mutex. -Christoffer