diff mbox series

[v2,28/42] target/xtensa: Restrict semihosting tests to system mode

Message ID 20250318213209.2579218-29-richard.henderson@linaro.org
State New
Headers show
Series accel/tcg, codebase: Build once patches | expand

Commit Message

Richard Henderson March 18, 2025, 9:31 p.m. UTC
We do not set CONFIG_SEMIHOSTING in
configs/targets/xtensa*-linux-user.mak.

Do not raise SIGILL for user-only unconditionally.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/xtensa/translate.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

Comments

Pierrick Bouvier March 19, 2025, 12:27 a.m. UTC | #1
On 3/18/25 14:31, Richard Henderson wrote:
> We do not set CONFIG_SEMIHOSTING in
> configs/targets/xtensa*-linux-user.mak.
> 
> Do not raise SIGILL for user-only unconditionally.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/xtensa/translate.c | 24 +++++++++++-------------
>   1 file changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
> index 4f02cefde3..cb817b3119 100644
> --- a/target/xtensa/translate.c
> +++ b/target/xtensa/translate.c
> @@ -35,14 +35,14 @@
>   #include "tcg/tcg-op.h"
>   #include "qemu/log.h"
>   #include "qemu/qemu-print.h"
> -#include "semihosting/semihost.h"
>   #include "exec/translator.h"
>   #include "exec/translation-block.h"
> -
>   #include "exec/helper-proto.h"
>   #include "exec/helper-gen.h"
> -
>   #include "exec/log.h"
> +#ifndef CONFIG_USER_ONLY
> +#include "semihosting/semihost.h"
> +#endif
>   
>   #define HELPER_H "helper.h"
>   #include "exec/helper-info.c.inc"
> @@ -2241,17 +2241,15 @@ static uint32_t test_exceptions_simcall(DisasContext *dc,
>                                           const OpcodeArg arg[],
>                                           const uint32_t par[])
>   {
> -    bool is_semi = semihosting_enabled(dc->cring != 0);
> -#ifdef CONFIG_USER_ONLY
> -    bool ill = true;
> -#else
> -    /* Between RE.2 and RE.3 simcall opcode's become nop for the hardware. */
> -    bool ill = dc->config->hw_version <= 250002 && !is_semi;
> -#endif
> -    if (ill || !is_semi) {
> -        qemu_log_mask(LOG_GUEST_ERROR, "SIMCALL but semihosting is disabled\n");
> +#ifndef CONFIG_USER_ONLY
> +    if (semihosting_enabled(dc->cring != 0)) {
> +        return 0;
>       }
> -    return ill ? XTENSA_OP_ILL : 0;
> +#endif
> +    qemu_log_mask(LOG_GUEST_ERROR, "SIMCALL but semihosting is disabled\n");
> +
> +    /* Between RE.2 and RE.3 simcall opcode's become nop for the hardware. */
> +    return dc->config->hw_version <= 250002 ? XTENSA_OP_ILL : 0;
>   }
>   
>   static void translate_simcall(DisasContext *dc, const OpcodeArg arg[],

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
diff mbox series

Patch

diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
index 4f02cefde3..cb817b3119 100644
--- a/target/xtensa/translate.c
+++ b/target/xtensa/translate.c
@@ -35,14 +35,14 @@ 
 #include "tcg/tcg-op.h"
 #include "qemu/log.h"
 #include "qemu/qemu-print.h"
-#include "semihosting/semihost.h"
 #include "exec/translator.h"
 #include "exec/translation-block.h"
-
 #include "exec/helper-proto.h"
 #include "exec/helper-gen.h"
-
 #include "exec/log.h"
+#ifndef CONFIG_USER_ONLY
+#include "semihosting/semihost.h"
+#endif
 
 #define HELPER_H "helper.h"
 #include "exec/helper-info.c.inc"
@@ -2241,17 +2241,15 @@  static uint32_t test_exceptions_simcall(DisasContext *dc,
                                         const OpcodeArg arg[],
                                         const uint32_t par[])
 {
-    bool is_semi = semihosting_enabled(dc->cring != 0);
-#ifdef CONFIG_USER_ONLY
-    bool ill = true;
-#else
-    /* Between RE.2 and RE.3 simcall opcode's become nop for the hardware. */
-    bool ill = dc->config->hw_version <= 250002 && !is_semi;
-#endif
-    if (ill || !is_semi) {
-        qemu_log_mask(LOG_GUEST_ERROR, "SIMCALL but semihosting is disabled\n");
+#ifndef CONFIG_USER_ONLY
+    if (semihosting_enabled(dc->cring != 0)) {
+        return 0;
     }
-    return ill ? XTENSA_OP_ILL : 0;
+#endif
+    qemu_log_mask(LOG_GUEST_ERROR, "SIMCALL but semihosting is disabled\n");
+
+    /* Between RE.2 and RE.3 simcall opcode's become nop for the hardware. */
+    return dc->config->hw_version <= 250002 ? XTENSA_OP_ILL : 0;
 }
 
 static void translate_simcall(DisasContext *dc, const OpcodeArg arg[],