aboutsummaryrefslogtreecommitdiff
path: root/linux-user/microblaze/cpu_loop.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2022-01-12 11:51:47 +0000
committerPeter Maydell <peter.maydell@linaro.org>2022-01-12 11:51:47 +0000
commit91f5f7a5df1fda8c34677a7c49ee8a4bb5b56a36 (patch)
tree5cd77f7883bbebf37e2a70a78a91d6f03091e23a /linux-user/microblaze/cpu_loop.c
parentb37778b840f6dc6d1bbaf0e8e0641b3d48ad77c5 (diff)
parent4f4e5567f856d9b841494b3b5216a37d2952ee54 (diff)
Merge remote-tracking branch 'remotes/lvivier-gitlab/tags/linux-user-for-7.0-pull-request' into staging
linux-user pull request 20220111 siginfo_t cleanup more prtctl() update target_struct.h cleanup # gpg: Signature made Tue 11 Jan 2022 19:52:20 GMT # gpg: using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C # gpg: issuer "laurent@vivier.eu" # gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full] # gpg: aka "Laurent Vivier <laurent@vivier.eu>" [full] # gpg: aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full] # Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F 5173 F30C 38BD 3F2F BE3C * remotes/lvivier-gitlab/tags/linux-user-for-7.0-pull-request: (30 commits) linux-user: Implement capability prctls linux-user: Implement PR_SET_PDEATHSIG linux-user: Map signal number in PR_GET_PDEATHSIG linux-user: Do not special-case NULL for PR_GET_PDEATHSIG linux-user: Move target_struct.h generic definitions to generic/ linux-user/arm: Move target_oabi_flock64 out of target_structs.h linux-user/xtensa: Use force_sig_fault linux-user/sparc: Use force_sig_fault linux-user/sh4: Use force_sig_fault linux-user/s390x: Use force_sig_fault linux-user/riscv: Use force_sig_fault linux-user/ppc: Use force_sig_fault linux-user/openrisc: Use force_sig_fault target/mips: Extract trap code into env->error_code target/mips: Extract break code into env->error_code linux-user/mips: Use force_sig_fault linux-user/mips: Improve do_break linux-user/microblaze: Fix SIGFPE si_codes linux-user/microblaze: Use force_sig_fault linux-user/m68k: Use force_sig_fault ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'linux-user/microblaze/cpu_loop.c')
-rw-r--r--linux-user/microblaze/cpu_loop.c71
1 files changed, 35 insertions, 36 deletions
diff --git a/linux-user/microblaze/cpu_loop.c b/linux-user/microblaze/cpu_loop.c
index ff1fb26c8b..1a2556be2c 100644
--- a/linux-user/microblaze/cpu_loop.c
+++ b/linux-user/microblaze/cpu_loop.c
@@ -27,9 +27,8 @@
void cpu_loop(CPUMBState *env)
{
CPUState *cs = env_cpu(env);
- int trapnr, ret;
- target_siginfo_t info;
-
+ int trapnr, ret, si_code;
+
while (1) {
cpu_exec_start(cs);
trapnr = cpu_exec(cs);
@@ -38,8 +37,8 @@ void cpu_loop(CPUMBState *env)
switch (trapnr) {
case EXCP_INTERRUPT:
- /* just indicate that signals should be handled asap */
- break;
+ /* just indicate that signals should be handled asap */
+ break;
case EXCP_SYSCALL:
/* Return address is 4 bytes after the call. */
env->regs[14] += 4;
@@ -67,6 +66,7 @@ void cpu_loop(CPUMBState *env)
*/
env->regs[14] = env->pc;
break;
+
case EXCP_HW_EXCP:
env->regs[17] = env->pc + 4;
if (env->iflags & D_FLAG) {
@@ -74,42 +74,41 @@ void cpu_loop(CPUMBState *env)
env->pc -= 4;
/* FIXME: if branch was immed, replay the imm as well. */
}
-
env->iflags &= ~(IMM_FLAG | D_FLAG);
-
switch (env->esr & 31) {
- case ESR_EC_DIVZERO:
- info.si_signo = TARGET_SIGFPE;
- info.si_errno = 0;
- info.si_code = TARGET_FPE_FLTDIV;
- info._sifields._sigfault._addr = 0;
- queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
- break;
- case ESR_EC_FPU:
- info.si_signo = TARGET_SIGFPE;
- info.si_errno = 0;
- if (env->fsr & FSR_IO) {
- info.si_code = TARGET_FPE_FLTINV;
- }
- if (env->fsr & FSR_DZ) {
- info.si_code = TARGET_FPE_FLTDIV;
- }
- info._sifields._sigfault._addr = 0;
- queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
- break;
- default:
- fprintf(stderr, "Unhandled hw-exception: 0x%x\n",
- env->esr & ESR_EC_MASK);
- cpu_dump_state(cs, stderr, 0);
- exit(EXIT_FAILURE);
- break;
+ case ESR_EC_DIVZERO:
+ si_code = TARGET_FPE_INTDIV;
+ break;
+ case ESR_EC_FPU:
+ /*
+ * Note that the kernel passes along fsr as si_code
+ * if there's no recognized bit set. Possibly this
+ * implies that si_code is 0, but follow the structure.
+ */
+ si_code = env->fsr;
+ if (si_code & FSR_IO) {
+ si_code = TARGET_FPE_FLTINV;
+ } else if (si_code & FSR_OF) {
+ si_code = TARGET_FPE_FLTOVF;
+ } else if (si_code & FSR_UF) {
+ si_code = TARGET_FPE_FLTUND;
+ } else if (si_code & FSR_DZ) {
+ si_code = TARGET_FPE_FLTDIV;
+ } else if (si_code & FSR_DO) {
+ si_code = TARGET_FPE_FLTRES;
+ }
+ break;
+ default:
+ fprintf(stderr, "Unhandled hw-exception: 0x%x\n",
+ env->esr & ESR_EC_MASK);
+ cpu_dump_state(cs, stderr, 0);
+ exit(EXIT_FAILURE);
}
+ force_sig_fault(TARGET_SIGFPE, si_code, env->pc);
break;
+
case EXCP_DEBUG:
- info.si_signo = TARGET_SIGTRAP;
- info.si_errno = 0;
- info.si_code = TARGET_TRAP_BRKPT;
- queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+ force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc);
break;
case EXCP_ATOMIC:
cpu_exec_step_atomic(cs);