mirror of https://gitee.com/openkylin/linux.git
[PATCH] common compat_sys_timer_create
The comment in compat.c is wrong, every architecture provides a get_compat_sigevent() for the IPC compat code already. This basically moves the x86_64 version to common code and removes all the others. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Paul Mackerras <paulus@samba.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: "David S. Miller" <davem@davemloft.net> Acked-by: Andi Kleen <ak@muc.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
f042e0f80b
commit
3a0f69d59b
|
@ -469,7 +469,7 @@ ia32_syscall_table:
|
|||
data8 sys32_epoll_wait
|
||||
data8 sys_remap_file_pages
|
||||
data8 sys_set_tid_address
|
||||
data8 sys32_timer_create
|
||||
data8 compat_sys_timer_create
|
||||
data8 compat_sys_timer_settime /* 260 */
|
||||
data8 compat_sys_timer_gettime
|
||||
data8 sys_timer_getoverrun
|
||||
|
|
|
@ -2553,34 +2553,6 @@ sys32_get_thread_area (struct ia32_user_desc __user *u_info)
|
|||
return 0;
|
||||
}
|
||||
|
||||
asmlinkage long
|
||||
sys32_timer_create(u32 clock, struct compat_sigevent __user *se32, timer_t __user *timer_id)
|
||||
{
|
||||
struct sigevent se;
|
||||
mm_segment_t oldfs;
|
||||
timer_t t;
|
||||
long err;
|
||||
|
||||
if (se32 == NULL)
|
||||
return sys_timer_create(clock, NULL, timer_id);
|
||||
|
||||
if (get_compat_sigevent(&se, se32))
|
||||
return -EFAULT;
|
||||
|
||||
if (!access_ok(VERIFY_WRITE,timer_id,sizeof(timer_t)))
|
||||
return -EFAULT;
|
||||
|
||||
oldfs = get_fs();
|
||||
set_fs(KERNEL_DS);
|
||||
err = sys_timer_create(clock, (struct sigevent __user *) &se, (timer_t __user *) &t);
|
||||
set_fs(oldfs);
|
||||
|
||||
if (!err)
|
||||
err = __put_user (t, timer_id);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
|
||||
__u32 len_low, __u32 len_high, int advice)
|
||||
{
|
||||
|
|
|
@ -956,38 +956,6 @@ long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low,
|
|||
advice);
|
||||
}
|
||||
|
||||
long ppc32_timer_create(clockid_t clock,
|
||||
struct compat_sigevent __user *ev32,
|
||||
timer_t __user *timer_id)
|
||||
{
|
||||
sigevent_t event;
|
||||
timer_t t;
|
||||
long err;
|
||||
mm_segment_t savefs;
|
||||
|
||||
if (ev32 == NULL)
|
||||
return sys_timer_create(clock, NULL, timer_id);
|
||||
|
||||
if (get_compat_sigevent(&event, ev32))
|
||||
return -EFAULT;
|
||||
|
||||
if (!access_ok(VERIFY_WRITE, timer_id, sizeof(timer_t)))
|
||||
return -EFAULT;
|
||||
|
||||
savefs = get_fs();
|
||||
set_fs(KERNEL_DS);
|
||||
/* The __user pointer casts are valid due to the set_fs() */
|
||||
err = sys_timer_create(clock,
|
||||
(sigevent_t __user *) &event,
|
||||
(timer_t __user *) &t);
|
||||
set_fs(savefs);
|
||||
|
||||
if (err == 0)
|
||||
err = __put_user(t, timer_id);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
asmlinkage long compat_sys_add_key(const char __user *_type,
|
||||
const char __user *_description,
|
||||
const void __user *_payload,
|
||||
|
|
|
@ -281,7 +281,7 @@ SYSCALL(epoll_create)
|
|||
SYSCALL(epoll_ctl)
|
||||
SYSCALL(epoll_wait)
|
||||
SYSCALL(remap_file_pages)
|
||||
SYSX(sys_timer_create,ppc32_timer_create,sys_timer_create)
|
||||
SYSX(sys_timer_create,compat_sys_timer_create,sys_timer_create)
|
||||
COMPAT_SYS(timer_settime)
|
||||
COMPAT_SYS(timer_gettime)
|
||||
SYSCALL(timer_getoverrun)
|
||||
|
|
|
@ -1013,38 +1013,6 @@ asmlinkage long sys32_clone(struct pt_regs regs)
|
|||
parent_tidptr, child_tidptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wrapper function for sys_timer_create.
|
||||
*/
|
||||
extern asmlinkage long
|
||||
sys_timer_create(clockid_t, struct sigevent *, timer_t *);
|
||||
|
||||
asmlinkage long
|
||||
sys32_timer_create(clockid_t which_clock, struct compat_sigevent *se32,
|
||||
timer_t *timer_id)
|
||||
{
|
||||
struct sigevent se;
|
||||
timer_t ktimer_id;
|
||||
mm_segment_t old_fs;
|
||||
long ret;
|
||||
|
||||
if (se32 == NULL)
|
||||
return sys_timer_create(which_clock, NULL, timer_id);
|
||||
|
||||
if (get_compat_sigevent(&se, se32))
|
||||
return -EFAULT;
|
||||
|
||||
old_fs = get_fs();
|
||||
set_fs(KERNEL_DS);
|
||||
ret = sys_timer_create(which_clock, &se, &ktimer_id);
|
||||
set_fs(old_fs);
|
||||
|
||||
if (!ret)
|
||||
ret = put_user (ktimer_id, timer_id);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* 31 bit emulation wrapper functions for sys_fadvise64/fadvise64_64.
|
||||
* These need to rewrite the advise values for POSIX_FADV_{DONTNEED,NOREUSE}
|
||||
|
|
|
@ -1289,7 +1289,7 @@ sys32_timer_create_wrapper:
|
|||
lgfr %r2,%r2 # timer_t (int)
|
||||
llgtr %r3,%r3 # struct compat_sigevent *
|
||||
llgtr %r4,%r4 # timer_t *
|
||||
jg sys32_timer_create
|
||||
jg compat_sys_timer_create
|
||||
|
||||
.globl sys32_timer_settime_wrapper
|
||||
sys32_timer_settime_wrapper:
|
||||
|
|
|
@ -1120,39 +1120,3 @@ long sys32_lookup_dcookie(unsigned long cookie_high,
|
|||
return sys_lookup_dcookie((cookie_high << 32) | cookie_low,
|
||||
buf, len);
|
||||
}
|
||||
|
||||
extern asmlinkage long
|
||||
sys_timer_create(clockid_t which_clock,
|
||||
struct sigevent __user *timer_event_spec,
|
||||
timer_t __user *created_timer_id);
|
||||
|
||||
long
|
||||
sys32_timer_create(u32 clock, struct compat_sigevent __user *se32,
|
||||
timer_t __user *timer_id)
|
||||
{
|
||||
struct sigevent se;
|
||||
mm_segment_t oldfs;
|
||||
timer_t t;
|
||||
long err;
|
||||
|
||||
if (se32 == NULL)
|
||||
return sys_timer_create(clock, NULL, timer_id);
|
||||
|
||||
if (get_compat_sigevent(&se, se32))
|
||||
return -EFAULT;
|
||||
|
||||
if (!access_ok(VERIFY_WRITE,timer_id,sizeof(timer_t)))
|
||||
return -EFAULT;
|
||||
|
||||
oldfs = get_fs();
|
||||
set_fs(KERNEL_DS);
|
||||
err = sys_timer_create(clock,
|
||||
(struct sigevent __user *) &se,
|
||||
(timer_t __user *) &t);
|
||||
set_fs(oldfs);
|
||||
|
||||
if (!err)
|
||||
err = __put_user (t, timer_id);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ sys_call_table32:
|
|||
/*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
|
||||
.word sys_ni_syscall, sys32_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
|
||||
/*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
|
||||
.word sys_timer_delete, sys32_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
|
||||
.word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
|
||||
/*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
|
||||
.word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
|
||||
/*280*/ .word sys_ni_syscall, sys_add_key, sys_request_key, sys_keyctl
|
||||
|
|
|
@ -608,7 +608,7 @@ ia32_sys_call_table:
|
|||
.quad sys_epoll_wait
|
||||
.quad sys_remap_file_pages
|
||||
.quad sys_set_tid_address
|
||||
.quad sys32_timer_create
|
||||
.quad compat_sys_timer_create
|
||||
.quad compat_sys_timer_settime /* 260 */
|
||||
.quad compat_sys_timer_gettime
|
||||
.quad sys_timer_getoverrun
|
||||
|
|
|
@ -969,25 +969,6 @@ long sys32_kill(int pid, int sig)
|
|||
return sys_kill(pid, sig);
|
||||
}
|
||||
|
||||
extern asmlinkage long
|
||||
sys_timer_create(clockid_t which_clock,
|
||||
struct sigevent __user *timer_event_spec,
|
||||
timer_t __user * created_timer_id);
|
||||
|
||||
long
|
||||
sys32_timer_create(u32 clock, struct compat_sigevent __user *se32, timer_t __user *timer_id)
|
||||
{
|
||||
struct sigevent __user *p = NULL;
|
||||
if (se32) {
|
||||
struct sigevent se;
|
||||
p = compat_alloc_user_space(sizeof(struct sigevent));
|
||||
if (get_compat_sigevent(&se, se32) ||
|
||||
copy_to_user(p, &se, sizeof(se)))
|
||||
return -EFAULT;
|
||||
}
|
||||
return sys_timer_create(clock, p, timer_id);
|
||||
}
|
||||
|
||||
long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
|
||||
__u32 len_low, __u32 len_high, int advice)
|
||||
{
|
||||
|
|
|
@ -514,6 +514,24 @@ static int put_compat_itimerspec(struct compat_itimerspec __user *dst,
|
|||
return 0;
|
||||
}
|
||||
|
||||
long compat_sys_timer_create(clockid_t which_clock,
|
||||
struct compat_sigevent __user *timer_event_spec,
|
||||
timer_t __user *created_timer_id)
|
||||
{
|
||||
struct sigevent __user *event = NULL;
|
||||
|
||||
if (timer_event_spec) {
|
||||
struct sigevent kevent;
|
||||
|
||||
event = compat_alloc_user_space(sizeof(*event));
|
||||
if (get_compat_sigevent(&kevent, timer_event_spec) ||
|
||||
copy_to_user(event, &kevent, sizeof(*event)))
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return sys_timer_create(which_clock, event, created_timer_id);
|
||||
}
|
||||
|
||||
long compat_sys_timer_settime(timer_t timer_id, int flags,
|
||||
struct compat_itimerspec __user *new,
|
||||
struct compat_itimerspec __user *old)
|
||||
|
@ -649,8 +667,6 @@ int get_compat_sigevent(struct sigevent *event,
|
|||
? -EFAULT : 0;
|
||||
}
|
||||
|
||||
/* timer_create is architecture specific because it needs sigevent conversion */
|
||||
|
||||
long compat_get_bitmap(unsigned long *mask, compat_ulong_t __user *umask,
|
||||
unsigned long bitmap_size)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue