All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3] linux-user: Handle compressed ISA encodings when processing MIPS exceptions
@ 2013-07-19 16:21 Kwok Cheung Yeung
  2013-07-23 14:56 ` Peter Maydell
  2013-07-29 10:23 ` Maciej W. Rozycki
  0 siblings, 2 replies; 4+ messages in thread
From: Kwok Cheung Yeung @ 2013-07-19 16:21 UTC (permalink / raw)
  To: peter.maydell, qemu-devel; +Cc: Kwok Cheung Yeung, riku.voipio, aurelien

Decode trap instructions during the handling of an EXCP_BREAK or EXCP_TRAP
according to the current ISA mode.

Signed-off-by: Kwok Cheung Yeung <kcy@codesourcery.com>
---
 linux-user/main.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 43 insertions(+), 3 deletions(-)

v2->v3: Handle microMIPS and MIPS16e instructions when processing EXCP_BREAK.

diff --git a/linux-user/main.c b/linux-user/main.c
index 7f15d3d..b137216 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2348,7 +2348,31 @@ done_syscall:
                 abi_ulong trap_instr;
                 unsigned int code;
 
-                ret = get_user_ual(trap_instr, env->active_tc.PC);
+                if (env->hflags & MIPS_HFLAG_M16) {
+                    if (env->insn_flags & ASE_MICROMIPS) {
+                        /* microMIPS mode */
+                        abi_ulong instr[2];
+
+                        ret = get_user_u16(instr[0], env->active_tc.PC) ||
+                              get_user_u16(instr[1], env->active_tc.PC + 2);
+
+                        trap_instr = (instr[0] << 16) | instr[1];
+                    } else {
+                        /* MIPS16e mode */
+                        ret = get_user_u16(trap_instr, env->active_tc.PC);
+                        if (ret != 0) {
+                            goto error;
+                        }
+                        code = (trap_instr >> 6) & 0x3f;
+                        if (do_break(env, &info, code) != 0) {
+                            goto error;
+                        }
+                        break;
+                    }
+                } else {
+                    ret = get_user_ual(trap_instr, env->active_tc.PC);
+                }
+
                 if (ret != 0) {
                     goto error;
                 }
@@ -2372,14 +2396,30 @@ done_syscall:
                 abi_ulong trap_instr;
                 unsigned int code = 0;
 
-                ret = get_user_ual(trap_instr, env->active_tc.PC);
+                if (env->hflags & MIPS_HFLAG_M16) {
+                    /* microMIPS mode */
+                    abi_ulong instr[2];
+
+                    ret = get_user_u16(instr[0], env->active_tc.PC) ||
+                          get_user_u16(instr[1], env->active_tc.PC + 2);
+
+                    trap_instr = (instr[0] << 16) | instr[1];
+                } else {
+                    ret = get_user_ual(trap_instr, env->active_tc.PC);
+                }
+
                 if (ret != 0) {
                     goto error;
                 }
 
                 /* The immediate versions don't provide a code.  */
                 if (!(trap_instr & 0xFC000000)) {
-                    code = ((trap_instr >> 6) & ((1 << 10) - 1));
+                    if (env->hflags & MIPS_HFLAG_M16) {
+                        /* microMIPS mode */
+                        code = ((trap_instr >> 12) & ((1 << 4) - 1));
+                    } else {
+                        code = ((trap_instr >> 6) & ((1 << 10) - 1));
+                    }
                 }
 
                 if (do_break(env, &info, code) != 0) {
-- 
1.8.3.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v3] linux-user: Handle compressed ISA encodings when processing MIPS exceptions
  2013-07-19 16:21 [Qemu-devel] [PATCH v3] linux-user: Handle compressed ISA encodings when processing MIPS exceptions Kwok Cheung Yeung
@ 2013-07-23 14:56 ` Peter Maydell
  2013-07-29 10:23 ` Maciej W. Rozycki
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2013-07-23 14:56 UTC (permalink / raw)
  To: Kwok Cheung Yeung; +Cc: riku.voipio, qemu-devel, aurelien

