Message ID | 20211221025012.1057923-6-richard.henderson@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | linux-user: nios2 fixes | expand |
Le 21/12/2021 à 03:50, Richard Henderson a écrit : > The real kernel will talk about the user PC as EA, > because that's where the hardware will have copied it, > and where it expects to put it to then use ERET. > But qemu does not emulate all of the exception stuff > while emulating user-only. Manipulate PC directly. > > This fixes signal entry and return, and eliminates > some slight confusion from target_cpu_copy_regs. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > linux-user/nios2/cpu_loop.c | 5 +---- > linux-user/nios2/signal.c | 6 +++--- > 2 files changed, 4 insertions(+), 7 deletions(-) > Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Le 21/12/2021 à 03:50, Richard Henderson a écrit : > The real kernel will talk about the user PC as EA, > because that's where the hardware will have copied it, > and where it expects to put it to then use ERET. > But qemu does not emulate all of the exception stuff > while emulating user-only. Manipulate PC directly. > > This fixes signal entry and return, and eliminates > some slight confusion from target_cpu_copy_regs. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > linux-user/nios2/cpu_loop.c | 5 +---- > linux-user/nios2/signal.c | 6 +++--- > 2 files changed, 4 insertions(+), 7 deletions(-) > > diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c > index de0fc63e21..1e93ef34e6 100644 > --- a/linux-user/nios2/cpu_loop.c > +++ b/linux-user/nios2/cpu_loop.c > @@ -155,9 +155,6 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) > env->regs[R_SP] = regs->sp; > env->regs[R_GP] = regs->gp; > env->regs[CR_ESTATUS] = regs->estatus; > - env->regs[R_EA] = regs->ea; > - /* TODO: unsigned long orig_r7; */ > - > - /* Emulate eret when starting thread. */ > env->regs[R_PC] = regs->ea; > + /* TODO: unsigned long orig_r7; */ > } > diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c > index adbffe32e3..20b65aa06e 100644 > --- a/linux-user/nios2/signal.c > +++ b/linux-user/nios2/signal.c > @@ -73,7 +73,7 @@ static void rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env) > __put_user(env->regs[R_RA], &gregs[23]); > __put_user(env->regs[R_FP], &gregs[24]); > __put_user(env->regs[R_GP], &gregs[25]); > - __put_user(env->regs[R_EA], &gregs[27]); > + __put_user(env->regs[R_PC], &gregs[27]); > __put_user(env->regs[R_SP], &gregs[28]); > } > > @@ -122,7 +122,7 @@ static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc, > __get_user(env->regs[R_GP], &gregs[25]); > /* Not really necessary no user settable bits */ > __get_user(temp, &gregs[26]); > - __get_user(env->regs[R_EA], &gregs[27]); > + __get_user(env->regs[R_PC], &gregs[27]); > > __get_user(env->regs[R_RA], &gregs[23]); > __get_user(env->regs[R_SP], &gregs[28]); > @@ -181,7 +181,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, > env->regs[4] = sig; > env->regs[5] = frame_addr + offsetof(struct target_rt_sigframe, info); > env->regs[6] = frame_addr + offsetof(struct target_rt_sigframe, uc); > - env->regs[R_EA] = ka->_sa_handler; > + env->regs[R_PC] = ka->_sa_handler; > > unlock_user_struct(frame, frame_addr, 1); > } Applied to my linux-user-for-7.0 branch. Thanks, Laurent
diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index de0fc63e21..1e93ef34e6 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -155,9 +155,6 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) env->regs[R_SP] = regs->sp; env->regs[R_GP] = regs->gp; env->regs[CR_ESTATUS] = regs->estatus; - env->regs[R_EA] = regs->ea; - /* TODO: unsigned long orig_r7; */ - - /* Emulate eret when starting thread. */ env->regs[R_PC] = regs->ea; + /* TODO: unsigned long orig_r7; */ } diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index adbffe32e3..20b65aa06e 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -73,7 +73,7 @@ static void rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env) __put_user(env->regs[R_RA], &gregs[23]); __put_user(env->regs[R_FP], &gregs[24]); __put_user(env->regs[R_GP], &gregs[25]); - __put_user(env->regs[R_EA], &gregs[27]); + __put_user(env->regs[R_PC], &gregs[27]); __put_user(env->regs[R_SP], &gregs[28]); } @@ -122,7 +122,7 @@ static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc, __get_user(env->regs[R_GP], &gregs[25]); /* Not really necessary no user settable bits */ __get_user(temp, &gregs[26]); - __get_user(env->regs[R_EA], &gregs[27]); + __get_user(env->regs[R_PC], &gregs[27]); __get_user(env->regs[R_RA], &gregs[23]); __get_user(env->regs[R_SP], &gregs[28]); @@ -181,7 +181,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, env->regs[4] = sig; env->regs[5] = frame_addr + offsetof(struct target_rt_sigframe, info); env->regs[6] = frame_addr + offsetof(struct target_rt_sigframe, uc); - env->regs[R_EA] = ka->_sa_handler; + env->regs[R_PC] = ka->_sa_handler; unlock_user_struct(frame, frame_addr, 1); }
The real kernel will talk about the user PC as EA, because that's where the hardware will have copied it, and where it expects to put it to then use ERET. But qemu does not emulate all of the exception stuff while emulating user-only. Manipulate PC directly. This fixes signal entry and return, and eliminates some slight confusion from target_cpu_copy_regs. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- linux-user/nios2/cpu_loop.c | 5 +---- linux-user/nios2/signal.c | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-)