diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/lib/brand/lx/lx_brand/common/lx_brand.c | 8 | ||||
-rw-r--r-- | usr/src/lib/brand/lx/lx_brand/common/misc.c | 22 | ||||
-rw-r--r-- | usr/src/lib/brand/lx/lx_brand/common/time.c | 21 | ||||
-rw-r--r-- | usr/src/lib/brand/lx/lx_brand/sys/lx_syscall.h | 2 | ||||
-rw-r--r-- | usr/src/uts/common/brand/lx/os/lx_syscall.c | 8 | ||||
-rw-r--r-- | usr/src/uts/common/brand/lx/sys/lx_syscalls.h | 2 | ||||
-rw-r--r-- | usr/src/uts/common/brand/lx/syscall/lx_cpu.c | 35 | ||||
-rw-r--r-- | usr/src/uts/common/brand/lx/syscall/lx_timer.c | 38 | ||||
-rw-r--r-- | usr/src/uts/intel/Makefile.files | 1 |
9 files changed, 84 insertions, 53 deletions
diff --git a/usr/src/lib/brand/lx/lx_brand/common/lx_brand.c b/usr/src/lib/brand/lx/lx_brand/common/lx_brand.c index 76eee84ef1..65477504c8 100644 --- a/usr/src/lib/brand/lx/lx_brand/common/lx_brand.c +++ b/usr/src/lib/brand/lx/lx_brand/common/lx_brand.c @@ -1127,7 +1127,7 @@ static lx_syscall_handler_t lx_handlers[] = { NULL, /* 198: lremovexattr */ NULL, /* 199: fremovexattr */ NULL, /* 200: tkill */ - lx_time, /* 201: time */ + NULL, /* 201: time */ NULL, /* 202: futex */ lx_sched_setaffinity, /* 203: sched_setaffinity */ lx_sched_getaffinity, /* 204: sched_getaffinity */ @@ -1235,7 +1235,7 @@ static lx_syscall_handler_t lx_handlers[] = { NULL, /* 306: syncfs */ NULL, /* 307: sendmmsg */ NULL, /* 309: setns */ - lx_getcpu, /* 309: getcpu */ + NULL, /* 309: getcpu */ NULL, /* 310: process_vm_readv */ NULL, /* 311: process_vm_writev */ NULL, /* 312: kcmp */ @@ -1270,7 +1270,7 @@ static lx_syscall_handler_t lx_handlers[] = { lx_unlink, /* 10: unlink */ lx_execve, /* 11: execve */ lx_chdir, /* 12: chdir */ - lx_time, /* 13: time */ + NULL, /* 13: time */ lx_mknod, /* 14: mknod */ NULL, /* 15: chmod */ NULL, /* 16: lchown16 */ @@ -1575,7 +1575,7 @@ static lx_syscall_handler_t lx_handlers[] = { NULL, /* 315: tee */ NULL, /* 316: vmsplice */ NULL, /* 317: move_pages */ - lx_getcpu, /* 318: getcpu */ + NULL, /* 318: getcpu */ lx_epoll_pwait, /* 319: epoll_pwait */ lx_utimensat, /* 320: utimensat */ NULL, /* 321: signalfd */ diff --git a/usr/src/lib/brand/lx/lx_brand/common/misc.c b/usr/src/lib/brand/lx/lx_brand/common/misc.c index c314ade018..9ce3b24243 100644 --- a/usr/src/lib/brand/lx/lx_brand/common/misc.c +++ b/usr/src/lib/brand/lx/lx_brand/common/misc.c @@ -823,28 +823,6 @@ lx_fchdir(int fildes) return ((r == -1) ? -errno : r); } -/* - * We support neither the second argument (NUMA node), nor the third (obsolete - * pre-2.6.24 caching functionality which was ultimately broken). - */ -long -lx_getcpu(unsigned int *cpu, uintptr_t p2, uintptr_t p3) -{ - psinfo_t psinfo; - int procfd; - unsigned int curcpu; - - if ((procfd = open("/native/proc/self/psinfo", O_RDONLY)) == -1) - return (-errno); - - if (read(procfd, &psinfo, sizeof (psinfo_t)) == -1) - return (-errno); - - curcpu = psinfo.pr_lwp.pr_onpro; - - return ((uucopy(&curcpu, cpu, sizeof (curcpu)) != 0) ? -errno : 0); -} - long lx_getgid(void) { diff --git a/usr/src/lib/brand/lx/lx_brand/common/time.c b/usr/src/lib/brand/lx/lx_brand/common/time.c index e0df2a92b4..c810aa33f1 100644 --- a/usr/src/lib/brand/lx/lx_brand/common/time.c +++ b/usr/src/lib/brand/lx/lx_brand/common/time.c @@ -34,27 +34,6 @@ #include <sys/lx_misc.h> /* - * time() - This cannot be passthrough because on Linux a bad buffer will - * set errno to EFAULT, and on Illumos the failure mode is documented - * as "undefined." - * - * (At present, Illumos' time(2) will segmentation fault, as the call - * is simply a libc wrapper atop the time() syscall that will - * dereference the passed pointer if it is non-zero.) - */ -long -lx_time(uintptr_t p1) -{ - time_t ret = time((time_t *)0); - - if ((ret == (time_t)-1) || - ((p1 != 0) && (uucopy(&ret, (time_t *)p1, sizeof (ret)) != 0))) - return (-errno); - - return (ret); -} - -/* * times() - The Linux implementation avoids writing to NULL, while Illumos * returns EFAULT. */ diff --git a/usr/src/lib/brand/lx/lx_brand/sys/lx_syscall.h b/usr/src/lib/brand/lx/lx_brand/sys/lx_syscall.h index d1fc31d114..bbb4afacbc 100644 --- a/usr/src/lib/brand/lx/lx_brand/sys/lx_syscall.h +++ b/usr/src/lib/brand/lx/lx_brand/sys/lx_syscall.h @@ -178,7 +178,6 @@ extern long lx_llseek(uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); extern long lx_lseek(uintptr_t, uintptr_t, uintptr_t); extern long lx_sysfs(uintptr_t, uintptr_t, uintptr_t); -extern long lx_getcpu(unsigned int *, uintptr_t, uintptr_t); extern long lx_getcwd(uintptr_t, uintptr_t); extern long lx_uname(uintptr_t); extern long lx_reboot(uintptr_t, uintptr_t, uintptr_t, uintptr_t); @@ -190,7 +189,6 @@ extern long lx_personality(uintptr_t); extern long lx_query_module(uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); -extern long lx_time(uintptr_t); extern long lx_times(uintptr_t); extern long lx_setitimer(uintptr_t, uintptr_t, uintptr_t); diff --git a/usr/src/uts/common/brand/lx/os/lx_syscall.c b/usr/src/uts/common/brand/lx/os/lx_syscall.c index 298907f21f..0c41d56baf 100644 --- a/usr/src/uts/common/brand/lx/os/lx_syscall.c +++ b/usr/src/uts/common/brand/lx/os/lx_syscall.c @@ -531,7 +531,7 @@ lx_sysent_t lx_sysent32[] = { {"unlink", NULL, 0, 1}, /* 10 */ {"execve", NULL, 0, 3}, /* 11 */ {"chdir", NULL, 0, 1}, /* 12 */ - {"time", NULL, 0, 1}, /* 13 */ + {"time", lx_time, 0, 1}, /* 13 */ {"mknod", NULL, 0, 3}, /* 14 */ {"chmod", lx_chmod, 0, 2}, /* 15 */ {"lchown16", lx_lchown16, 0, 3}, /* 16 */ @@ -840,7 +840,7 @@ lx_sysent_t lx_sysent32[] = { {"tee", NULL, NOSYS_NULL, 0}, /* 315 */ {"vmsplice", NULL, NOSYS_NULL, 0}, /* 316 */ {"move_pages", NULL, NOSYS_NULL, 0}, /* 317 */ - {"getcpu", NULL, 0, 3}, /* 318 */ + {"getcpu", lx_getcpu, 0, 3}, /* 318 */ {"epoll_pwait", NULL, 0, 5}, /* 319 */ {"utimensat", NULL, 0, 4}, /* 320 */ {"signalfd", NULL, NOSYS_NULL, 0}, /* 321 */ @@ -1090,7 +1090,7 @@ lx_sysent_t lx_sysent64[] = { {"lremovexattr", lx_xattr, 0, 2}, /* 198 */ {"fremovexattr", lx_xattr, 0, 2}, /* 199 */ {"tkill", lx_tkill, 0, 2}, /* 200 */ - {"time", NULL, 0, 1}, /* 201 */ + {"time", lx_time, 0, 1}, /* 201 */ {"futex", lx_futex, 0, 6}, /* 202 */ {"sched_setaffinity", NULL, 0, 3}, /* 203 */ {"sched_getaffinity", NULL, 0, 3}, /* 204 */ @@ -1198,7 +1198,7 @@ lx_sysent_t lx_sysent64[] = { {"syncfs", NULL, NOSYS_NULL, 0}, /* 306 */ {"sendmmsg", NULL, NOSYS_NULL, 0}, /* 307 */ {"setns", NULL, NOSYS_NULL, 0}, /* 309 */ - {"getcpu", NULL, 0, 3}, /* 309 */ + {"getcpu", lx_getcpu, 0, 3}, /* 309 */ {"process_vm_readv", NULL, NOSYS_NULL, 0}, /* 310 */ {"process_vm_writev", NULL, NOSYS_NULL, 0}, /* 311 */ {"kcmp", NULL, NOSYS_NULL, 0}, /* 312 */ diff --git a/usr/src/uts/common/brand/lx/sys/lx_syscalls.h b/usr/src/uts/common/brand/lx/sys/lx_syscalls.h index 033192f241..3c033af429 100644 --- a/usr/src/uts/common/brand/lx/sys/lx_syscalls.h +++ b/usr/src/uts/common/brand/lx/sys/lx_syscalls.h @@ -49,6 +49,7 @@ extern long lx_fchown16(); extern long lx_fchownat(); extern long lx_futex(); extern long lx_get_thread_area(); +extern long lx_getcpu(); extern long lx_getpid(); extern long lx_getppid(); extern long lx_gettid(); @@ -78,6 +79,7 @@ extern long lx_setresuid16(); extern long lx_sysinfo32(); extern long lx_sysinfo64(); extern long lx_tgkill(); +extern long lx_time(); extern long lx_tkill(); extern long lx_wait4(); extern long lx_waitid(); diff --git a/usr/src/uts/common/brand/lx/syscall/lx_cpu.c b/usr/src/uts/common/brand/lx/syscall/lx_cpu.c new file mode 100644 index 0000000000..ec8b7576d8 --- /dev/null +++ b/usr/src/uts/common/brand/lx/syscall/lx_cpu.c @@ -0,0 +1,35 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2015 Joyent, Inc. + */ + +#include <sys/systm.h> +#include <sys/thread.h> +#include <sys/cpuvar.h> +#include <sys/cmn_err.h> +#include <sys/lx_impl.h> + +/* + * We support neither the second argument (NUMA node), nor the third (obsolete + * pre-2.6.24 caching functionality which was ultimately broken). + */ +long +lx_getcpu(unsigned int *cpu, uintptr_t p2, uintptr_t p3) +{ + unsigned int curcpu = curthread->t_cpu->cpu_id; + + if (copyout(&curcpu, cpu, sizeof (curcpu)) != 0) + return (set_errno(EFAULT)); + + return (0); +} diff --git a/usr/src/uts/common/brand/lx/syscall/lx_timer.c b/usr/src/uts/common/brand/lx/syscall/lx_timer.c index 319d3033b1..aa22228808 100644 --- a/usr/src/uts/common/brand/lx/syscall/lx_timer.c +++ b/usr/src/uts/common/brand/lx/syscall/lx_timer.c @@ -327,3 +327,41 @@ lx_gettimeofday(struct timeval *tvp, struct lx_timezone *tzp) return (0); } + +/* + * On Linux a bad buffer will set errno to EFAULT, and on Illumos the failure + * mode is documented as "undefined." + */ +long +lx_time(time_t *tp) +{ + timestruc_t ts; + struct timeval tv; + + gethrestime(&ts); + tv.tv_sec = ts.tv_sec; + tv.tv_usec = 0; + + if (get_udatamodel() == DATAMODEL_NATIVE) { + if (tp != NULL && + copyout(&tv.tv_sec, tp, sizeof (tv.tv_sec)) != 0) + return (set_errno(EFAULT)); + + return (tv.tv_sec); + } +#ifdef _SYSCALL32_IMPL + else { + struct timeval32 tv32; + + if (TIMEVAL_OVERFLOW(&tv)) + return (set_errno(EOVERFLOW)); + TIMEVAL_TO_TIMEVAL32(&tv32, &tv); + + if (tp != NULL && + copyout(&tv32.tv_sec, tp, sizeof (tv32.tv_sec))) + return (set_errno(EFAULT)); + + return (tv32.tv_sec); + } +#endif +} diff --git a/usr/src/uts/intel/Makefile.files b/usr/src/uts/intel/Makefile.files index 1f2cddbd61..ea1812b393 100644 --- a/usr/src/uts/intel/Makefile.files +++ b/usr/src/uts/intel/Makefile.files @@ -282,6 +282,7 @@ LX_BRAND_OBJS = \ lx_chmod.o \ lx_chown.o \ lx_clone.o \ + lx_cpu.o \ lx_errno.o \ lx_futex.o \ lx_getpid.o \ |