qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: Handle microMIPS encoding when processing trap exceptions
@ 2013-07-17 16:50 Kwok Cheung Yeung
  2013-07-17 17:20 ` Peter Maydell
  0 siblings, 1 reply; 2+ messages in thread
From: Kwok Cheung Yeung @ 2013-07-17 16:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kwok Cheung Yeung, riku.voipio, aurelien

Decode trap instructions during the handling of a EXCP_TRAP according to
the current ISA mode.

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

diff --git a/linux-user/main.c b/linux-user/main.c
index 7f15d3d..c417e26 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2379,7 +2379,10 @@ done_syscall:
 
                 /* 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] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: Handle microMIPS encoding when processing trap exceptions
  2013-07-17 16:50 [Qemu-devel] [PATCH] linux-user: Handle microMIPS encoding when processing trap exceptions Kwok Cheung Yeung
@ 2013-07-17 17:20 ` Peter Maydell
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2013-07-17 17:20 UTC (permalink / raw)
  To: Kwok Cheung Yeung; +Cc: riku.voipio, qemu-devel, aurelien

On 17 July 2013 17:50, Kwok Cheung Yeung <kcy@codesourcery.com> wrote:
> Decode trap instructions during the handling of a EXCP_TRAP according to
> the current ISA mode.
>
> Signed-off-by: Kwok Cheung Yeung <kcy@codesourcery.com>
> ---
>  linux-user/main.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/linux-user/main.c b/linux-user/main.c
> index 7f15d3d..c417e26 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -2379,7 +2379,10 @@ done_syscall:
>
>                  /* The immediate versions don't provide a code.  */
>                  if (!(trap_instr & 0xFC000000)) {

So this trap_instr is read in QEMU via a simple get_user_ual(),
whereas if you look at the Linux kernel:
http://lxr.linux.no/#linux+v3.10.1/arch/mips/kernel/traps.c#L904

it specifically does two 16 bit loads for the microMIPS case.
Are you sure this code is correct for both big and little
endian MIPS configs?

(Similar remarks apply for EXCP_BREAK.)

> -                    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));

This if statement needs braces to fit QEMU coding style.
scripts/checkpatch.pl will tell you about this sort of thing.

thanks
-- PMM

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

end of thread, other threads:[~2013-07-17 17:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-17 16:50 [Qemu-devel] [PATCH] linux-user: Handle microMIPS encoding when processing trap exceptions Kwok Cheung Yeung
2013-07-17 17:20 ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).