Re: [PATCH v5 05/20] linux-user: mips: Update syscall numbers to kernel 5.5 rc3 level

2020-02-04 Thread Aleksandar Markovic
On Tuesday, February 4, 2020, Laurent Vivier  wrote:

> Le 04/02/2020 à 12:56, Aleksandar Markovic a écrit :
> > On Tue, Jan 14, 2020 at 5:40 PM Laurent Vivier 
> wrote:
> >>
> >> Le 13/01/2020 à 21:34, Aleksandar Markovic a écrit :
> >>> From: Aleksandar Markovic 
> >>>
> >>> Update mips syscall numbers based on Linux kernel tag v5.5-rc3
> >>> (commit 46cf053e).
> >>>
> >>> Signed-off-by: Aleksandar Markovic 
> >>> ---
> >>>  linux-user/mips/cpu_loop.c | 78 ++
> +++-
> >>>  linux-user/mips/syscall_nr.h   | 45 
> >>>  linux-user/mips64/syscall_nr.h | 13 +++
> >>>  3 files changed, 135 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c
> >>> index 39915b3..b81479b 100644
> >>> --- a/linux-user/mips/cpu_loop.c
> >>> +++ b/linux-user/mips/cpu_loop.c
> >>> @@ -25,8 +25,9 @@
> >>>  #include "internal.h"
> >>>
> >>>  # ifdef TARGET_ABI_MIPSO32
> >>> +#  define MIPS_SYSCALL_NUMBER_UNUSED -1
> >>
> >> I'm not sure you need to introduce this change.
> >>
> >> The case already exists (stat, fstat, old_select, lstat, ...) and the
> >> entry that was used is:
> >>
> >>MIPS_SYS(sys_ni_syscall , 0)
> >>
> >> perhaps you can do the same ?
> >>
> >
> > I like better the new way of dealing with this (like in this patch),
> since it is
> > more explicit. For now, I won't change this patch, if you agree, and
> later on
> > I will synchronize all such cases to be the same (but this is not
> critical for
> > the time being).
>
> So Perhaps you can do:
>
> #  define MIPS_SYSCALL_NUMBER_UNUSED 0
>
> And so the real availability of the syscall will be detected in
> do_syscall1() based on a "#ifdef TARGET_" (well, not sure
> syscall_nr.h differentiates O32 and N32)
>
> By the way, do we really need this table?
>
> It seems kernel is always copying 4 words from the stack.
> But kernel code is not really clear, perhaps I'm missing something...
>
>
Yes, Laurent, we actually don't need that table. We could have just a
series of preprocessor constants, like any other ABI, but it would have
required larger code reorganization. It started that way long time ago, and
nobody bothered to correct this, partially for sure because of fear of
regressions.

I am not in the mood for refactoring this area of code right now in any
substantial way, until the situation stabilizes with new syscalls. The
current solution in this patch is good enough for me, and it is not that
intrusive, which I like. Please accept it as is, and the time for
refactoring will hopefully come at some later point of time.

I prefer several incremental smaller refactoring to one large one. I'll
take into account all your suggestions and hints.

Thanks, Aleksandar


> In the end, as you are the MIPS maintainer, you can choose the solution
> you prefer.
>
> Thanks,
> Laurent
>


Re: [PATCH v5 05/20] linux-user: mips: Update syscall numbers to kernel 5.5 rc3 level

2020-02-04 Thread Laurent Vivier
Le 04/02/2020 à 12:56, Aleksandar Markovic a écrit :
> On Tue, Jan 14, 2020 at 5:40 PM Laurent Vivier  wrote:
>>
>> Le 13/01/2020 à 21:34, Aleksandar Markovic a écrit :
>>> From: Aleksandar Markovic 
>>>
>>> Update mips syscall numbers based on Linux kernel tag v5.5-rc3
>>> (commit 46cf053e).
>>>
>>> Signed-off-by: Aleksandar Markovic 
>>> ---
>>>  linux-user/mips/cpu_loop.c | 78 
>>> +-
>>>  linux-user/mips/syscall_nr.h   | 45 
>>>  linux-user/mips64/syscall_nr.h | 13 +++
>>>  3 files changed, 135 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c
>>> index 39915b3..b81479b 100644
>>> --- a/linux-user/mips/cpu_loop.c
>>> +++ b/linux-user/mips/cpu_loop.c
>>> @@ -25,8 +25,9 @@
>>>  #include "internal.h"
>>>
>>>  # ifdef TARGET_ABI_MIPSO32
>>> +#  define MIPS_SYSCALL_NUMBER_UNUSED -1
>>
>> I'm not sure you need to introduce this change.
>>
>> The case already exists (stat, fstat, old_select, lstat, ...) and the
>> entry that was used is:
>>
>>MIPS_SYS(sys_ni_syscall , 0)
>>
>> perhaps you can do the same ?
>>
> 
> I like better the new way of dealing with this (like in this patch), since it 
> is
> more explicit. For now, I won't change this patch, if you agree, and later on
> I will synchronize all such cases to be the same (but this is not critical for
> the time being).

