Skip to content

Commit 5f119c6

Browse files
hdellerMichael Tokarev
authored andcommitted
linux-user/hppa: Send proper si_code on SIGFPE exception
Improve the linux-user emulation to send the correct si_code depending on overflow (TARGET_FPE_FLTOVF), underflow (TARGET_FPE_FLTUND), ... Note that the hardware stores the relevant flags in FP exception register #1, which is actually the lower 32-bits of the 64-bit fr[0] register in qemu. Signed-off-by: Helge Deller <[email protected]> (cherry picked from commit b4b49cf) Signed-off-by: Michael Tokarev <[email protected]>
1 parent 679450c commit 5f119c6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

linux-user/hppa/cpu_loop.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static abi_ulong hppa_lws(CPUHPPAState *env)
112112
void cpu_loop(CPUHPPAState *env)
113113
{
114114
CPUState *cs = env_cpu(env);
115-
abi_ulong ret;
115+
abi_ulong ret, si_code = 0;
116116
int trapnr;
117117

118118
while (1) {
@@ -169,7 +169,15 @@ void cpu_loop(CPUHPPAState *env)
169169
force_sig_fault(TARGET_SIGFPE, TARGET_FPE_CONDTRAP, env->iaoq_f);
170170
break;
171171
case EXCP_ASSIST:
172-
force_sig_fault(TARGET_SIGFPE, 0, env->iaoq_f);
172+
#define set_si_code(mask, val) \
173+
if (env->fr[0] & mask) { si_code = val; }
174+
set_si_code(R_FPSR_FLG_I_MASK, TARGET_FPE_FLTRES);
175+
set_si_code(R_FPSR_FLG_U_MASK, TARGET_FPE_FLTUND);
176+
set_si_code(R_FPSR_FLG_O_MASK, TARGET_FPE_FLTOVF);
177+
set_si_code(R_FPSR_FLG_Z_MASK, TARGET_FPE_FLTDIV);
178+
set_si_code(R_FPSR_FLG_V_MASK, TARGET_FPE_FLTINV);
179+
#undef set_si_code
180+
force_sig_fault(TARGET_SIGFPE, si_code, env->iaoq_f);
173181
break;
174182
case EXCP_BREAK:
175183
force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->iaoq_f);

0 commit comments

Comments
 (0)