From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 18/18] KVM: PPC: Implement Paired Single emulation Date: Sun, 07 Feb 2010 14:50:30 +0200 Message-ID: <4B6EB716.2080704@redhat.com> References: <1265298925-31954-1-git-send-email-agraf@suse.de> <1265298925-31954-19-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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Alexander Graf Return-path: In-Reply-To: <1265298925-31954-19-git-send-email-agraf-l3A5Bk7waGM@public.gmane.org> Sender: kvm-ppc-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: kvm.vger.kernel.org On 02/04/2010 05:55 PM, Alexander Graf wrote: > The one big thing about the Gekko is paired singles. > > Paired singles are an extension to the instruction set, that adds 32 single > precision floating point registers (qprs), some SPRs to modify the behavior > of paired singled operations and instructions to deal with qprs to the > instruction set. > > Unfortunately, it also changes semantics of existing operations that affect > single values in FPRs. In most cases they get mirrored to the coresponding > QPR. > > Thanks to that we need to emulate all FPU operations and all the new paired > single operations too. > > In order to achieve that, we take the guest's instruction, rip out the > parameters, put in our own and execute the very same instruction, but also > fix up the QPR values along the way. > > That way we can execute paired single FPU operations without implementing a > soft fpu. > > A little frightening. How many instructions are there? Maybe we can just have an array of all of them followed by a return instruction, so we don't jit code. > static void call_fpu_inst(u32 inst, u64 *out, u64 *in1, u64 *in2, u64 *in3, > + u32 *cr, u32 *fpscr) > +{ > + u32 cr_val = 0; > + u32 *call_stack; > + u64 inout[5] = { 0, 0, 0, 0, 0 }; > + > + if (fpscr) > + inout[0] = *fpscr; > + if (in1) > + inout[1] = *in1; > + if (in2) > + inout[2] = *in2; > + if (in3) > + inout[3] = *in3; > + if (cr) > + cr_val = *cr; > + > + dprintk(KERN_INFO "FPU Emulator 0x%x ( 0x%llx, 0x%llx, 0x%llx )", inst, > + inout[1], inout[2], inout[3]); > + > + call_stack =&kvmppc_call_stack[(smp_processor_id() * 2)]; > + call_stack[0] = inst; > + /* call_stack[1] is INS_BLR */ > + > Would be easier on the cache to do this per-cpu? -- error compiling committee.c: too many arguments to function