All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: Add getcpu() support
@ 2017-12-28 15:00 Samuel Thibault
  2017-12-28 17:39 ` Laurent Vivier
  0 siblings, 1 reply; 4+ messages in thread
From: Samuel Thibault @ 2017-12-28 15:00 UTC (permalink / raw)
  To: qemu-devel, Riku Voipio, Laurent Vivier; +Cc: Samuel Thibault

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 linux-user/syscall.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8ec7de96ce..bb8cb726f5 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -296,6 +296,8 @@ _syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned int, len,
 #define __NR_sys_sched_setaffinity __NR_sched_setaffinity
 _syscall3(int, sys_sched_setaffinity, pid_t, pid, unsigned int, len,
           unsigned long *, user_mask_ptr);
+#define __NR_sys_getcpu __NR_getcpu
+_syscall3(int, sys_getcpu, unsigned *, cpu, unsigned *, node, void *, tcache);
 _syscall4(int, reboot, int, magic1, int, magic2, unsigned int, cmd,
           void *, arg);
 _syscall2(int, capget, struct __user_cap_header_struct *, header,
@@ -10443,6 +10445,20 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(sys_sched_setaffinity(arg1, mask_size, mask));
         }
         break;
+    case TARGET_NR_getcpu:
+        {
+            unsigned cpu, node;
+            ret = get_errno(sys_getcpu(arg1 ? &cpu : NULL,
+                                       arg2 ? &node : NULL,
+                                       NULL));
+            if (arg1) {
+                put_user(cpu, arg1, abi_uint);
+            }
+            if (arg2) {
+                put_user(node, arg2, abi_uint);
+            }
+        }
+        break;
     case TARGET_NR_sched_setparam:
         {
             struct sched_param *target_schp;
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: Add getcpu() support
  2017-12-28 15:00 [Qemu-devel] [PATCH] linux-user: Add getcpu() support Samuel Thibault
@ 2017-12-28 17:39 ` Laurent Vivier
  2018-01-10 15:53   ` Laurent Vivier
  0 siblings, 1 reply; 4+ messages in thread
From: Laurent Vivier @ 2017-12-28 17:39 UTC (permalink / raw)
  To: Samuel Thibault, qemu-devel, Riku Voipio

Le 28/12/2017 à 16:00, Samuel Thibault a écrit :
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> ---
>  linux-user/syscall.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 8ec7de96ce..bb8cb726f5 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -296,6 +296,8 @@ _syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned int, len,
>  #define __NR_sys_sched_setaffinity __NR_sched_setaffinity
>  _syscall3(int, sys_sched_setaffinity, pid_t, pid, unsigned int, len,
>            unsigned long *, user_mask_ptr);
> +#define __NR_sys_getcpu __NR_getcpu
> +_syscall3(int, sys_getcpu, unsigned *, cpu, unsigned *, node, void *, tcache);
>  _syscall4(int, reboot, int, magic1, int, magic2, unsigned int, cmd,
>            void *, arg);
>  _syscall2(int, capget, struct __user_cap_header_struct *, header,
> @@ -10443,6 +10445,20 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>              ret = get_errno(sys_sched_setaffinity(arg1, mask_size, mask));
>          }
>          break> +    case TARGET_NR_getcpu:
> +        {
> +            unsigned cpu, node;
> +            ret = get_errno(sys_getcpu(arg1 ? &cpu : NULL,
> +                                       arg2 ? &node : NULL,
> +                                       NULL));
> +            if (arg1) {
> +                put_user(cpu, arg1, abi_uint);
> +            }
> +            if (arg2) {
> +                put_user(node, arg2, abi_uint);
> +            }

You must check for EFAULT.

    if (arg1 && put_user_u32(cpu, arg1)) {
        goto efault;
    }
...

I don't think you need to use the abi_uint type as we are using
put_user_u32() for all the other syscalls for unsigned int.

Thanks,
Laurent

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: Add getcpu() support
  2017-12-28 17:39 ` Laurent Vivier
@ 2018-01-10 15:53   ` Laurent Vivier
  2018-01-10 16:05     ` Samuel Thibault
  0 siblings, 1 reply; 4+ messages in thread
From: Laurent Vivier @ 2018-01-10 15:53 UTC (permalink / raw)
  To: Samuel Thibault, qemu-devel, Riku Voipio

