From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:42778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9uSi-0000k3-Lc for qemu-devel@nongnu.org; Wed, 13 Apr 2011 03:26:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q9uSh-0003El-JD for qemu-devel@nongnu.org; Wed, 13 Apr 2011 03:26:04 -0400 Received: from mail-qy0-f180.google.com ([209.85.216.180]:42159) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9uSh-0003EJ-Gi for qemu-devel@nongnu.org; Wed, 13 Apr 2011 03:26:03 -0400 Received: by qyk10 with SMTP id 10so230550qyk.4 for ; Wed, 13 Apr 2011 00:26:02 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20110412213221.GA4800@volta.aurel32.net> References: <20110412213221.GA4800@volta.aurel32.net> Date: Wed, 13 Apr 2011 12:26:01 +0500 Message-ID: From: Khansa Butt Content-Type: multipart/alternative; boundary=485b397dcc9d8bbf2f04a0c7b806 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: Aurelien Jarno , Riku Voipio Cc: qemu-devel@nongnu.org --485b397dcc9d8bbf2f04a0c7b806 Content-Type: text/plain; charset=ISO-8859-1 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 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? --485b397dcc9d8bbf2f04a0c7b806 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
We ported MIPS64 r2 user mode=A0emulation. When a binary is given to qe= mu-mips64, our code first check whether it is Octeon binary or not if yes i= t =A0enable 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,
> =A0 =A0 =A0 =A0 when we load the interpreter. =A0*/
> =A0 =A0 =A0elf_ex =3D *(struct elfhdr *)bprm->buf;
>
> +#if defined(TARGET_MIPS64)
> + =A0 =A0if ((elf_ex.e_flags & EF_MIPS_MARCH) =3D=3D E_MIPS_MACH_O= CTEON) {
> + =A0 =A0 =A0 =A0info->elf_arch =3D 1;
> + =A0 =A0}
> +#endif
> +++ b/linux-user/main.c
> @@ -3348,6 +3348,11 @@ int main(int argc, char **argv, char **envp) > =A0 =A0 =A0 =A0 =A0if (regs->cp0_epc & 1) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0env->hflags |=3D MIPS_HFLAG_M16;
> =A0 =A0 =A0 =A0 =A0}
> +#if defined(TARGET_MIPS64)
> + =A0 =A0 =A0 =A0if (info->elf_arch) {
> + =A0 =A0 =A0 =A0 =A0 =A0env->insn_flags |=3D=A0=A0INSN_OCTEON;
> + =A0 =A0 =A0 =A0}
> +#endif
> =A0 =A0 =A0}

where we = put elf_arch in image_info=A0

and INSN_OCTEON is i= n target_mips/mips-defs.h as follows
=A0=A0#define INSN_LOONGSON2E =A0= 0x20000000
=A0=A0#define= INSN_LOONGSON2F =A00x40000000
=A0=A0#define INSN_VR54XX 0x80000000
+#define =A0 =A0 =A0 =A0 =A0 =A0INSN_OCTEON 0x10000000

Is this solution=A0acceptable=A0for you?
=A0
--485b397dcc9d8bbf2f04a0c7b806--