Skip to content

Commit

Permalink
target/loongarch: Add CHECK_SXE maccro for check LSX enable
Browse files Browse the repository at this point in the history
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20230504122810.4094787-4-gaosong@loongson.cn>
  • Loading branch information
gaosong-loongson committed May 6, 2023
1 parent a0c9400 commit a3f3db5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions target/loongarch/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static const char * const excp_names[] = {
[EXCCODE_FPE] = "Floating Point Exception",
[EXCCODE_DBP] = "Debug breakpoint",
[EXCCODE_BCE] = "Bound Check Exception",
[EXCCODE_SXD] = "128 bit vector instructions Disable exception",
};

const char *loongarch_exception_name(int32_t exception)
Expand Down Expand Up @@ -187,6 +188,7 @@ static void loongarch_cpu_do_interrupt(CPUState *cs)
case EXCCODE_FPD:
case EXCCODE_FPE:
case EXCCODE_BCE:
case EXCCODE_SXD:
env->CSR_BADV = env->pc;
QEMU_FALLTHROUGH;
case EXCCODE_ADEM:
Expand Down
2 changes: 2 additions & 0 deletions target/loongarch/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ static inline int cpu_mmu_index(CPULoongArchState *env, bool ifetch)
#define HW_FLAGS_PLV_MASK R_CSR_CRMD_PLV_MASK /* 0x03 */
#define HW_FLAGS_CRMD_PG R_CSR_CRMD_PG_MASK /* 0x10 */
#define HW_FLAGS_EUEN_FPE 0x04
#define HW_FLAGS_EUEN_SXE 0x08

static inline void cpu_get_tb_cpu_state(CPULoongArchState *env,
target_ulong *pc,
Expand All @@ -429,6 +430,7 @@ static inline void cpu_get_tb_cpu_state(CPULoongArchState *env,
*cs_base = 0;
*flags = env->CSR_CRMD & (R_CSR_CRMD_PLV_MASK | R_CSR_CRMD_PG_MASK);
*flags |= FIELD_EX64(env->CSR_EUEN, CSR_EUEN, FPE) * HW_FLAGS_EUEN_FPE;
*flags |= FIELD_EX64(env->CSR_EUEN, CSR_EUEN, SXE) * HW_FLAGS_EUEN_SXE;
}

void loongarch_cpu_list(void);
Expand Down
11 changes: 11 additions & 0 deletions target/loongarch/insn_trans/trans_lsx.c.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@
* LSX translate functions
* Copyright (c) 2022-2023 Loongson Technology Corporation Limited
*/

#ifndef CONFIG_USER_ONLY
#define CHECK_SXE do { \
if ((ctx->base.tb->flags & HW_FLAGS_EUEN_SXE) == 0) { \
generate_exception(ctx, EXCCODE_SXD); \
return true; \
} \
} while (0)
#else
#define CHECK_SXE
#endif

0 comments on commit a3f3db5

Please sign in to comment.