Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
target/openrisc: Set PC to cpu state on FPU exception
Store the PC to ensure the correct value can be read in the exception
handler.

Signed-off-by: Stafford Horne <shorne@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
stffrdhrn committed May 11, 2023
1 parent 08f021d commit 9156ca7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions target/openrisc/fpu_helper.c
Expand Up @@ -20,8 +20,8 @@

#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/helper-proto.h"
#include "exception.h"
#include "fpu/softfloat.h"

static int ieee_ex_to_openrisc(int fexcp)
Expand All @@ -45,6 +45,15 @@ static int ieee_ex_to_openrisc(int fexcp)
return ret;
}

static G_NORETURN
void do_fpe(CPUOpenRISCState *env, uintptr_t pc)
{
CPUState *cs = env_cpu(env);

cs->exception_index = EXCP_FPE;
cpu_loop_exit_restore(cs, pc);
}

void HELPER(update_fpcsr)(CPUOpenRISCState *env)
{
int tmp = get_float_exception_flags(&env->fp_status);
Expand All @@ -55,7 +64,7 @@ void HELPER(update_fpcsr)(CPUOpenRISCState *env)
if (tmp) {
env->fpcsr |= tmp;
if (env->fpcsr & FPCSR_FPEE) {
helper_exception(env, EXCP_FPE);
do_fpe(env, GETPC());
}
}
}
Expand Down

0 comments on commit 9156ca7

Please sign in to comment.