linux-user: Add getcpu() support
PATCH v2 1/1 linux-user: Add getcpu() support
Signed-off-by Samuel Thibault <[email protected]>
---
Difference from v1: handle failure of put_user_u32 with goto efault;
--- linux-user/syscall.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
linux-user/syscall.c +16 -0
@@ -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,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_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;
Signature · 1 line
2.15.1
Le 11/01/2018 à 01:17, Samuel Thibault a écrit :
Quoted 22 lines
Signed-off-by Samuel Thibault <[email protected]>---
Difference from v1: handle failure ofput_user_u32with goto efault;--- linux-user/syscall.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)linux-user/syscall.c +2
-0@@ -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,
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 10413
Quoted 9 lines
linux-user/syscall.c +6
-0@@ -10403,6 +10405,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 ));
you must check for return status to avoid setting the values if there is an error:
if (!is_error(ret)) {linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 10419
Quoted 6 lines
linux-user/syscall.c +6
-0+if (arg1 &&put_user_u32 (cpu, arg1)) { + goto efault; + } +if (arg2 &&put_user_u32 (node, arg2)) { + goto efault; + }
}
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 10424
Quoted 6 lines
linux-user/syscall.c +2
-0+ } +break ;case TARGET_NR_sched_setparam: {struct sched_param *target_schp;
Thanks,
Laurent