All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target-arm: Handle 'smc' as an undefined instruction
@ 2010-09-02 21:40 Adam Lackorzynski
  2010-09-02 22:14 ` Peter Maydell
  0 siblings, 1 reply; 10+ messages in thread
From: Adam Lackorzynski @ 2010-09-02 21:40 UTC (permalink / raw)
  To: qemu-devel

Handle smc as an undefined instruction instead of having it wrongly
interpreted as some other one.

Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
---
 target-arm/translate.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index 6fcdd7e..c1d55ed 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -6346,7 +6346,12 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)
             dead_tmp(tmp2);
             store_reg(s, rd, tmp);
             break;
-        case 7: /* bkpt */
+        case 7:
+            /* SMC? */
+            if ((insn & 0xfffffff0) == 0xe1600070) {
+                goto illegal_op;
+            }
+            /* bkpt */
             gen_set_condexec(s);
             gen_set_pc_im(s->pc - 4);
             gen_exception(EXCP_BKPT);
-- 
1.7.1

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

* Re: [Qemu-devel] [PATCH] target-arm: Handle 'smc' as an undefined instruction
  2010-09-02 21:40 [Qemu-devel] [PATCH] target-arm: Handle 'smc' as an undefined instruction Adam Lackorzynski
@ 2010-09-02 22:14 ` Peter Maydell
  2010-09-02 23:11   ` Adam Lackorzynski
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Maydell @ 2010-09-02 22:14 UTC (permalink / raw)
  To: Adam Lackorzynski; +Cc: qemu-devel

On Thu, Sep 02, 2010 at 11:40:50PM +0200, Adam Lackorzynski wrote:
> +        case 7:
> +            /* SMC? */
> +            if ((insn & 0xfffffff0) == 0xe1600070) {
> +                goto illegal_op;
> +            }
> +            /* bkpt */

This doesn't look right to me. SMC in the ARM encoding is a standard
conditionalised instruction, so you shouldn't be mandating that the
cond field is 0xe.

I think the correct way to distinguish BKPT from SMC is to look at
bits [22..21] of the instruction: 01 for BKPT, 11 for SMC and
other combinations are UNDEFINED. This is in 'op1' at this point
in the code...

-- Peter Maydell

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

* Re: [Qemu-devel] [PATCH] target-arm: Handle 'smc' as an undefined instruction
  2010-09-02 22:14 ` Peter Maydell
@ 2010-09-02 23:11   ` Adam Lackorzynski
  0 siblings, 0 replies; 10+ messages in thread
From: Adam Lackorzynski @ 2010-09-02 23:11 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel


On Thu Sep 02, 2010 at 23:14:23 +0100, Peter Maydell wrote:
> On Thu, Sep 02, 2010 at 11:40:50PM +0200, Adam Lackorzynski wrote:
> > +        case 7:
> > +            /* SMC? */
> > +            if ((insn & 0xfffffff0) == 0xe1600070) {
> > +                goto illegal_op;
> > +            }
> > +            /* bkpt */
> 
> This doesn't look right to me. SMC in the ARM encoding is a standard
> conditionalised instruction, so you shouldn't be mandating that the
> cond field is 0xe.

True.

> I think the correct way to distinguish BKPT from SMC is to look at
> bits [22..21] of the instruction: 01 for BKPT, 11 for SMC and
> other combinations are UNDEFINED. This is in 'op1' at this point
> in the code...

target-arm: Handle 'smc' as an undefined instruction

Refine check on bkpt so that smc is handled as an undefined instruction.

Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
---
 target-arm/translate.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index 6fcdd7e..fac4f5d 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -6346,7 +6346,11 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)
             dead_tmp(tmp2);
             store_reg(s, rd, tmp);
             break;
-        case 7: /* bkpt */
+        case 7:
+            if (op1 != 1) {
+                goto illegal_op;
+            }
+            /* bkpt */
             gen_set_condexec(s);
             gen_set_pc_im(s->pc - 4);
             gen_exception(EXCP_BKPT);
-- 
1.7.1


Thanks,
Adam
-- 
Adam                 adam@os.inf.tu-dresden.de
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/

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

* Re: [Qemu-devel] [PATCH] target-arm: Handle 'smc' as an undefined instruction
  2010-11-04 22:21 Adam Lackorzynski
@ 2010-11-14 17:10 ` Peter Maydell
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Maydell @ 2010-11-14 17:10 UTC (permalink / raw)
  To: Adam Lackorzynski; +Cc: qemu-devel

