Received: from eggs.gnu.org ([140.186.70.92]:45294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QA4cx-0007Wd-UU for qemu-devel@nongnu.org; Wed, 13 Apr 2011 14:17:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QA4cw-0003FG-Uk for qemu-devel@nongnu.org; Wed, 13 Apr 2011 14:17:19 -0400 Received: from hall.aurel32.net ([88.191.126.93]:49670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QA4cw-0003F6-QB for qemu-devel@nongnu.org; Wed, 13 Apr 2011 14:17:18 -0400 Date: Wed, 13 Apr 2011 20:17:14 +0200 From: Aurelien Jarno Message-ID: <20110413181714.GA908@volta.aurel32.net> References: <20110412213221.GA4800@volta.aurel32.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH 2/2] Support for Cavium-Octeon specific instruction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Khansa Butt Cc: Riku Voipio , qemu-devel@nongnu.org On Wed, Apr 13, 2011 at 12:26:01PM +0500, Khansa Butt wrote: > We ported MIPS64 r2 user mode emulation. When a binary is given to > qemu-mips64, our code first check whether it is Octeon binary or not if yes > it enable Octeon specific Instructions for. The following code snippet do > this job: > > > > > > diff --git a/linux-user/elfload.c b/linux-user/elfload.c > > > index 2832a33..9399e44 100644 > > > --- a/linux-user/elfload.c > > > +++ b/linux-user/elfload.c > > > @@ -1662,6 +1662,11 @@ int load_elf_binary(struct linux_binprm * bprm, > > > struct target_pt_regs * regs, > > > when we load the interpreter. */ > > > elf_ex = *(struct elfhdr *)bprm->buf; > > > > > > +#if defined(TARGET_MIPS64) > > > + if ((elf_ex.e_flags & EF_MIPS_MARCH) == E_MIPS_MACH_OCTEON) { > > > + info->elf_arch = 1; > > > + } > > > +#endif > > > > > > +++ b/linux-user/main.c > > > @@ -3348,6 +3348,11 @@ int main(int argc, char **argv, char **envp) > > > if (regs->cp0_epc & 1) { > > > env->hflags |= MIPS_HFLAG_M16; > > > } > > > +#if defined(TARGET_MIPS64) > > > + if (info->elf_arch) { > > > + env->insn_flags |= INSN_OCTEON; > > > + } > > > +#endif > > > } > > > > where we put elf_arch in image_info I am not really sure about this name info->elf_arch, it is something specific to octeon, but the name doesn't represent that. Also we probably want a generic framework for changing a CPU to another one. Note that in any case you can run qemu-mips64 with -cpu octeon if you define an octeon CPU in translate_init.c. > and INSN_OCTEON is in target_mips/mips-defs.h as follows > #define INSN_LOONGSON2E 0x20000000 > #define INSN_LOONGSON2F 0x40000000 > #define INSN_VR54XX 0x80000000 > +#define INSN_OCTEON 0x10000000 > > Is this solution acceptable for you? This part is clearly the way to go -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net