[Xenomai-git] Philippe Gerum : cobalt/posix: 32bit syscall wrappers
Module: xenomai-3 Branch: next Commit: c2d5275f64cedbf945474f29ce058f42f9163fb1 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c2d5275f64cedbf945474f29ce058f42f9163fb1 Author: Philippe Gerum Date: Thu Oct 16 14:43:59 2014 +0200 cobalt/posix: 32bit syscall wrappers --- kernel/cobalt/posix/Makefile|2 +- kernel/cobalt/posix/syscall32.c | 1078 ++- kernel/cobalt/posix/syscall32.h | 239 + 3 files changed, 1304 insertions(+), 15 deletions(-) diff --git a/kernel/cobalt/posix/Makefile b/kernel/cobalt/posix/Makefile index e965846..22d5f2b 100644 --- a/kernel/cobalt/posix/Makefile +++ b/kernel/cobalt/posix/Makefile @@ -20,6 +20,6 @@ xenomai-y := \ timer.o \ timerfd.o -xenomai-$(CONFIG_XENO_OPT_SYS3264) += syscall32.o +xenomai-$(CONFIG_XENO_ARCH_SYS3264) += syscall32.o ccflags-y := -Iarch/$(SRCARCH)/xenomai/include -Iinclude/xenomai -Ikernel diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c index 3b0b71c..e29f7c1 100644 --- a/kernel/cobalt/posix/syscall32.c +++ b/kernel/cobalt/posix/syscall32.c @@ -17,19 +17,1069 @@ */ #include #include -#include #include +#include #include "internal.h" -#include "thread.h" -#include "sched.h" -#include "mutex.h" -#include "cond.h" -#include "mqueue.h" -#include "sem.h" -#include "signal.h" -#include "timer.h" -#include "monitor.h" -#include "clock.h" -#include "event.h" -#include "timerfd.h" -#include "io.h" +#include "syscall32.h" +#include "../debug.h" + +static int sys32_get_timespec(struct timespec *ts, + const struct compat_timespec __user *cts) +{ + return (cts == NULL || + !access_rok(cts, sizeof(*cts)) || + __xn_get_user(ts->tv_sec, &cts->tv_sec) || + __xn_get_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; +} + +static int sys32_put_timespec(struct compat_timespec __user *cts, + const struct timespec *ts) +{ + return (cts == NULL || + !access_wok(cts, sizeof(*cts)) || + __xn_put_user(ts->tv_sec, &cts->tv_sec) || + __xn_put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; +} + +static int sys32_get_itimerspec(struct itimerspec *its, + const struct compat_itimerspec __user *cits) +{ + int ret = sys32_get_timespec(&its->it_value, &cits->it_value); + + return ret ?: sys32_get_timespec(&its->it_interval, &cits->it_interval); +} + +static int sys32_put_itimerspec(struct compat_itimerspec __user *cits, + const struct itimerspec *its) +{ + int ret = sys32_put_timespec(&cits->it_value, &its->it_value); + + return ret ?: sys32_put_timespec(&cits->it_interval, &its->it_interval); +} + +static int sys32_get_timeval(struct timeval *tv, +const struct compat_timeval __user *ctv) +{ + return (ctv == NULL || + !access_rok(ctv, sizeof(*ctv)) || + __xn_get_user(tv->tv_sec, &ctv->tv_sec) || + __xn_get_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0; +} + +static int sys32_put_timeval(struct compat_timeval __user *ctv, +const struct timeval *tv) +{ + return (ctv == NULL || + !access_wok(ctv, sizeof(*ctv)) || + __xn_put_user(tv->tv_sec, &ctv->tv_sec) || + __xn_put_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0; +} + +static ssize_t sys32_get_fdset(fd_set *fds, const compat_fd_set __user *cfds, + size_t cfdsize) +{ + int rdpos, wrpos, rdlim = cfdsize / sizeof(compat_long_t); + + if (cfds == NULL || !access_rok(cfds, cfdsize)) + return -EFAULT; + + for (rdpos = 0, wrpos = 0; rdpos < rdlim; rdpos++, wrpos++) + if (__xn_get_user(fds->fds_bits[wrpos], cfds->fds_bits + rdpos)) + return -EFAULT; + + return (ssize_t)rdlim * sizeof(long); +} + +static ssize_t sys32_put_fdset(compat_fd_set __user *cfds, const fd_set *fds, + size_t fdsize) +{ + int rdpos, wrpos, wrlim = fdsize / sizeof(long); + + if (cfds == NULL || !access_wok(cfds, wrlim * sizeof(compat_long_t))) + return -EFAULT; + + for (rdpos = 0, wrpos = 0; wrpos < wrlim; rdpos++, wrpos++) + if (__xn_put_user(fds->fds_bits[rdpos], cfds->fds_bits + wrpos)) + return -EFAULT; + + return (ssize_t)wrlim * sizeof(compat_long_t); +} + +static int sys32_get_param_ex(int policy, + struct sched_param_ex *p, + const struct compat_sched_param_ex __user *u_cp) +{ + struct compat_sched_param_ex cpex; + + if (u_cp == NULL || __xn_safe_copy_from_user(&cpex, u_cp, sizeof(cpex))) + return -EFAULT; + + p->sched_priority = cpex.sched_priority; + +
[Xenomai-git] Philippe Gerum : cobalt/posix: 32bit syscall wrappers
Module: xenomai-3 Branch: next Commit: e34b18e0f5de26254b774977acae119cbd7f1f1d URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e34b18e0f5de26254b774977acae119cbd7f1f1d Author: Philippe Gerum Date: Thu Oct 16 14:43:59 2014 +0200 cobalt/posix: 32bit syscall wrappers --- kernel/cobalt/posix/Makefile|2 +- kernel/cobalt/posix/syscall32.c | 1149 ++- kernel/cobalt/posix/syscall32.h | 267 + 3 files changed, 1403 insertions(+), 15 deletions(-) diff --git a/kernel/cobalt/posix/Makefile b/kernel/cobalt/posix/Makefile index e965846..22d5f2b 100644 --- a/kernel/cobalt/posix/Makefile +++ b/kernel/cobalt/posix/Makefile @@ -20,6 +20,6 @@ xenomai-y := \ timer.o \ timerfd.o -xenomai-$(CONFIG_XENO_OPT_SYS3264) += syscall32.o +xenomai-$(CONFIG_XENO_ARCH_SYS3264) += syscall32.o ccflags-y := -Iarch/$(SRCARCH)/xenomai/include -Iinclude/xenomai -Ikernel diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c index 3b0b71c..603c379 100644 --- a/kernel/cobalt/posix/syscall32.c +++ b/kernel/cobalt/posix/syscall32.c @@ -17,19 +17,1140 @@ */ #include #include -#include #include +#include #include "internal.h" -#include "thread.h" -#include "sched.h" -#include "mutex.h" -#include "cond.h" -#include "mqueue.h" -#include "sem.h" -#include "signal.h" -#include "timer.h" -#include "monitor.h" -#include "clock.h" -#include "event.h" -#include "timerfd.h" -#include "io.h" +#include "syscall32.h" +#include "../debug.h" + +static int sys32_get_timespec(struct timespec *ts, + const struct compat_timespec __user *cts) +{ + return (cts == NULL || + !access_rok(cts, sizeof(*cts)) || + __xn_get_user(ts->tv_sec, &cts->tv_sec) || + __xn_get_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; +} + +static int sys32_put_timespec(struct compat_timespec __user *cts, + const struct timespec *ts) +{ + return (cts == NULL || + !access_wok(cts, sizeof(*cts)) || + __xn_put_user(ts->tv_sec, &cts->tv_sec) || + __xn_put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; +} + +static int sys32_get_itimerspec(struct itimerspec *its, + const struct compat_itimerspec __user *cits) +{ + int ret = sys32_get_timespec(&its->it_value, &cits->it_value); + + return ret ?: sys32_get_timespec(&its->it_interval, &cits->it_interval); +} + +static int sys32_put_itimerspec(struct compat_itimerspec __user *cits, + const struct itimerspec *its) +{ + int ret = sys32_put_timespec(&cits->it_value, &its->it_value); + + return ret ?: sys32_put_timespec(&cits->it_interval, &its->it_interval); +} + +static int sys32_get_timeval(struct timeval *tv, +const struct compat_timeval __user *ctv) +{ + return (ctv == NULL || + !access_rok(ctv, sizeof(*ctv)) || + __xn_get_user(tv->tv_sec, &ctv->tv_sec) || + __xn_get_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0; +} + +static int sys32_put_timeval(struct compat_timeval __user *ctv, +const struct timeval *tv) +{ + return (ctv == NULL || + !access_wok(ctv, sizeof(*ctv)) || + __xn_put_user(tv->tv_sec, &ctv->tv_sec) || + __xn_put_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0; +} + +static ssize_t sys32_get_fdset(fd_set *fds, const compat_fd_set __user *cfds, + size_t cfdsize) +{ + int rdpos, wrpos, rdlim = cfdsize / sizeof(compat_ulong_t); + + if (cfds == NULL || !access_rok(cfds, cfdsize)) + return -EFAULT; + + for (rdpos = 0, wrpos = 0; rdpos < rdlim; rdpos++, wrpos++) + if (__xn_get_user(fds->fds_bits[wrpos], cfds->fds_bits + rdpos)) + return -EFAULT; + + return (ssize_t)rdlim * sizeof(long); +} + +static ssize_t sys32_put_fdset(compat_fd_set __user *cfds, const fd_set *fds, + size_t fdsize) +{ + int rdpos, wrpos, wrlim = fdsize / sizeof(long); + + if (cfds == NULL || !access_wok(cfds, wrlim * sizeof(compat_ulong_t))) + return -EFAULT; + + for (rdpos = 0, wrpos = 0; wrpos < wrlim; rdpos++, wrpos++) + if (__xn_put_user(fds->fds_bits[rdpos], cfds->fds_bits + wrpos)) + return -EFAULT; + + return (ssize_t)wrlim * sizeof(compat_ulong_t); +} + +static int sys32_get_param_ex(int policy, + struct sched_param_ex *p, + const struct compat_sched_param_ex __user *u_cp) +{ + struct compat_sched_param_ex cpex; + + if (u_cp == NULL || __xn_safe_copy_from_user(&cpex, u_cp, sizeof(cpex))) + return -EFAULT; + + p->sched_priority = cpex.sched_priority;
[Xenomai-git] Philippe Gerum : cobalt/posix: 32bit syscall wrappers
Module: xenomai-3 Branch: master Commit: e34b18e0f5de26254b774977acae119cbd7f1f1d URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e34b18e0f5de26254b774977acae119cbd7f1f1d Author: Philippe Gerum Date: Thu Oct 16 14:43:59 2014 +0200 cobalt/posix: 32bit syscall wrappers --- kernel/cobalt/posix/Makefile|2 +- kernel/cobalt/posix/syscall32.c | 1149 ++- kernel/cobalt/posix/syscall32.h | 267 + 3 files changed, 1403 insertions(+), 15 deletions(-) diff --git a/kernel/cobalt/posix/Makefile b/kernel/cobalt/posix/Makefile index e965846..22d5f2b 100644 --- a/kernel/cobalt/posix/Makefile +++ b/kernel/cobalt/posix/Makefile @@ -20,6 +20,6 @@ xenomai-y := \ timer.o \ timerfd.o -xenomai-$(CONFIG_XENO_OPT_SYS3264) += syscall32.o +xenomai-$(CONFIG_XENO_ARCH_SYS3264) += syscall32.o ccflags-y := -Iarch/$(SRCARCH)/xenomai/include -Iinclude/xenomai -Ikernel diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c index 3b0b71c..603c379 100644 --- a/kernel/cobalt/posix/syscall32.c +++ b/kernel/cobalt/posix/syscall32.c @@ -17,19 +17,1140 @@ */ #include #include -#include #include +#include #include "internal.h" -#include "thread.h" -#include "sched.h" -#include "mutex.h" -#include "cond.h" -#include "mqueue.h" -#include "sem.h" -#include "signal.h" -#include "timer.h" -#include "monitor.h" -#include "clock.h" -#include "event.h" -#include "timerfd.h" -#include "io.h" +#include "syscall32.h" +#include "../debug.h" + +static int sys32_get_timespec(struct timespec *ts, + const struct compat_timespec __user *cts) +{ + return (cts == NULL || + !access_rok(cts, sizeof(*cts)) || + __xn_get_user(ts->tv_sec, &cts->tv_sec) || + __xn_get_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; +} + +static int sys32_put_timespec(struct compat_timespec __user *cts, + const struct timespec *ts) +{ + return (cts == NULL || + !access_wok(cts, sizeof(*cts)) || + __xn_put_user(ts->tv_sec, &cts->tv_sec) || + __xn_put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; +} + +static int sys32_get_itimerspec(struct itimerspec *its, + const struct compat_itimerspec __user *cits) +{ + int ret = sys32_get_timespec(&its->it_value, &cits->it_value); + + return ret ?: sys32_get_timespec(&its->it_interval, &cits->it_interval); +} + +static int sys32_put_itimerspec(struct compat_itimerspec __user *cits, + const struct itimerspec *its) +{ + int ret = sys32_put_timespec(&cits->it_value, &its->it_value); + + return ret ?: sys32_put_timespec(&cits->it_interval, &its->it_interval); +} + +static int sys32_get_timeval(struct timeval *tv, +const struct compat_timeval __user *ctv) +{ + return (ctv == NULL || + !access_rok(ctv, sizeof(*ctv)) || + __xn_get_user(tv->tv_sec, &ctv->tv_sec) || + __xn_get_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0; +} + +static int sys32_put_timeval(struct compat_timeval __user *ctv, +const struct timeval *tv) +{ + return (ctv == NULL || + !access_wok(ctv, sizeof(*ctv)) || + __xn_put_user(tv->tv_sec, &ctv->tv_sec) || + __xn_put_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0; +} + +static ssize_t sys32_get_fdset(fd_set *fds, const compat_fd_set __user *cfds, + size_t cfdsize) +{ + int rdpos, wrpos, rdlim = cfdsize / sizeof(compat_ulong_t); + + if (cfds == NULL || !access_rok(cfds, cfdsize)) + return -EFAULT; + + for (rdpos = 0, wrpos = 0; rdpos < rdlim; rdpos++, wrpos++) + if (__xn_get_user(fds->fds_bits[wrpos], cfds->fds_bits + rdpos)) + return -EFAULT; + + return (ssize_t)rdlim * sizeof(long); +} + +static ssize_t sys32_put_fdset(compat_fd_set __user *cfds, const fd_set *fds, + size_t fdsize) +{ + int rdpos, wrpos, wrlim = fdsize / sizeof(long); + + if (cfds == NULL || !access_wok(cfds, wrlim * sizeof(compat_ulong_t))) + return -EFAULT; + + for (rdpos = 0, wrpos = 0; wrpos < wrlim; rdpos++, wrpos++) + if (__xn_put_user(fds->fds_bits[rdpos], cfds->fds_bits + wrpos)) + return -EFAULT; + + return (ssize_t)wrlim * sizeof(compat_ulong_t); +} + +static int sys32_get_param_ex(int policy, + struct sched_param_ex *p, + const struct compat_sched_param_ex __user *u_cp) +{ + struct compat_sched_param_ex cpex; + + if (u_cp == NULL || __xn_safe_copy_from_user(&cpex, u_cp, sizeof(cpex))) + return -EFAULT; + + p->sched_priority = cpex.sched_priority