qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target/arm: Make disas_thumb2_insn() generate its own UNDEF exceptions
@ 2017-12-12 12:08 Peter Maydell
  2017-12-12 17:39 ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2017-12-12 12:08 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: patches, Richard Henderson

Refactor disas_thumb2_insn() so that it generates the code for raising
an UNDEF exception for invalid insns, rather than returning a flag
which the caller must check to see if it needs to generate the UNDEF
code. This brings the function in to line with the behaviour of
disas_thumb_insn() and disas_arm_insn().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
This fixes the odd asymmetry of API that caused the bug fixed
in commit 7472e2efb...
---
 target/arm/translate.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/target/arm/translate.c b/target/arm/translate.c
index f120932..89ee353 100644
--- a/target/arm/translate.c
+++ b/target/arm/translate.c
@@ -9771,9 +9771,8 @@ gen_thumb2_data_op(DisasContext *s, int op, int conds, uint32_t shifter_out,
     return 0;
 }
 
-/* Translate a 32-bit thumb instruction.  Returns nonzero if the instruction
-   is not legal.  */
-static int disas_thumb2_insn(DisasContext *s, uint32_t insn)
+/* Translate a 32-bit thumb instruction. */
+static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
 {
     uint32_t imm, shift, offset;
     uint32_t rd, rn, rm, rs;
@@ -10985,16 +10984,16 @@ static int disas_thumb2_insn(DisasContext *s, uint32_t insn)
                     /* UNPREDICTABLE, unallocated hint or
                      * PLD/PLDW/PLI (literal)
                      */
-                    return 0;
+                    return;
                 }
                 if (op1 & 1) {
-                    return 0; /* PLD/PLDW/PLI or unallocated hint */
+                    return; /* PLD/PLDW/PLI or unallocated hint */
                 }
                 if ((op2 == 0) || ((op2 & 0x3c) == 0x30)) {
-                    return 0; /* PLD/PLDW/PLI or unallocated hint */
+                    return; /* PLD/PLDW/PLI or unallocated hint */
                 }
                 /* UNDEF space, or an UNPREDICTABLE */
-                return 1;
+                goto illegal_op;
             }
         }
         memidx = get_mem_index(s);
@@ -11120,9 +11119,10 @@ static int disas_thumb2_insn(DisasContext *s, uint32_t insn)
     default:
         goto illegal_op;
     }
-    return 0;
+    return;
 illegal_op:
-    return 1;
+    gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(),
+                       default_exception_el(s));
 }
 
 static void disas_thumb_insn(DisasContext *s, uint32_t insn)
@@ -12245,10 +12245,7 @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
     if (is_16bit) {
         disas_thumb_insn(dc, insn);
     } else {
-        if (disas_thumb2_insn(dc, insn)) {
-            gen_exception_insn(dc, 4, EXCP_UDEF, syn_uncategorized(),
-                               default_exception_el(dc));
-        }
+        disas_thumb2_insn(dc, insn);
     }
 
     /* Advance the Thumb condexec condition.  */
-- 
2.7.4

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

* Re: [Qemu-devel] [PATCH] target/arm: Make disas_thumb2_insn() generate its own UNDEF exceptions
  2017-12-12 12:08 [Qemu-devel] [PATCH] target/arm: Make disas_thumb2_insn() generate its own UNDEF exceptions Peter Maydell
@ 2017-12-12 17:39 ` Richard Henderson
  2018-01-09 14:22   ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2017-12-12 17:39 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel; +Cc: patches

On 12/12/2017 04:08 AM, Peter Maydell wrote:
> Refactor disas_thumb2_insn() so that it generates the code for raising
> an UNDEF exception for invalid insns, rather than returning a flag
> which the caller must check to see if it needs to generate the UNDEF
> code. This brings the function in to line with the behaviour of
> disas_thumb_insn() and disas_arm_insn().
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> This fixes the odd asymmetry of API that caused the bug fixed
> in commit 7472e2efb...
> ---
>  target/arm/translate.c | 23 ++++++++++-------------
>  1 file changed, 10 insertions(+), 13 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

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

* Re: [Qemu-devel] [PATCH] target/arm: Make disas_thumb2_insn() generate its own UNDEF exceptions
  2017-12-12 17:39 ` Richard Henderson
@ 2018-01-09 14:22   ` Peter Maydell
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2018-01-09 14:22 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-arm, QEMU Developers, patches@linaro.org

On 12 December 2017 at 17:39, Richard Henderson
<richard.henderson@linaro.org> wrote:
> On 12/12/2017 04:08 AM, Peter Maydell wrote:
>> Refactor disas_thumb2_insn() so that it generates the code for raising
>> an UNDEF exception for invalid insns, rather than returning a flag
>> which the caller must check to see if it needs to generate the UNDEF
>> code. This brings the function in to line with the behaviour of
>> disas_thumb_insn() and disas_arm_insn().
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>> This fixes the odd asymmetry of API that caused the bug fixed
>> in commit 7472e2efb...
>> ---
>>  target/arm/translate.c | 23 ++++++++++-------------
>>  1 file changed, 10 insertions(+), 13 deletions(-)
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Thanks; applied to target-arm.next.

-- PMM

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

end of thread, other threads:[~2018-01-09 14:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-12 12:08 [Qemu-devel] [PATCH] target/arm: Make disas_thumb2_insn() generate its own UNDEF exceptions Peter Maydell
2017-12-12 17:39 ` Richard Henderson
2018-01-09 14:22   ` 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).