On 4 November 2010 22:21, Adam Lackorzynski <adam@os.inf.tu-dresden.de> wrote:
>
> Refine check on bkpt so that smc and undefined instruction encodings are
> handled as an undefined instruction and trap.
>
> Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>

This patch looks good to me. I note that there's actually an implementation
of SMC and at least some of the TrustZone extension in the qemu-meego
tree. However, for the moment this patch is correct: SMC should UNDEF on
cores without TrustZone (which is what current qemu effectively is).

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

-- PMM

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

* [Qemu-devel] [PATCH] target-arm: Handle 'smc' as an undefined instruction
@ 2010-11-04 22:21 Adam Lackorzynski
  2010-11-14 17:10 ` Peter Maydell
  0 siblings, 1 reply; 10+ messages in thread
From: Adam Lackorzynski @ 2010-11-04 22:21 UTC (permalink / raw)
  To: qemu-devel


Refine check on bkpt so that smc and undefined instruction encodings are
handled as an undefined instruction and trap.

Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
---
 target-arm/translate.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index 99464ab..c7283e3 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -6346,7 +6346,14 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)
             dead_tmp(tmp2);
             store_reg(s, rd, tmp);
             break;
-        case 7: /* bkpt */
+        case 7:
+            /* SMC instruction (op1 == 3)
+               and undefined instructions (op1 == 0 || op1 == 2)
+               will trap */
+            if (op1 != 1) {
+                goto illegal_op;
+            }
+            /* bkpt */
             gen_set_condexec(s);
             gen_set_pc_im(s->pc - 4);
             gen_exception(EXCP_BKPT);
-- 
1.7.2.3


Adam
-- 
Adam                 adam@os.inf.tu-dresden.de
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/

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

* [Qemu-devel] [PATCH] target-arm: Handle 'smc' as an undefined instruction
@ 2010-09-25  8:50 Adam Lackorzynski
  0 siblings, 0 replies; 10+ messages in thread
From: Adam Lackorzynski @ 2010-09-25  8:50 UTC (permalink / raw)
  To: qemu-devel


Refine check on bkpt so that smc and undefined instruction encodings are
handled as an undefined instruction and trap.

Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
---
 target-arm/translate.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index 6fcdd7e..9ac1f8b 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -6346,7 +6346,14 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)
             dead_tmp(tmp2);
             store_reg(s, rd, tmp);
             break;
-        case 7: /* bkpt */
+        case 7:
+            /* SMC instruction (op1 == 3)
+               and undefined instructions (op1 == 0 || op1 == 2)
+               will trap */
+            if (op1 != 1) {
+                goto illegal_op;
+            }
+            /* bkpt */
             gen_set_condexec(s);
             gen_set_pc_im(s->pc - 4);
             gen_exception(EXCP_BKPT);
-- 
1.7.1


Adam
-- 
Adam                 adam@os.inf.tu-dresden.de
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/

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

* Re: [Qemu-devel] [PATCH] target-arm: Handle 'smc' as an undefined instruction
  2010-09-02 20:27 Adam Lackorzynski
@ 2010-09-02 21:19 ` Stefan Weil
  0 siblings, 0 replies; 10+ messages in thread
From: Stefan Weil @ 2010-09-02 21:19 UTC (permalink / raw)
  To: Adam Lackorzynski; +Cc: qemu-devel

Am 02.09.2010 22:27, schrieb Adam Lackorzynski:
> Handle smc as an undefined instruction instead of having it wrongly
> interpreted as some other one.
>
> Signed-off-by: Adam Lackorzynski<adam@os.inf.tu-dresden.de>
> ---
>   target-arm/translate.c |    6 +++++-
>   1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/target-arm/translate.c b/target-arm/translate.c
> index 6fcdd7e..9b5d650 100644
> --- a/target-arm/translate.c
> +++ b/target-arm/translate.c
> @@ -6346,7 +6346,11 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)
>               dead_tmp(tmp2);
>               store_reg(s, rd, tmp);
>               break;
> -        case 7: /* bkpt */
> +        case 7:
> +            /* SMC? */
> +            if ((insn&  0xfffffff0) == 0xe1600070)
> +              goto illegal_op;
>    

