[Xenomai-git] Philippe Gerum : cobalt/posix/sched: prepare for 32bit syscall emulation
Module: xenomai-3 Branch: master Commit: 87bb4ce0a3dbe4234a184ccee03576423ede17af URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=87bb4ce0a3dbe4234a184ccee03576423ede17af Author: Philippe Gerum Date: Thu Oct 16 14:39:53 2014 +0200 cobalt/posix/sched: prepare for 32bit syscall emulation --- include/cobalt/uapi/sched.h| 38 +-- kernel/cobalt/posix/sched.c| 345 ++-- kernel/cobalt/posix/sched.h| 25 +- kernel/cobalt/trace/cobalt-posix.h | 31 +-- testsuite/smokey/sched-quota/sched-quota.c |8 +- 5 files changed, 276 insertions(+), 171 deletions(-) diff --git a/include/cobalt/uapi/sched.h b/include/cobalt/uapi/sched.h index 8ead498..fc04f49 100644 --- a/include/cobalt/uapi/sched.h +++ b/include/cobalt/uapi/sched.h @@ -29,8 +29,6 @@ #define sched_ss_max_repl sched_u.ss.__sched_max_repl #endif /* !SCHED_SPORADIC */ -#define sched_rr_quantum sched_u.rr.__sched_rr_quantum - struct __sched_ss_param { int __sched_low_priority; struct timespec __sched_repl_period; @@ -38,6 +36,8 @@ struct __sched_ss_param { int __sched_max_repl; }; +#define sched_rr_quantum sched_u.rr.__sched_rr_quantum + struct __sched_rr_param { struct timespec __sched_rr_quantum; }; @@ -84,24 +84,28 @@ enum { struct __sched_config_quota { int op; - int *sum_r; - struct { - int pshared; - int *tgid_r; - } add; - struct { - int tgid; - } remove; - struct { + union { + struct { + int pshared; + } add; + struct { + int tgid; + } remove; + struct { + int tgid; + int quota; + int quota_peak; + } set; + struct { + int tgid; + } get; + }; + struct __sched_quota_info { int tgid; int quota; int quota_peak; - } set; - struct { - int tgid; - int *quota_r; - int *quota_peak_r; - } get; + int quota_sum; + } info; }; #define sched_quota_confsz() sizeof(struct __sched_config_quota) diff --git a/kernel/cobalt/posix/sched.c b/kernel/cobalt/posix/sched.c index bfdd2e0..f2fe09a 100644 --- a/kernel/cobalt/posix/sched.c +++ b/kernel/cobalt/posix/sched.c @@ -239,6 +239,9 @@ int set_tp_config(int cpu, union sched_config *config, size_t len) spl_t s; int n; + if (len < sizeof(config->tp)) + return -EINVAL; + if (config->tp.nr_windows == 0) { gps = NULL; goto set_schedule; @@ -294,15 +297,20 @@ fail: } static inline -ssize_t get_tp_config(int cpu, union sched_config __user *u_config, - size_t len) +ssize_t get_tp_config(int cpu, void __user *u_config, size_t len, + union sched_config *(*fetch_config) + (int policy, const void __user *u_config, + size_t *len), + ssize_t (*put_config)(int policy, void __user *u_config, + const union sched_config *config, + size_t len)) { struct xnsched_tp_window *pw, *w; struct xnsched_tp_schedule *gps; struct sched_tp_window *pp, *p; union sched_config *config; struct xnsched *sched; - ssize_t ret = 0, elen; + ssize_t ret, elen; spl_t s; int n; @@ -329,6 +337,7 @@ ssize_t get_tp_config(int cpu, union sched_config __user *u_config, goto out; } + ret = elen; config->tp.nr_windows = gps->pwin_nr; for (n = 0, pp = p = config->tp.windows, pw = w = gps->pwins; n < gps->pwin_nr; pp = p, p++, pw = w, w++, n++) { @@ -337,11 +346,12 @@ ssize_t get_tp_config(int cpu, union sched_config __user *u_config, p->ptid = w->w_part; } ns2ts(&pp->duration, gps->tf_duration - pw->w_offset); - ret = __xn_safe_copy_to_user(u_config, config, elen); + ret = put_config(SCHED_TP, u_config, config, elen); + xnfree(config); out: xnsched_tp_put_schedule(gps); - return ret ?: elen; + return ret; } #else /* !CONFIG_XENO_OPT_SCHED_TP */ @@ -353,8 +363,13 @@ set_tp_config(int cpu, union sched_config *config, size_t len) } static inline ssize_t -get_tp_config(int cpu, union sched_config __user *u_config, - size_t len) +get_tp_config(int cpu, union sched_config __user *u_config, size_t len, + union sched_config *(*fetch_config) + (int policy, const void __user *u_config, + size_t *len), + ssize_t (*p
[Xenomai-git] Philippe Gerum : cobalt/posix/sched: prepare for 32bit syscall emulation
Module: xenomai-3 Branch: next Commit: 87bb4ce0a3dbe4234a184ccee03576423ede17af URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=87bb4ce0a3dbe4234a184ccee03576423ede17af Author: Philippe Gerum Date: Thu Oct 16 14:39:53 2014 +0200 cobalt/posix/sched: prepare for 32bit syscall emulation --- include/cobalt/uapi/sched.h| 38 +-- kernel/cobalt/posix/sched.c| 345 ++-- kernel/cobalt/posix/sched.h| 25 +- kernel/cobalt/trace/cobalt-posix.h | 31 +-- testsuite/smokey/sched-quota/sched-quota.c |8 +- 5 files changed, 276 insertions(+), 171 deletions(-) diff --git a/include/cobalt/uapi/sched.h b/include/cobalt/uapi/sched.h index 8ead498..fc04f49 100644 --- a/include/cobalt/uapi/sched.h +++ b/include/cobalt/uapi/sched.h @@ -29,8 +29,6 @@ #define sched_ss_max_repl sched_u.ss.__sched_max_repl #endif /* !SCHED_SPORADIC */ -#define sched_rr_quantum sched_u.rr.__sched_rr_quantum - struct __sched_ss_param { int __sched_low_priority; struct timespec __sched_repl_period; @@ -38,6 +36,8 @@ struct __sched_ss_param { int __sched_max_repl; }; +#define sched_rr_quantum sched_u.rr.__sched_rr_quantum + struct __sched_rr_param { struct timespec __sched_rr_quantum; }; @@ -84,24 +84,28 @@ enum { struct __sched_config_quota { int op; - int *sum_r; - struct { - int pshared; - int *tgid_r; - } add; - struct { - int tgid; - } remove; - struct { + union { + struct { + int pshared; + } add; + struct { + int tgid; + } remove; + struct { + int tgid; + int quota; + int quota_peak; + } set; + struct { + int tgid; + } get; + }; + struct __sched_quota_info { int tgid; int quota; int quota_peak; - } set; - struct { - int tgid; - int *quota_r; - int *quota_peak_r; - } get; + int quota_sum; + } info; }; #define sched_quota_confsz() sizeof(struct __sched_config_quota) diff --git a/kernel/cobalt/posix/sched.c b/kernel/cobalt/posix/sched.c index bfdd2e0..f2fe09a 100644 --- a/kernel/cobalt/posix/sched.c +++ b/kernel/cobalt/posix/sched.c @@ -239,6 +239,9 @@ int set_tp_config(int cpu, union sched_config *config, size_t len) spl_t s; int n; + if (len < sizeof(config->tp)) + return -EINVAL; + if (config->tp.nr_windows == 0) { gps = NULL; goto set_schedule; @@ -294,15 +297,20 @@ fail: } static inline -ssize_t get_tp_config(int cpu, union sched_config __user *u_config, - size_t len) +ssize_t get_tp_config(int cpu, void __user *u_config, size_t len, + union sched_config *(*fetch_config) + (int policy, const void __user *u_config, + size_t *len), + ssize_t (*put_config)(int policy, void __user *u_config, + const union sched_config *config, + size_t len)) { struct xnsched_tp_window *pw, *w; struct xnsched_tp_schedule *gps; struct sched_tp_window *pp, *p; union sched_config *config; struct xnsched *sched; - ssize_t ret = 0, elen; + ssize_t ret, elen; spl_t s; int n; @@ -329,6 +337,7 @@ ssize_t get_tp_config(int cpu, union sched_config __user *u_config, goto out; } + ret = elen; config->tp.nr_windows = gps->pwin_nr; for (n = 0, pp = p = config->tp.windows, pw = w = gps->pwins; n < gps->pwin_nr; pp = p, p++, pw = w, w++, n++) { @@ -337,11 +346,12 @@ ssize_t get_tp_config(int cpu, union sched_config __user *u_config, p->ptid = w->w_part; } ns2ts(&pp->duration, gps->tf_duration - pw->w_offset); - ret = __xn_safe_copy_to_user(u_config, config, elen); + ret = put_config(SCHED_TP, u_config, config, elen); + xnfree(config); out: xnsched_tp_put_schedule(gps); - return ret ?: elen; + return ret; } #else /* !CONFIG_XENO_OPT_SCHED_TP */ @@ -353,8 +363,13 @@ set_tp_config(int cpu, union sched_config *config, size_t len) } static inline ssize_t -get_tp_config(int cpu, union sched_config __user *u_config, - size_t len) +get_tp_config(int cpu, union sched_config __user *u_config, size_t len, + union sched_config *(*fetch_config) + (int policy, const void __user *u_config, + size_t *len), + ssize_t (*put