From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
To: y2038-cunTk1MwBs8s++Sfvej+rw@public.gmane.org
Cc: baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org,
albert.aribaud-iEu9NFBzPZE@public.gmane.org,
john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
ruchandani.tina-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
libc-alpha-9JcytcrH/bA+uJoB2kUjGw@public.gmane.org,
Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Subject: [PATCH 06/19] y2038: compile compat time code even when CONFIG_COMPAT is not set
Date: Wed, 6 May 2015 18:30:13 +0200 [thread overview]
Message-ID: <1430929826-318934-7-git-send-email-arnd@arndb.de> (raw)
In-Reply-To: <1430929826-318934-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>
For the time being, we use conditional compilation in fs/compat.c
and kernel/compat.c to differentiate two cases:
a) code that is used for CONFIG_COMPAT_TIME is shared between
32-bit and 64-bit architectures that provide support for
existing 32-bit binaries with 32-bit time_t
b) code that is defined under CONFIG_COMPAT is only used on
64-bit machines to provide support for 32-bit binaries,
either system calls that do not use time_t or (rare) that use a
64-bit time_t in compat mode.
We probably want to split those into separate files in the long
run, but at the moment, this makes it easier to avoid merge
conflicts.
Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
---
fs/Makefile | 1 +
fs/compat.c | 12 +++++++++++-
include/linux/thread_info.h | 2 +-
kernel/Makefile | 1 +
kernel/compat.c | 28 ++++++++++++++++++++++++++++
5 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/fs/Makefile b/fs/Makefile
index cb92fd4c3172..77f876cd94be 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_AIO) += aio.o
obj-$(CONFIG_FS_DAX) += dax.o
obj-$(CONFIG_FILE_LOCKING) += locks.o
obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o
+obj-$(CONFIG_COMPAT_TIME) += compat.o
obj-$(CONFIG_BINFMT_AOUT) += binfmt_aout.o
obj-$(CONFIG_BINFMT_EM86) += binfmt_em86.o
obj-$(CONFIG_BINFMT_MISC) += binfmt_misc.o
diff --git a/fs/compat.c b/fs/compat.c
index 7d78cde20fc3..c5065aa1852c 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -54,6 +54,7 @@
#include <asm/ioctls.h>
#include "internal.h"
+#ifdef CONFIG_COMPAT_TIME
/*
* Not all architectures have sys_utime, so implement this in terms
* of sys_utimes.
@@ -194,7 +195,9 @@ COMPAT_SYSCALL_DEFINE2(newfstat, unsigned int, fd,
error = cp_compat_stat(&stat, statbuf);
return error;
}
+#endif /* CONFIG_COMPAT_TIME */
+#ifdef CONFIG_COMPAT
static int put_compat_statfs(struct compat_statfs __user *ubuf, struct kstatfs *kbuf)
{
@@ -505,7 +508,9 @@ COMPAT_SYSCALL_DEFINE2(io_setup, unsigned, nr_reqs, u32 __user *, ctx32p)
ret = put_user((u32) ctx64, ctx32p);
return ret;
}
+#endif
+#ifdef CONFIG_COMPAT_TIME
COMPAT_SYSCALL_DEFINE5(io_getevents, compat_aio_context_t, ctx_id,
compat_long_t, min_nr,
compat_long_t, nr,
@@ -525,7 +530,9 @@ COMPAT_SYSCALL_DEFINE5(io_getevents, compat_aio_context_t, ctx_id,
}
return sys_io_getevents(ctx_id, min_nr, nr, events, ut);
}
+#endif
+#ifdef CONFIG_COMPAT
/* A write operation does a read from user space and vice versa */
#define vrfy_dir(type) ((type) == READ ? VERIFY_WRITE : VERIFY_READ)
@@ -1086,7 +1093,9 @@ COMPAT_SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, fla
{
return do_sys_open(dfd, filename, flags, mode);
}
+#endif
+#ifdef CONFIG_COMPAT_TIME
#define __COMPAT_NFDBITS (8 * sizeof(compat_ulong_t))
static int poll_select_copy_remaining(struct timespec *end_time, void __user *p,
@@ -1453,8 +1462,9 @@ COMPAT_SYSCALL_DEFINE5(ppoll, struct pollfd __user *, ufds,
return ret;
}
+#endif
-#ifdef CONFIG_FHANDLE
+#if defined(CONFIG_FHANDLE) && defined(CONFIG_COMPAT)
/*
* Exactly like fs/open.c:sys_open_by_handle_at(), except that it
* doesn't set the O_LARGEFILE flag.
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index ff307b548ed3..43686bb94374 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -32,7 +32,7 @@ struct restart_block {
struct {
clockid_t clockid;
struct timespec __user *rmtp;
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_COMPAT_TIME
struct compat_timespec __user *compat_rmtp;
#endif
u64 expires;
diff --git a/kernel/Makefile b/kernel/Makefile
index 60c302cfb4d3..970f880a5f17 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -53,6 +53,7 @@ obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
obj-$(CONFIG_KEXEC) += kexec.o
obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o
obj-$(CONFIG_COMPAT) += compat.o
+obj-$(CONFIG_COMPAT_TIME) += compat.o
obj-$(CONFIG_CGROUPS) += cgroup.o
obj-$(CONFIG_CGROUP_FREEZER) += cgroup_freezer.o
obj-$(CONFIG_CPUSETS) += cpuset.o
diff --git a/kernel/compat.c b/kernel/compat.c
index 24f00610c575..115ad84d4048 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -30,6 +30,7 @@
#include <asm/uaccess.h>
+#ifdef CONFIG_COMPAT_TIME
static int compat_get_timex(struct timex *txc, struct compat_timex __user *utp)
{
memset(txc, 0, sizeof(struct timex));
@@ -190,6 +191,7 @@ int compat_put_timespec(const struct timespec *ts, void __user *uts)
}
EXPORT_SYMBOL_GPL(compat_put_timespec);
+#ifdef CONFIG_COMPAT
int compat_convert_timespec(struct timespec __user **kts,
const void __user *cts)
{
@@ -212,6 +214,7 @@ int compat_convert_timespec(struct timespec __user **kts,
*kts = uts;
return 0;
}
+#endif
static long compat_nanosleep_restart(struct restart_block *restart)
{
@@ -339,7 +342,9 @@ COMPAT_SYSCALL_DEFINE3(setitimer, int, which,
return -EFAULT;
return 0;
}
+#endif
+#ifdef CONFIG_COMPAT
static compat_clock_t clock_t_to_compat_clock_t(clock_t x)
{
return compat_jiffies_to_clock_t(clock_t_to_jiffies(x));
@@ -507,7 +512,9 @@ COMPAT_SYSCALL_DEFINE2(getrlimit, unsigned int, resource,
}
return ret;
}
+#endif
+#ifdef CONFIG_COMPAT_TIME
int put_compat_rusage(const struct rusage *r, struct compat_rusage __user *ru)
{
if (!access_ok(VERIFY_WRITE, ru, sizeof(*ru)) ||
@@ -598,7 +605,9 @@ COMPAT_SYSCALL_DEFINE5(waitid,
info.si_code |= __SI_CHLD;
return copy_siginfo_to_user32(uinfo, &info);
}
+#endif
+#ifdef CONFIG_COMPAT
static int compat_get_user_cpu_mask(compat_ulong_t __user *user_mask_ptr,
unsigned len, struct cpumask *new_mask)
{
@@ -660,7 +669,9 @@ COMPAT_SYSCALL_DEFINE3(sched_getaffinity, compat_pid_t, pid, unsigned int, len,
return ret;
}
+#endif
+#ifdef CONFIG_COMPAT_TIME
int get_compat_itimerspec(struct itimerspec *dst,
const struct compat_itimerspec __user *src)
{
@@ -678,7 +689,9 @@ int put_compat_itimerspec(struct compat_itimerspec __user *dst,
return -EFAULT;
return 0;
}
+#endif
+#ifdef CONFIG_COMPAT
COMPAT_SYSCALL_DEFINE3(timer_create, clockid_t, which_clock,
struct compat_sigevent __user *, timer_event_spec,
timer_t __user *, created_timer_id)
@@ -696,7 +709,9 @@ COMPAT_SYSCALL_DEFINE3(timer_create, clockid_t, which_clock,
return sys_timer_create(which_clock, event, created_timer_id);
}
+#endif
+#ifdef CONFIG_COMPAT_TIME
COMPAT_SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags,
struct compat_itimerspec __user *, new,
struct compat_itimerspec __user *, old)
@@ -865,7 +880,9 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
}
return err;
}
+#endif
+#ifdef CONFIG_COMPAT
/*
* We currently only need the following fields from the sigevent
* structure: sigev_value, sigev_signo, sig_notify and (sometimes
@@ -991,6 +1008,7 @@ sigset_to_compat(compat_sigset_t *compat, const sigset_t *set)
}
}
+#ifdef CONFIG_COMPAT_TIME
COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait, compat_sigset_t __user *, uthese,
struct compat_siginfo __user *, uinfo,
struct compat_timespec __user *, uts, compat_size_t, sigsetsize)
@@ -1022,7 +1040,10 @@ COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait, compat_sigset_t __user *, uthese,
return ret;
}
+#endif
+#endif
+#ifdef CONFIG_COMPAT_TIME
#ifdef __ARCH_WANT_COMPAT_SYS_TIME
/* compat_time_t is a 32 bit "long" and needs to get converted. */
@@ -1080,7 +1101,9 @@ COMPAT_SYSCALL_DEFINE1(adjtimex, struct compat_timex __user *, utp)
return ret;
}
+#endif
+#ifdef CONFIG_COMPAT
#ifdef CONFIG_NUMA
COMPAT_SYSCALL_DEFINE6(move_pages, pid_t, pid, compat_ulong_t, nr_pages,
compat_uptr_t __user *, pages32,
@@ -1135,7 +1158,9 @@ COMPAT_SYSCALL_DEFINE4(migrate_pages, compat_pid_t, pid,
return sys_migrate_pages(pid, nr_bits + 1, old, new);
}
#endif
+#endif
+#ifdef CONFIG_COMPAT_TIME
COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval,
compat_pid_t, pid,
struct compat_timespec __user *, interval)
@@ -1151,7 +1176,9 @@ COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval,
return -EFAULT;
return ret;
}
+#endif
+#ifdef CONFIG_COMPAT
/*
* Allocate user-space memory for the duration of a single system call,
* in order to marshall parameters inside a compat thunk.
@@ -1172,3 +1199,4 @@ void __user *compat_alloc_user_space(unsigned long len)
return ptr;
}
EXPORT_SYMBOL_GPL(compat_alloc_user_space);
+#endif
--
2.1.0.rc2
next prev parent reply other threads:[~2015-05-06 16:30 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-06 16:30 [PATCH 00/19] converting system calls to 64-bit time_t, part 1 Arnd Bergmann
2015-05-06 16:30 ` [PATCH 01/19] compat: remove compat_printk Arnd Bergmann
2015-05-06 16:30 ` [PATCH 02/19] initramfs: use vfs_stat/lstat directly Arnd Bergmann
2015-05-06 16:30 ` [PATCH 03/19] y2038: introduce linux/compat_time.h header Arnd Bergmann
2015-05-06 16:30 ` [PATCH 04/19] y2038: introduce CONFIG_COMPAT_TIME Arnd Bergmann
2015-05-06 16:30 ` [PATCH 05/19] y2038: make linux/compat_time.h usable on 32-bit Arnd Bergmann
2015-05-06 16:30 ` [PATCH 07/19] y2038: add compat_sys_rt_sigtimedwait variants Arnd Bergmann
2015-05-06 16:30 ` [PATCH 08/19] y2038: introduce struct __kernel_timespec Arnd Bergmann
2015-05-06 16:30 ` [PATCH 10/19] y2038: use __kernel_stat for sys_newstat syscalls Arnd Bergmann
2015-05-06 16:30 ` [PATCH 12/19] y2038: add compat_{get,put}_timespec64 Arnd Bergmann
2015-05-06 16:30 ` [PATCH 13/19] y2038: add compat handling for sys_semtimedop Arnd Bergmann
[not found] ` <1430929826-318934-14-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>
2015-05-15 22:46 ` Thomas Gleixner
2015-05-16 7:28 ` Arnd Bergmann
2015-05-16 19:54 ` Arnd Bergmann
2015-05-19 9:19 ` Thomas Gleixner
2015-05-06 16:30 ` [PATCH 14/19] y2038: use __kernel_timespec for sys_mq_timed{send,receive} Arnd Bergmann
2015-05-06 16:30 ` [PATCH 15/19] y2038: introduce timespec64_to_jiffies Arnd Bergmann
2015-05-19 9:28 ` Thomas Gleixner
2015-05-06 16:30 ` [PATCH 16/19] y2038: use __kernel_timespec in sys_rt_sigtimedwait Arnd Bergmann
2015-05-19 9:28 ` Thomas Gleixner
2015-05-06 16:30 ` [PATCH 17/19] y2038: use __kernel_timespec in sys_futex Arnd Bergmann
2015-05-15 22:53 ` Thomas Gleixner
2015-05-16 7:21 ` Thomas Gleixner
[not found] ` <1430929826-318934-18-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>
2015-05-19 9:24 ` Thomas Gleixner
2015-05-06 16:30 ` [PATCH 18/19] y2038: introduce jiffies_to_timespec64 Arnd Bergmann
[not found] ` <1430929826-318934-19-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>
2015-05-19 9:25 ` Thomas Gleixner
2015-05-06 16:30 ` [PATCH 19/19] y2038: use __kernel_timespec in sys_sched_rr_get_interval Arnd Bergmann
2015-05-19 9:27 ` Thomas Gleixner
[not found] ` <1430929826-318934-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>
2015-05-06 16:30 ` Arnd Bergmann [this message]
2015-05-06 16:30 ` [PATCH 09/19] y2038: introduce struct __kernel_stat Arnd Bergmann
2015-05-06 16:30 ` [PATCH 11/19] y2038: introduce and use struct __kernel_rusage Arnd Bergmann
2015-05-07 7:27 ` [PATCH 00/19] converting system calls to 64-bit time_t, part 1 Paul Bolle
2015-05-07 7:39 ` Paul Bolle
2015-05-07 8:52 ` Arnd Bergmann
2015-05-07 9:24 ` Paul Bolle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1430929826-318934-7-git-send-email-arnd@arndb.de \
--to=arnd-r2ngtmty4d4@public.gmane.org \
--cc=albert.aribaud-iEu9NFBzPZE@public.gmane.org \
--cc=bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=libc-alpha-9JcytcrH/bA+uJoB2kUjGw@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ruchandani.tina-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
--cc=y2038-cunTk1MwBs8s++Sfvej+rw@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).