diff mbox

[33/34] linux-user: Support for restarting system calls for CRIS targets

Message ID 1441497448-32489-34-git-send-email-T.E.Baldwin99@members.leeds.ac.uk
State New
Headers show

Commit Message

Timothy Baldwin Sept. 5, 2015, 11:57 p.m. UTC
Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
---

WARNING - NOT TESTED

 linux-user/cris/syscall.h | 2 ++
 linux-user/main.c         | 6 +++++-
 linux-user/signal.c       | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

Comments

Peter Maydell Sept. 10, 2015, 7:12 p.m. UTC | #1
On 6 September 2015 at 00:57, Timothy E Baldwin
<T.E.Baldwin99@members.leeds.ac.uk> wrote:
> Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
> ---
>
> WARNING - NOT TESTED
>
>  linux-user/cris/syscall.h | 2 ++
>  linux-user/main.c         | 6 +++++-
>  linux-user/signal.c       | 2 +-
>  3 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/cris/syscall.h b/linux-user/cris/syscall.h
> index 2957b0d..29218e2 100644
> --- a/linux-user/cris/syscall.h
> +++ b/linux-user/cris/syscall.h
> @@ -44,3 +44,5 @@ struct target_pt_regs {
>  #define TARGET_MLOCKALL_MCL_FUTURE  2
>
>  #endif
> +
> +#define TARGET_USE_ERESTARTSYS 1
> diff --git a/linux-user/main.c b/linux-user/main.c
> index a59907e..a9eb15c 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -2878,7 +2878,11 @@ void cpu_loop(CPUCRISState *env)
>                               env->pregs[7],
>                               env->pregs[11],
>                               0, 0);
> -            env->regs[10] = ret;
> +            if (ret == -TARGET_ERESTARTSYS) {
> +                env->pc -= 2;
> +            } else if (ret != -TARGET_QEMU_ESIGRETURN) {
> +                env->regs[10] = ret;
> +            }
>              break;
>          case EXCP_DEBUG:
>              {
> diff --git a/linux-user/signal.c b/linux-user/signal.c
> index e17514e..3741517 100644
> --- a/linux-user/signal.c
> +++ b/linux-user/signal.c
> @@ -3761,7 +3761,7 @@ long do_sigreturn(CPUCRISState *env)
>
>      restore_sigcontext(&frame->sc, env);
>      unlock_user_struct(frame, frame_addr, 0);
> -    return env->regs[10];
> +    return -TARGET_QEMU_ESIGRETURN;
>  badframe:
>      force_sig(TARGET_SIGSEGV);
>  }

Looks OK, but this one I'm not sure enough about the CRIS instruction
set and the surrounding code doesn't clarify. Edgar -- is the CRIS
instruction for "take linux system call" always exactly 2 bytes long?

thanks
-- PMM
Edgar E. Iglesias Sept. 11, 2015, 2:18 p.m. UTC | #2
On Thu, Sep 10, 2015 at 08:12:21PM +0100, Peter Maydell wrote:
> On 6 September 2015 at 00:57, Timothy E Baldwin
> <T.E.Baldwin99@members.leeds.ac.uk> wrote:
> > Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
> > ---
> >
> > WARNING - NOT TESTED
> >
> >  linux-user/cris/syscall.h | 2 ++
> >  linux-user/main.c         | 6 +++++-
> >  linux-user/signal.c       | 2 +-
> >  3 files changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/linux-user/cris/syscall.h b/linux-user/cris/syscall.h
> > index 2957b0d..29218e2 100644
> > --- a/linux-user/cris/syscall.h
> > +++ b/linux-user/cris/syscall.h
> > @@ -44,3 +44,5 @@ struct target_pt_regs {
> >  #define TARGET_MLOCKALL_MCL_FUTURE  2
> >
> >  #endif
> > +
> > +#define TARGET_USE_ERESTARTSYS 1
> > diff --git a/linux-user/main.c b/linux-user/main.c
> > index a59907e..a9eb15c 100644
> > --- a/linux-user/main.c
> > +++ b/linux-user/main.c
> > @@ -2878,7 +2878,11 @@ void cpu_loop(CPUCRISState *env)
> >                               env->pregs[7],
> >                               env->pregs[11],
> >                               0, 0);
> > -            env->regs[10] = ret;
> > +            if (ret == -TARGET_ERESTARTSYS) {
> > +                env->pc -= 2;
> > +            } else if (ret != -TARGET_QEMU_ESIGRETURN) {
> > +                env->regs[10] = ret;
> > +            }
> >              break;
> >          case EXCP_DEBUG:
> >              {
> > diff --git a/linux-user/signal.c b/linux-user/signal.c
> > index e17514e..3741517 100644
> > --- a/linux-user/signal.c
> > +++ b/linux-user/signal.c
> > @@ -3761,7 +3761,7 @@ long do_sigreturn(CPUCRISState *env)
> >
> >      restore_sigcontext(&frame->sc, env);
> >      unlock_user_struct(frame, frame_addr, 0);
> > -    return env->regs[10];
> > +    return -TARGET_QEMU_ESIGRETURN;
> >  badframe:
> >      force_sig(TARGET_SIGSEGV);
> >  }
> 
> Looks OK, but this one I'm not sure enough about the CRIS instruction
> set and the surrounding code doesn't clarify. Edgar -- is the CRIS
> instruction for "take linux system call" always exactly 2 bytes long?
>

Yes, those are always 2 bytes.

Cheers,
Edgar
Peter Maydell Sept. 11, 2015, 2:20 p.m. UTC | #3
On 11 September 2015 at 15:18, Edgar E. Iglesias
<edgar.iglesias@xilinx.com> wrote:
> On Thu, Sep 10, 2015 at 08:12:21PM +0100, Peter Maydell wrote:
>> On 6 September 2015 at 00:57, Timothy E Baldwin
>> <T.E.Baldwin99@members.leeds.ac.uk> wrote:
>> > Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
>> > ---
>> >
>> > WARNING - NOT TESTED
>> >
>> >  linux-user/cris/syscall.h | 2 ++
>> >  linux-user/main.c         | 6 +++++-
>> >  linux-user/signal.c       | 2 +-
>> >  3 files changed, 8 insertions(+), 2 deletions(-)


>> Looks OK, but this one I'm not sure enough about the CRIS instruction
>> set and the surrounding code doesn't clarify. Edgar -- is the CRIS
>> instruction for "take linux system call" always exactly 2 bytes long?
>>
>
> Yes, those are always 2 bytes.

Cool. In that case
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM
Edgar E. Iglesias Sept. 11, 2015, 2:26 p.m. UTC | #4
On Fri, Sep 11, 2015 at 03:20:31PM +0100, Peter Maydell wrote:
> On 11 September 2015 at 15:18, Edgar E. Iglesias
> <edgar.iglesias@xilinx.com> wrote:
> > On Thu, Sep 10, 2015 at 08:12:21PM +0100, Peter Maydell wrote:
> >> On 6 September 2015 at 00:57, Timothy E Baldwin
> >> <T.E.Baldwin99@members.leeds.ac.uk> wrote:
> >> > Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
> >> > ---
> >> >
> >> > WARNING - NOT TESTED
> >> >
> >> >  linux-user/cris/syscall.h | 2 ++
> >> >  linux-user/main.c         | 6 +++++-
> >> >  linux-user/signal.c       | 2 +-
> >> >  3 files changed, 8 insertions(+), 2 deletions(-)
> 
> 
> >> Looks OK, but this one I'm not sure enough about the CRIS instruction
> >> set and the surrounding code doesn't clarify. Edgar -- is the CRIS
> >> instruction for "take linux system call" always exactly 2 bytes long?
> >>
> >
> > Yes, those are always 2 bytes.
> 
> Cool. In that case
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>

Thanks, me too:

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
diff mbox

Patch

diff --git a/linux-user/cris/syscall.h b/linux-user/cris/syscall.h
index 2957b0d..29218e2 100644
--- a/linux-user/cris/syscall.h
+++ b/linux-user/cris/syscall.h
@@ -44,3 +44,5 @@  struct target_pt_regs {
 #define TARGET_MLOCKALL_MCL_FUTURE  2
 
 #endif
+
+#define TARGET_USE_ERESTARTSYS 1
diff --git a/linux-user/main.c b/linux-user/main.c
index a59907e..a9eb15c 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2878,7 +2878,11 @@  void cpu_loop(CPUCRISState *env)
                              env->pregs[7], 
                              env->pregs[11],
                              0, 0);
-            env->regs[10] = ret;
+            if (ret == -TARGET_ERESTARTSYS) {
+                env->pc -= 2;
+            } else if (ret != -TARGET_QEMU_ESIGRETURN) {
+                env->regs[10] = ret;
+            }
             break;
         case EXCP_DEBUG:
             {
diff --git a/linux-user/signal.c b/linux-user/signal.c
index e17514e..3741517 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -3761,7 +3761,7 @@  long do_sigreturn(CPUCRISState *env)
 
     restore_sigcontext(&frame->sc, env);
     unlock_user_struct(frame, frame_addr, 0);
-    return env->regs[10];
+    return -TARGET_QEMU_ESIGRETURN;
 badframe:
     force_sig(TARGET_SIGSEGV);
 }