[Qemu-devel] [PATCH v2 19/27] target/sh4: Unify code for CHECK_PRIVILEGED

Richard Henderson posted 27 patches 8 years, 4 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v2 19/27] target/sh4: Unify code for CHECK_PRIVILEGED
Posted by Richard Henderson 8 years, 4 months ago
We do not need to emit N copies of raising an exception.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 target/sh4/translate.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/target/sh4/translate.c b/target/sh4/translate.c
index 41157a0..dd14b43 100644
--- a/target/sh4/translate.c
+++ b/target/sh4/translate.c
@@ -381,16 +381,9 @@ static inline void gen_store_fpr64(DisasContext *ctx, TCGv_i64 t, int reg)
         goto do_illegal_slot;               \
     }
 
-#define CHECK_PRIVILEGED                                             \
-    if (IS_USER(ctx)) {                                              \
-        gen_save_cpu_state(ctx, true);                               \
-        if (ctx->envflags & DELAY_SLOT_MASK) {                       \
-            gen_helper_raise_slot_illegal_instruction(cpu_env);      \
-        } else {                                                     \
-            gen_helper_raise_illegal_instruction(cpu_env);           \
-        }                                                            \
-        ctx->bstate = BS_EXCP;                                       \
-        return;                                                      \
+#define CHECK_PRIVILEGED \
+    if (IS_USER(ctx)) {                     \
+        goto do_illegal;                    \
     }
 
 #define CHECK_FPU_ENABLED                                            \
@@ -1817,6 +1810,7 @@ static void _decode_opc(DisasContext * ctx)
 	    ctx->opcode, ctx->pc);
     fflush(stderr);
 #endif
+ do_illegal:
     if (ctx->envflags & DELAY_SLOT_MASK) {
  do_illegal_slot:
         gen_save_cpu_state(ctx, true);
-- 
2.9.4


Re: [Qemu-devel] [PATCH v2 19/27] target/sh4: Unify code for CHECK_PRIVILEGED
Posted by Aurelien Jarno 8 years, 4 months ago
On 2017-07-06 16:21, Richard Henderson wrote:
> We do not need to emit N copies of raising an exception.
> 
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  target/sh4/translate.c | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net

Re: [Qemu-devel] [PATCH v2 19/27] target/sh4: Unify code for CHECK_PRIVILEGED
Posted by Philippe Mathieu-Daudé 8 years, 3 months ago
On 07/06/2017 11:21 PM, Richard Henderson wrote:
> We do not need to emit N copies of raising an exception.
> 
> Signed-off-by: Richard Henderson <rth@twiddle.net>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   target/sh4/translate.c | 14 ++++----------
>   1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/target/sh4/translate.c b/target/sh4/translate.c
> index 41157a0..dd14b43 100644
> --- a/target/sh4/translate.c
> +++ b/target/sh4/translate.c
> @@ -381,16 +381,9 @@ static inline void gen_store_fpr64(DisasContext *ctx, TCGv_i64 t, int reg)
>           goto do_illegal_slot;               \
>       }
>   
> -#define CHECK_PRIVILEGED                                             \
> -    if (IS_USER(ctx)) {                                              \
> -        gen_save_cpu_state(ctx, true);                               \
> -        if (ctx->envflags & DELAY_SLOT_MASK) {                       \
> -            gen_helper_raise_slot_illegal_instruction(cpu_env);      \
> -        } else {                                                     \
> -            gen_helper_raise_illegal_instruction(cpu_env);           \
> -        }                                                            \
> -        ctx->bstate = BS_EXCP;                                       \
> -        return;                                                      \
> +#define CHECK_PRIVILEGED \
> +    if (IS_USER(ctx)) {                     \
> +        goto do_illegal;                    \
>       }
>   
>   #define CHECK_FPU_ENABLED                                            \
> @@ -1817,6 +1810,7 @@ static void _decode_opc(DisasContext * ctx)
>   	    ctx->opcode, ctx->pc);
>       fflush(stderr);
>   #endif
> + do_illegal:
>       if (ctx->envflags & DELAY_SLOT_MASK) {
>    do_illegal_slot:
>           gen_save_cpu_state(ctx, true);
>