From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 08/26] KVM: PPC: Add PV guest critical sections Date: Sun, 27 Jun 2010 13:03:57 +0300 Message-ID: <4C27220D.7090508@redhat.com> References: <1277508314-915-1-git-send-email-agraf@suse.de> <1277508314-915-9-git-send-email-agraf@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm-ppc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, KVM list , linuxppc-dev To: Alexander Graf Return-path: In-Reply-To: <1277508314-915-9-git-send-email-agraf-l3A5Bk7waGM@public.gmane.org> Sender: kvm-ppc-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: kvm.vger.kernel.org On 06/26/2010 02:24 AM, Alexander Graf wrote: > When running in hooked code we need a way to disable interrupts without > clobbering any interrupts or exiting out to the hypervisor. > > To achieve this, we have an additional critical field in the shared page. If > that field is equal to the r1 register of the guest, it tells the hypervisor > that we're in such a critical section and thus may not receive any interrupts. > > > --- a/arch/powerpc/kvm/book3s.c > +++ b/arch/powerpc/kvm/book3s.c > @@ -251,14 +251,25 @@ int kvmppc_book3s_irqprio_deliver(struct kvm_vcpu *vcpu, unsigned int priority) > int deliver = 1; > int vec = 0; > ulong flags = 0ULL; > + ulong crit_raw = vcpu->arch.shared->critical; > + ulong crit_r1 = kvmppc_get_gpr(vcpu, 1); > + bool crit; > + > + /* Truncate crit indicators in 32 bit mode */ > + if (!(vcpu->arch.shared->msr& MSR_SF)) { > + crit_raw&= 0xffffffff; > + crit_r1&= 0xffffffff; > + } > + > + crit = (crit_raw == crit_r1); > I think you need to qualify that for supervisor mode only. Otherwise guest userspace can guess the value of shared->critical and disable interrupts. -- error compiling committee.c: too many arguments to function