qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCHv3] linux-user: Add getcpu() support
@ 2018-01-12  0:15 Samuel Thibault
  2018-01-12  8:11 ` Laurent Vivier
  0 siblings, 1 reply; 2+ messages in thread
From: Samuel Thibault @ 2018-01-12  0:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: Samuel Thibault, Laurent Vivier, Riku Voipio

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

---
Difference between v1 and v2: handle failure of put_user_u32 with goto efault;
Difference between v2 and v3: handle failure of sys_getcpu system call
---
 linux-user/syscall.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 11c9116c4a..f8cfaf043a 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,
@@ -10403,6 +10405,23 @@ 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 (ret < 0) {
+                goto fail;
+            }
+            if (arg1 && put_user_u32(cpu, arg1)) {
+                goto efault;
+            }
+            if (arg2 && put_user_u32(node, arg2)) {
+                goto efault;
+            }
+        }
+        break;
     case TARGET_NR_sched_setparam:
         {
             struct sched_param *target_schp;
-- 
2.15.1

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

* Re: [Qemu-devel] [PATCHv3] linux-user: Add getcpu() support
  2018-01-12  0:15 [Qemu-devel] [PATCHv3] linux-user: Add getcpu() support Samuel Thibault
@ 2018-01-12  8:11 ` Laurent Vivier
  0 siblings, 0 replies; 2+ messages in thread
From: Laurent Vivier @ 2018-01-12  8:11 UTC (permalink / raw)
  To: Samuel Thibault, qemu-devel; +Cc: Riku Voipio

Le 12/01/2018 à 01:15, Samuel Thibault a écrit :
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> 
> ---
> Difference between v1 and v2: handle failure of put_user_u32 with goto efault;
> Difference between v2 and v3: handle failure of sys_getcpu system call
> ---
>  linux-user/syscall.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 11c9116c4a..f8cfaf043a 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,
> @@ -10403,6 +10405,23 @@ 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 (ret < 0) {

"if (is_error(ret))" would be better.

Thanks,
Laurent

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

end of thread, other threads:[~2018-01-12  8:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-12  0:15 [Qemu-devel] [PATCHv3] linux-user: Add getcpu() support Samuel Thibault
2018-01-12  8:11 ` Laurent Vivier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).