Le 28/12/2017 à 18:39, Laurent Vivier a écrit :
> Le 28/12/2017 à 16:00, Samuel Thibault a écrit :
>> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
>> ---
>>  linux-user/syscall.c | 16 ++++++++++++++++
>>  1 file changed, 16 insertions(+)
>>
>> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
>> index 8ec7de96ce..bb8cb726f5 100644
>> --- a/linux-user/syscall.c
>> +++ b/linux-user/syscall.c
>> @@ -296,6 +296,8 @@ _syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned int, len,
>>  #define __NR_sys_sched_setaffinity __NR_sched_setaffinity
>>  _syscall3(int, sys_sched_setaffinity, pid_t, pid, unsigned int, len,
>>            unsigned long *, user_mask_ptr);
>> +#define __NR_sys_getcpu __NR_getcpu
>> +_syscall3(int, sys_getcpu, unsigned *, cpu, unsigned *, node, void *, tcache);
>>  _syscall4(int, reboot, int, magic1, int, magic2, unsigned int, cmd,
>>            void *, arg);
>>  _syscall2(int, capget, struct __user_cap_header_struct *, header,
>> @@ -10443,6 +10445,20 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>>              ret = get_errno(sys_sched_setaffinity(arg1, mask_size, mask));
>>          }
>>          break> +    case TARGET_NR_getcpu:
>> +        {
>> +            unsigned cpu, node;
>> +            ret = get_errno(sys_getcpu(arg1 ? &cpu : NULL,
>> +                                       arg2 ? &node : NULL,
>> +                                       NULL));
>> +            if (arg1) {
>> +                put_user(cpu, arg1, abi_uint);
>> +            }
>> +            if (arg2) {
>> +                put_user(node, arg2, abi_uint);
>> +            }
> 
> You must check for EFAULT.
> 
>     if (arg1 && put_user_u32(cpu, arg1)) {
>         goto efault;
>     }
> ...
> 
> I don't think you need to use the abi_uint type as we are using
> put_user_u32() for all the other syscalls for unsigned int.

Samuel,

could you send an updated version of your patch?

Thanks,
Laurent

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: Add getcpu() support
  2018-01-10 15:53   ` Laurent Vivier
@ 2018-01-10 16:05     ` Samuel Thibault
  0 siblings, 0 replies; 4+ messages in thread
From: Samuel Thibault @ 2018-01-10 16:05 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: qemu-devel, Riku Voipio

Laurent Vivier, on mer. 10 janv. 2018 16:53:47 +0100, wrote:
> Le 28/12/2017 à 18:39, Laurent Vivier a écrit :
> > Le 28/12/2017 à 16:00, Samuel Thibault a écrit :
> >> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> >> ---
> >>  linux-user/syscall.c | 16 ++++++++++++++++
> >>  1 file changed, 16 insertions(+)
> >>
> >> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> >> index 8ec7de96ce..bb8cb726f5 100644
> >> --- a/linux-user/syscall.c
> >> +++ b/linux-user/syscall.c
> >> @@ -296,6 +296,8 @@ _syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned int, len,
> >>  #define __NR_sys_sched_setaffinity __NR_sched_setaffinity
> >>  _syscall3(int, sys_sched_setaffinity, pid_t, pid, unsigned int, len,
> >>            unsigned long *, user_mask_ptr);
> >> +#define __NR_sys_getcpu __NR_getcpu
> >> +_syscall3(int, sys_getcpu, unsigned *, cpu, unsigned *, node, void *, tcache);
> >>  _syscall4(int, reboot, int, magic1, int, magic2, unsigned int, cmd,
> >>            void *, arg);
> >>  _syscall2(int, capget, struct __user_cap_header_struct *, header,
> >> @@ -10443,6 +10445,20 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> >>              ret = get_errno(sys_sched_setaffinity(arg1, mask_size, mask));
> >>          }
> >>          break> +    case TARGET_NR_getcpu:
> >> +        {
> >> +            unsigned cpu, node;
> >> +            ret = get_errno(sys_getcpu(arg1 ? &cpu : NULL,
> >> +                                       arg2 ? &node : NULL,
> >> +                                       NULL));
> >> +            if (arg1) {
> >> +                put_user(cpu, arg1, abi_uint);
> >> +            }
> >> +            if (arg2) {
> >> +                put_user(node, arg2, abi_uint);
> >> +            }
> > 
> > You must check for EFAULT.
> > 
> >     if (arg1 && put_user_u32(cpu, arg1)) {
> >         goto efault;
> >     }
> > ...
> > 
> > I don't think you need to use the abi_uint type as we are using
> > put_user_u32() for all the other syscalls for unsigned int.
> 
> could you send an updated version of your patch?

Oops, I had missed that mail. Will work on it.

Samuel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-10 16:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-28 15:00 [Qemu-devel] [PATCH] linux-user: Add getcpu() support Samuel Thibault
2017-12-28 17:39 ` Laurent Vivier
2018-01-10 15:53   ` Laurent Vivier
2018-01-10 16:05     ` Samuel Thibault

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.