Message ID | 20170620205121.26515-7-laurent@vivier.eu |
---|---|
State | New |
Headers | show |
On 06/20/2017 01:51 PM, Laurent Vivier wrote:
> + __get_user(env->fpcr, &fpregs->f_fpcntl[0]);
cpu_m68k_set_fpcr
r~
Riku, could you ACK this patch, so I will add it in my next pull request for m68k? Thanks, Laurent Le 20/06/2017 à 22:51, Laurent Vivier a écrit : > Signed-off-by: Laurent Vivier <laurent@vivier.eu> > --- > linux-user/signal.c | 41 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 41 insertions(+) > > diff --git a/linux-user/signal.c b/linux-user/signal.c > index 3d18d1b..d3753e4 100644 > --- a/linux-user/signal.c > +++ b/linux-user/signal.c > @@ -5673,6 +5673,24 @@ give_sigsegv: > force_sigsegv(sig); > } > > +static inline void target_rt_save_fpu_state(struct target_ucontext *uc, > + CPUM68KState *env) > +{ > + int i; > + target_fpregset_t *fpregs = &uc->tuc_mcontext.fpregs; > + > + __put_user(env->fpcr, &fpregs->f_fpcntl[0]); > + __put_user(env->fpsr, &fpregs->f_fpcntl[1]); > + /* fpiar is not emulated */ > + > + for (i = 0; i < 8; i++) { > + uint32_t high = env->fregs[i].d.high << 16; > + __put_user(high, &fpregs->f_fpregs[i * 3]); > + __put_user(env->fregs[i].d.low, > + (uint64_t *)&fpregs->f_fpregs[i * 3 + 1]); > + } > +} > + > static inline int target_rt_setup_ucontext(struct target_ucontext *uc, > CPUM68KState *env) > { > @@ -5699,9 +5717,30 @@ static inline int target_rt_setup_ucontext(struct target_ucontext *uc, > __put_user(env->pc, &gregs[16]); > __put_user(sr, &gregs[17]); > > + target_rt_save_fpu_state(uc, env); > + > return 0; > } > > +static inline void target_rt_restore_fpu_state(CPUM68KState *env, > + struct target_ucontext *uc) > +{ > + int i; > + target_fpregset_t *fpregs = &uc->tuc_mcontext.fpregs; > + > + __get_user(env->fpcr, &fpregs->f_fpcntl[0]); > + __get_user(env->fpsr, &fpregs->f_fpcntl[1]); > + /* fpiar is not emulated */ > + > + for (i = 0; i < 8; i++) { > + uint32_t high; > + __get_user(high, &fpregs->f_fpregs[i * 3]); > + env->fregs[i].d.high = high >> 16; > + __get_user(env->fregs[i].d.low, > + (uint64_t *)&fpregs->f_fpregs[i * 3 + 1]); > + } > +} > + > static inline int target_rt_restore_ucontext(CPUM68KState *env, > struct target_ucontext *uc) > { > @@ -5733,6 +5772,8 @@ static inline int target_rt_restore_ucontext(CPUM68KState *env, > __get_user(temp, &gregs[17]); > cpu_m68k_set_ccr(env, temp); > > + target_rt_restore_fpu_state(env, uc); > + > return 0; > > badframe: >
On Wed, Jun 28, 2017 at 10:44:57PM +0200, Laurent Vivier wrote: > Riku, > > could you ACK this patch, so I will add it in my next pull request for m68k? Whatabout Richard's comment about using cpu_m68k_set_fpcr ? Riku > Thanks, > Laurent > > Le 20/06/2017 à 22:51, Laurent Vivier a écrit : > > Signed-off-by: Laurent Vivier <laurent@vivier.eu> > > --- > > linux-user/signal.c | 41 +++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 41 insertions(+) > > > > diff --git a/linux-user/signal.c b/linux-user/signal.c > > index 3d18d1b..d3753e4 100644 > > --- a/linux-user/signal.c > > +++ b/linux-user/signal.c > > @@ -5673,6 +5673,24 @@ give_sigsegv: > > force_sigsegv(sig); > > } > > > > +static inline void target_rt_save_fpu_state(struct target_ucontext *uc, > > + CPUM68KState *env) > > +{ > > + int i; > > + target_fpregset_t *fpregs = &uc->tuc_mcontext.fpregs; > > + > > + __put_user(env->fpcr, &fpregs->f_fpcntl[0]); > > + __put_user(env->fpsr, &fpregs->f_fpcntl[1]); > > + /* fpiar is not emulated */ > > + > > + for (i = 0; i < 8; i++) { > > + uint32_t high = env->fregs[i].d.high << 16; > > + __put_user(high, &fpregs->f_fpregs[i * 3]); > > + __put_user(env->fregs[i].d.low, > > + (uint64_t *)&fpregs->f_fpregs[i * 3 + 1]); > > + } > > +} > > + > > static inline int target_rt_setup_ucontext(struct target_ucontext *uc, > > CPUM68KState *env) > > { > > @@ -5699,9 +5717,30 @@ static inline int target_rt_setup_ucontext(struct target_ucontext *uc, > > __put_user(env->pc, &gregs[16]); > > __put_user(sr, &gregs[17]); > > > > + target_rt_save_fpu_state(uc, env); > > + > > return 0; > > } > > > > +static inline void target_rt_restore_fpu_state(CPUM68KState *env, > > + struct target_ucontext *uc) > > +{ > > + int i; > > + target_fpregset_t *fpregs = &uc->tuc_mcontext.fpregs; > > + > > + __get_user(env->fpcr, &fpregs->f_fpcntl[0]); > > + __get_user(env->fpsr, &fpregs->f_fpcntl[1]); > > + /* fpiar is not emulated */ > > + > > + for (i = 0; i < 8; i++) { > > + uint32_t high; > > + __get_user(high, &fpregs->f_fpregs[i * 3]); > > + env->fregs[i].d.high = high >> 16; > > + __get_user(env->fregs[i].d.low, > > + (uint64_t *)&fpregs->f_fpregs[i * 3 + 1]); > > + } > > +} > > + > > static inline int target_rt_restore_ucontext(CPUM68KState *env, > > struct target_ucontext *uc) > > { > > @@ -5733,6 +5772,8 @@ static inline int target_rt_restore_ucontext(CPUM68KState *env, > > __get_user(temp, &gregs[17]); > > cpu_m68k_set_ccr(env, temp); > > > > + target_rt_restore_fpu_state(env, uc); > > + > > return 0; > > > > badframe: > > >
Le 29/06/2017 à 15:46, Riku Voipio a écrit : > On Wed, Jun 28, 2017 at 10:44:57PM +0200, Laurent Vivier wrote: >> Riku, >> >> could you ACK this patch, so I will add it in my next pull request for m68k? > > Whatabout Richard's comment about using cpu_m68k_set_fpcr ? You're right. I've fixed it my tree and forgotten to send it. I'm going to resend it. Thanks, Laurent
Le 29/06/2017 à 16:11, Laurent Vivier a écrit : > Le 29/06/2017 à 15:46, Riku Voipio a écrit : >> On Wed, Jun 28, 2017 at 10:44:57PM +0200, Laurent Vivier wrote: >>> Riku, >>> >>> could you ACK this patch, so I will add it in my next pull request for m68k? >> >> Whatabout Richard's comment about using cpu_m68k_set_fpcr ? > > You're right. I've fixed it my tree and forgotten to send it. > > I'm going to resend it. In fact the patch has been re-sent out of the series: https://lists.gnu.org/archive/html/qemu-devel/2017-06/msg04911.html Thanks, Laurent
diff --git a/linux-user/signal.c b/linux-user/signal.c index 3d18d1b..d3753e4 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -5673,6 +5673,24 @@ give_sigsegv: force_sigsegv(sig); } +static inline void target_rt_save_fpu_state(struct target_ucontext *uc, + CPUM68KState *env) +{ + int i; + target_fpregset_t *fpregs = &uc->tuc_mcontext.fpregs; + + __put_user(env->fpcr, &fpregs->f_fpcntl[0]); + __put_user(env->fpsr, &fpregs->f_fpcntl[1]); + /* fpiar is not emulated */ + + for (i = 0; i < 8; i++) { + uint32_t high = env->fregs[i].d.high << 16; + __put_user(high, &fpregs->f_fpregs[i * 3]); + __put_user(env->fregs[i].d.low, + (uint64_t *)&fpregs->f_fpregs[i * 3 + 1]); + } +} + static inline int target_rt_setup_ucontext(struct target_ucontext *uc, CPUM68KState *env) { @@ -5699,9 +5717,30 @@ static inline int target_rt_setup_ucontext(struct target_ucontext *uc, __put_user(env->pc, &gregs[16]); __put_user(sr, &gregs[17]); + target_rt_save_fpu_state(uc, env); + return 0; } +static inline void target_rt_restore_fpu_state(CPUM68KState *env, + struct target_ucontext *uc) +{ + int i; + target_fpregset_t *fpregs = &uc->tuc_mcontext.fpregs; + + __get_user(env->fpcr, &fpregs->f_fpcntl[0]); + __get_user(env->fpsr, &fpregs->f_fpcntl[1]); + /* fpiar is not emulated */ + + for (i = 0; i < 8; i++) { + uint32_t high; + __get_user(high, &fpregs->f_fpregs[i * 3]); + env->fregs[i].d.high = high >> 16; + __get_user(env->fregs[i].d.low, + (uint64_t *)&fpregs->f_fpregs[i * 3 + 1]); + } +} + static inline int target_rt_restore_ucontext(CPUM68KState *env, struct target_ucontext *uc) { @@ -5733,6 +5772,8 @@ static inline int target_rt_restore_ucontext(CPUM68KState *env, __get_user(temp, &gregs[17]); cpu_m68k_set_ccr(env, temp); + target_rt_restore_fpu_state(env, uc); + return 0; badframe:
Signed-off-by: Laurent Vivier <laurent@vivier.eu> --- linux-user/signal.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)