So Perhaps you can do:

#  define MIPS_SYSCALL_NUMBER_UNUSED 0

And so the real availability of the syscall will be detected in
do_syscall1() based on a "#ifdef TARGET_" (well, not sure
syscall_nr.h differentiates O32 and N32)

By the way, do we really need this table?

It seems kernel is always copying 4 words from the stack.
But kernel code is not really clear, perhaps I'm missing something...

In the end, as you are the MIPS maintainer, you can choose the solution
you prefer.

Thanks,
Laurent



Re: [PATCH v5 05/20] linux-user: mips: Update syscall numbers to kernel 5.5 rc3 level

2020-02-04 Thread Aleksandar Markovic
On Tue, Jan 14, 2020 at 5:40 PM Laurent Vivier  wrote:
>
> Le 13/01/2020 à 21:34, Aleksandar Markovic a écrit :
> > From: Aleksandar Markovic 
> >
> > Update mips syscall numbers based on Linux kernel tag v5.5-rc3
> > (commit 46cf053e).
> >
> > Signed-off-by: Aleksandar Markovic 
> > ---
> >  linux-user/mips/cpu_loop.c | 78 
> > +-
> >  linux-user/mips/syscall_nr.h   | 45 
> >  linux-user/mips64/syscall_nr.h | 13 +++
> >  3 files changed, 135 insertions(+), 1 deletion(-)
> >
> > diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c
> > index 39915b3..b81479b 100644
> > --- a/linux-user/mips/cpu_loop.c
> > +++ b/linux-user/mips/cpu_loop.c
> > @@ -25,8 +25,9 @@
> >  #include "internal.h"
> >
> >  # ifdef TARGET_ABI_MIPSO32
> > +#  define MIPS_SYSCALL_NUMBER_UNUSED -1
>
> I'm not sure you need to introduce this change.
>
> The case already exists (stat, fstat, old_select, lstat, ...) and the
> entry that was used is:
>
>MIPS_SYS(sys_ni_syscall , 0)
>
> perhaps you can do the same ?
>

I like better the new way of dealing with this (like in this patch), since it is
more explicit. For now, I won't change this patch, if you agree, and later on
I will synchronize all such cases to be the same (but this is not critical for
the time being).

Yours,
Aleksandar

> I think the do_syscall() will return -ENOSYS as the TARGET_NR_XXX is not
> defined for o32 in linux-user/mips/syscall_nr.h.
>
> Thanks,
> Laurent
>



Re: [PATCH v5 05/20] linux-user: mips: Update syscall numbers to kernel 5.5 rc3 level

2020-01-14 Thread Laurent Vivier
Le 13/01/2020 à 21:34, Aleksandar Markovic a écrit :
> From: Aleksandar Markovic 
> 
> Update mips syscall numbers based on Linux kernel tag v5.5-rc3
> (commit 46cf053e).
> 
> Signed-off-by: Aleksandar Markovic 
> ---
>  linux-user/mips/cpu_loop.c | 78 
> +-
>  linux-user/mips/syscall_nr.h   | 45 
>  linux-user/mips64/syscall_nr.h | 13 +++
>  3 files changed, 135 insertions(+), 1 deletion(-)
> 
> diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c
> index 39915b3..b81479b 100644
> --- a/linux-user/mips/cpu_loop.c
> +++ b/linux-user/mips/cpu_loop.c
> @@ -25,8 +25,9 @@
>  #include "internal.h"
>  
>  # ifdef TARGET_ABI_MIPSO32
> +#  define MIPS_SYSCALL_NUMBER_UNUSED -1

I'm not sure you need to introduce this change.

The case already exists (stat, fstat, old_select, lstat, ...) and the
entry that was used is:

   MIPS_SYS(sys_ni_syscall , 0)

perhaps you can do the same ?

I think the do_syscall() will return -ENOSYS as the TARGET_NR_XXX is not
defined for o32 in linux-user/mips/syscall_nr.h.

Thanks,
Laurent



[PATCH v5 05/20] linux-user: mips: Update syscall numbers to kernel 5.5 rc3 level

2020-01-13 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Update mips syscall numbers based on Linux kernel tag v5.5-rc3
(commit 46cf053e).

Signed-off-by: Aleksandar Markovic 
---
 linux-user/mips/cpu_loop.c | 78 +-
 linux-user/mips/syscall_nr.h   | 45 
 linux-user/mips64/syscall_nr.h | 13 +++
 3 files changed, 135 insertions(+), 1 deletion(-)

diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c
index 39915b3..b81479b 100644
--- a/linux-user/mips/cpu_loop.c
+++ b/linux-user/mips/cpu_loop.c
@@ -25,8 +25,9 @@
 #include "internal.h"
 
 # ifdef TARGET_ABI_MIPSO32
+#  define MIPS_SYSCALL_NUMBER_UNUSED -1
 #  define MIPS_SYS(name, args) args,
-static const uint8_t mips_syscall_args[] = {
+static const int8_t mips_syscall_args[] = {
 MIPS_SYS(sys_syscall, 8)/* 4000 */
 MIPS_SYS(sys_exit   , 1)
 MIPS_SYS(sys_fork   , 0)
@@ -390,6 +391,75 @@ static const uint8_t mips_syscall_args[] = {
 MIPS_SYS(sys_copy_file_range, 6) /* 360 */
 MIPS_SYS(sys_preadv2, 6)
 MIPS_SYS(sys_pwritev2, 6)
+MIPS_SYS(sys_pkey_mprotect, 4)
+MIPS_SYS(sys_pkey_alloc, 2)
+MIPS_SYS(sys_pkey_free, 1) /* 365 */
+MIPS_SYS(sys_statx, 5)
+MIPS_SYS(sys_rseq, 4)
+MIPS_SYS(sys_io_pgetevents, 6)
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,/* 370 */
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,/* 375 */
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,/* 380 */
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,/* 385 */
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,/* 390 */
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYS(sys_semget, 3)
+MIPS_SYS(sys_semctl, 4)
+MIPS_SYS(sys_shmget, 3)/* 395 */
+MIPS_SYS(sys_shmctl, 3)
+MIPS_SYS(sys_shmat, 3)
+MIPS_SYS(sys_shmdt, 1)
+MIPS_SYS(sys_msgget, 2)
+MIPS_SYS(sys_msgsnd, 4)/* 400 */
+MIPS_SYS(sys_msgrcv, 5)
+MIPS_SYS(sys_msgctl, 3)
+MIPS_SYS(sys_timer_gettime64, 2)
+MIPS_SYS(sys_timer_settime64, 4)
+MIPS_SYS(sys_timerfd_gettime64, 2) /* 410 */
+MIPS_SYS(sys_timerfd_settime64, 4)
+MIPS_SYS(sys_utimensat_time64, 4)
+MIPS_SYS(sys_pselect6_time64, 6)
+MIPS_SYS(sys_ppoll_time64, 5)
+MIPS_SYSCALL_NUMBER_UNUSED,/* 415 */
+MIPS_SYS(sys_io_pgetevents_time64, 6)
+MIPS_SYS(sys_recvmmsg_time64, 5)
+MIPS_SYS(sys_mq_timedsend_time64, 5)
+MIPS_SYS(sys_mq_timedreceive_time64, 5)
+MIPS_SYS(sys_semtimedop_time64, 4) /* 420 */
+MIPS_SYS(sys_rt_sigtimedwait_time64, 4)
+MIPS_SYS(sys_futex_time64, 6)
+MIPS_SYS(sys_sched_rr_get_interval_time64, 2)
+MIPS_SYS(sys_pidfd_send_signal, 4)
+MIPS_SYS(sys_io_uring_setup, 2)/* 425 */
+MIPS_SYS(sys_io_uring_enter, 6)
+MIPS_SYS(sys_io_uring_register, 4)
+MIPS_SYS(sys_open_tree, 3)
+MIPS_SYS(sys_move_mount, 5)
+MIPS_SYS(sys_fsopen, 2)/* 430 */
+MIPS_SYS(sys_fsconfig, 5)
+MIPS_SYS(sys_fsmount, 3)
+MIPS_SYS(sys_fspick, 3)
+MIPS_SYS(sys_pidfd_open, 2)
+MIPS_SYS(sys_clone3, 2)/* 435 */
+
 };
 #  undef MIPS_SYS
 # endif /* O32 */
@@ -447,8 +517,14 @@ void cpu_loop(CPUMIPSState *env)
 # ifdef TARGET_ABI_MIPSO32
 syscall_num = env->active_tc.gpr[2] - 4000;
 if (syscall_num >= sizeof(mips_syscall_args)) {
+/* syscall_num is larger that any defined for MIPS O32 */
+ret = -TARGET_ENOSYS;
+} else if (mips_syscall_args[syscall_num] ==
+   MIPS_SYSCALL_NUMBER_UNUSED) {
+/* syscall_num belongs to the range not defined for MIPS O32 */
 ret = -TARGET_ENOSYS;
 } else {
+/* syscall_num is valid */
 int nb_args;
 abi_ulong sp_reg;
 abi_ulong arg5 = 0, arg6 = 0, arg7 = 0, arg8 = 0;
diff --git a/linux-user/mips/syscall_nr.h b/linux-user/mips/syscall_nr.h
index 7fa7fa5..0be3af1 100644
--- a/linux-user/mips/syscall_nr.h
+++