On 19 July 2013 17:21, Kwok Cheung Yeung <kcy@codesourcery.com> wrote:
> Decode trap instructions during the handling of an EXCP_BREAK or EXCP_TRAP
> according to the current ISA mode.
>
> Signed-off-by: Kwok Cheung Yeung <kcy@codesourcery.com>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v3] linux-user: Handle compressed ISA encodings when processing MIPS exceptions
  2013-07-19 16:21 [Qemu-devel] [PATCH v3] linux-user: Handle compressed ISA encodings when processing MIPS exceptions Kwok Cheung Yeung
  2013-07-23 14:56 ` Peter Maydell
@ 2013-07-29 10:23 ` Maciej W. Rozycki
  2013-08-14 12:03   ` Maciej W. Rozycki
  1 sibling, 1 reply; 4+ messages in thread
From: Maciej W. Rozycki @ 2013-07-29 10:23 UTC (permalink / raw)
  To: Kwok Cheung Yeung; +Cc: peter.maydell, riku.voipio, qemu-devel, aurelien

On Fri, 19 Jul 2013, Kwok Cheung Yeung wrote:

> Decode trap instructions during the handling of an EXCP_BREAK or EXCP_TRAP
> according to the current ISA mode.
> 
> Signed-off-by: Kwok Cheung Yeung <kcy@codesourcery.com>
> ---
>  linux-user/main.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 43 insertions(+), 3 deletions(-)
> 
> v2->v3: Handle microMIPS and MIPS16e instructions when processing EXCP_BREAK.
> 
> diff --git a/linux-user/main.c b/linux-user/main.c
> index 7f15d3d..b137216 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -2348,7 +2348,31 @@ done_syscall:
>                  abi_ulong trap_instr;
>                  unsigned int code;
>  
> -                ret = get_user_ual(trap_instr, env->active_tc.PC);
> +                if (env->hflags & MIPS_HFLAG_M16) {
> +                    if (env->insn_flags & ASE_MICROMIPS) {
> +                        /* microMIPS mode */
> +                        abi_ulong instr[2];
> +
> +                        ret = get_user_u16(instr[0], env->active_tc.PC) ||
> +                              get_user_u16(instr[1], env->active_tc.PC + 2);
> +
> +                        trap_instr = (instr[0] << 16) | instr[1];

 You need to tell 16-bit and 32-bit microMIPS BREAK instructions apart 
somehow.

  Maciej

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v3] linux-user: Handle compressed ISA encodings when processing MIPS exceptions
  2013-07-29 10:23 ` Maciej W. Rozycki
@ 2013-08-14 12:03   ` Maciej W. Rozycki
  0 siblings, 0 replies; 4+ messages in thread
From: Maciej W. Rozycki @ 2013-08-14 12:03 UTC (permalink / raw)
  To: Kwok Cheung Yeung; +Cc: peter.maydell, riku.voipio, qemu-devel, aurelien

On Mon, 29 Jul 2013, Maciej W. Rozycki wrote:

> > Decode trap instructions during the handling of an EXCP_BREAK or EXCP_TRAP
> > according to the current ISA mode.
> > 
> > Signed-off-by: Kwok Cheung Yeung <kcy@codesourcery.com>
> > ---
> >  linux-user/main.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
> >  1 file changed, 43 insertions(+), 3 deletions(-)
> > 
> > v2->v3: Handle microMIPS and MIPS16e instructions when processing EXCP_BREAK.
> > 
> > diff --git a/linux-user/main.c b/linux-user/main.c
> > index 7f15d3d..b137216 100644
> > --- a/linux-user/main.c
> > +++ b/linux-user/main.c
> > @@ -2348,7 +2348,31 @@ done_syscall:
> >                  abi_ulong trap_instr;
> >                  unsigned int code;
> >  
> > -                ret = get_user_ual(trap_instr, env->active_tc.PC);
> > +                if (env->hflags & MIPS_HFLAG_M16) {
> > +                    if (env->insn_flags & ASE_MICROMIPS) {
> > +                        /* microMIPS mode */
> > +                        abi_ulong instr[2];
> > +
> > +                        ret = get_user_u16(instr[0], env->active_tc.PC) ||
> > +                              get_user_u16(instr[1], env->active_tc.PC + 2);
> > +
> > +                        trap_instr = (instr[0] << 16) | instr[1];
> 
>  You need to tell 16-bit and 32-bit microMIPS BREAK instructions apart 
> somehow.

 I can see the broken change was actually applied -- Kwok, did you have a
chance to have a look at making a fix?

  Maciej

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-08-14 12:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-19 16:21 [Qemu-devel] [PATCH v3] linux-user: Handle compressed ISA encodings when processing MIPS exceptions Kwok Cheung Yeung
2013-07-23 14:56 ` Peter Maydell
2013-07-29 10:23 ` Maciej W. Rozycki
2013-08-14 12:03   ` Maciej W. Rozycki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.