QEMU's CODING_STYLE requires {} here.


> +            /* bkpt */
>               gen_set_condexec(s);
>               gen_set_pc_im(s->pc - 4);
>               gen_exception(EXCP_BKPT);
>    

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

* [Qemu-devel] [PATCH] target-arm: Handle 'smc' as an undefined instruction
@ 2010-09-02 20:27 Adam Lackorzynski
  2010-09-02 21:19 ` Stefan Weil
  0 siblings, 1 reply; 10+ messages in thread
From: Adam Lackorzynski @ 2010-09-02 20:27 UTC (permalink / raw)
  To: qemu-devel


Handle smc as an undefined instruction instead of having it wrongly
interpreted as some other one.

Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
---
 target-arm/translate.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index 6fcdd7e..9b5d650 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -6346,7 +6346,11 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)
             dead_tmp(tmp2);
             store_reg(s, rd, tmp);
             break;
-        case 7: /* bkpt */
+        case 7:
+            /* SMC? */
+            if ((insn & 0xfffffff0) == 0xe1600070)
+              goto illegal_op;
+            /* bkpt */
             gen_set_condexec(s);
             gen_set_pc_im(s->pc - 4);
             gen_exception(EXCP_BKPT);
-- 
1.7.1

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

* [Qemu-devel] [PATCH] target-arm: Handle 'smc' as an undefined instruction
@ 2010-06-04  8:59 Adam Lackorzynski
  0 siblings, 0 replies; 10+ messages in thread
From: Adam Lackorzynski @ 2010-06-04  8:59 UTC (permalink / raw)
  To: qemu-devel


Handle smc as undefined instruction instead of having it wrongly interpreted
as some other instruction.

Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
---
 target-arm/translate.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index 0eccca5..afd6716 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -6344,7 +6344,11 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)
             dead_tmp(tmp2);
             store_reg(s, rd, tmp);
             break;
-        case 7: /* bkpt */
+        case 7:
+            /* SMC? */
+            if ((insn & 0xfffffff0) == 0xe1600070)
+              goto illegal_op;
+            /* bkpt */
             gen_set_condexec(s);
             gen_set_pc_im(s->pc - 4);
             gen_exception(EXCP_BKPT);
-- 
1.7.1

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

* [Qemu-devel] [PATCH] target-arm: Handle 'smc' as an undefined instruction
@ 2010-05-10 23:01 Adam Lackorzynski
  0 siblings, 0 replies; 10+ messages in thread
From: Adam Lackorzynski @ 2010-05-10 23:01 UTC (permalink / raw)
  To: qemu-devel



Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
---
 target-arm/translate.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index 0eccca5..afd6716 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -6344,7 +6344,11 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)
             dead_tmp(tmp2);
             store_reg(s, rd, tmp);
             break;
-        case 7: /* bkpt */
+        case 7:
+            /* SMC? */
+            if ((insn & 0xfffffff0) == 0xe1600070)
+              goto illegal_op;
+            /* bkpt */
             gen_set_condexec(s);
             gen_set_pc_im(s->pc - 4);
             gen_exception(EXCP_BKPT);
-- 
1.7.1


Adam
-- 
Adam                 adam@os.inf.tu-dresden.de
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/

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

end of thread, other threads:[~2010-11-14 17:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-02 21:40 [Qemu-devel] [PATCH] target-arm: Handle 'smc' as an undefined instruction Adam Lackorzynski
2010-09-02 22:14 ` Peter Maydell
2010-09-02 23:11   ` Adam Lackorzynski
  -- strict thread matches above, loose matches on Subject: below --
2010-11-04 22:21 Adam Lackorzynski
2010-11-14 17:10 ` Peter Maydell
2010-09-25  8:50 Adam Lackorzynski
2010-09-02 20:27 Adam Lackorzynski
2010-09-02 21:19 ` Stefan Weil
2010-06-04  8:59 Adam Lackorzynski
2010-05-10 23:01 Adam Lackorzynski

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.