From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Wood Subject: Re: [PATCH 17/38] KVM: PPC: BookE: Add support for vcpu->mode Date: Tue, 14 Aug 2012 19:17:37 -0500 Message-ID: <502AEAA1.10603@freescale.com> References: <1344985483-7440-1-git-send-email-agraf@suse.de> <1344985483-7440-18-git-send-email-agraf@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: , KVM list To: Alexander Graf Return-path: In-Reply-To: <1344985483-7440-18-git-send-email-agraf@suse.de> Sender: kvm-ppc-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 08/14/2012 06:04 PM, Alexander Graf wrote: > Generic KVM code might want to know whether we are inside guest context > or outside. It also wants to be able to push us out of guest context. > > Add support to the BookE code for the generic vcpu->mode field that describes > the above states. > > Signed-off-by: Alexander Graf > --- > arch/powerpc/kvm/booke.c | 11 +++++++++++ > 1 files changed, 11 insertions(+), 0 deletions(-) > > diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c > index bcf87fe..70a86c0 100644 > --- a/arch/powerpc/kvm/booke.c > +++ b/arch/powerpc/kvm/booke.c > @@ -501,6 +501,15 @@ static int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu) > continue; > } > > + if (vcpu->mode == EXITING_GUEST_MODE) { > + r = 1; > + break; > + } > + > + /* Going into guest context! Yay! */ > + vcpu->mode = IN_GUEST_MODE; > + smp_wmb(); > + > break; > } Normally on entry to this function mode should be OUTSIDE_GUEST_MODE, right? How could it possibly be EXITING_GUEST_MODE then, since that only replaces IN_GUEST_MODE? This doesn't match what x86 does with mode on entry. Mode is supposed to be set to IN_GUEST_MODE before requests are checked. I'm not sure what the point of EXITING_GUEST_MODE is at all, compared to just waiting until after interrupts are disabled before setting IN_GUEST_MODE (which we do on ppc, but not on x86 even though it seems like a trivial change), plus the existing ordering between mode and requests. -Scott