From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH 03/18] KVM: PPC: Teach MMIO Signedness Date: Sun, 07 Feb 2010 10:27:03 -0600 Message-ID: <4B6EE9D7.5030608@codemonkey.ws> References: <1265298925-31954-1-git-send-email-agraf@suse.de> <1265298925-31954-4-git-send-email-agraf@suse.de> <4B6EB2D7.1030500@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Alexander Graf , kvm-ppc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Avi Kivity Return-path: In-Reply-To: <4B6EB2D7.1030500-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Sender: kvm-ppc-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: kvm.vger.kernel.org On 02/07/2010 06:32 AM, Avi Kivity wrote: > On 02/04/2010 05:55 PM, Alexander Graf wrote: >> The guest I was trying to get to run uses the LHA and LHAU instructions. >> Those instructions basically do a load, but also sign extend the result. >> >> Since we need to fill our registers by hand when doing MMIO, we also >> need >> to sign extend manually. >> >> This patch implements sign extended MMIO and the LHA(U) instructions. >> >> @@ -300,6 +300,25 @@ static void kvmppc_complete_mmio_load(struct >> kvm_vcpu *vcpu, >> } >> } >> >> + if (vcpu->arch.mmio_sign_extend) { >> + switch (run->mmio.len) { >> +#ifdef CONFIG_PPC64 >> + case 4: >> + if (gpr& 0x80000000) >> + gpr |= 0xffffffff00000000ULL; >> + break; > > Wouldn't > > gpr = (s64)(gpr << 32) >> 32; > > work? Not sure if >> is guaranteed to sign extend. It's technically implementation dependent but I don't know of an implementation that doesn't sign extend. Regards, Anthony Liguori