]> git.proxmox.com Git - mirror_qemu.git/commitdiff
linux-user/loongarch64: Use traps to track LSX/LASX usage
authorRichard Henderson <richard.henderson@linaro.org>
Wed, 1 Nov 2023 03:08:11 +0000 (11:08 +0800)
committerSong Gao <gaosong@loongson.cn>
Fri, 3 Nov 2023 06:13:18 +0000 (14:13 +0800)
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231101030816.2353416-2-gaosong@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
linux-user/loongarch64/cpu_loop.c
target/loongarch/insn_trans/trans_vec.c.inc

index 894fdd111a8b9dbced38b31d986a7cfb9587eb99..73d7b6796a4261a77e73d8504b4ba9a722ae822d 100644 (file)
@@ -72,6 +72,19 @@ void cpu_loop(CPULoongArchState *env)
         case EXCCODE_BCE:
             force_sig_fault(TARGET_SIGSYS, TARGET_SI_KERNEL, env->pc);
             break;
+
+        /*
+         * Begin with LSX and LASX disabled, then enable on the first trap.
+         * In this way we can tell if the unit is in use.  This is used to
+         * choose the layout of any signal frame.
+         */
+        case EXCCODE_SXD:
+            env->CSR_EUEN |= R_CSR_EUEN_SXE_MASK;
+            break;
+        case EXCCODE_ASXD:
+            env->CSR_EUEN |= R_CSR_EUEN_ASXE_MASK;
+            break;
+
         case EXCP_ATOMIC:
             cpu_exec_step_atomic(cs);
             break;
index 98f856bb29c18a7b2cf4d00b9ac0bc72b8d4195e..92b1d22e28934b524a1f6ae6cb2bcbb189de27e3 100644 (file)
@@ -4,8 +4,6 @@
  * Copyright (c) 2022-2023 Loongson Technology Corporation Limited
  */
 
-#ifndef CONFIG_USER_ONLY
-
 static bool check_vec(DisasContext *ctx, uint32_t oprsz)
 {
     if ((oprsz == 16) && ((ctx->base.tb->flags & HW_FLAGS_EUEN_SXE) == 0)) {
@@ -21,15 +19,6 @@ static bool check_vec(DisasContext *ctx, uint32_t oprsz)
     return true;
 }
 
-#else
-
-static bool check_vec(DisasContext *ctx, uint32_t oprsz)
-{
-    return true;
-}
-
-#endif
-
 static bool gen_vvvv_ptr_vl(DisasContext *ctx, arg_vvvv *a, uint32_t oprsz,
                             gen_helper_gvec_4_ptr *fn)
 {