diff mbox series

[2/3] target/openrisc: Set PC to cpu state on FPU exception

Message ID 20230502185731.3543420-3-shorne@gmail.com (mailing list archive)
State New, archived
Headers show
Series OpenRISC updates for user space FPU | expand

Commit Message

Stafford Horne May 2, 2023, 6:57 p.m. UTC
Store the PC to ensure the correct value can be read in the exception
handler.

Signed-off-by: Stafford Horne <shorne@gmail.com>
---
 target/openrisc/fpu_helper.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Richard Henderson May 3, 2023, 7:36 a.m. UTC | #1
On 5/2/23 19:57, Stafford Horne wrote:
> @@ -55,6 +56,9 @@ void HELPER(update_fpcsr)(CPUOpenRISCState *env)
>           if (tmp) {
>               env->fpcsr |= tmp;
>               if (env->fpcsr & FPCSR_FPEE) {
> +                CPUState *cs = env_cpu(env);
> +
> +                cpu_restore_state(cs, GETPC());
>                   helper_exception(env, EXCP_FPE);

Better to mirror do_range().

r~
Stafford Horne May 3, 2023, 9:12 a.m. UTC | #2
On Wed, May 03, 2023 at 08:36:13AM +0100, Richard Henderson wrote:
> On 5/2/23 19:57, Stafford Horne wrote:
> > @@ -55,6 +56,9 @@ void HELPER(update_fpcsr)(CPUOpenRISCState *env)
> >           if (tmp) {
> >               env->fpcsr |= tmp;
> >               if (env->fpcsr & FPCSR_FPEE) {
> > +                CPUState *cs = env_cpu(env);
> > +
> > +                cpu_restore_state(cs, GETPC());
> >                   helper_exception(env, EXCP_FPE);
> 
> Better to mirror do_range().

OK.
diff mbox series

Patch

diff --git a/target/openrisc/fpu_helper.c b/target/openrisc/fpu_helper.c
index f9e34fa2cc..1feebb9ac7 100644
--- a/target/openrisc/fpu_helper.c
+++ b/target/openrisc/fpu_helper.c
@@ -20,6 +20,7 @@ 
 
 #include "qemu/osdep.h"
 #include "cpu.h"
+#include "exec/exec-all.h"
 #include "exec/helper-proto.h"
 #include "exception.h"
 #include "fpu/softfloat.h"
@@ -55,6 +56,9 @@  void HELPER(update_fpcsr)(CPUOpenRISCState *env)
         if (tmp) {
             env->fpcsr |= tmp;
             if (env->fpcsr & FPCSR_FPEE) {
+                CPUState *cs = env_cpu(env);
+
+                cpu_restore_state(cs, GETPC());
                 helper_exception(env, EXCP_FPE);
             }
         }