* [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps
@ 2024-08-16 7:23 Richard Henderson
2024-08-16 7:23 ` [PATCH v3 1/6] target/sparc: Restrict STQF to sparcv9 Richard Henderson
` (6 more replies)
0 siblings, 7 replies; 15+ messages in thread
From: Richard Henderson @ 2024-08-16 7:23 UTC (permalink / raw)
To: qemu-devel; +Cc: chauser
Hi Carl,
While digging through the manual to figure out if we were really
doing the right thing raising the fp exception, I found the fpu
exception state machine. I'm not sure it's worth emulating the
fp_exception_pending state, but it's certainly easy enough to
emulate the fp_executing/fp_exception states.
In addition, this simplifies the implementation of STDFQ,
restricts FQ to sparc32 system mode, and handles migration.
Would you please double-check this against your Solaris images?
r~
Carl Hauser (2):
target/sparc: Add FQ and FSR.QNE
target/sparc: Populate sparc32 FQ when raising fp exception
Richard Henderson (4):
target/sparc: Restrict STQF to sparcv9
target/sparc: Add FSR_QNE to tb_flags
target/sparc: Implement STDFQ
target/sparc: Add gen_trap_if_nofpu_fpexception
target/sparc/cpu.h | 30 ++++++++-
target/sparc/fop_helper.c | 4 ++
target/sparc/int32_helper.c | 32 ++++-----
target/sparc/machine.c | 25 +++++++
target/sparc/translate.c | 126 ++++++++++++++++++++++++++----------
target/sparc/insns.decode | 4 +-
6 files changed, 169 insertions(+), 52 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v3 1/6] target/sparc: Restrict STQF to sparcv9
2024-08-16 7:23 [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps Richard Henderson
@ 2024-08-16 7:23 ` Richard Henderson
2024-08-16 7:58 ` Philippe Mathieu-Daudé
2024-08-16 7:23 ` [PATCH v3 2/6] target/sparc: Add FQ and FSR.QNE Richard Henderson
` (5 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Richard Henderson @ 2024-08-16 7:23 UTC (permalink / raw)
To: qemu-devel; +Cc: chauser, qemu-stable
Prior to sparcv9, the same encoding was STDFQ.
Cc: qemu-stable@nongnu.org
Fixes: 06c060d9e5b ("target/sparc: Move simple fp load/store to decodetree")
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/sparc/translate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index 113639083b..c803e8d1ba 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -4521,7 +4521,7 @@ static bool do_st_fpr(DisasContext *dc, arg_r_r_ri_asi *a, MemOp sz)
TRANS(STF, ALL, do_st_fpr, a, MO_32)
TRANS(STDF, ALL, do_st_fpr, a, MO_64)
-TRANS(STQF, ALL, do_st_fpr, a, MO_128)
+TRANS(STQF, 64, do_st_fpr, a, MO_128)
TRANS(STFA, 64, do_st_fpr, a, MO_32)
TRANS(STDFA, 64, do_st_fpr, a, MO_64)
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 2/6] target/sparc: Add FQ and FSR.QNE
2024-08-16 7:23 [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps Richard Henderson
2024-08-16 7:23 ` [PATCH v3 1/6] target/sparc: Restrict STQF to sparcv9 Richard Henderson
@ 2024-08-16 7:23 ` Richard Henderson
2024-08-16 7:23 ` [PATCH v3 3/6] target/sparc: Populate sparc32 FQ when raising fp exception Richard Henderson
` (4 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Richard Henderson @ 2024-08-16 7:23 UTC (permalink / raw)
To: qemu-devel; +Cc: chauser
From: Carl Hauser <chauser@pullman.com>
Add support for, and migrate, a single-entry fp
instruction queue for sparc32.
Signed-off-by: Carl Hauser <chauser@pullman.com>
[rth: Split from a larger patch;
adjust representation with union;
add migration state]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/sparc/cpu.h | 22 ++++++++++++++++++++++
target/sparc/fop_helper.c | 4 ++++
target/sparc/machine.c | 25 +++++++++++++++++++++++++
3 files changed, 51 insertions(+)
diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
index dfd9512a21..9f2bc44722 100644
--- a/target/sparc/cpu.h
+++ b/target/sparc/cpu.h
@@ -184,6 +184,8 @@ enum {
#define FSR_FTT_SEQ_ERROR (4ULL << 14)
#define FSR_FTT_INVAL_FPR (6ULL << 14)
+#define FSR_QNE (1ULL << 13)
+
#define FSR_FCC0_SHIFT 10
#define FSR_FCC1_SHIFT 32
#define FSR_FCC2_SHIFT 34
@@ -438,6 +440,26 @@ struct CPUArchState {
uint32_t fsr_cexc_ftt; /* cexc, ftt */
uint32_t fcc[TARGET_FCCREGS]; /* fcc* */
+#if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY)
+ /*
+ * Single-element FPU fault queue, with address and insn,
+ * packaged into the double-word with which it is stored.
+ */
+ uint32_t fsr_qne; /* qne */
+ union {
+ uint64_t d;
+ struct {
+#if HOST_BIG_ENDIAN
+ uint32_t addr;
+ uint32_t insn;
+#else
+ uint32_t insn;
+ uint32_t addr;
+#endif
+ } s;
+ } fq;
+#endif
+
CPU_DoubleU fpr[TARGET_DPREGS]; /* floating point registers */
uint32_t cwp; /* index of current register window (extracted
from PSR) */
diff --git a/target/sparc/fop_helper.c b/target/sparc/fop_helper.c
index 0b30665b51..b6692382b3 100644
--- a/target/sparc/fop_helper.c
+++ b/target/sparc/fop_helper.c
@@ -545,6 +545,8 @@ target_ulong cpu_get_fsr(CPUSPARCState *env)
fsr |= (uint64_t)env->fcc[1] << FSR_FCC1_SHIFT;
fsr |= (uint64_t)env->fcc[2] << FSR_FCC2_SHIFT;
fsr |= (uint64_t)env->fcc[3] << FSR_FCC3_SHIFT;
+#elif !defined(CONFIG_USER_ONLY)
+ fsr |= env->fsr_qne;
#endif
/* VER is kept completely separate until re-assembly. */
@@ -591,6 +593,8 @@ void cpu_put_fsr(CPUSPARCState *env, target_ulong fsr)
env->fcc[1] = extract64(fsr, FSR_FCC1_SHIFT, 2);
env->fcc[2] = extract64(fsr, FSR_FCC2_SHIFT, 2);
env->fcc[3] = extract64(fsr, FSR_FCC3_SHIFT, 2);
+#elif !defined(CONFIG_USER_ONLY)
+ env->fsr_qne = fsr & FSR_QNE;
#endif
set_fsr_nonsplit(env, fsr);
diff --git a/target/sparc/machine.c b/target/sparc/machine.c
index 48e0cf22f3..222e5709c5 100644
--- a/target/sparc/machine.c
+++ b/target/sparc/machine.c
@@ -143,6 +143,24 @@ static const VMStateInfo vmstate_xcc = {
.get = get_xcc,
.put = put_xcc,
};
+#else
+static bool fq_needed(void *opaque)
+{
+ SPARCCPU *cpu = opaque;
+ return cpu->env.fsr_qne;
+}
+
+static const VMStateDescription vmstate_fq = {
+ .name = "cpu/fq",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = fq_needed,
+ .fields = (const VMStateField[]) {
+ VMSTATE_UINT32(env.fq.s.addr, SPARCCPU),
+ VMSTATE_UINT32(env.fq.s.insn, SPARCCPU),
+ VMSTATE_END_OF_LIST()
+ },
+};
#endif
static int cpu_pre_save(void *opaque)
@@ -265,4 +283,11 @@ const VMStateDescription vmstate_sparc_cpu = {
#endif
VMSTATE_END_OF_LIST()
},
+#ifndef TARGET_SPARC64
+ .subsections = (const VMStateDescription * const []) {
+ &vmstate_fq,
+ NULL
+ },
+#endif
+
};
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 3/6] target/sparc: Populate sparc32 FQ when raising fp exception
2024-08-16 7:23 [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps Richard Henderson
2024-08-16 7:23 ` [PATCH v3 1/6] target/sparc: Restrict STQF to sparcv9 Richard Henderson
2024-08-16 7:23 ` [PATCH v3 2/6] target/sparc: Add FQ and FSR.QNE Richard Henderson
@ 2024-08-16 7:23 ` Richard Henderson
2024-08-16 7:23 ` [PATCH v3 4/6] target/sparc: Add FSR_QNE to tb_flags Richard Henderson
` (3 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Richard Henderson @ 2024-08-16 7:23 UTC (permalink / raw)
To: qemu-devel; +Cc: chauser
From: Carl Hauser <chauser@pullman.com>
Implement a single instruction floating point queue,
populated while delivering an fp exception.
Signed-off-by: Carl Hauser <chauser@pullman.com>
[rth: Split from a larger patch]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/sparc/int32_helper.c | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/target/sparc/int32_helper.c b/target/sparc/int32_helper.c
index 6b7d65b031..fb6f3799c8 100644
--- a/target/sparc/int32_helper.c
+++ b/target/sparc/int32_helper.c
@@ -21,10 +21,10 @@
#include "qemu/main-loop.h"
#include "cpu.h"
#include "trace.h"
+#include "exec/cpu_ldst.h"
#include "exec/log.h"
#include "sysemu/runstate.h"
-
static const char * const excp_names[0x80] = {
[TT_TFAULT] = "Instruction Access Fault",
[TT_ILL_INSN] = "Illegal Instruction",
@@ -116,22 +116,9 @@ void sparc_cpu_do_interrupt(CPUState *cs)
qemu_log("%6d: %s (v=%02x)\n", count, name, intno);
log_cpu_state(cs, 0);
-#if 0
- {
- int i;
- uint8_t *ptr;
-
- qemu_log(" code=");
- ptr = (uint8_t *)env->pc;
- for (i = 0; i < 16; i++) {
- qemu_log(" %02x", ldub(ptr + i));
- }
- qemu_log("\n");
- }
-#endif
count++;
}
-#if !defined(CONFIG_USER_ONLY)
+#ifndef CONFIG_USER_ONLY
if (env->psret == 0) {
if (cs->exception_index == 0x80 &&
env->def.features & CPU_FEATURE_TA0_SHUTDOWN) {
@@ -143,6 +130,21 @@ void sparc_cpu_do_interrupt(CPUState *cs)
}
return;
}
+ if (intno == TT_FP_EXCP) {
+ env->fsr_qne = FSR_QNE;
+ env->fq.s.addr = env->pc;
+ env->fq.s.insn = cpu_ldl_code(env, env->pc);
+ /*
+ * The sparc32 fpu has three states related to exception handling.
+ * The FPop that signals an exception transitions from fp_execute
+ * to fp_exception_pending. A subsequent FPop transitions from
+ * fp_exception_pending to fp_exception, which forces the trap.
+ * We do not model the fp_exception_pending state, but we do need
+ * to advance pc/npc to mimic the delayed trap delivery.
+ */
+ env->pc = env->npc;
+ env->npc = env->npc + 4;
+ }
#endif
env->psret = 0;
cwp = cpu_cwp_dec(env, env->cwp - 1);
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 4/6] target/sparc: Add FSR_QNE to tb_flags
2024-08-16 7:23 [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps Richard Henderson
` (2 preceding siblings ...)
2024-08-16 7:23 ` [PATCH v3 3/6] target/sparc: Populate sparc32 FQ when raising fp exception Richard Henderson
@ 2024-08-16 7:23 ` Richard Henderson
2024-08-16 7:23 ` [PATCH v3 5/6] target/sparc: Implement STDFQ Richard Henderson
` (2 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Richard Henderson @ 2024-08-16 7:23 UTC (permalink / raw)
To: qemu-devel; +Cc: chauser
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/sparc/cpu.h | 8 +++++++-
target/sparc/translate.c | 10 +++++++---
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
index 9f2bc44722..f517e5a383 100644
--- a/target/sparc/cpu.h
+++ b/target/sparc/cpu.h
@@ -744,6 +744,7 @@ trap_state* cpu_tsptr(CPUSPARCState* env);
#define TB_FLAG_AM_ENABLED (1 << 5)
#define TB_FLAG_SUPER (1 << 6)
#define TB_FLAG_HYPER (1 << 7)
+#define TB_FLAG_FSR_QNE (1 << 8)
#define TB_FLAG_ASI_SHIFT 24
static inline void cpu_get_tb_cpu_state(CPUSPARCState *env, vaddr *pc,
@@ -775,7 +776,12 @@ static inline void cpu_get_tb_cpu_state(CPUSPARCState *env, vaddr *pc,
if (env->psref) {
flags |= TB_FLAG_FPU_ENABLED;
}
-#endif
+#ifndef CONFIG_USER_ONLY
+ if (env->fsr_qne) {
+ flags |= TB_FLAG_FSR_QNE;
+ }
+#endif /* !CONFIG_USER_ONLY */
+#endif /* TARGET_SPARC64 */
*pflags = flags;
}
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index c803e8d1ba..eb0158a11d 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -185,6 +185,8 @@ typedef struct DisasContext {
bool supervisor;
#ifdef TARGET_SPARC64
bool hypervisor;
+#else
+ bool fsr_qne;
#endif
#endif
@@ -5596,13 +5598,15 @@ static void sparc_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
dc->address_mask_32bit = tb_am_enabled(dc->base.tb->flags);
#ifndef CONFIG_USER_ONLY
dc->supervisor = (dc->base.tb->flags & TB_FLAG_SUPER) != 0;
+# ifdef TARGET_SPARC64
+ dc->hypervisor = (dc->base.tb->flags & TB_FLAG_HYPER) != 0;
+# else
+ dc->fsr_qne = (dc->base.tb->flags & TB_FLAG_FSR_QNE) != 0;
+# endif
#endif
#ifdef TARGET_SPARC64
dc->fprs_dirty = 0;
dc->asi = (dc->base.tb->flags >> TB_FLAG_ASI_SHIFT) & 0xff;
-#ifndef CONFIG_USER_ONLY
- dc->hypervisor = (dc->base.tb->flags & TB_FLAG_HYPER) != 0;
-#endif
#endif
/*
* if we reach a page boundary, we stop generation so that the
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 5/6] target/sparc: Implement STDFQ
2024-08-16 7:23 [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps Richard Henderson
` (3 preceding siblings ...)
2024-08-16 7:23 ` [PATCH v3 4/6] target/sparc: Add FSR_QNE to tb_flags Richard Henderson
@ 2024-08-16 7:23 ` Richard Henderson
2024-08-16 7:23 ` [PATCH v3 6/6] target/sparc: Add gen_trap_if_nofpu_fpexception Richard Henderson
2024-08-16 21:19 ` [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps Carl Hauser
6 siblings, 0 replies; 15+ messages in thread
From: Richard Henderson @ 2024-08-16 7:23 UTC (permalink / raw)
To: qemu-devel; +Cc: chauser
Invalid encoding of addr should raise TT_ILL_INSN, so
check before supervisor, which might raise TT_PRIV_INSN.
Clear QNE after execution.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/sparc/translate.c | 24 +++++++++++++++++++++++-
target/sparc/insns.decode | 4 ++--
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index eb0158a11d..6d4c0e79c9 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -4531,17 +4531,39 @@ TRANS(STQFA, 64, do_st_fpr, a, MO_128)
static bool trans_STDFQ(DisasContext *dc, arg_STDFQ *a)
{
+ TCGv addr = gen_ldst_addr(dc, a->rs1, a->imm, a->rs2_or_imm);
+
if (!avail_32(dc)) {
return false;
}
+ if (addr == NULL) {
+ return false;
+ }
if (!supervisor(dc)) {
return raise_priv(dc);
}
+#if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY)
if (gen_trap_ifnofpu(dc)) {
return true;
}
- gen_op_fpexception_im(dc, FSR_FTT_SEQ_ERROR);
+ if (dc->fsr_qne) {
+ TCGv_i64 fq = tcg_temp_new_i64();
+
+ /* Store the single element from the queue. */
+ tcg_gen_ld_i64(fq, tcg_env, offsetof(CPUSPARCState, fq.d));
+ tcg_gen_qemu_st_i64(fq, addr, dc->mem_idx, MO_TEUQ | MO_ALIGN_4);
+
+ /* Mark the queue empty, transitioning to fp_execute state. */
+ tcg_gen_st_i32(tcg_constant_i32(0), tcg_env,
+ offsetof(CPUSPARCState, fsr_qne));
+ dc->fsr_qne = 0;
+ } else {
+ gen_op_fpexception_im(dc, FSR_FTT_SEQ_ERROR);
+ }
return true;
+#else
+ qemu_build_not_reached();
+#endif
}
static bool trans_LDFSR(DisasContext *dc, arg_r_r_ri *a)
diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode
index fbcb4f7aef..923f348580 100644
--- a/target/sparc/insns.decode
+++ b/target/sparc/insns.decode
@@ -644,8 +644,8 @@ STF 11 ..... 100100 ..... . ............. @r_r_ri_na
STFSR 11 00000 100101 ..... . ............. @n_r_ri
STXFSR 11 00001 100101 ..... . ............. @n_r_ri
{
- STQF 11 ..... 100110 ..... . ............. @q_r_ri_na
- STDFQ 11 ----- 100110 ----- - -------------
+ STQF 11 ..... 100110 ..... . ............. @q_r_ri_na # v9
+ STDFQ 11 ..... 100110 ..... . ............. @r_r_ri # v7,v8
}
STDF 11 ..... 100111 ..... . ............. @d_r_ri_na
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 6/6] target/sparc: Add gen_trap_if_nofpu_fpexception
2024-08-16 7:23 [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps Richard Henderson
` (4 preceding siblings ...)
2024-08-16 7:23 ` [PATCH v3 5/6] target/sparc: Implement STDFQ Richard Henderson
@ 2024-08-16 7:23 ` Richard Henderson
2024-08-16 21:19 ` [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps Carl Hauser
6 siblings, 0 replies; 15+ messages in thread
From: Richard Henderson @ 2024-08-16 7:23 UTC (permalink / raw)
To: qemu-devel; +Cc: chauser
Model fp_exception state, in which only fp stores are allowed
until such time as the FQ has been flushed.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/sparc/translate.c | 90 +++++++++++++++++++++++++++-------------
1 file changed, 61 insertions(+), 29 deletions(-)
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index 6d4c0e79c9..46eb27c497 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -1465,15 +1465,48 @@ static void gen_op_fpexception_im(DisasContext *dc, int ftt)
gen_exception(dc, TT_FP_EXCP);
}
-static int gen_trap_ifnofpu(DisasContext *dc)
+static bool gen_trap_ifnofpu(DisasContext *dc)
{
#if !defined(CONFIG_USER_ONLY)
if (!dc->fpu_enabled) {
gen_exception(dc, TT_NFPU_INSN);
- return 1;
+ return true;
}
#endif
- return 0;
+ return false;
+}
+
+static bool gen_trap_iffpexception(DisasContext *dc)
+{
+#if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY)
+ /*
+ * There are 3 states for the sparc32 fpu:
+ * Normally the fpu is in fp_execute, and all insns are allowed.
+ * When an exception is signaled, it moves to fp_exception_pending state.
+ * Upon seeing the next FPop, the fpu moves to fp_exception state,
+ * populates the FQ, and generates an fp_exception trap.
+ * The fpu remains in fp_exception state until FQ becomes empty
+ * after execution of a STDFQ instruction. While the fpu is in
+ * fp_exception state, and FPop, fp load or fp branch insn will
+ * return to fp_exception_pending state, set FSR.FTT to sequence_error,
+ * and the insn will not be entered into the FQ.
+ *
+ * In QEMU, we do not model the fp_exception_pending state and
+ * instead populate FQ and raise the exception immediately.
+ * But we can still honor fp_exception state by noticing when
+ * the FQ is not empty.
+ */
+ if (dc->fsr_qne) {
+ gen_op_fpexception_im(dc, FSR_FTT_SEQ_ERROR);
+ return true;
+ }
+#endif
+ return false;
+}
+
+static bool gen_trap_if_nofpu_fpexception(DisasContext *dc)
+{
+ return gen_trap_ifnofpu(dc) || gen_trap_iffpexception(dc);
}
/* asi moves */
@@ -2643,7 +2676,7 @@ static bool do_fbpfcc(DisasContext *dc, arg_bcc *a)
{
DisasCompare cmp;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
gen_fcompare(&cmp, a->cc, a->cond);
@@ -4482,7 +4515,7 @@ static bool do_ld_fpr(DisasContext *dc, arg_r_r_ri_asi *a, MemOp sz)
if (addr == NULL) {
return false;
}
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
if (sz == MO_128 && gen_trap_float128(dc)) {
@@ -4510,6 +4543,7 @@ static bool do_st_fpr(DisasContext *dc, arg_r_r_ri_asi *a, MemOp sz)
if (addr == NULL) {
return false;
}
+ /* Store insns are ok in fp_exception_pending state. */
if (gen_trap_ifnofpu(dc)) {
return true;
}
@@ -4574,7 +4608,7 @@ static bool trans_LDFSR(DisasContext *dc, arg_r_r_ri *a)
if (addr == NULL) {
return false;
}
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
@@ -4598,7 +4632,7 @@ static bool do_ldxfsr(DisasContext *dc, arg_r_r_ri *a, bool entire)
if (addr == NULL) {
return false;
}
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
@@ -4635,6 +4669,7 @@ static bool do_stfsr(DisasContext *dc, arg_r_r_ri *a, MemOp mop)
if (addr == NULL) {
return false;
}
+ /* Store insns are ok in fp_exception_pending state. */
if (gen_trap_ifnofpu(dc)) {
return true;
}
@@ -4677,7 +4712,7 @@ static bool do_ff(DisasContext *dc, arg_r_r *a,
{
TCGv_i32 tmp;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
@@ -4718,7 +4753,7 @@ static bool do_env_ff(DisasContext *dc, arg_r_r *a,
{
TCGv_i32 tmp;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
@@ -4738,7 +4773,7 @@ static bool do_env_fd(DisasContext *dc, arg_r_r *a,
TCGv_i32 dst;
TCGv_i64 src;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
@@ -4758,7 +4793,7 @@ static bool do_dd(DisasContext *dc, arg_r_r *a,
{
TCGv_i64 dst, src;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
@@ -4780,7 +4815,7 @@ static bool do_env_dd(DisasContext *dc, arg_r_r *a,
{
TCGv_i64 dst, src;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
@@ -4820,7 +4855,7 @@ static bool do_env_df(DisasContext *dc, arg_r_r *a,
TCGv_i64 dst;
TCGv_i32 src;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
@@ -4863,7 +4898,7 @@ static bool do_env_qq(DisasContext *dc, arg_r_r *a,
{
TCGv_i128 t;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
if (gen_trap_float128(dc)) {
@@ -4884,7 +4919,7 @@ static bool do_env_fq(DisasContext *dc, arg_r_r *a,
TCGv_i128 src;
TCGv_i32 dst;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
if (gen_trap_float128(dc)) {
@@ -4907,7 +4942,7 @@ static bool do_env_dq(DisasContext *dc, arg_r_r *a,
TCGv_i128 src;
TCGv_i64 dst;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
if (gen_trap_float128(dc)) {
@@ -4930,7 +4965,7 @@ static bool do_env_qf(DisasContext *dc, arg_r_r *a,
TCGv_i32 src;
TCGv_i128 dst;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
if (gen_trap_float128(dc)) {
@@ -4953,10 +4988,7 @@ static bool do_env_qd(DisasContext *dc, arg_r_r *a,
TCGv_i64 src;
TCGv_i128 dst;
- if (gen_trap_ifnofpu(dc)) {
- return true;
- }
- if (gen_trap_float128(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
@@ -5013,7 +5045,7 @@ static bool do_env_fff(DisasContext *dc, arg_r_r_r *a,
{
TCGv_i32 src1, src2;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
@@ -5222,7 +5254,7 @@ static bool do_env_ddd(DisasContext *dc, arg_r_r_r *a,
{
TCGv_i64 dst, src1, src2;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
@@ -5246,7 +5278,7 @@ static bool trans_FsMULd(DisasContext *dc, arg_r_r_r *a)
TCGv_i64 dst;
TCGv_i32 src1, src2;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
if (!(dc->def->features & CPU_FEATURE_FSMULD)) {
@@ -5355,7 +5387,7 @@ static bool do_env_qqq(DisasContext *dc, arg_r_r_r *a,
{
TCGv_i128 src1, src2;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
if (gen_trap_float128(dc)) {
@@ -5379,7 +5411,7 @@ static bool trans_FdMULq(DisasContext *dc, arg_r_r_r *a)
TCGv_i64 src1, src2;
TCGv_i128 dst;
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
if (gen_trap_float128(dc)) {
@@ -5469,7 +5501,7 @@ static bool do_fcmps(DisasContext *dc, arg_FCMPs *a, bool e)
if (avail_32(dc) && a->cc != 0) {
return false;
}
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
@@ -5493,7 +5525,7 @@ static bool do_fcmpd(DisasContext *dc, arg_FCMPd *a, bool e)
if (avail_32(dc) && a->cc != 0) {
return false;
}
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
@@ -5517,7 +5549,7 @@ static bool do_fcmpq(DisasContext *dc, arg_FCMPq *a, bool e)
if (avail_32(dc) && a->cc != 0) {
return false;
}
- if (gen_trap_ifnofpu(dc)) {
+ if (gen_trap_if_nofpu_fpexception(dc)) {
return true;
}
if (gen_trap_float128(dc)) {
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v3 1/6] target/sparc: Restrict STQF to sparcv9
2024-08-16 7:23 ` [PATCH v3 1/6] target/sparc: Restrict STQF to sparcv9 Richard Henderson
@ 2024-08-16 7:58 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-16 7:58 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: chauser, qemu-stable
On 16/8/24 09:23, Richard Henderson wrote:
> Prior to sparcv9, the same encoding was STDFQ.
>
> Cc: qemu-stable@nongnu.org
> Fixes: 06c060d9e5b ("target/sparc: Move simple fp load/store to decodetree")
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> target/sparc/translate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps
2024-08-16 7:23 [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps Richard Henderson
` (5 preceding siblings ...)
2024-08-16 7:23 ` [PATCH v3 6/6] target/sparc: Add gen_trap_if_nofpu_fpexception Richard Henderson
@ 2024-08-16 21:19 ` Carl Hauser
2024-08-16 21:46 ` Carl Hauser
6 siblings, 1 reply; 15+ messages in thread
From: Carl Hauser @ 2024-08-16 21:19 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
[-- Attachment #1: Type: text/html, Size: 4169 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps
2024-08-16 21:19 ` [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps Carl Hauser
@ 2024-08-16 21:46 ` Carl Hauser
2024-08-16 22:05 ` Richard Henderson
0 siblings, 1 reply; 15+ messages in thread
From: Carl Hauser @ 2024-08-16 21:46 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
[-- Attachment #1: Type: text/html, Size: 4711 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps
2024-08-16 21:46 ` Carl Hauser
@ 2024-08-16 22:05 ` Richard Henderson
[not found] ` <a06ebc2a-e67b-49d9-91a8-ae2a7a1d8b9d@pullman.com>
[not found] ` <aa172755-faf8-4587-a4e8-d1cbfdc139b1@pullman.com>
0 siblings, 2 replies; 15+ messages in thread
From: Richard Henderson @ 2024-08-16 22:05 UTC (permalink / raw)
To: Carl Hauser, qemu-devel
On 8/17/24 07:46, Carl Hauser wrote:
> OK, I think the problem is the handling of dc->fsr_qne in trans_STDFQ, lines 4583 and 4593
> -- the code is evaluating dc->fsr_qne at translation time and not at runtime.
That's what patch 4 does, ensure that the runtime value is available at translation time.
r~
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps
[not found] ` <a06ebc2a-e67b-49d9-91a8-ae2a7a1d8b9d@pullman.com>
@ 2024-08-16 23:59 ` Richard Henderson
0 siblings, 0 replies; 15+ messages in thread
From: Richard Henderson @ 2024-08-16 23:59 UTC (permalink / raw)
To: Carl Hauser, qemu-devel
On 8/17/24 08:58, Carl Hauser wrote:
> Yes, but ...
>
> isn't the state of dc->fsr_qne at translation time irrelevant?
No, because patch 4 made it part of the hashed TB state.
It's checked and verified, generating a new TB if state does not match.
> And changing it at
> translation time (line 4593) is dangerous (because it pertains to runtime, not translation
> time); i.e. why is 0 stored at both translation time (4593) and at runtime (4591)?
That keeps the translation time state in sync with the runtime state until the end of the TB.
r~
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps
[not found] ` <aa172755-faf8-4587-a4e8-d1cbfdc139b1@pullman.com>
@ 2024-08-17 0:16 ` Richard Henderson
[not found] ` <275021f0-887c-4de8-a86d-ad9abc83df95@pullman.com>
0 siblings, 1 reply; 15+ messages in thread
From: Richard Henderson @ 2024-08-17 0:16 UTC (permalink / raw)
To: Carl Hauser, qemu-devel
On 8/17/24 09:48, Carl Hauser wrote:
> netbsd panics in the kernel trap handler; unfortunately it does not include the fsr in the
> panic message, but I expect it will be the same as on Solaris.
Ok, I have reproduced this with netbsd 9.3.
I'll have a look.
r~
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps -- CORRECTION
[not found] ` <275021f0-887c-4de8-a86d-ad9abc83df95@pullman.com>
@ 2024-08-19 2:42 ` Richard Henderson
[not found] ` <24c5b02b-c401-4081-aa46-f745592002ca@pullman.com>
0 siblings, 1 reply; 15+ messages in thread
From: Richard Henderson @ 2024-08-19 2:42 UTC (permalink / raw)
To: Carl Hauser, qemu-devel
On 8/18/24 10:03, Carl Hauser wrote:
> I changed translate.c:4597 from return true; to return advance_pc(dc); and it worked.
Whoops, yes indeed. Thanks for the catch.
r~
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps -- CORRECTION
[not found] ` <24c5b02b-c401-4081-aa46-f745592002ca@pullman.com>
@ 2024-08-20 22:16 ` Richard Henderson
0 siblings, 0 replies; 15+ messages in thread
From: Richard Henderson @ 2024-08-20 22:16 UTC (permalink / raw)
To: Carl Hauser, qemu-devel
On 8/21/24 02:59, Carl Hauser wrote:
> Do you want me to submit a patch set fixing this or will you?
I will.
r~
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2024-08-20 22:17 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-16 7:23 [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps Richard Henderson
2024-08-16 7:23 ` [PATCH v3 1/6] target/sparc: Restrict STQF to sparcv9 Richard Henderson
2024-08-16 7:58 ` Philippe Mathieu-Daudé
2024-08-16 7:23 ` [PATCH v3 2/6] target/sparc: Add FQ and FSR.QNE Richard Henderson
2024-08-16 7:23 ` [PATCH v3 3/6] target/sparc: Populate sparc32 FQ when raising fp exception Richard Henderson
2024-08-16 7:23 ` [PATCH v3 4/6] target/sparc: Add FSR_QNE to tb_flags Richard Henderson
2024-08-16 7:23 ` [PATCH v3 5/6] target/sparc: Implement STDFQ Richard Henderson
2024-08-16 7:23 ` [PATCH v3 6/6] target/sparc: Add gen_trap_if_nofpu_fpexception Richard Henderson
2024-08-16 21:19 ` [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps Carl Hauser
2024-08-16 21:46 ` Carl Hauser
2024-08-16 22:05 ` Richard Henderson
[not found] ` <a06ebc2a-e67b-49d9-91a8-ae2a7a1d8b9d@pullman.com>
2024-08-16 23:59 ` Richard Henderson
[not found] ` <aa172755-faf8-4587-a4e8-d1cbfdc139b1@pullman.com>
2024-08-17 0:16 ` Richard Henderson
[not found] ` <275021f0-887c-4de8-a86d-ad9abc83df95@pullman.com>
2024-08-19 2:42 ` [PATCH for-9.2 v3 0/6] target/sparc: emulate floating point queue when raising fp traps -- CORRECTION Richard Henderson
[not found] ` <24c5b02b-c401-4081-aa46-f745592002ca@pullman.com>
2024-08-20 22:16 ` Richard Henderson
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).