Re: [Y2038] [PATCH v4 02/10] include: Move compat_timespec/ timeval to compat_time.h

2018-03-14 Thread Deepa Dinamani
On Wed, Mar 14, 2018 at 1:52 PM, Arnd Bergmann  wrote:
> On Wed, Mar 14, 2018 at 4:50 AM, Deepa Dinamani  
> wrote:
>> The file arch/arm64/kernel/process.c needs asm/compat.h also to be
>> included directly since this is included conditionally from
>> include/compat.h. This does seem to be typical of arm64 as I was not
>> completely able to get rid of asm/compat.h includes for arm64 in this
>> series. My plan is to have separate patches to get rid of asm/compat.h
>> includes for the architectures that are not straight forward to keep
>> this series simple.
>> I will fix this and update the series.
>>
>
> I ran across the same thing in two more files during randconfig testing on
> arm64 now, adding this fixup on top for the moment, but maybe there
> is a better way:

I was looking at how Al tested his uaccess patches:
https://www.spinics.net/lists/linux-fsdevel/msg108752.html

He seems to be running the kbuild bot tests on his own git.
Is it possible to verify it this way on the 2038 tree? Or, I could
host a tree also.

Thanks,
Deepa
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 02/10] include: Move compat_timespec/ timeval to compat_time.h

2018-03-13 Thread Deepa Dinamani
All the current architecture specific defines for these
are the same. Refactor these common defines to a common
header file.

The new common linux/compat_time.h is also useful as it
will eventually be used to hold all the defines that
are needed for compat time types that support non y2038
safe types. New architectures need not have to define these
new types as they will only use new y2038 safe syscalls.
This file can be deleted after y2038 when we stop supporting
non y2038 safe syscalls.

The patch also requires an operation similar to:

git grep "asm/compat\.h" | cut -d ":" -f 1 |  xargs -n 1 sed -i -e 
"s%asm/compat.h%linux/compat.h%g"

Cc: a...@kernel.org
Cc: b...@kernel.crashing.org
Cc: borntrae...@de.ibm.com
Cc: catalin.mari...@arm.com
Cc: cmetc...@mellanox.com
Cc: coh...@redhat.com
Cc: da...@davemloft.net
Cc: del...@gmx.de
Cc: de...@driverdev.osuosl.org
Cc: gerald.schae...@de.ibm.com
Cc: gre...@linuxfoundation.org
Cc: heiko.carst...@de.ibm.com
Cc: hoepp...@linux.vnet.ibm.com
Cc: h...@zytor.com
Cc: j...@parisc-linux.org
Cc: j...@linux.vnet.ibm.com
Cc: linux-ker...@vger.kernel.org
Cc: linux-m...@linux-mips.org
Cc: linux-par...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: mark.rutl...@arm.com
Cc: mi...@redhat.com
Cc: m...@ellerman.id.au
Cc: ober...@linux.vnet.ibm.com
Cc: oprofile-l...@lists.sf.net
Cc: pau...@samba.org
Cc: pet...@infradead.org
Cc: r...@linux-mips.org
Cc: rost...@goodmis.org
Cc: r...@kernel.org
Cc: schwidef...@de.ibm.com
Cc: seb...@linux.vnet.ibm.com
Cc: sparcli...@vger.kernel.org
Cc: s...@linux.vnet.ibm.com
Cc: ubr...@linux.vnet.ibm.com
Cc: will.dea...@arm.com
Cc: x...@kernel.org
Signed-off-by: Arnd Bergmann 
Signed-off-by: Deepa Dinamani 
Acked-by: Steven Rostedt (VMware) 
Acked-by: Catalin Marinas 
Acked-by: James Hogan 
Acked-by: Helge Deller 
---
 arch/arm64/include/asm/compat.h   | 11 ---
 arch/arm64/include/asm/stat.h |  1 +
 arch/arm64/kernel/hw_breakpoint.c |  1 -
 arch/arm64/kernel/perf_regs.c |  2 +-
 arch/mips/include/asm/compat.h| 11 ---
 arch/mips/kernel/signal32.c   |  2 +-
 arch/parisc/include/asm/compat.h  | 11 ---
 arch/powerpc/include/asm/compat.h | 11 ---
 arch/powerpc/kernel/asm-offsets.c |  2 +-
 arch/powerpc/oprofile/backtrace.c |  1 +
 arch/s390/hypfs/hypfs_sprp.c  |  1 -
 arch/s390/include/asm/compat.h| 11 ---
 arch/s390/include/asm/elf.h   |  4 ++--
 arch/s390/kvm/priv.c  |  1 -
 arch/s390/pci/pci_clp.c   |  1 -
 arch/sparc/include/asm/compat.h   | 11 ---
 arch/tile/include/asm/compat.h| 11 ---
 arch/x86/events/core.c|  2 +-
 arch/x86/include/asm/compat.h | 11 ---
 arch/x86/include/asm/ftrace.h |  2 +-
 arch/x86/include/asm/sys_ia32.h   |  2 +-
 arch/x86/kernel/sys_x86_64.c  |  2 +-
 drivers/s390/block/dasd_ioctl.c   |  1 -
 drivers/s390/char/fs3270.c|  1 -
 drivers/s390/char/sclp_ctl.c  |  1 -
 drivers/s390/char/vmcp.c  |  1 -
 drivers/s390/cio/chsc_sch.c   |  1 -
 drivers/s390/net/qeth_core_main.c |  2 +-
 include/linux/compat.h|  1 +
 include/linux/compat_time.h   | 19 +++
 30 files changed, 32 insertions(+), 107 deletions(-)
 create mode 100644 include/linux/compat_time.h

diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index c00c62e1a4a3..0030f79808b3 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -34,7 +34,6 @@
 
 typedef u32compat_size_t;
 typedef s32compat_ssize_t;
-typedef s32compat_time_t;
 typedef s32compat_clock_t;
 typedef s32compat_pid_t;
 typedef u16__compat_uid_t;
@@ -66,16 +65,6 @@ typedef u32  compat_ulong_t;
 typedef u64compat_u64;
 typedef u32compat_uptr_t;
 
-struct compat_timespec {
-   compat_time_t   tv_sec;
-   s32 tv_nsec;
-};
-
-struct compat_timeval {
-   compat_time_t   tv_sec;
-   s32 tv_usec;
-};
-
 struct compat_stat {
 #ifdef __AARCH64EB__
short   st_dev;
diff --git a/arch/arm64/include/asm/stat.h b/arch/arm64/include/asm/stat.h
index 15e35598ac40..eab738019707 100644
--- a/arch/arm64/include/asm/stat.h
+++ b/arch/arm64/include/asm/stat.h
@@ -20,6 +20,7 @@
 
 #ifdef CONFIG_COMPAT
 
+#include 
 #include 
 
 /*
diff --git a/arch/arm64/kernel/hw_breakpoint.c 
b/arch/arm64/kernel/hw_breakpoint.c
index 74bb56f656ef..413dbe530da8 100644
--- a/arch/arm64/kernel/hw_breakpoint.c
+++ b/arch/arm64/kernel/hw_breakpoint.c
@@ -30,7 +30,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c
index 1d091d048d04..0bbac612146e 100644
--- a/arch/arm64/kernel/perf_regs.c
+++ b/arch/arm64/kernel/perf_regs.c
@@ -1,11 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0
+

[PATCH v5 00/10] posix_clocks: Prepare syscalls for 64 bit time_t conversion

2018-03-13 Thread Deepa Dinamani
The series is a preparation series for individual architectures
to use 64 bit time_t syscalls in compat and 32 bit emulation modes.

This is a follow up to the series Arnd Bergmann posted:
https://sourceware.org/ml/libc-alpha/2015-05/msg00070.html [1]

Thomas, Arnd, this seems ready to be merged now.
Can you help get this merged?

Big picture is as per the lwn article:
https://lwn.net/Articles/643234/ [2]

The series is directed at converting posix clock syscalls:
clock_gettime, clock_settime, clock_getres and clock_nanosleep
to use a new data structure __kernel_timespec at syscall boundaries.
__kernel_timespec maintains 64 bit time_t across all execution modes.

vdso will be handled as part of each architecture when they enable
support for 64 bit time_t.

The compat syscalls are repurposed to provide backward compatibility
by using them as native syscalls as well for 32 bit architectures.
They will continue to use timespec at syscall boundaries.

CONFIG_64_BIT_TIME controls whether the syscalls use __kernel_timespec
or timespec at syscall boundaries.

The series does the following:
1. Enable compat syscalls on 32 bit architectures.
2. Add a new __kernel_timespec type to be used as the data structure
   for all the new syscalls.
3. Add new config CONFIG_64BIT_TIME(intead of the CONFIG_COMPAT_TIME in
   [1] and [2] to switch to new definition of __kernel_timespec. It is
   the same as struct timespec otherwise.
4. Add new CONFIG_32BIT_TIME to conditionally compile compat syscalls.

* Changes since v4:
 * Fixed up kbuild errors for arm64 and powerpc non compat configs
* Changes since v3:
 * Updated include file ordering
* Changes since v2:
 * Dropped the ARCH_HAS_64BIT_TIME config.
 * Fixed zeroing out of higher order bits of tv_nsec for real.
 * Addressed minor review comments from v1.
* Changes since v1:
 * Introduce CONFIG_32BIT_TIME
 * Fixed zeroing out of higher order bits of tv_nsec
 * Included Arnd's changes to fix up use of compat headers

I decided against using LEGACY_TIME_SYSCALLS to conditionally compile
legacy time syscalls such as sys_nanosleep because this will need to
enclose compat_sys_nanosleep as well. So, defining it as 

config LEGACY_TIME_SYSCALLS
 def_bool 64BIT || !64BIT_TIME

will not include compat_sys_nanosleep. We will instead need a new config to
exclusively mark legacy syscalls.

Deepa Dinamani (10):
  compat: Make compat helpers independent of CONFIG_COMPAT
  include: Move compat_timespec/ timeval to compat_time.h
  compat: enable compat_get/put_timespec64 always
  arch: introduce CONFIG_64BIT_TIME
  arch: Introduce CONFIG_COMPAT_32BIT_TIME
  posix-clocks: Make compat syscalls depend on CONFIG_COMPAT_32BIT_TIME
  include: Add new y2038 safe __kernel_timespec
  fix get_timespec64() for y2038 safe compat interfaces
  change time types to new y2038 safe __kernel_* types
  nanosleep: change time types to safe __kernel_* types

 arch/Kconfig   | 15 +
 arch/arm64/include/asm/compat.h| 11 ---
 arch/arm64/include/asm/stat.h  |  1 +
 arch/arm64/kernel/hw_breakpoint.c  |  1 -
 arch/arm64/kernel/perf_regs.c  |  2 +-
 arch/mips/include/asm/compat.h | 11 ---
 arch/mips/kernel/signal32.c|  2 +-
 arch/parisc/include/asm/compat.h   | 11 ---
 arch/powerpc/include/asm/compat.h  | 11 ---
 arch/powerpc/kernel/asm-offsets.c  |  2 +-
 arch/powerpc/oprofile/backtrace.c  |  1 +
 arch/s390/hypfs/hypfs_sprp.c   |  1 -
 arch/s390/include/asm/compat.h | 11 ---
 arch/s390/include/asm/elf.h|  4 +--
 arch/s390/kvm/priv.c   |  1 -
 arch/s390/pci/pci_clp.c|  1 -
 arch/sparc/include/asm/compat.h| 11 ---
 arch/tile/include/asm/compat.h | 11 ---
 arch/x86/events/core.c |  2 +-
 arch/x86/include/asm/compat.h  | 11 ---
 arch/x86/include/asm/ftrace.h  |  2 +-
 arch/x86/include/asm/sys_ia32.h|  2 +-
 arch/x86/kernel/sys_x86_64.c   |  2 +-
 drivers/s390/block/dasd_ioctl.c|  1 -
 drivers/s390/char/fs3270.c |  1 -
 drivers/s390/char/sclp_ctl.c   |  1 -
 drivers/s390/char/vmcp.c   |  1 -
 drivers/s390/cio/chsc_sch.c|  1 -
 drivers/s390/net/qeth_core_main.c  |  2 +-
 include/linux/compat.h | 11 ---
 include/linux/compat_time.h| 23 ++
 include/linux/restart_block.h  |  7 ++--
 include/linux/syscalls.h   | 12 +++
 include/linux/time.h   |  4 +--
 include/linux/time64.h | 10 +-
 include/uapi/asm-generic/posix_types.h |  1 +
 include/uapi/linux/time.h  |  7 
 kernel/compat.c| 52 +-
 kernel/time/hrtimer.c  | 10 --
 kernel/time/posix-stubs.c  | 12 ---
 kernel/time/posix-timers.c

Re: [PATCH v4 02/10] include: Move compat_timespec/ timeval to compat_time.h

2018-03-13 Thread Deepa Dinamani
This is again a tricky include file ordering when linux/compat.h is
included instead of asm/compat.h. is_compat_task() is unconditionally
defined in linux/compat.h as a macro which conflicts with inline
function define in asm/compat.h for this arch.
As before, I will do the simple thing here and leave the asm/compat.h
to keep this series simple.
I will submit follow up patches to eliminate direct inclusion asm/compat.h.

I will include this also in the update.

-Deepa

On Tue, Mar 13, 2018 at 8:30 AM, kbuild test robot  wrote:
> Hi Deepa,
>
> Thank you for the patch! Yet something to improve:
>
> [auto build test ERROR on ]
>
> url:
> https://github.com/0day-ci/linux/commits/Deepa-Dinamani/posix_clocks-Prepare-syscalls-for-64-bit-time_t-conversion/20180313-203305
> base:
> config: powerpc-iss476-smp_defconfig (attached as .config)
> compiler: powerpc-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
> reproduce:
> wget 
> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=powerpc
>
> All errors (new ones prefixed by >>):
>
>arch/powerpc/oprofile/backtrace.c: In function 'user_getsp32':
>>> arch/powerpc/oprofile/backtrace.c:31:19: error: implicit declaration of 
>>> function 'compat_ptr'; did you mean 'complete'? 
>>> [-Werror=implicit-function-declaration]
>  void __user *p = compat_ptr(sp);
>   ^~
>   complete
>>> arch/powerpc/oprofile/backtrace.c:31:19: error: initialization makes 
>>> pointer from integer without a cast [-Werror=int-conversion]
>cc1: all warnings being treated as errors
>
> vim +31 arch/powerpc/oprofile/backtrace.c
>
> 6c6bd754 Brian Rogan 2006-03-27  27
> 6c6bd754 Brian Rogan 2006-03-27  28  static unsigned int 
> user_getsp32(unsigned int sp, int is_first)
> 6c6bd754 Brian Rogan 2006-03-27  29  {
> 6c6bd754 Brian Rogan 2006-03-27  30 unsigned int stack_frame[2];
> 62034f03 Al Viro 2006-09-23 @31 void __user *p = compat_ptr(sp);
> 6c6bd754 Brian Rogan 2006-03-27  32
> 62034f03 Al Viro 2006-09-23  33 if (!access_ok(VERIFY_READ, p, 
> sizeof(stack_frame)))
> 6c6bd754 Brian Rogan 2006-03-27  34 return 0;
> 6c6bd754 Brian Rogan 2006-03-27  35
> 6c6bd754 Brian Rogan 2006-03-27  36 /*
> 6c6bd754 Brian Rogan 2006-03-27  37  * The most likely reason for this is 
> that we returned -EFAULT,
> 6c6bd754 Brian Rogan 2006-03-27  38  * which means that we've done all 
> that we can do from
> 6c6bd754 Brian Rogan 2006-03-27  39  * interrupt context.
> 6c6bd754 Brian Rogan 2006-03-27  40  */
> 62034f03 Al Viro 2006-09-23  41 if 
> (__copy_from_user_inatomic(stack_frame, p, sizeof(stack_frame)))
> 6c6bd754 Brian Rogan 2006-03-27  42 return 0;
> 6c6bd754 Brian Rogan 2006-03-27  43
> 6c6bd754 Brian Rogan 2006-03-27  44 if (!is_first)
> 6c6bd754 Brian Rogan 2006-03-27  45 
> oprofile_add_trace(STACK_LR32(stack_frame));
> 6c6bd754 Brian Rogan 2006-03-27  46
> 6c6bd754 Brian Rogan 2006-03-27  47 /*
> 6c6bd754 Brian Rogan 2006-03-27  48  * We do not enforce increasing stack 
> addresses here because
> 6c6bd754 Brian Rogan 2006-03-27  49  * we may transition to a different 
> stack, eg a signal handler.
> 6c6bd754 Brian Rogan 2006-03-27  50  */
> 6c6bd754 Brian Rogan 2006-03-27  51 return STACK_SP(stack_frame);
> 6c6bd754 Brian Rogan 2006-03-27  52  }
> 6c6bd754 Brian Rogan 2006-03-27  53
>
> :: The code at line 31 was first introduced by commit
> :: 62034f03380a64c0144b6721f4a2aa55d65346c1 [POWERPC] powerpc oprofile 
> __user annotations
>
> :: TO: Al Viro 
> :: CC: Paul Mackerras 
>
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [Y2038] [PATCH v4 02/10] include: Move compat_timespec/ timeval to compat_time.h

2018-03-13 Thread Deepa Dinamani
The file arch/arm64/kernel/process.c needs asm/compat.h also to be
included directly since this is included conditionally from
include/compat.h. This does seem to be typical of arm64 as I was not
completely able to get rid of asm/compat.h includes for arm64 in this
series. My plan is to have separate patches to get rid of asm/compat.h
includes for the architectures that are not straight forward to keep
this series simple.
I will fix this and update the series.

-Deepa


On Tue, Mar 13, 2018 at 8:22 AM, kbuild test robot  wrote:
> Hi Deepa,
>
> Thank you for the patch! Yet something to improve:
>
> [auto build test ERROR on ]
>
> url:
> https://github.com/0day-ci/linux/commits/Deepa-Dinamani/posix_clocks-Prepare-syscalls-for-64-bit-time_t-conversion/20180313-203305
> base:
> config: arm64-allnoconfig (attached as .config)
> compiler: aarch64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
> reproduce:
> wget 
> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=arm64
>
> All errors (new ones prefixed by >>):
>
>arch/arm64/kernel/process.c: In function 'copy_thread':
>>> arch/arm64/kernel/process.c:342:8: error: implicit declaration of function 
>>> 'is_compat_thread'; did you mean 'is_compat_task'? 
>>> [-Werror=implicit-function-declaration]
>if (is_compat_thread(task_thread_info(p)))
>^~~~
>is_compat_task
>cc1: some warnings being treated as errors
>
> vim +342 arch/arm64/kernel/process.c
>
> b3901d54d Catalin Marinas  2012-03-05  307
> b3901d54d Catalin Marinas  2012-03-05  308  int copy_thread(unsigned long 
> clone_flags, unsigned long stack_start,
> afa86fc42 Al Viro  2012-10-22  309  unsigned long stk_sz, 
> struct task_struct *p)
> b3901d54d Catalin Marinas  2012-03-05  310  {
> b3901d54d Catalin Marinas  2012-03-05  311  struct pt_regs *childregs = 
> task_pt_regs(p);
> b3901d54d Catalin Marinas  2012-03-05  312
> c34501d21 Catalin Marinas  2012-10-05  313  
> memset(&p->thread.cpu_context, 0, sizeof(struct cpu_context));
> c34501d21 Catalin Marinas  2012-10-05  314
> bc0ee4760 Dave Martin  2017-10-31  315  /*
> bc0ee4760 Dave Martin  2017-10-31  316   * Unalias 
> p->thread.sve_state (if any) from the parent task
> bc0ee4760 Dave Martin  2017-10-31  317   * and disable discard SVE 
> state for p:
> bc0ee4760 Dave Martin  2017-10-31  318   */
> bc0ee4760 Dave Martin  2017-10-31  319  clear_tsk_thread_flag(p, 
> TIF_SVE);
> bc0ee4760 Dave Martin  2017-10-31  320  p->thread.sve_state = NULL;
> bc0ee4760 Dave Martin  2017-10-31  321
> 071b6d4a5 Dave Martin  2017-12-05  322  /*
> 071b6d4a5 Dave Martin  2017-12-05  323   * In case p was allocated 
> the same task_struct pointer as some
> 071b6d4a5 Dave Martin  2017-12-05  324   * other recently-exited 
> task, make sure p is disassociated from
> 071b6d4a5 Dave Martin  2017-12-05  325   * any cpu that may have run 
> that now-exited task recently.
> 071b6d4a5 Dave Martin  2017-12-05  326   * Otherwise we could 
> erroneously skip reloading the FPSIMD
> 071b6d4a5 Dave Martin  2017-12-05  327   * registers for p.
> 071b6d4a5 Dave Martin  2017-12-05  328   */
> 071b6d4a5 Dave Martin  2017-12-05  329  fpsimd_flush_task_state(p);
> 071b6d4a5 Dave Martin  2017-12-05  330
> 9ac080021 Al Viro  2012-10-21  331  if (likely(!(p->flags & 
> PF_KTHREAD))) {
> 9ac080021 Al Viro  2012-10-21  332  *childregs = 
> *current_pt_regs();
> b3901d54d Catalin Marinas  2012-03-05  333  childregs->regs[0] = 
> 0;
> d00a3810c Will Deacon  2015-05-27  334
> b3901d54d Catalin Marinas  2012-03-05  335  /*
> b3901d54d Catalin Marinas  2012-03-05  336   * Read the current 
> TLS pointer from tpidr_el0 as it may be
> b3901d54d Catalin Marinas  2012-03-05  337   * out-of-sync with 
> the saved value.
> b3901d54d Catalin Marinas  2012-03-05  338   */
> adf758999 Mark Rutland 2016-09-08  339  *task_user_tls(p) = 
> read_sysreg(tpidr_el0);
> d00a3810c Will Deacon  2015-05-27  340
> e0fd18ce1 Al Viro  2012-10-18  341  if (stack_start) {
> d00a3810c Will Deacon  2015-05-27 @342  if 
> (is_compat_thread(task_thread_info(p)))
> d00a3810c Will Deacon  2015-05-27  343  
> childregs->compat_

Re: [PATCH v3 02/10] include: Move compat_timespec/ timeval to compat_time.h

2018-03-12 Thread Deepa Dinamani
I posted the updated series. I fixed up the order of include files
where I could find some order.
There have been other commits that used scripts to do such
replacements and have already stomped on the order.
For example:

commit 7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
Author: Linus Torvalds 
Replace  with  globally

-Deepa


On Tue, Mar 6, 2018 at 2:58 PM, Deepa Dinamani  wrote:
> On Tue, Mar 6, 2018 at 4:48 AM, Christian Borntraeger
>  wrote:
>>
>>
>> On 03/06/2018 01:46 PM, Arnd Bergmann wrote:
>>> On Mon, Mar 5, 2018 at 10:30 AM, Christian Borntraeger
>>>  wrote:
>>>> On 01/16/2018 03:18 AM, Deepa Dinamani wrote:
>>>>> All the current architecture specific defines for these
>>>>> are the same. Refactor these common defines to a common
>>>>> header file.
>>>>>
>>>>> The new common linux/compat_time.h is also useful as it
>>>>> will eventually be used to hold all the defines that
>>>>> are needed for compat time types that support non y2038
>>>>> safe types. New architectures need not have to define these
>>>>> new types as they will only use new y2038 safe syscalls.
>>>>> This file can be deleted after y2038 when we stop supporting
>>>>> non y2038 safe syscalls.
>>>>
>>>> You are now include a  from several asm files
>>>> (
>>>>  arch/arm64/include/asm/stat.h
>>>>  arch/s390/include/asm/elf.h
>>>>  arch/x86/include/asm/ftrace.h
>>>>  arch/x86/include/asm/sys_ia32.h
>>>> )
>>>> It works, and it is done in many places, but it looks somewhat weird.
>>>> Would it make sense to have an asm-generic/compate-time.h instead? Asking 
>>>> for
>>>> opinions here.
>>>
>>> I don't think we have such a rule. If a header file is common to all
>>> architectures (i.e. no architecture uses a different implementation),
>>> it should be in include/linux rather than include/asm-generic, regardless
>>> of whether it can be used by assembler files or not.
>>>
>>>>> --- a/drivers/s390/net/qeth_core_main.c
>>>>> +++ b/drivers/s390/net/qeth_core_main.c
>>>>> @@ -32,7 +32,7 @@
>>>>>  #include 
>>>>>  #include 
>>>>>  #include 
>>>>> -#include 
>>>>> +#include 
>>>>>  #include 
>>>>>  #include 
>>>>>  #include 
>>>>
>>>> Can you move that into the other includes (where all the other  
>>>> includes are.
>>>
>>> Good catch, this is definitely a rule we have ;-)
>>
>> FWIW, this was also broken for
>> arch/x86/include/asm/sys_ia32.h
>
> The reason that this was done this way is because of the sed script
> mentioned in the commit text.
> I was trying to make minimal change apart from the script so that we
> don't have other changes like moving the lines to keep the patch
> simpler.
> I will fix this by hand since this is preferred.
> I will post an update.
>
> -Deepa
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 02/10] include: Move compat_timespec/ timeval to compat_time.h

2018-03-12 Thread Deepa Dinamani
All the current architecture specific defines for these
are the same. Refactor these common defines to a common
header file.

The new common linux/compat_time.h is also useful as it
will eventually be used to hold all the defines that
are needed for compat time types that support non y2038
safe types. New architectures need not have to define these
new types as they will only use new y2038 safe syscalls.
This file can be deleted after y2038 when we stop supporting
non y2038 safe syscalls.

The patch also requires an operation similar to:

git grep "asm/compat\.h" | cut -d ":" -f 1 |  xargs -n 1 sed -i -e 
"s%asm/compat.h%linux/compat.h%g"

Cc: a...@kernel.org
Cc: b...@kernel.crashing.org
Cc: borntrae...@de.ibm.com
Cc: catalin.mari...@arm.com
Cc: cmetc...@mellanox.com
Cc: coh...@redhat.com
Cc: da...@davemloft.net
Cc: del...@gmx.de
Cc: de...@driverdev.osuosl.org
Cc: gerald.schae...@de.ibm.com
Cc: gre...@linuxfoundation.org
Cc: heiko.carst...@de.ibm.com
Cc: hoepp...@linux.vnet.ibm.com
Cc: h...@zytor.com
Cc: j...@parisc-linux.org
Cc: j...@linux.vnet.ibm.com
Cc: linux-ker...@vger.kernel.org
Cc: linux-m...@linux-mips.org
Cc: linux-par...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: mark.rutl...@arm.com
Cc: mi...@redhat.com
Cc: m...@ellerman.id.au
Cc: ober...@linux.vnet.ibm.com
Cc: oprofile-l...@lists.sf.net
Cc: pau...@samba.org
Cc: pet...@infradead.org
Cc: r...@linux-mips.org
Cc: rost...@goodmis.org
Cc: r...@kernel.org
Cc: schwidef...@de.ibm.com
Cc: seb...@linux.vnet.ibm.com
Cc: sparcli...@vger.kernel.org
Cc: s...@linux.vnet.ibm.com
Cc: ubr...@linux.vnet.ibm.com
Cc: will.dea...@arm.com
Cc: x...@kernel.org
Signed-off-by: Arnd Bergmann 
Signed-off-by: Deepa Dinamani 
Acked-by: Steven Rostedt (VMware) 
Acked-by: Catalin Marinas 
Acked-by: James Hogan 
Acked-by: Helge Deller 
---
 arch/arm64/include/asm/compat.h   | 11 ---
 arch/arm64/include/asm/stat.h |  1 +
 arch/arm64/kernel/hw_breakpoint.c |  1 -
 arch/arm64/kernel/perf_regs.c |  2 +-
 arch/arm64/kernel/process.c   |  1 -
 arch/mips/include/asm/compat.h| 11 ---
 arch/mips/kernel/signal32.c   |  2 +-
 arch/parisc/include/asm/compat.h  | 11 ---
 arch/powerpc/include/asm/compat.h | 11 ---
 arch/powerpc/kernel/asm-offsets.c |  2 +-
 arch/powerpc/oprofile/backtrace.c |  2 +-
 arch/s390/hypfs/hypfs_sprp.c  |  1 -
 arch/s390/include/asm/compat.h| 11 ---
 arch/s390/include/asm/elf.h   |  4 ++--
 arch/s390/kvm/priv.c  |  1 -
 arch/s390/pci/pci_clp.c   |  1 -
 arch/sparc/include/asm/compat.h   | 11 ---
 arch/tile/include/asm/compat.h| 11 ---
 arch/x86/events/core.c|  2 +-
 arch/x86/include/asm/compat.h | 11 ---
 arch/x86/include/asm/ftrace.h |  2 +-
 arch/x86/include/asm/sys_ia32.h   |  2 +-
 arch/x86/kernel/sys_x86_64.c  |  2 +-
 drivers/s390/block/dasd_ioctl.c   |  1 -
 drivers/s390/char/fs3270.c|  1 -
 drivers/s390/char/sclp_ctl.c  |  1 -
 drivers/s390/char/vmcp.c  |  1 -
 drivers/s390/cio/chsc_sch.c   |  1 -
 drivers/s390/net/qeth_core_main.c |  2 +-
 include/linux/compat.h|  1 +
 include/linux/compat_time.h   | 19 +++
 31 files changed, 32 insertions(+), 109 deletions(-)
 create mode 100644 include/linux/compat_time.h

diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index c00c62e1a4a3..0030f79808b3 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -34,7 +34,6 @@
 
 typedef u32compat_size_t;
 typedef s32compat_ssize_t;
-typedef s32compat_time_t;
 typedef s32compat_clock_t;
 typedef s32compat_pid_t;
 typedef u16__compat_uid_t;
@@ -66,16 +65,6 @@ typedef u32  compat_ulong_t;
 typedef u64compat_u64;
 typedef u32compat_uptr_t;
 
-struct compat_timespec {
-   compat_time_t   tv_sec;
-   s32 tv_nsec;
-};
-
-struct compat_timeval {
-   compat_time_t   tv_sec;
-   s32 tv_usec;
-};
-
 struct compat_stat {
 #ifdef __AARCH64EB__
short   st_dev;
diff --git a/arch/arm64/include/asm/stat.h b/arch/arm64/include/asm/stat.h
index 15e35598ac40..eab738019707 100644
--- a/arch/arm64/include/asm/stat.h
+++ b/arch/arm64/include/asm/stat.h
@@ -20,6 +20,7 @@
 
 #ifdef CONFIG_COMPAT
 
+#include 
 #include 
 
 /*
diff --git a/arch/arm64/kernel/hw_breakpoint.c 
b/arch/arm64/kernel/hw_breakpoint.c
index 74bb56f656ef..413dbe530da8 100644
--- a/arch/arm64/kernel/hw_breakpoint.c
+++ b/arch/arm64/kernel/hw_breakpoint.c
@@ -30,7 +30,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c
index 1d091d048d04..0bbac612146e 100644
--- a/arch/arm64/kernel/perf_regs.c
+++ b/arch/arm64/kernel/perf_regs.c
@@ -1,11 +1,11 @@
 /

[PATCH v4 00/10] posix_clocks: Prepare syscalls for 64 bit time_t conversion

2018-03-12 Thread Deepa Dinamani
The series is a preparation series for individual architectures
to use 64 bit time_t syscalls in compat and 32 bit emulation modes.

This is a follow up to the series Arnd Bergmann posted:
https://sourceware.org/ml/libc-alpha/2015-05/msg00070.html [1]

Thomas, Arnd, this seems ready to be merged now.
Can you help get this merged?

Big picture is as per the lwn article:
https://lwn.net/Articles/643234/ [2]

The series is directed at converting posix clock syscalls:
clock_gettime, clock_settime, clock_getres and clock_nanosleep
to use a new data structure __kernel_timespec at syscall boundaries.
__kernel_timespec maintains 64 bit time_t across all execution modes.

vdso will be handled as part of each architecture when they enable
support for 64 bit time_t.

The compat syscalls are repurposed to provide backward compatibility
by using them as native syscalls as well for 32 bit architectures.
They will continue to use timespec at syscall boundaries.

CONFIG_64_BIT_TIME controls whether the syscalls use __kernel_timespec
or timespec at syscall boundaries.

The series does the following:
1. Enable compat syscalls on 32 bit architectures.
2. Add a new __kernel_timespec type to be used as the data structure
   for all the new syscalls.
3. Add new config CONFIG_64BIT_TIME(intead of the CONFIG_COMPAT_TIME in
   [1] and [2] to switch to new definition of __kernel_timespec. It is
   the same as struct timespec otherwise.
4. Add new CONFIG_32BIT_TIME to conditionally compile compat syscalls.

* Changes since v3:
 * Updated include file ordering
* Changes since v2:
 * Dropped the ARCH_HAS_64BIT_TIME config.
 * Fixed zeroing out of higher order bits of tv_nsec for real.
 * Addressed minor review comments from v1.
* Changes since v1:
 * Introduce CONFIG_32BIT_TIME
 * Fixed zeroing out of higher order bits of tv_nsec
 * Included Arnd's changes to fix up use of compat headers

I decided against using LEGACY_TIME_SYSCALLS to conditionally compile
legacy time syscalls such as sys_nanosleep because this will need to
enclose compat_sys_nanosleep as well. So, defining it as 

config LEGACY_TIME_SYSCALLS
 def_bool 64BIT || !64BIT_TIME

will not include compat_sys_nanosleep. We will instead need a new config to
exclusively mark legacy syscalls.

Deepa Dinamani (10):
  compat: Make compat helpers independent of CONFIG_COMPAT
  include: Move compat_timespec/ timeval to compat_time.h
  compat: enable compat_get/put_timespec64 always
  arch: introduce CONFIG_64BIT_TIME
  arch: Introduce CONFIG_COMPAT_32BIT_TIME
  posix-clocks: Make compat syscalls depend on CONFIG_COMPAT_32BIT_TIME
  include: Add new y2038 safe __kernel_timespec
  fix get_timespec64() for y2038 safe compat interfaces
  change time types to new y2038 safe __kernel_* types
  nanosleep: change time types to safe __kernel_* types

 arch/Kconfig   | 15 +
 arch/arm64/include/asm/compat.h| 11 ---
 arch/arm64/include/asm/stat.h  |  1 +
 arch/arm64/kernel/hw_breakpoint.c  |  1 -
 arch/arm64/kernel/perf_regs.c  |  2 +-
 arch/arm64/kernel/process.c|  1 -
 arch/mips/include/asm/compat.h | 11 ---
 arch/mips/kernel/signal32.c|  2 +-
 arch/parisc/include/asm/compat.h   | 11 ---
 arch/powerpc/include/asm/compat.h  | 11 ---
 arch/powerpc/kernel/asm-offsets.c  |  2 +-
 arch/powerpc/oprofile/backtrace.c  |  2 +-
 arch/s390/hypfs/hypfs_sprp.c   |  1 -
 arch/s390/include/asm/compat.h | 11 ---
 arch/s390/include/asm/elf.h|  4 +--
 arch/s390/kvm/priv.c   |  1 -
 arch/s390/pci/pci_clp.c|  1 -
 arch/sparc/include/asm/compat.h| 11 ---
 arch/tile/include/asm/compat.h | 11 ---
 arch/x86/events/core.c |  2 +-
 arch/x86/include/asm/compat.h  | 11 ---
 arch/x86/include/asm/ftrace.h  |  2 +-
 arch/x86/include/asm/sys_ia32.h|  2 +-
 arch/x86/kernel/sys_x86_64.c   |  2 +-
 drivers/s390/block/dasd_ioctl.c|  1 -
 drivers/s390/char/fs3270.c |  1 -
 drivers/s390/char/sclp_ctl.c   |  1 -
 drivers/s390/char/vmcp.c   |  1 -
 drivers/s390/cio/chsc_sch.c|  1 -
 drivers/s390/net/qeth_core_main.c  |  2 +-
 include/linux/compat.h | 11 ---
 include/linux/compat_time.h| 23 ++
 include/linux/restart_block.h  |  7 ++--
 include/linux/syscalls.h   | 12 +++
 include/linux/time.h   |  4 +--
 include/linux/time64.h | 10 +-
 include/uapi/asm-generic/posix_types.h |  1 +
 include/uapi/linux/time.h  |  7 
 kernel/compat.c| 52 +-
 kernel/time/hrtimer.c  | 10 --
 kernel/time/posix-stubs.c  | 12 ---
 kernel/time/posix-timers.c | 24 ++
 kernel/time/time.c

Re: [PATCH v3 02/10] include: Move compat_timespec/ timeval to compat_time.h

2018-03-06 Thread Deepa Dinamani
On Tue, Mar 6, 2018 at 4:48 AM, Christian Borntraeger
 wrote:
>
>
> On 03/06/2018 01:46 PM, Arnd Bergmann wrote:
>> On Mon, Mar 5, 2018 at 10:30 AM, Christian Borntraeger
>>  wrote:
>>> On 01/16/2018 03:18 AM, Deepa Dinamani wrote:
>>>> All the current architecture specific defines for these
>>>> are the same. Refactor these common defines to a common
>>>> header file.
>>>>
>>>> The new common linux/compat_time.h is also useful as it
>>>> will eventually be used to hold all the defines that
>>>> are needed for compat time types that support non y2038
>>>> safe types. New architectures need not have to define these
>>>> new types as they will only use new y2038 safe syscalls.
>>>> This file can be deleted after y2038 when we stop supporting
>>>> non y2038 safe syscalls.
>>>
>>> You are now include a  from several asm files
>>> (
>>>  arch/arm64/include/asm/stat.h
>>>  arch/s390/include/asm/elf.h
>>>  arch/x86/include/asm/ftrace.h
>>>  arch/x86/include/asm/sys_ia32.h
>>> )
>>> It works, and it is done in many places, but it looks somewhat weird.
>>> Would it make sense to have an asm-generic/compate-time.h instead? Asking 
>>> for
>>> opinions here.
>>
>> I don't think we have such a rule. If a header file is common to all
>> architectures (i.e. no architecture uses a different implementation),
>> it should be in include/linux rather than include/asm-generic, regardless
>> of whether it can be used by assembler files or not.
>>
>>>> --- a/drivers/s390/net/qeth_core_main.c
>>>> +++ b/drivers/s390/net/qeth_core_main.c
>>>> @@ -32,7 +32,7 @@
>>>>  #include 
>>>>  #include 
>>>>  #include 
>>>> -#include 
>>>> +#include 
>>>>  #include 
>>>>  #include 
>>>>  #include 
>>>
>>> Can you move that into the other includes (where all the other  
>>> includes are.
>>
>> Good catch, this is definitely a rule we have ;-)
>
> FWIW, this was also broken for
> arch/x86/include/asm/sys_ia32.h

The reason that this was done this way is because of the sed script
mentioned in the commit text.
I was trying to make minimal change apart from the script so that we
don't have other changes like moving the lines to keep the patch
simpler.
I will fix this by hand since this is preferred.
I will post an update.

-Deepa
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 00/10] posix_clocks: Prepare syscalls for 64 bit time_t conversion

2018-01-15 Thread Deepa Dinamani
The series is a preparation series for individual architectures
to use 64 bit time_t syscalls in compat and 32 bit emulation modes.

This is a follow up to the series Arnd Bergmann posted:
https://sourceware.org/ml/libc-alpha/2015-05/msg00070.html [1]

Big picture is as per the lwn article:
https://lwn.net/Articles/643234/ [2]

The series is directed at converting posix clock syscalls:
clock_gettime, clock_settime, clock_getres and clock_nanosleep
to use a new data structure __kernel_timespec at syscall boundaries.
__kernel_timespec maintains 64 bit time_t across all execution modes.

vdso will be handled as part of each architecture when they enable
support for 64 bit time_t.

The compat syscalls are repurposed to provide backward compatibility
by using them as native syscalls as well for 32 bit architectures.
They will continue to use timespec at syscall boundaries.

CONFIG_64_BIT_TIME controls whether the syscalls use __kernel_timespec
or timespec at syscall boundaries.

The series does the following:
1. Enable compat syscalls on 32 bit architectures.
2. Add a new __kernel_timespec type to be used as the data structure
   for all the new syscalls.
3. Add new config CONFIG_64BIT_TIME(intead of the CONFIG_COMPAT_TIME in
   [1] and [2] to switch to new definition of __kernel_timespec. It is
   the same as struct timespec otherwise.
4. Add new CONFIG_32BIT_TIME to conditionally compile compat syscalls.

* Changes since v2:
 * Dropped the ARCH_HAS_64BIT_TIME config.
 * Fixed zeroing out of higher order bits of tv_nsec for real.
 * Addressed minor review comments from v1.
* Changes since v1:
 * Introduce CONFIG_32BIT_TIME
 * Fixed zeroing out of higher order bits of tv_nsec
 * Included Arnd's changes to fix up use of compat headers

I decided against using LEGACY_TIME_SYSCALLS to conditionally compile
legacy time syscalls such as sys_nanosleep because this will need to
enclose compat_sys_nanosleep as well. So, defining it as 

config LEGACY_TIME_SYSCALLS
 def_bool 64BIT || !64BIT_TIME

will not include compat_sys_nanosleep. We will instead need a new config to
exclusively mark legacy syscalls.

Deepa Dinamani (10):
  compat: Make compat helpers independent of CONFIG_COMPAT
  include: Move compat_timespec/ timeval to compat_time.h
  compat: enable compat_get/put_timespec64 always
  arch: introduce CONFIG_64BIT_TIME
  arch: Introduce CONFIG_COMPAT_32BIT_TIME
  posix-clocks: Make compat syscalls depend on CONFIG_COMPAT_32BIT_TIME
  include: Add new y2038 safe __kernel_timespec
  fix get_timespec64() for y2038 safe compat interfaces
  change time types to new y2038 safe __kernel_* types
  nanosleep: change time types to safe __kernel_* types

 arch/Kconfig   | 15 +
 arch/arm64/include/asm/compat.h| 11 ---
 arch/arm64/include/asm/stat.h  |  1 +
 arch/arm64/kernel/hw_breakpoint.c  |  1 -
 arch/arm64/kernel/perf_regs.c  |  2 +-
 arch/arm64/kernel/process.c|  1 -
 arch/mips/include/asm/compat.h | 11 ---
 arch/mips/kernel/signal32.c|  2 +-
 arch/parisc/include/asm/compat.h   | 11 ---
 arch/powerpc/include/asm/compat.h  | 11 ---
 arch/powerpc/kernel/asm-offsets.c  |  2 +-
 arch/powerpc/oprofile/backtrace.c  |  2 +-
 arch/s390/hypfs/hypfs_sprp.c   |  1 -
 arch/s390/include/asm/compat.h | 11 ---
 arch/s390/include/asm/elf.h|  3 +-
 arch/s390/kvm/priv.c   |  1 -
 arch/s390/pci/pci_clp.c|  1 -
 arch/sparc/include/asm/compat.h| 11 ---
 arch/tile/include/asm/compat.h | 11 ---
 arch/x86/events/core.c |  2 +-
 arch/x86/include/asm/compat.h  | 11 ---
 arch/x86/include/asm/ftrace.h  |  2 +-
 arch/x86/include/asm/sys_ia32.h|  2 +-
 arch/x86/kernel/sys_x86_64.c   |  2 +-
 drivers/s390/block/dasd_ioctl.c|  1 -
 drivers/s390/char/fs3270.c |  1 -
 drivers/s390/char/sclp_ctl.c   |  1 -
 drivers/s390/char/vmcp.c   |  1 -
 drivers/s390/cio/chsc_sch.c|  1 -
 drivers/s390/net/qeth_core_main.c  |  2 +-
 include/linux/compat.h | 11 ---
 include/linux/compat_time.h| 23 ++
 include/linux/restart_block.h  |  7 ++--
 include/linux/syscalls.h   | 12 +++
 include/linux/time.h   |  4 +--
 include/linux/time64.h | 10 +-
 include/uapi/asm-generic/posix_types.h |  1 +
 include/uapi/linux/time.h  |  7 
 kernel/compat.c| 52 +-
 kernel/time/hrtimer.c  | 10 --
 kernel/time/posix-stubs.c  | 12 ---
 kernel/time/posix-timers.c | 24 ++
 kernel/time/time.c | 58 +++---
 43 files changed, 176 insertions(+), 190 deletions(-)
 create mode 100644 include/

[PATCH v3 02/10] include: Move compat_timespec/ timeval to compat_time.h

2018-01-15 Thread Deepa Dinamani
All the current architecture specific defines for these
are the same. Refactor these common defines to a common
header file.

The new common linux/compat_time.h is also useful as it
will eventually be used to hold all the defines that
are needed for compat time types that support non y2038
safe types. New architectures need not have to define these
new types as they will only use new y2038 safe syscalls.
This file can be deleted after y2038 when we stop supporting
non y2038 safe syscalls.

The patch also requires an operation similar to:

git grep "asm/compat\.h" | cut -d ":" -f 1 |  xargs -n 1 sed -i -e 
"s%asm/compat.h%linux/compat.h%g"

Cc: a...@kernel.org
Cc: b...@kernel.crashing.org
Cc: borntrae...@de.ibm.com
Cc: catalin.mari...@arm.com
Cc: cmetc...@mellanox.com
Cc: coh...@redhat.com
Cc: da...@davemloft.net
Cc: del...@gmx.de
Cc: de...@driverdev.osuosl.org
Cc: gerald.schae...@de.ibm.com
Cc: gre...@linuxfoundation.org
Cc: heiko.carst...@de.ibm.com
Cc: hoepp...@linux.vnet.ibm.com
Cc: h...@zytor.com
Cc: j...@parisc-linux.org
Cc: j...@linux.vnet.ibm.com
Cc: linux-ker...@vger.kernel.org
Cc: linux-m...@linux-mips.org
Cc: linux-par...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: mark.rutl...@arm.com
Cc: mi...@redhat.com
Cc: m...@ellerman.id.au
Cc: ober...@linux.vnet.ibm.com
Cc: oprofile-l...@lists.sf.net
Cc: pau...@samba.org
Cc: pet...@infradead.org
Cc: r...@linux-mips.org
Cc: rost...@goodmis.org
Cc: r...@kernel.org
Cc: schwidef...@de.ibm.com
Cc: seb...@linux.vnet.ibm.com
Cc: sparcli...@vger.kernel.org
Cc: s...@linux.vnet.ibm.com
Cc: ubr...@linux.vnet.ibm.com
Cc: will.dea...@arm.com
Cc: x...@kernel.org
Signed-off-by: Arnd Bergmann 
Signed-off-by: Deepa Dinamani 
Acked-by: Steven Rostedt (VMware) 
---
 arch/arm64/include/asm/compat.h   | 11 ---
 arch/arm64/include/asm/stat.h |  1 +
 arch/arm64/kernel/hw_breakpoint.c |  1 -
 arch/arm64/kernel/perf_regs.c |  2 +-
 arch/arm64/kernel/process.c   |  1 -
 arch/mips/include/asm/compat.h| 11 ---
 arch/mips/kernel/signal32.c   |  2 +-
 arch/parisc/include/asm/compat.h  | 11 ---
 arch/powerpc/include/asm/compat.h | 11 ---
 arch/powerpc/kernel/asm-offsets.c |  2 +-
 arch/powerpc/oprofile/backtrace.c |  2 +-
 arch/s390/hypfs/hypfs_sprp.c  |  1 -
 arch/s390/include/asm/compat.h| 11 ---
 arch/s390/include/asm/elf.h   |  3 +--
 arch/s390/kvm/priv.c  |  1 -
 arch/s390/pci/pci_clp.c   |  1 -
 arch/sparc/include/asm/compat.h   | 11 ---
 arch/tile/include/asm/compat.h| 11 ---
 arch/x86/events/core.c|  2 +-
 arch/x86/include/asm/compat.h | 11 ---
 arch/x86/include/asm/ftrace.h |  2 +-
 arch/x86/include/asm/sys_ia32.h   |  2 +-
 arch/x86/kernel/sys_x86_64.c  |  2 +-
 drivers/s390/block/dasd_ioctl.c   |  1 -
 drivers/s390/char/fs3270.c|  1 -
 drivers/s390/char/sclp_ctl.c  |  1 -
 drivers/s390/char/vmcp.c  |  1 -
 drivers/s390/cio/chsc_sch.c   |  1 -
 drivers/s390/net/qeth_core_main.c |  2 +-
 include/linux/compat.h|  1 +
 include/linux/compat_time.h   | 19 +++
 31 files changed, 31 insertions(+), 109 deletions(-)
 create mode 100644 include/linux/compat_time.h

diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index a3c7f271ad4c..977b5064afc1 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -34,7 +34,6 @@
 
 typedef u32compat_size_t;
 typedef s32compat_ssize_t;
-typedef s32compat_time_t;
 typedef s32compat_clock_t;
 typedef s32compat_pid_t;
 typedef u16__compat_uid_t;
@@ -66,16 +65,6 @@ typedef u32  compat_ulong_t;
 typedef u64compat_u64;
 typedef u32compat_uptr_t;
 
-struct compat_timespec {
-   compat_time_t   tv_sec;
-   s32 tv_nsec;
-};
-
-struct compat_timeval {
-   compat_time_t   tv_sec;
-   s32 tv_usec;
-};
-
 struct compat_stat {
 #ifdef __AARCH64EB__
short   st_dev;
diff --git a/arch/arm64/include/asm/stat.h b/arch/arm64/include/asm/stat.h
index 15e35598ac40..eab738019707 100644
--- a/arch/arm64/include/asm/stat.h
+++ b/arch/arm64/include/asm/stat.h
@@ -20,6 +20,7 @@
 
 #ifdef CONFIG_COMPAT
 
+#include 
 #include 
 
 /*
diff --git a/arch/arm64/kernel/hw_breakpoint.c 
b/arch/arm64/kernel/hw_breakpoint.c
index 74bb56f656ef..413dbe530da8 100644
--- a/arch/arm64/kernel/hw_breakpoint.c
+++ b/arch/arm64/kernel/hw_breakpoint.c
@@ -30,7 +30,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c
index 1d091d048d04..929fc369d0be 100644
--- a/arch/arm64/kernel/perf_regs.c
+++ b/arch/arm64/kernel/perf_regs.c
@@ -5,7 +5,7 @@
 #include 
 #include 
 
-#include 
+#include 
 #include 
 #include 
 
diff --git a

Re: [PATCH v2 00/10] posix_clocks: Prepare syscalls for 64 bit time_t conversion

2017-11-28 Thread Deepa Dinamani
On Tue, Nov 28, 2017 at 6:17 AM, Arnd Bergmann  wrote:
> On Mon, Nov 27, 2017 at 11:29 PM, Deepa Dinamani  
> wrote:
>>>> I decided against using LEGACY_TIME_SYSCALLS to conditionally compile
>>>> legacy time syscalls such as sys_nanosleep because this will need to
>>>> enclose compat_sys_nanosleep as well. So, defining it as
>>>>
>>>> config LEGACY_TIME_SYSCALLS
>>>>  def_bool 64BIT || !64BIT_TIME
>>>>
>>>> will not include compat_sys_nanosleep. We will instead need a new config to
>>>> exclusively mark legacy syscalls.
>>>
>>> Do you mean we would need to do this separately for native and compat
>>> syscalls, and have yet another option, like LEGACY_TIME_SYSCALLS
>>> and LEGACY_TIME_COMPAT_SYSCALLS, to cover all cases? I would
>>> think that CONFIG_COMPAT_32BIT_TIME handles all the compat versions,
>>> while CONFIG_LEGACY_TIME_SYSCALLS handles all the native ones.
>>
>> I meant sys_nanosleep would be covered by LEGACY_TIME_SYSCALLS, but
>> compat_sys_nanosleep would be covered by CONFIG_COMPAT_32BIT_TIME
>> along with other compat syscalls.
>> So, if we define the LEGACY_TIME_SYSCALLS as
>>
>>
>> "This controls the compilation of the following system calls:
>> time, stime, gettimeofday, settimeofday, adjtimex, nanosleep,
>> alarm, getitimer,
>> setitimer, select, utime, utimes, futimesat, and
>> {old,new}{l,f,}stat{,64}.
>> These all pass 32-bit time_t arguments on 32-bit architectures and
>> are replaced by other interfaces (e.g. posix timers and clocks, 
>> statx).
>> C libraries implementing 64-bit time_t in 32-bit architectures have 
>> to
>> implement the handles by wrapping around the newer interfaces.
>> New architectures should not explicitly enable this."
>>
>> This would not be really true as compat interfaces have nothing to do
>> with this config.
>>
>> I was proposing that we could have LEGACY_TIME_SYSCALLS config, but
>> then have all these "deprecated" syscalls be enclosed within this,
>> compat or not.
>> This will also mean that we will have to come up representing these
>> syscalls in the syscall header files.
>> This can be a separate patch and this series can be merged as is if
>> everyone agrees.
>
> I think doing this separately  would be good, I don't see any interdependency
> with the other patches, we just need to decide what we want in the long
> run.

Right. There are three options:

1. Use two configs to identify which syscalls need not be supported by
new architectures.
In this case it makes sense to say LEGACY_TIME_SYSCALLS and
COMPAT_32BIT_TIME both need to be disabled for new architectures. And,
I can reword the config to what you mention below.

2. Make the LEGACY_TIME_SYSCALLS eliminate non y2038 safe syscalls
mentioned below only.
In this case only the native and compat functions of the below
mentioned syscalls need to be identified by the config. I like this
option as this clearly identifies which syscalls are deprecated and do
not have a 64 bit counterpart. Not all architectures need to support
turning this off.

3. If we don't need either 1 or 2, then we could stick with what we
have today in the series as CONFIG_64BIT_TIME will be deleted and they
only need #ifdef CONFIG_64BIT.

Let me know if anyone prefers something else.

> I agree my text that you cited doesn't capture the situation correctly,
> as this is really about the obsolete system calls that take 64-bit time_t
> arguments on architectures that are converted to allow 64-bit time_t
> for non-obsolete system calls.
>
> Maybe it's better to just reword this to
>
>   "This controls the compilation of the following system calls:
>   time, stime, gettimeofday, settimeofday, adjtimex, nanosleep,
> alarm, getitimer,
>   setitimer, select, utime, utimes, futimesat, and 
> {old,new}{l,f,}stat{,64}.
>   These are all replaced by other interfaces (e.g. posix timers and 
> clocks,
>   statx) on architectures that got converted from 32-bit time_t to
> 64-bit time_t.
>   C libraries implementing 64-bit time_t in 32-bit architectures have to
>   implement the handles by wrapping around the newer interfaces.
>   New architectures should not explicitly enable this."
>
> That would clarify that it's not about the compat system calls, while
> also allowing the two options to be set independently.

-Deepa
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 00/10] posix_clocks: Prepare syscalls for 64 bit time_t conversion

2017-11-27 Thread Deepa Dinamani
>> I decided against using LEGACY_TIME_SYSCALLS to conditionally compile
>> legacy time syscalls such as sys_nanosleep because this will need to
>> enclose compat_sys_nanosleep as well. So, defining it as
>>
>> config LEGACY_TIME_SYSCALLS
>>  def_bool 64BIT || !64BIT_TIME
>>
>> will not include compat_sys_nanosleep. We will instead need a new config to
>> exclusively mark legacy syscalls.
>
> Do you mean we would need to do this separately for native and compat
> syscalls, and have yet another option, like LEGACY_TIME_SYSCALLS
> and LEGACY_TIME_COMPAT_SYSCALLS, to cover all cases? I would
> think that CONFIG_COMPAT_32BIT_TIME handles all the compat versions,
> while CONFIG_LEGACY_TIME_SYSCALLS handles all the native ones.

I meant sys_nanosleep would be covered by LEGACY_TIME_SYSCALLS, but
compat_sys_nanosleep would be covered by CONFIG_COMPAT_32BIT_TIME
along with other compat syscalls.
So, if we define the LEGACY_TIME_SYSCALLS as


"This controls the compilation of the following system calls:
time, stime, gettimeofday, settimeofday, adjtimex, nanosleep,
alarm, getitimer,
setitimer, select, utime, utimes, futimesat, and
{old,new}{l,f,}stat{,64}.
These all pass 32-bit time_t arguments on 32-bit architectures and
are replaced by other interfaces (e.g. posix timers and clocks, statx).
C libraries implementing 64-bit time_t in 32-bit architectures have to
implement the handles by wrapping around the newer interfaces.
New architectures should not explicitly enable this."

This would not be really true as compat interfaces have nothing to do
with this config.

I was proposing that we could have LEGACY_TIME_SYSCALLS config, but
then have all these "deprecated" syscalls be enclosed within this,
compat or not.
This will also mean that we will have to come up representing these
syscalls in the syscall header files.
This can be a separate patch and this series can be merged as is if
everyone agrees.

-Deepa
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 00/10] posix_clocks: Prepare syscalls for 64 bit time_t conversion

2017-11-27 Thread Deepa Dinamani
The series is a preparation series for individual architectures
to use 64 bit time_t syscalls in compat and 32 bit emulation modes.

This is a follow up to the series Arnd Bergmann posted:
https://sourceware.org/ml/libc-alpha/2015-05/msg00070.html [1]

Big picture is as per the lwn article:
https://lwn.net/Articles/643234/ [2]

The series is directed at converting posix clock syscalls:
clock_gettime, clock_settime, clock_getres and clock_nanosleep
to use a new data structure __kernel_timespec at syscall boundaries.
__kernel_timespec maintains 64 bit time_t across all execution modes.

vdso will be handled as part of each architecture when they enable
support for 64 bit time_t.

The compat syscalls are repurposed to provide backward compatibility
by using them as native syscalls as well for 32 bit architectures.
They will continue to use timespec at syscall boundaries.

CONFIG_64_BIT_TIME controls whether the syscalls use __kernel_timespec
or timespec at syscall boundaries.

The series does the following:
1. Enable compat syscalls on 32 bit architectures.
2. Add a new __kernel_timespec type to be used as the data structure
   for all the new syscalls.
3. Add new config CONFIG_64BIT_TIME(intead of the CONFIG_COMPAT_TIME in
   [1] and [2] to switch to new definition of __kernel_timespec. It is
   the same as struct timespec otherwise.
4. Add new CONFIG_32BIT_TIME to conditionally compile compat syscalls.

* Changes since v1:
 * Introduce CONFIG_32BIT_TIME
 * Fixed zeroing out of higher order bits of tv_nsec
 * Included Arnd's changes to fix up use of compat headers

I decided against using LEGACY_TIME_SYSCALLS to conditionally compile
legacy time syscalls such as sys_nanosleep because this will need to
enclose compat_sys_nanosleep as well. So, defining it as 

config LEGACY_TIME_SYSCALLS
 def_bool 64BIT || !64BIT_TIME

will not include compat_sys_nanosleep. We will instead need a new config to
exclusively mark legacy syscalls.

Deepa Dinamani (10):
  compat: Make compat helpers independent of CONFIG_COMPAT
  include: Move compat_timespec/ timeval to compat_time.h
  compat: enable compat_get/put_timespec64 always
  arch: introduce CONFIG_64BIT_TIME
  arch: Introduce CONFIG_COMPAT_32BIT_TIME
  posix-clocks: Make compat syscalls depend on CONFIG_COMPAT_32BIT_TIME
  include: Add new y2038 safe __kernel_timespec
  fix get_timespec64() for y2038 safe compat interfaces
  change time types to new y2038 safe __kernel_* types
  nanosleep: change time types to safe __kernel_* types

 arch/Kconfig   | 18 +++
 arch/arm64/include/asm/compat.h| 11 
 arch/arm64/include/asm/stat.h  |  1 +
 arch/arm64/kernel/hw_breakpoint.c  |  1 -
 arch/arm64/kernel/perf_regs.c  |  2 +-
 arch/arm64/kernel/process.c|  1 -
 arch/mips/include/asm/compat.h | 11 
 arch/mips/kernel/signal32.c|  2 +-
 arch/parisc/include/asm/compat.h   | 11 
 arch/powerpc/include/asm/compat.h  | 11 
 arch/powerpc/kernel/asm-offsets.c  |  2 +-
 arch/powerpc/oprofile/backtrace.c  |  2 +-
 arch/s390/hypfs/hypfs_sprp.c   |  1 -
 arch/s390/include/asm/compat.h | 11 
 arch/s390/include/asm/elf.h|  3 +-
 arch/s390/kvm/priv.c   |  1 -
 arch/s390/pci/pci_clp.c|  1 -
 arch/sparc/include/asm/compat.h| 11 
 arch/tile/include/asm/compat.h | 11 
 arch/x86/events/core.c |  2 +-
 arch/x86/include/asm/compat.h  | 11 
 arch/x86/include/asm/ftrace.h  |  2 +-
 arch/x86/include/asm/sys_ia32.h|  2 +-
 arch/x86/kernel/sys_x86_64.c   |  2 +-
 drivers/s390/block/dasd_ioctl.c|  1 -
 drivers/s390/char/fs3270.c |  1 -
 drivers/s390/char/sclp_ctl.c   |  1 -
 drivers/s390/char/vmcp.c   |  1 -
 drivers/s390/cio/chsc_sch.c|  1 -
 drivers/s390/net/qeth_core_main.c  |  2 +-
 drivers/staging/pi433/pi433_if.c   |  2 +-
 include/linux/compat.h | 11 ++--
 include/linux/compat_time.h| 23 +
 include/linux/restart_block.h  |  7 +--
 include/linux/syscalls.h   | 12 ++---
 include/linux/time.h   |  4 +-
 include/linux/time64.h | 10 +++-
 include/uapi/asm-generic/posix_types.h |  1 +
 include/uapi/linux/time.h  |  7 +++
 kernel/Makefile|  2 +-
 kernel/compat.c| 92 ++
 kernel/time/hrtimer.c  | 10 ++--
 kernel/time/posix-stubs.c  | 12 +++--
 kernel/time/posix-timers.c | 24 ++---
 kernel/time/time.c | 10 +++-
 45 files changed, 175 insertions(+), 190 deletions(-)
 create mode 100644 include/linux/compat_time.h

base-commit: b0a84f19a5161418d4360cd57603e94ed489915e
-- 
2.14.1

Cc: a...@kernel.org
Cc: b...@kernel.crashing.org
Cc: borntrae...@de.ibm.c

[PATCH v2 02/10] include: Move compat_timespec/ timeval to compat_time.h

2017-11-27 Thread Deepa Dinamani
All the current architecture specific defines for these
are the same. Refactor these common defines to a common
header file.

The new common linux/compat_time.h is also useful as it
will eventually be used to hold all the defines that
are needed for compat time types that support non y2038
safe types. New architectures need not have to define these
new types as they will only use new y2038 safe syscalls.
This file can be deleted after y2038 when we stop supporting
non y2038 safe syscalls.

The patch also requires an operation similar to:

git grep "asm/compat\.h" | cut -d ":" -f 1 |  xargs -n 1 sed -i -e 
"s%asm/compat.h%linux/compat.h%g"

Cc: a...@kernel.org
Cc: b...@kernel.crashing.org
Cc: borntrae...@de.ibm.com
Cc: catalin.mari...@arm.com
Cc: cmetc...@mellanox.com
Cc: coh...@redhat.com
Cc: da...@davemloft.net
Cc: del...@gmx.de
Cc: de...@driverdev.osuosl.org
Cc: gerald.schae...@de.ibm.com
Cc: gre...@linuxfoundation.org
Cc: heiko.carst...@de.ibm.com
Cc: hoepp...@linux.vnet.ibm.com
Cc: h...@zytor.com
Cc: j...@parisc-linux.org
Cc: j...@linux.vnet.ibm.com
Cc: linux-ker...@vger.kernel.org
Cc: linux-m...@linux-mips.org
Cc: linux-par...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: mark.rutl...@arm.com
Cc: mi...@redhat.com
Cc: m...@ellerman.id.au
Cc: ober...@linux.vnet.ibm.com
Cc: oprofile-l...@lists.sf.net
Cc: pau...@samba.org
Cc: pet...@infradead.org
Cc: r...@linux-mips.org
Cc: rost...@goodmis.org
Cc: r...@kernel.org
Cc: schwidef...@de.ibm.com
Cc: seb...@linux.vnet.ibm.com
Cc: sparcli...@vger.kernel.org
Cc: s...@linux.vnet.ibm.com
Cc: ubr...@linux.vnet.ibm.com
Cc: will.dea...@arm.com
Cc: x...@kernel.org
Signed-off-by: Arnd Bergmann 
Signed-off-by: Deepa Dinamani 
Acked-by: Steven Rostedt (VMware) 
---
 arch/arm64/include/asm/compat.h   | 11 ---
 arch/arm64/include/asm/stat.h |  1 +
 arch/arm64/kernel/hw_breakpoint.c |  1 -
 arch/arm64/kernel/perf_regs.c |  2 +-
 arch/arm64/kernel/process.c   |  1 -
 arch/mips/include/asm/compat.h| 11 ---
 arch/mips/kernel/signal32.c   |  2 +-
 arch/parisc/include/asm/compat.h  | 11 ---
 arch/powerpc/include/asm/compat.h | 11 ---
 arch/powerpc/kernel/asm-offsets.c |  2 +-
 arch/powerpc/oprofile/backtrace.c |  2 +-
 arch/s390/hypfs/hypfs_sprp.c  |  1 -
 arch/s390/include/asm/compat.h| 11 ---
 arch/s390/include/asm/elf.h   |  3 +--
 arch/s390/kvm/priv.c  |  1 -
 arch/s390/pci/pci_clp.c   |  1 -
 arch/sparc/include/asm/compat.h   | 11 ---
 arch/tile/include/asm/compat.h| 11 ---
 arch/x86/events/core.c|  2 +-
 arch/x86/include/asm/compat.h | 11 ---
 arch/x86/include/asm/ftrace.h |  2 +-
 arch/x86/include/asm/sys_ia32.h   |  2 +-
 arch/x86/kernel/sys_x86_64.c  |  2 +-
 drivers/s390/block/dasd_ioctl.c   |  1 -
 drivers/s390/char/fs3270.c|  1 -
 drivers/s390/char/sclp_ctl.c  |  1 -
 drivers/s390/char/vmcp.c  |  1 -
 drivers/s390/cio/chsc_sch.c   |  1 -
 drivers/s390/net/qeth_core_main.c |  2 +-
 drivers/staging/pi433/pi433_if.c  |  2 +-
 include/linux/compat.h|  1 +
 include/linux/compat_time.h   | 19 +++
 32 files changed, 32 insertions(+), 110 deletions(-)
 create mode 100644 include/linux/compat_time.h

diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index a3c7f271ad4c..977b5064afc1 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -34,7 +34,6 @@
 
 typedef u32compat_size_t;
 typedef s32compat_ssize_t;
-typedef s32compat_time_t;
 typedef s32compat_clock_t;
 typedef s32compat_pid_t;
 typedef u16__compat_uid_t;
@@ -66,16 +65,6 @@ typedef u32  compat_ulong_t;
 typedef u64compat_u64;
 typedef u32compat_uptr_t;
 
-struct compat_timespec {
-   compat_time_t   tv_sec;
-   s32 tv_nsec;
-};
-
-struct compat_timeval {
-   compat_time_t   tv_sec;
-   s32 tv_usec;
-};
-
 struct compat_stat {
 #ifdef __AARCH64EB__
short   st_dev;
diff --git a/arch/arm64/include/asm/stat.h b/arch/arm64/include/asm/stat.h
index 15e35598ac40..eab738019707 100644
--- a/arch/arm64/include/asm/stat.h
+++ b/arch/arm64/include/asm/stat.h
@@ -20,6 +20,7 @@
 
 #ifdef CONFIG_COMPAT
 
+#include 
 #include 
 
 /*
diff --git a/arch/arm64/kernel/hw_breakpoint.c 
b/arch/arm64/kernel/hw_breakpoint.c
index 749f81779420..bfa2b78cf0e3 100644
--- a/arch/arm64/kernel/hw_breakpoint.c
+++ b/arch/arm64/kernel/hw_breakpoint.c
@@ -29,7 +29,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c
index 1d091d048d04..929fc369d0be 100644
--- a/arch/arm64/kernel/perf_regs.c
+++ b/arch/arm64/kernel/perf_regs.c
@@ -5,7 +5,7 @@
 #include 
 #include 
 
-#include 
+

Re: [PATCH 0/9] posix_clocks: Prepare syscalls for 64 bit time_t conversion

2017-11-15 Thread Deepa Dinamani
> I had on concern about x32, maybe we should check
> for "COMPAT_USE_64BIT_TIME" before zeroing out the tv_nsec
> bits.

Thanks, I think you are right. I had the check conditional on
CONFIG_64BIT_TIME and then removed as I forgot why I added it. :)

> Regarding CONFIG_COMPAT_TIME/CONFIG_64BIT_TIME, would
> it help to just leave out that part for now and unconditionally
> define '__kernel_timespec' as 'timespec' until we are ready to
> convert the architectures?

Another approach would be to use separate configs:

1. To indicate 64 bit time_t syscall support. This will be dependent
on architectures as CONFIG_64BIT_TIME.
We can delete this once all architectures have provided support for this.

2. Another config (maybe COMPAT_32BIT_TIME?) to be introduced later,
which will compile out all syscalls/ features that use 32 bit time_t.
This can help build a y2038 safe kernel later.

Would this work for everyone?

-Deepa
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/9] include: Move compat_timespec/ timeval to compat_time.h

2017-11-10 Thread Deepa Dinamani
All the current architecture specific defines for these
are the same. Refactor these common defines to a common
header file.

The new common linux/compat_time.h is also useful as it
will eventually be used to hold all the defines that
are needed for compat time types that support non y2038
safe types. New architectures need not have to define these
new types as they will only use new y2038 safe syscalls.
This file can be deleted after y2038 when we stop supporting
non y2038 safe syscalls.

The patch also requires an operation similar to:

git grep "asm/compat\.h" | cut -d ":" -f 1 |  xargs -n 1 sed -i -e 
"s%asm/compat.h%linux/compat.h%g"

Cc: a...@kernel.org
Cc: b...@kernel.crashing.org
Cc: borntrae...@de.ibm.com
Cc: catalin.mari...@arm.com
Cc: cmetc...@mellanox.com
Cc: coh...@redhat.com
Cc: da...@davemloft.net
Cc: del...@gmx.de
Cc: de...@driverdev.osuosl.org
Cc: gerald.schae...@de.ibm.com
Cc: gre...@linuxfoundation.org
Cc: heiko.carst...@de.ibm.com
Cc: hoepp...@linux.vnet.ibm.com
Cc: h...@zytor.com
Cc: j...@parisc-linux.org
Cc: j...@linux.vnet.ibm.com
Cc: linux-ker...@vger.kernel.org
Cc: linux-m...@linux-mips.org
Cc: linux-par...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: mark.rutl...@arm.com
Cc: mi...@redhat.com
Cc: m...@ellerman.id.au
Cc: ober...@linux.vnet.ibm.com
Cc: oprofile-l...@lists.sf.net
Cc: pau...@samba.org
Cc: pet...@infradead.org
Cc: r...@linux-mips.org
Cc: rost...@goodmis.org
Cc: r...@kernel.org
Cc: schwidef...@de.ibm.com
Cc: seb...@linux.vnet.ibm.com
Cc: sparcli...@vger.kernel.org
Cc: s...@linux.vnet.ibm.com
Cc: ubr...@linux.vnet.ibm.com
Cc: will.dea...@arm.com
Cc: x...@kernel.org
Signed-off-by: Deepa Dinamani 
---
 arch/arm64/include/asm/compat.h   | 11 ---
 arch/arm64/include/asm/stat.h |  1 +
 arch/arm64/kernel/hw_breakpoint.c |  1 -
 arch/arm64/kernel/perf_regs.c |  2 +-
 arch/arm64/kernel/process.c   |  1 -
 arch/mips/include/asm/compat.h| 11 ---
 arch/mips/kernel/signal32.c   |  2 +-
 arch/parisc/include/asm/compat.h  | 11 ---
 arch/powerpc/include/asm/compat.h | 11 ---
 arch/powerpc/kernel/asm-offsets.c |  2 +-
 arch/powerpc/oprofile/backtrace.c |  2 +-
 arch/s390/hypfs/hypfs_sprp.c  |  1 -
 arch/s390/include/asm/compat.h| 11 ---
 arch/s390/include/asm/elf.h   |  3 +--
 arch/s390/kvm/priv.c  |  1 -
 arch/s390/pci/pci_clp.c   |  1 -
 arch/sparc/include/asm/compat.h   | 11 ---
 arch/tile/include/asm/compat.h| 11 ---
 arch/x86/events/core.c|  2 +-
 arch/x86/include/asm/compat.h | 11 ---
 arch/x86/include/asm/ftrace.h |  2 +-
 arch/x86/include/asm/sys_ia32.h   |  2 +-
 arch/x86/kernel/sys_x86_64.c  |  2 +-
 drivers/s390/block/dasd_ioctl.c   |  1 -
 drivers/s390/char/fs3270.c|  1 -
 drivers/s390/char/sclp_ctl.c  |  1 -
 drivers/s390/char/vmcp.c  |  1 -
 drivers/s390/cio/chsc_sch.c   |  1 -
 drivers/s390/net/qeth_core_main.c |  2 +-
 drivers/staging/pi433/pi433_if.c  |  2 +-
 include/linux/compat.h|  1 +
 include/linux/compat_time.h   | 19 +++
 32 files changed, 32 insertions(+), 110 deletions(-)
 create mode 100644 include/linux/compat_time.h

diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index e39d487bf724..d4f9c9ee3b15 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -34,7 +34,6 @@
 
 typedef u32compat_size_t;
 typedef s32compat_ssize_t;
-typedef s32compat_time_t;
 typedef s32compat_clock_t;
 typedef s32compat_pid_t;
 typedef u16__compat_uid_t;
@@ -66,16 +65,6 @@ typedef u32  compat_ulong_t;
 typedef u64compat_u64;
 typedef u32compat_uptr_t;
 
-struct compat_timespec {
-   compat_time_t   tv_sec;
-   s32 tv_nsec;
-};
-
-struct compat_timeval {
-   compat_time_t   tv_sec;
-   s32 tv_usec;
-};
-
 struct compat_stat {
 #ifdef __AARCH64EB__
short   st_dev;
diff --git a/arch/arm64/include/asm/stat.h b/arch/arm64/include/asm/stat.h
index 15e35598ac40..eab738019707 100644
--- a/arch/arm64/include/asm/stat.h
+++ b/arch/arm64/include/asm/stat.h
@@ -20,6 +20,7 @@
 
 #ifdef CONFIG_COMPAT
 
+#include 
 #include 
 
 /*
diff --git a/arch/arm64/kernel/hw_breakpoint.c 
b/arch/arm64/kernel/hw_breakpoint.c
index 749f81779420..bfa2b78cf0e3 100644
--- a/arch/arm64/kernel/hw_breakpoint.c
+++ b/arch/arm64/kernel/hw_breakpoint.c
@@ -29,7 +29,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c
index 1d091d048d04..929fc369d0be 100644
--- a/arch/arm64/kernel/perf_regs.c
+++ b/arch/arm64/kernel/perf_regs.c
@@ -5,7 +5,7 @@
 #include 
 #include 
 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/arch/arm64/kernel

[PATCH 0/9] posix_clocks: Prepare syscalls for 64 bit time_t conversion

2017-11-10 Thread Deepa Dinamani
The series is a preparation series for individual architectures
to use 64 bit time_t syscalls in compat and 32 bit emulation modes.

This is a follow up to the series Arnd Bergmann posted:
https://sourceware.org/ml/libc-alpha/2015-05/msg00070.html

Big picture is as per the lwn article:
https://lwn.net/Articles/643234/

The series is directed at converting posix clock syscalls:
clock_gettime, clock_settime, clock_getres and clock_nanosleep
to use a new data structure __kernel_timespec at syscall boundaries.
__kernel_timespec maintains 64 bit time_t across all execution modes.

vdso will be handled as part of each architecture when they enable
support for 64 bit time_t.

The compat syscalls are repurposed to provide backward compatibility
by using them as native syscalls as well for 32 bit architectures.
They will continue to use timespec at syscall boundaries.

CONFIG_64_BIT_TIME controls whether the syscalls use __kernel_timespec
or timespec at syscall boundaries.

The series does the following:
1. Enable compat syscalls unconditionally.
2. Add a new __kernel_timespec type to be used as the data structure
   for all the new syscalls.
3. Add new config CONFIG_64BIT_TIME(intead of the CONFIG_COMPAT_TIME in
   [1] and [2] to switch to new definition of __kernel_timespec. It is
   the same as struct timespec otherwise.

Arnd Bergmann (1):
  y2038: introduce CONFIG_64BIT_TIME

Deepa Dinamani (8):
  include: Move compat_timespec/ timeval to compat_time.h
  compat: Make compat helpers independent of CONFIG_COMPAT
  compat: enable compat_get/put_timespec64 always
  posix-clocks: Enable compat syscalls always
  include: Add new y2038 safe __kernel_timespec
  fix get_timespec64() for y2038 safe compat interfaces
  change time types to new y2038 safe __kernel_* types
  nanosleep: change time types to safe __kernel_* types

 arch/Kconfig   | 11 
 arch/arm64/include/asm/compat.h| 11 
 arch/arm64/include/asm/stat.h  |  1 +
 arch/arm64/kernel/hw_breakpoint.c  |  1 -
 arch/arm64/kernel/perf_regs.c  |  2 +-
 arch/arm64/kernel/process.c|  1 -
 arch/mips/include/asm/compat.h | 11 
 arch/mips/kernel/signal32.c|  2 +-
 arch/parisc/include/asm/compat.h   | 11 
 arch/powerpc/include/asm/compat.h  | 11 
 arch/powerpc/kernel/asm-offsets.c  |  2 +-
 arch/powerpc/oprofile/backtrace.c  |  2 +-
 arch/s390/hypfs/hypfs_sprp.c   |  1 -
 arch/s390/include/asm/compat.h | 11 
 arch/s390/include/asm/elf.h|  3 +-
 arch/s390/kvm/priv.c   |  1 -
 arch/s390/pci/pci_clp.c|  1 -
 arch/sparc/include/asm/compat.h| 11 
 arch/tile/include/asm/compat.h | 11 
 arch/x86/events/core.c |  2 +-
 arch/x86/include/asm/compat.h  | 11 
 arch/x86/include/asm/ftrace.h  |  2 +-
 arch/x86/include/asm/sys_ia32.h|  2 +-
 arch/x86/kernel/sys_x86_64.c   |  2 +-
 drivers/s390/block/dasd_ioctl.c|  1 -
 drivers/s390/char/fs3270.c |  1 -
 drivers/s390/char/sclp_ctl.c   |  1 -
 drivers/s390/char/vmcp.c   |  1 -
 drivers/s390/cio/chsc_sch.c|  1 -
 drivers/s390/net/qeth_core_main.c  |  2 +-
 drivers/staging/pi433/pi433_if.c   |  2 +-
 include/linux/compat.h |  7 ++-
 include/linux/compat_time.h| 23 +
 include/linux/restart_block.h  |  7 +--
 include/linux/syscalls.h   | 12 ++---
 include/linux/time.h   |  4 +-
 include/linux/time64.h | 10 +++-
 include/uapi/asm-generic/posix_types.h |  1 +
 include/uapi/linux/time.h  |  7 +++
 kernel/Makefile|  2 +-
 kernel/compat.c| 92 ++
 kernel/time/hrtimer.c  |  7 +--
 kernel/time/posix-stubs.c  | 12 ++---
 kernel/time/posix-timers.c | 20 
 kernel/time/time.c | 10 +++-
 45 files changed, 152 insertions(+), 195 deletions(-)
 create mode 100644 include/linux/compat_time.h


base-commit: d9e0e63d9a6f88440eb201e1491fcf730272c706
-- 
2.11.0

Cc: a...@kernel.org
Cc: b...@kernel.crashing.org
Cc: borntrae...@de.ibm.com
Cc: catalin.mari...@arm.com
Cc: cmetc...@mellanox.com
Cc: coh...@redhat.com
Cc: da...@davemloft.net
Cc: del...@gmx.de
Cc: de...@driverdev.osuosl.org
Cc: gerald.schae...@de.ibm.com
Cc: gre...@linuxfoundation.org
Cc: heiko.carst...@de.ibm.com
Cc: hoepp...@linux.vnet.ibm.com
Cc: h...@zytor.com
Cc: j...@parisc-linux.org
Cc: j...@linux.vnet.ibm.com
Cc: linux-...@vger.kernel.org
Cc: linux-a...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Cc: linux-m...@linux-mips.org
Cc: linux-par...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: mark.rutl...@arm.com
Cc: mi...@redhat.com
Cc: m...@ellerman.id.au
Cc: ober...@linux.vnet.ibm.com
Cc: oprofile

Re: [PATCH 04/12] fs: ceph: CURRENT_TIME with ktime_get_real_ts()

2017-06-01 Thread Deepa Dinamani
On Thu, Jun 1, 2017 at 5:36 PM, John Stultz  wrote:
> On Thu, Jun 1, 2017 at 5:26 PM, Yan, Zheng  wrote:
>> On Thu, Jun 1, 2017 at 6:22 PM, Arnd Bergmann  wrote:
>>> On Thu, Jun 1, 2017 at 11:56 AM, Yan, Zheng  wrote:
>>>> On Sat, Apr 8, 2017 at 8:57 AM, Deepa Dinamani  
>>>> wrote:
>>>
>>>>> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
>>>>> index 517838b..77204da 100644
>>>>> --- a/drivers/block/rbd.c
>>>>> +++ b/drivers/block/rbd.c
>>>>> @@ -1922,7 +1922,7 @@ static void rbd_osd_req_format_write(struct 
>>>>> rbd_obj_request *obj_request)
>>>>>  {
>>>>> struct ceph_osd_request *osd_req = obj_request->osd_req;
>>>>>
>>>>> -   osd_req->r_mtime = CURRENT_TIME;
>>>>> +   ktime_get_real_ts(&osd_req->r_mtime);
>>>>> osd_req->r_data_offset = obj_request->offset;
>>>>>  }
>>>>>
>>>>> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
>>>>> index c681762..1d3fa90 100644
>>>>> --- a/fs/ceph/mds_client.c
>>>>> +++ b/fs/ceph/mds_client.c
>>>>> @@ -1666,6 +1666,7 @@ struct ceph_mds_request *
>>>>>  ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode)
>>>>>  {
>>>>> struct ceph_mds_request *req = kzalloc(sizeof(*req), GFP_NOFS);
>>>>> +   struct timespec ts;
>>>>>
>>>>> if (!req)
>>>>> return ERR_PTR(-ENOMEM);
>>>>> @@ -1684,7 +1685,8 @@ ceph_mdsc_create_request(struct ceph_mds_client 
>>>>> *mdsc, int op, int mode)
>>>>> init_completion(&req->r_safe_completion);
>>>>> INIT_LIST_HEAD(&req->r_unsafe_item);
>>>>>
>>>>> -   req->r_stamp = current_fs_time(mdsc->fsc->sb);
>>>>> +   ktime_get_real_ts(&ts);
>>>>> +   req->r_stamp = timespec_trunc(ts, mdsc->fsc->sb->s_time_gran);
>>>>
>>>> This change causes our kernel_untar_tar test case to fail (inode's
>>>> ctime goes back). The reason is that there is time drift between the
>>>> time stamps got by  ktime_get_real_ts() and current_time(). We need to
>>>> revert this change until current_time() uses ktime_get_real_ts()
>>>> internally.
>>>
>>> Hmm, the change was not supposed to have a user-visible effect, so
>>> something has gone wrong, but I don't immediately see how it
>>> relates to what you observe.
>>>
>>> ktime_get_real_ts() and current_time() use the same time base, there
>>> is no drift, but there is a difference in resolution, as the latter uses
>>> the time stamp of the last jiffies update, which may be up to one jiffy
>>> (10ms) behind the exact time we put in the request stamps here.
>>>
>>> Do you still see problems if you use current_kernel_time() instead of
>>> ktime_get_real_ts()?
>>
>> The problem disappears after using current_kernel_time().
>>
>> https://github.com/ceph/ceph-client/commit/2e0f648da23167034a3cf1500bc90ec60aef2417
>
> From the commit above:
> "It seems there is time drift between ktime_get_real_ts() and
> current_kernel_time()"
>
> Its more of a granularity difference. current_kernel_time() returns
> the cached time at the last tick, where as ktime_get_real_ts() reads
> the clocksource hardware and returns the immediate time.
>
> Filesystems usually use the cached time (similar to
> CLOCK_REALTIME_COARSE), for performance reasons, as touching the
> clocksource takes time.

Alternatively, it would be best for this code also to use current_time().
I had suggested this in one of the previous versions of the patch.
The implementation of current_time() will change when we switch vfs to
use 64 bit time. This will prevent such errors from happening again.
But, this also means there is more code reordering for these modules
to get a reference to inode.

-Deepa
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 06/12] audit: Use timespec64 to represent audit timestamps

2017-04-08 Thread Deepa Dinamani
> I have no problem merging this patch into audit/next for v4.12, would
> you prefer me to do that so at least this patch is merged?

This would be fine.
But, I think whoever takes the last 2 deletion patches should also take them.
I'm not sure how that part works out.

> It would probably make life a small bit easier for us in the audit
> world too as it would reduce the potential merge conflict.  However,
> that's a relatively small thing to worry about.

-Deepa
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 02/12] trace: Make trace_hwlat timestamp y2038 safe

2017-04-07 Thread Deepa Dinamani
>> - trace_seq_printf(s, "#%-5u inner/outer(us): %4llu/%-5llu ts:%ld.%09ld",
>> + trace_seq_printf(s, "#%-5u inner/outer(us): %4llu/%-5llu 
>> ts:%lld.%09ld",
>>field->seqnum,
>>field->duration,
>>field->outer_duration,
>> -  field->timestamp.tv_sec,
>> +  (long long)field->timestamp.tv_sec,
>
> Refresh my memory. We need the cast because on 64 bit boxes
> timestamp.tv_sec is just a long?

This is only required until we change the definition of timespec64.
Right now it is defined as

#if __BITS_PER_LONG == 64
# define timespec64 timespec
#else
struct timespec64 {
time64_t tv_sec;
long tv_nsec;
};
#endif

And timespec.tv_sec is just long int on 64 bit machines.
This is why we need the cast now.

We will probably change this and only define __kernel_timespec instead
of timespec, leaving only one definition of timespec64.
At that time, we will not need this.

-Deepa
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/12] time: Delete current_fs_time() function

2017-04-07 Thread Deepa Dinamani
All uses of the current_fs_time() function have been
replaced by other time interfaces.

And, its use cases can be fulfilled by current_time()
or ktime_get_* variants.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
---
 include/linux/fs.h |  1 -
 kernel/time/time.c | 14 --
 2 files changed, 15 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index f1d7347..cce6c57 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1430,7 +1430,6 @@ static inline void i_gid_write(struct inode *inode, gid_t 
gid)
inode->i_gid = make_kgid(inode->i_sb->s_user_ns, gid);
 }
 
-extern struct timespec current_fs_time(struct super_block *sb);
 extern struct timespec current_time(struct inode *inode);
 
 /*
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 25bdd25..cf69cca 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -230,20 +230,6 @@ SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p)
return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret;
 }
 
-/**
- * current_fs_time - Return FS time
- * @sb: Superblock.
- *
- * Return the current time truncated to the time granularity supported by
- * the fs.
- */
-struct timespec current_fs_time(struct super_block *sb)
-{
-   struct timespec now = current_kernel_time();
-   return timespec_trunc(now, sb->s_time_gran);
-}
-EXPORT_SYMBOL(current_fs_time);
-
 /*
  * Convert jiffies to milliseconds and back.
  *
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/12] fs: btrfs: Use ktime_get_real_ts for root ctime

2017-04-07 Thread Deepa Dinamani
btrfs_root_item maintains the ctime for root updates.
This is not part of vfs_inode.

Since current_time() uses struct inode* as an argument
as Linus suggested, this cannot be used to update root
times unless, we modify the signature to use inode.

Since btrfs uses nanosecond time granularity, it can also
use ktime_get_real_ts directly to obtain timestamp for
the root. It is necessary to use the timespec time api
here because the same btrfs_set_stack_timespec_*() apis
are used for vfs inode times as well. These can be
transitioned to using timespec64 when btrfs internally
changes to use timespec64 as well.

Signed-off-by: Deepa Dinamani 
Acked-by: David Sterba 
Reviewed-by: Arnd Bergmann 
---
 fs/btrfs/root-tree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index a08224e..7d6bc30 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -501,8 +501,9 @@ void btrfs_update_root_times(struct btrfs_trans_handle 
*trans,
 struct btrfs_root *root)
 {
struct btrfs_root_item *item = &root->root_item;
-   struct timespec ct = current_fs_time(root->fs_info->sb);
+   struct timespec ct;
 
+   ktime_get_real_ts(&ct);
spin_lock(&root->root_item_lock);
btrfs_set_root_ctransid(item, trans->transid);
btrfs_set_stack_timespec_sec(&item->ctime, ct.tv_sec);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/12] time: Delete CURRENT_TIME_SEC and CURRENT_TIME

2017-04-07 Thread Deepa Dinamani
All uses of CURRENT_TIME_SEC and CURRENT_TIME macros have
been replaced by other time functions. These macros are
also not y2038 safe.
And, all their use cases can be fulfilled by y2038 safe
ktime_get_* variants.

Signed-off-by: Deepa Dinamani 
Acked-by: John Stultz 
Reviewed-by: Arnd Bergmann 
---
 include/linux/time.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/linux/time.h b/include/linux/time.h
index 23f0f5c..c0543f5 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -151,9 +151,6 @@ static inline bool timespec_inject_offset_valid(const 
struct timespec *ts)
return true;
 }
 
-#define CURRENT_TIME   (current_kernel_time())
-#define CURRENT_TIME_SEC   ((struct timespec) { get_seconds(), 0 })
-
 /* Some architectures do not supply their own clocksource.
  * This is mainly the case in architectures that get their
  * inter-tick times by reading the counter on their interval
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/12] apparmorfs: Replace CURRENT_TIME with current_time()

2017-04-07 Thread Deepa Dinamani
CURRENT_TIME macro is not y2038 safe on 32 bit systems.

The patch replaces all the uses of CURRENT_TIME by
current_time().

This is also in preparation for the patch that transitions
vfs timestamps to use 64 bit time and hence make them
y2038 safe. current_time() is also planned to be transitioned
to y2038 safe behavior along with this change.

CURRENT_TIME macro will be deleted before merging the
aforementioned change.

Signed-off-by: Deepa Dinamani 
---
 security/apparmor/apparmorfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index be0b498..4f6ac9d 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -1357,7 +1357,7 @@ static int aa_mk_null_file(struct dentry *parent)
 
inode->i_ino = get_next_ino();
inode->i_mode = S_IFCHR | S_IRUGO | S_IWUGO;
-   inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+   inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
init_special_inode(inode, S_IFCHR | S_IRUGO | S_IWUGO,
   MKDEV(MEM_MAJOR, 3));
d_instantiate(dentry, inode);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/12] fs: cifs: Replace CURRENT_TIME by other appropriate apis

2017-04-07 Thread Deepa Dinamani
CURRENT_TIME macro is not y2038 safe on 32 bit systems.

The patch replaces all the uses of CURRENT_TIME by
current_time() for filesystem times, and ktime_get_*
functions for authentication timestamps and timezone
calculations.

This is also in preparation for the patch that transitions
vfs timestamps to use 64 bit time and hence make them
y2038 safe.

CURRENT_TIME macro will be deleted before merging the
aforementioned change.

The inode timestamps read from the server are assumed
to have correct granularity and range.

The patch also assumes that the difference between server and
client times lie in the range INT_MIN..INT_MAX. This is valid
because this is the difference between current times between
server and client, and the largest timezone difference is in the
range of one day.

All cifs timestamps currently use timespec representation internally.
Authentication and timezone timestamps can also be transitioned into
using timespec64 when all other timestamps for cifs is transitioned
to use timespec64.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
---
 fs/cifs/cifsencrypt.c |  4 +++-
 fs/cifs/cifssmb.c | 10 +-
 fs/cifs/inode.c   | 28 +++-
 3 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 058ac9b..68abbb0 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -478,6 +478,7 @@ find_timestamp(struct cifs_ses *ses)
unsigned char *blobptr;
unsigned char *blobend;
struct ntlmssp2_name *attrptr;
+   struct timespec ts;
 
if (!ses->auth_key.len || !ses->auth_key.response)
return 0;
@@ -502,7 +503,8 @@ find_timestamp(struct cifs_ses *ses)
blobptr += attrsize; /* advance attr value */
}
 
-   return cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
+   ktime_get_real_ts(&ts);
+   return cpu_to_le64(cifs_UnixTimeToNT(ts));
 }
 
 static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 0669506..2f279b7 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -478,14 +478,14 @@ decode_lanman_negprot_rsp(struct TCP_Server_Info *server, 
NEGOTIATE_RSP *pSMBr)
 * this requirement.
 */
int val, seconds, remain, result;
-   struct timespec ts, utc;
-   utc = CURRENT_TIME;
+   struct timespec ts;
+   unsigned long utc = ktime_get_real_seconds();
ts = cnvrtDosUnixTm(rsp->SrvTime.Date,
rsp->SrvTime.Time, 0);
cifs_dbg(FYI, "SrvTime %d sec since 1970 (utc: %d) diff: %d\n",
-(int)ts.tv_sec, (int)utc.tv_sec,
-(int)(utc.tv_sec - ts.tv_sec));
-   val = (int)(utc.tv_sec - ts.tv_sec);
+(int)ts.tv_sec, (int)utc,
+(int)(utc - ts.tv_sec));
+   val = (int)(utc - ts.tv_sec);
seconds = abs(val);
result = (seconds / MIN_TZ_ADJ) * MIN_TZ_ADJ;
remain = seconds % MIN_TZ_ADJ;
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index b261db3..c3b2fa0 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -322,9 +322,9 @@ cifs_create_dfs_fattr(struct cifs_fattr *fattr, struct 
super_block *sb)
fattr->cf_mode = S_IFDIR | S_IXUGO | S_IRWXU;
fattr->cf_uid = cifs_sb->mnt_uid;
fattr->cf_gid = cifs_sb->mnt_gid;
-   fattr->cf_atime = CURRENT_TIME;
-   fattr->cf_ctime = CURRENT_TIME;
-   fattr->cf_mtime = CURRENT_TIME;
+   ktime_get_real_ts(&fattr->cf_mtime);
+   fattr->cf_mtime = timespec_trunc(fattr->cf_mtime, sb->s_time_gran);
+   fattr->cf_atime = fattr->cf_ctime = fattr->cf_mtime;
fattr->cf_nlink = 2;
fattr->cf_flags |= CIFS_FATTR_DFS_REFERRAL;
 }
@@ -586,9 +586,10 @@ static int cifs_sfu_mode(struct cifs_fattr *fattr, const 
unsigned char *path,
 /* Fill a cifs_fattr struct with info from FILE_ALL_INFO */
 static void
 cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
-  struct cifs_sb_info *cifs_sb, bool adjust_tz,
+  struct super_block *sb, bool adjust_tz,
   bool symlink)
 {
+   struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
 
memset(fattr, 0, sizeof(*fattr));
@@ -598,8 +599,10 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, 
FILE_ALL_INFO *info,
 
if (info->LastAccessTime)
fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime);
-   else
-   fattr->cf_atime = CURRENT_TIME;
+   else {
+   ktime_get_real_ts(&fattr->cf_atime);
+   fattr->cf_atime = timespec

[PATCH 09/12] lustre: Replace CURRENT_TIME macro

2017-04-07 Thread Deepa Dinamani
CURRENT_TIME macro is not y2038 safe on 32 bit systems.

The patch replaces all the uses of CURRENT_TIME by
current_time() for filesystem times, and ktime_get_*
functions for others.

struct timespec is also not y2038 safe.
Retain timespec for timestamp representation here as lustre
uses it internally everywhere.
These references will be changed to use struct timespec64
in a separate patch.

This is also in preparation for the patch that transitions
vfs timestamps to use 64 bit time and hence make them
y2038 safe. current_time() is also planned to be transitioned
to y2038 safe behavior along with this change.

CURRENT_TIME macro will be deleted before merging the
aforementioned change.

Signed-off-by: Deepa Dinamani 
---
 drivers/staging/lustre/lustre/llite/llite_lib.c | 6 +++---
 drivers/staging/lustre/lustre/osc/osc_io.c  | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 7b80040..2b4b6b9 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1472,17 +1472,17 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr 
*attr, bool hsm_import)
 
/* We mark all of the fields "set" so MDS/OST does not re-set them */
if (attr->ia_valid & ATTR_CTIME) {
-   attr->ia_ctime = CURRENT_TIME;
+   attr->ia_ctime = current_time(inode);
attr->ia_valid |= ATTR_CTIME_SET;
}
if (!(attr->ia_valid & ATTR_ATIME_SET) &&
(attr->ia_valid & ATTR_ATIME)) {
-   attr->ia_atime = CURRENT_TIME;
+   attr->ia_atime = current_time(inode);
attr->ia_valid |= ATTR_ATIME_SET;
}
if (!(attr->ia_valid & ATTR_MTIME_SET) &&
(attr->ia_valid & ATTR_MTIME)) {
-   attr->ia_mtime = CURRENT_TIME;
+   attr->ia_mtime = current_time(inode);
attr->ia_valid |= ATTR_MTIME_SET;
}
 
diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c 
b/drivers/staging/lustre/lustre/osc/osc_io.c
index f991bee..cbab800 100644
--- a/drivers/staging/lustre/lustre/osc/osc_io.c
+++ b/drivers/staging/lustre/lustre/osc/osc_io.c
@@ -216,7 +216,7 @@ static int osc_io_submit(const struct lu_env *env,
struct cl_object *obj = ios->cis_obj;
 
cl_object_attr_lock(obj);
-   attr->cat_mtime = LTIME_S(CURRENT_TIME);
+   attr->cat_mtime = ktime_get_real_seconds();
attr->cat_ctime = attr->cat_mtime;
cl_object_attr_update(env, obj, attr, CAT_MTIME | CAT_CTIME);
cl_object_attr_unlock(obj);
@@ -256,7 +256,7 @@ static void osc_page_touch_at(const struct lu_env *env,
   kms > loi->loi_kms ? "" : "not ", loi->loi_kms, kms,
   loi->loi_lvb.lvb_size);
 
-   attr->cat_ctime = LTIME_S(CURRENT_TIME);
+   attr->cat_ctime = ktime_get_real_seconds();
attr->cat_mtime = attr->cat_ctime;
valid = CAT_MTIME | CAT_CTIME;
if (kms > loi->loi_kms) {
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/12] fs: ubifs: Replace CURRENT_TIME_SEC with current_time

2017-04-07 Thread Deepa Dinamani
CURRENT_TIME_SEC is not y2038 safe. current_time() will
be transitioned to use 64 bit time along with vfs in a
separate patch.
There is no plan to transition CURRENT_TIME_SEC to use
y2038 safe time interfaces.

current_time() returns timestamps according to the
granularities set in the inode's super_block.
The granularity check to call current_fs_time() or
CURRENT_TIME_SEC is not required.

Use current_time() directly to update inode timestamp.
Use timespec_trunc during file system creation, before
the first inode is created.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
---
 fs/ubifs/dir.c   | 12 ++--
 fs/ubifs/file.c  | 12 ++--
 fs/ubifs/ioctl.c |  2 +-
 fs/ubifs/misc.h  | 10 --
 fs/ubifs/sb.c| 14 ++
 fs/ubifs/xattr.c |  6 +++---
 6 files changed, 26 insertions(+), 30 deletions(-)

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 30825d88..8510d79 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -121,7 +121,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, struct 
inode *dir,
 
inode_init_owner(inode, dir, mode);
inode->i_mtime = inode->i_atime = inode->i_ctime =
-ubifs_current_time(inode);
+current_time(inode);
inode->i_mapping->nrpages = 0;
 
switch (mode & S_IFMT) {
@@ -750,7 +750,7 @@ static int ubifs_link(struct dentry *old_dentry, struct 
inode *dir,
lock_2_inodes(dir, inode);
inc_nlink(inode);
ihold(inode);
-   inode->i_ctime = ubifs_current_time(inode);
+   inode->i_ctime = current_time(inode);
dir->i_size += sz_change;
dir_ui->ui_size = dir->i_size;
dir->i_mtime = dir->i_ctime = inode->i_ctime;
@@ -823,7 +823,7 @@ static int ubifs_unlink(struct inode *dir, struct dentry 
*dentry)
}
 
lock_2_inodes(dir, inode);
-   inode->i_ctime = ubifs_current_time(dir);
+   inode->i_ctime = current_time(dir);
drop_nlink(inode);
dir->i_size -= sz_change;
dir_ui->ui_size = dir->i_size;
@@ -927,7 +927,7 @@ static int ubifs_rmdir(struct inode *dir, struct dentry 
*dentry)
}
 
lock_2_inodes(dir, inode);
-   inode->i_ctime = ubifs_current_time(dir);
+   inode->i_ctime = current_time(dir);
clear_nlink(inode);
drop_nlink(dir);
dir->i_size -= sz_change;
@@ -1405,7 +1405,7 @@ static int do_rename(struct inode *old_dir, struct dentry 
*old_dentry,
 * Like most other Unix systems, set the @i_ctime for inodes on a
 * rename.
 */
-   time = ubifs_current_time(old_dir);
+   time = current_time(old_dir);
old_inode->i_ctime = time;
 
/* We must adjust parent link count when renaming directories */
@@ -1578,7 +1578,7 @@ static int ubifs_xrename(struct inode *old_dir, struct 
dentry *old_dentry,
 
lock_4_inodes(old_dir, new_dir, NULL, NULL);
 
-   time = ubifs_current_time(old_dir);
+   time = current_time(old_dir);
fst_inode->i_ctime = time;
snd_inode->i_ctime = time;
old_dir->i_mtime = old_dir->i_ctime = time;
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index d9ae86f..2cda3d6 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1196,7 +1196,7 @@ static int do_truncation(struct ubifs_info *c, struct 
inode *inode,
mutex_lock(&ui->ui_mutex);
ui->ui_size = inode->i_size;
/* Truncation changes inode [mc]time */
-   inode->i_mtime = inode->i_ctime = ubifs_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
/* Other attributes may be changed at the same time as well */
do_attr_changes(inode, attr);
err = ubifs_jnl_truncate(c, inode, old_size, new_size);
@@ -1243,7 +1243,7 @@ static int do_setattr(struct ubifs_info *c, struct inode 
*inode,
mutex_lock(&ui->ui_mutex);
if (attr->ia_valid & ATTR_SIZE) {
/* Truncation changes inode [mc]time */
-   inode->i_mtime = inode->i_ctime = ubifs_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
/* 'truncate_setsize()' changed @i_size, update @ui_size */
ui->ui_size = inode->i_size;
}
@@ -1420,7 +1420,7 @@ int ubifs_update_time(struct inode *inode, struct 
timespec *time,
  */
 static int update_mctime(struct inode *inode)
 {
-   struct timespec now = ubifs_current_time(inode);
+   struct timespec now = current_time(inode);
struct ubifs_inode *ui = ubifs_inode(inode);
struct ubifs_info *c = inode->i_sb->s_fs_info;
 
@@ -1434,7 +1434,7 @@ static int update_mctime(struct inode *inode)
return err;
 
mutex_lock(&ui->ui_mutex);
-   inode->i_mtime = inode->i_ctime =

[PATCH 05/12] fs: ufs: Use ktime_get_real_ts64() for birthtime

2017-04-07 Thread Deepa Dinamani
CURRENT_TIME is not y2038 safe.
Replace it with ktime_get_real_ts64().
Inode time formats are already 64 bit long and
accommodates time64_t.

Signed-off-by: Deepa Dinamani 
---
 fs/ufs/ialloc.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c
index 9774555..d1dd8cc 100644
--- a/fs/ufs/ialloc.c
+++ b/fs/ufs/ialloc.c
@@ -176,6 +176,7 @@ struct inode *ufs_new_inode(struct inode *dir, umode_t mode)
struct ufs_cg_private_info * ucpi;
struct ufs_cylinder_group * ucg;
struct inode * inode;
+   struct timespec64 ts;
unsigned cg, bit, i, j, start;
struct ufs_inode_info *ufsi;
int err = -ENOSPC;
@@ -323,8 +324,9 @@ struct inode *ufs_new_inode(struct inode *dir, umode_t mode)
lock_buffer(bh);
ufs2_inode = (struct ufs2_inode *)bh->b_data;
ufs2_inode += ufs_inotofsbo(inode->i_ino);
-   ufs2_inode->ui_birthtime = cpu_to_fs64(sb, CURRENT_TIME.tv_sec);
-   ufs2_inode->ui_birthnsec = cpu_to_fs32(sb, 
CURRENT_TIME.tv_nsec);
+   ktime_get_real_ts64(&ts);
+   ufs2_inode->ui_birthtime = cpu_to_fs64(sb, ts.tv_sec);
+   ufs2_inode->ui_birthnsec = cpu_to_fs32(sb, ts.tv_nsec);
mark_buffer_dirty(bh);
unlock_buffer(bh);
if (sb->s_flags & MS_SYNCHRONOUS)
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/12] fs: ceph: CURRENT_TIME with ktime_get_real_ts()

2017-04-07 Thread Deepa Dinamani
CURRENT_TIME is not y2038 safe.
The macro will be deleted and all the references to it
will be replaced by ktime_get_* apis.

struct timespec is also not y2038 safe.
Retain timespec for timestamp representation here as ceph
uses it internally everywhere.
These references will be changed to use struct timespec64
in a separate patch.

The current_fs_time() api is being changed to use vfs
struct inode* as an argument instead of struct super_block*.

Set the new mds client request r_stamp field using
ktime_get_real_ts() instead of using current_fs_time().

Also, since r_stamp is used as mtime on the server, use
timespec_trunc() to truncate the timestamp, using the right
granularity from the superblock.

This api will be transitioned to be y2038 safe along
with vfs.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
---
 drivers/block/rbd.c   | 2 +-
 fs/ceph/mds_client.c  | 4 +++-
 net/ceph/messenger.c  | 6 --
 net/ceph/osd_client.c | 4 ++--
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 517838b..77204da 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1922,7 +1922,7 @@ static void rbd_osd_req_format_write(struct 
rbd_obj_request *obj_request)
 {
struct ceph_osd_request *osd_req = obj_request->osd_req;
 
-   osd_req->r_mtime = CURRENT_TIME;
+   ktime_get_real_ts(&osd_req->r_mtime);
osd_req->r_data_offset = obj_request->offset;
 }
 
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index c681762..1d3fa90 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -1666,6 +1666,7 @@ struct ceph_mds_request *
 ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode)
 {
struct ceph_mds_request *req = kzalloc(sizeof(*req), GFP_NOFS);
+   struct timespec ts;
 
if (!req)
return ERR_PTR(-ENOMEM);
@@ -1684,7 +1685,8 @@ ceph_mdsc_create_request(struct ceph_mds_client *mdsc, 
int op, int mode)
init_completion(&req->r_safe_completion);
INIT_LIST_HEAD(&req->r_unsafe_item);
 
-   req->r_stamp = current_fs_time(mdsc->fsc->sb);
+   ktime_get_real_ts(&ts);
+   req->r_stamp = timespec_trunc(ts, mdsc->fsc->sb->s_time_gran);
 
req->r_op = op;
req->r_direct_mode = mode;
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index f76bb33..5766a6c 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1386,8 +1386,9 @@ static void prepare_write_keepalive(struct 
ceph_connection *con)
dout("prepare_write_keepalive %p\n", con);
con_out_kvec_reset(con);
if (con->peer_features & CEPH_FEATURE_MSGR_KEEPALIVE2) {
-   struct timespec now = CURRENT_TIME;
+   struct timespec now;
 
+   ktime_get_real_ts(&now);
con_out_kvec_add(con, sizeof(tag_keepalive2), &tag_keepalive2);
ceph_encode_timespec(&con->out_temp_keepalive2, &now);
con_out_kvec_add(con, sizeof(con->out_temp_keepalive2),
@@ -3176,8 +3177,9 @@ bool ceph_con_keepalive_expired(struct ceph_connection 
*con,
 {
if (interval > 0 &&
(con->peer_features & CEPH_FEATURE_MSGR_KEEPALIVE2)) {
-   struct timespec now = CURRENT_TIME;
+   struct timespec now;
struct timespec ts;
+   ktime_get_real_ts(&now);
jiffies_to_timespec(interval, &ts);
ts = timespec_add(con->last_keepalive_ack, ts);
return timespec_compare(&now, &ts) >= 0;
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index e15ea9e..242d7c0 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -3574,7 +3574,7 @@ ceph_osdc_watch(struct ceph_osd_client *osdc,
ceph_oid_copy(&lreq->t.base_oid, oid);
ceph_oloc_copy(&lreq->t.base_oloc, oloc);
lreq->t.flags = CEPH_OSD_FLAG_WRITE;
-   lreq->mtime = CURRENT_TIME;
+   ktime_get_real_ts(&lreq->mtime);
 
lreq->reg_req = alloc_linger_request(lreq);
if (!lreq->reg_req) {
@@ -3632,7 +3632,7 @@ int ceph_osdc_unwatch(struct ceph_osd_client *osdc,
ceph_oid_copy(&req->r_base_oid, &lreq->t.base_oid);
ceph_oloc_copy(&req->r_base_oloc, &lreq->t.base_oloc);
req->r_flags = CEPH_OSD_FLAG_WRITE;
-   req->r_mtime = CURRENT_TIME;
+   ktime_get_real_ts(&req->r_mtime);
osd_req_op_watch_init(req, 0, lreq->linger_id,
  CEPH_OSD_WATCH_OP_UNWATCH);
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/12] audit: Use timespec64 to represent audit timestamps

2017-04-07 Thread Deepa Dinamani
struct timespec is not y2038 safe.
Audit timestamps are recorded in string format into
an audit buffer for a given context.
These mark the entry timestamps for the syscalls.
Use y2038 safe struct timespec64 to represent the times.
The log strings can handle this transition as strings can
hold upto 1024 characters.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Acked-by: Paul Moore 
Acked-by: Richard Guy Briggs 
---
 include/linux/audit.h |  4 ++--
 kernel/audit.c| 10 +-
 kernel/audit.h|  2 +-
 kernel/auditsc.c  |  6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 6fdfefc..f830508 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -332,7 +332,7 @@ static inline void audit_ptrace(struct task_struct *t)
/* Private API (for audit.c only) */
 extern unsigned int audit_serial(void);
 extern int auditsc_get_stamp(struct audit_context *ctx,
- struct timespec *t, unsigned int *serial);
+ struct timespec64 *t, unsigned int *serial);
 extern int audit_set_loginuid(kuid_t loginuid);
 
 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
@@ -511,7 +511,7 @@ static inline void __audit_seccomp(unsigned long syscall, 
long signr, int code)
 static inline void audit_seccomp(unsigned long syscall, long signr, int code)
 { }
 static inline int auditsc_get_stamp(struct audit_context *ctx,
- struct timespec *t, unsigned int *serial)
+ struct timespec64 *t, unsigned int *serial)
 {
return 0;
 }
diff --git a/kernel/audit.c b/kernel/audit.c
index 2f4964c..fcbf377 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1625,10 +1625,10 @@ unsigned int audit_serial(void)
 }
 
 static inline void audit_get_stamp(struct audit_context *ctx,
-  struct timespec *t, unsigned int *serial)
+  struct timespec64 *t, unsigned int *serial)
 {
if (!ctx || !auditsc_get_stamp(ctx, t, serial)) {
-   *t = CURRENT_TIME;
+   ktime_get_real_ts64(t);
*serial = audit_serial();
}
 }
@@ -1652,7 +1652,7 @@ struct audit_buffer *audit_log_start(struct audit_context 
*ctx, gfp_t gfp_mask,
 int type)
 {
struct audit_buffer *ab;
-   struct timespec t;
+   struct timespec64 t;
unsigned int uninitialized_var(serial);
 
if (audit_initialized != AUDIT_INITIALIZED)
@@ -1705,8 +1705,8 @@ struct audit_buffer *audit_log_start(struct audit_context 
*ctx, gfp_t gfp_mask,
}
 
audit_get_stamp(ab->ctx, &t, &serial);
-   audit_log_format(ab, "audit(%lu.%03lu:%u): ",
-t.tv_sec, t.tv_nsec/100, serial);
+   audit_log_format(ab, "audit(%llu.%03lu:%u): ",
+(unsigned long long)t.tv_sec, t.tv_nsec/100, 
serial);
 
return ab;
 }
diff --git a/kernel/audit.h b/kernel/audit.h
index 0f1cf6d..cdf96f4 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -112,7 +112,7 @@ struct audit_context {
enum audit_statestate, current_state;
unsigned intserial; /* serial number for record */
int major;  /* syscall number */
-   struct timespec ctime;  /* time of syscall entry */
+   struct timespec64   ctime;  /* time of syscall entry */
unsigned long   argv[4];/* syscall arguments */
longreturn_code;/* syscall return code */
u64 prio;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index e59ffc7..a2d9217 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1532,7 +1532,7 @@ void __audit_syscall_entry(int major, unsigned long a1, 
unsigned long a2,
return;
 
context->serial = 0;
-   context->ctime  = CURRENT_TIME;
+   ktime_get_real_ts64(&context->ctime);
context->in_syscall = 1;
context->current_state  = state;
context->ppid   = 0;
@@ -1941,13 +1941,13 @@ EXPORT_SYMBOL_GPL(__audit_inode_child);
 /**
  * auditsc_get_stamp - get local copies of audit_context values
  * @ctx: audit_context for the task
- * @t: timespec to store time recorded in the audit_context
+ * @t: timespec64 to store time recorded in the audit_context
  * @serial: serial value that is recorded in the audit_context
  *
  * Also sets the context as auditable.
  */
 int auditsc_get_stamp(struct audit_context *ctx,
-  struct timespec *t, unsigned int *serial)
+  struct timespec64 *t, unsigned int *serial)
 {
if (!ctx->in_syscall)
return 0;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverpro

[PATCH 02/12] trace: Make trace_hwlat timestamp y2038 safe

2017-04-07 Thread Deepa Dinamani
struct timespec is not y2038 safe on 32 bit machines
and needs to be replaced by struct timespec64
in order to represent times beyond year 2038 on such
machines.

Fix all the timestamp representation in struct trace_hwlat
and all the corresponding implementations.

Signed-off-by: Deepa Dinamani 
---
 kernel/trace/trace_entries.h |  6 +++---
 kernel/trace/trace_hwlat.c   | 14 +++---
 kernel/trace/trace_output.c  |  9 -
 3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/kernel/trace/trace_entries.h b/kernel/trace/trace_entries.h
index c203ac4..adcdbbe 100644
--- a/kernel/trace/trace_entries.h
+++ b/kernel/trace/trace_entries.h
@@ -348,14 +348,14 @@ FTRACE_ENTRY(hwlat, hwlat_entry,
__field(u64,duration)
__field(u64,outer_duration  )
__field(u64,nmi_total_ts)
-   __field_struct( struct timespec,timestamp   )
-   __field_desc(   long,   timestamp,  tv_sec  )
+   __field_struct( struct timespec64,  timestamp   )
+   __field_desc(   s64,timestamp,  tv_sec  )
__field_desc(   long,   timestamp,  tv_nsec )
__field(unsigned int,   nmi_count   )
__field(unsigned int,   seqnum  )
),
 
-   
F_printk("cnt:%u\tts:%010lu.%010lu\tinner:%llu\touter:%llunmi-ts:%llu\tnmi-count:%u\n",
+   
F_printk("cnt:%u\tts:%010llu.%010lu\tinner:%llu\touter:%llunmi-ts:%llu\tnmi-count:%u\n",
 __entry->seqnum,
 __entry->tv_sec,
 __entry->tv_nsec,
diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c
index 21ea6ae..d7c8e4e 100644
--- a/kernel/trace/trace_hwlat.c
+++ b/kernel/trace/trace_hwlat.c
@@ -79,12 +79,12 @@ static u64 last_tracing_thresh = DEFAULT_LAT_THRESHOLD * 
NSEC_PER_USEC;
 
 /* Individual latency samples are stored here when detected. */
 struct hwlat_sample {
-   u64 seqnum; /* unique sequence */
-   u64 duration;   /* delta */
-   u64 outer_duration; /* delta (outer loop) */
-   u64 nmi_total_ts;   /* Total time spent in NMIs */
-   struct timespec timestamp;  /* wall time */
-   int nmi_count;  /* # NMIs during this sample */
+   u64 seqnum; /* unique sequence */
+   u64 duration;   /* delta */
+   u64 outer_duration; /* delta (outer loop) */
+   u64 nmi_total_ts;   /* Total time spent in NMIs */
+   struct timespec64   timestamp;  /* wall time */
+   int nmi_count;  /* # NMIs during this sample */
 };
 
 /* keep the global state somewhere. */
@@ -250,7 +250,7 @@ static int get_sample(void)
s.seqnum = hwlat_data.count;
s.duration = sample;
s.outer_duration = outer_sample;
-   s.timestamp = CURRENT_TIME;
+   ktime_get_real_ts64(&s.timestamp);
s.nmi_total_ts = nmi_total_ts;
s.nmi_count = nmi_count;
trace_hwlat_sample(&s);
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 02a4aeb..08f9bab 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -4,7 +4,6 @@
  * Copyright (C) 2008 Red Hat Inc, Steven Rostedt 
  *
  */
-
 #include 
 #include 
 #include 
@@ -1161,11 +1160,11 @@ trace_hwlat_print(struct trace_iterator *iter, int 
flags,
 
trace_assign_type(field, entry);
 
-   trace_seq_printf(s, "#%-5u inner/outer(us): %4llu/%-5llu ts:%ld.%09ld",
+   trace_seq_printf(s, "#%-5u inner/outer(us): %4llu/%-5llu ts:%lld.%09ld",
 field->seqnum,
 field->duration,
 field->outer_duration,
-field->timestamp.tv_sec,
+(long long)field->timestamp.tv_sec,
 field->timestamp.tv_nsec);
 
if (field->nmi_count) {
@@ -1195,10 +1194,10 @@ trace_hwlat_raw(struct trace_iterator *iter, int flags,
 
trace_assign_type(field, iter->ent);
 
-   trace_seq_printf(s, "%llu %lld %ld %09ld %u\n",
+   trace_seq_printf(s, "%llu %lld %lld %09ld %u\n",
 field->duration,
 field->outer_duration,
-field->timestamp.tv_sec,
+(long long)field->timestamp.tv_sec,
 field->timestamp.tv_nsec,
 field->seqnum);
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/12] Delete CURRENT_TIME, CURRENT_TIME_SEC and current_fs_time

2017-04-07 Thread Deepa Dinamani
The series contains the last unmerged uses of CURRENT_TIME,
CURRENT_TIME_SEC, and current_fs_time().
The series also deletes these apis.

All the patches except [PATCH 9/12] and [PATCH 10/12] are resend patches.
These patches fix new instances of CURRENT_TIME.
cifs and ceph patches have been squashed so that we have one patch per
filesystem.

We want to get these merged onto 4.12 release so that I can post the series
that changes vfs timestamps to use 64 bits for 4.13 release.

I'm proposing these to be merged through Andrew's tree.

Filesystem maintainers, please let Andrew know if you will be picking up
the patch in your trees.

Let me know if anybody has other preferences for merging.

Deepa Dinamani (12):
  fs: f2fs: Use ktime_get_real_seconds for sit_info times
  trace: Make trace_hwlat timestamp y2038 safe
  fs: cifs: Replace CURRENT_TIME by other appropriate apis
  fs: ceph: CURRENT_TIME with ktime_get_real_ts()
  fs: ufs: Use ktime_get_real_ts64() for birthtime
  audit: Use timespec64 to represent audit timestamps
  fs: btrfs: Use ktime_get_real_ts for root ctime
  fs: ubifs: Replace CURRENT_TIME_SEC with current_time
  lustre: Replace CURRENT_TIME macro
  apparmorfs: Replace CURRENT_TIME with current_time()
  time: Delete CURRENT_TIME_SEC and CURRENT_TIME
  time: Delete current_fs_time() function

 drivers/block/rbd.c |  2 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c |  6 +++---
 drivers/staging/lustre/lustre/osc/osc_io.c  |  4 ++--
 fs/btrfs/root-tree.c|  3 ++-
 fs/ceph/mds_client.c|  4 +++-
 fs/cifs/cifsencrypt.c   |  4 +++-
 fs/cifs/cifssmb.c   | 10 -
 fs/cifs/inode.c | 28 +
 fs/f2fs/segment.c   |  2 +-
 fs/f2fs/segment.h   |  5 +++--
 fs/ubifs/dir.c  | 12 +--
 fs/ubifs/file.c | 12 +--
 fs/ubifs/ioctl.c|  2 +-
 fs/ubifs/misc.h | 10 -
 fs/ubifs/sb.c   | 14 +
 fs/ubifs/xattr.c|  6 +++---
 fs/ufs/ialloc.c |  6 --
 include/linux/audit.h   |  4 ++--
 include/linux/fs.h  |  1 -
 include/linux/time.h|  3 ---
 kernel/audit.c  | 10 -
 kernel/audit.h  |  2 +-
 kernel/auditsc.c|  6 +++---
 kernel/time/time.c  | 14 -
 kernel/trace/trace_entries.h|  6 +++---
 kernel/trace/trace_hwlat.c  | 14 ++---
 kernel/trace/trace_output.c |  9 
 net/ceph/messenger.c|  6 --
 net/ceph/osd_client.c   |  4 ++--
 security/apparmor/apparmorfs.c  |  2 +-
 30 files changed, 100 insertions(+), 111 deletions(-)

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/12] fs: f2fs: Use ktime_get_real_seconds for sit_info times

2017-04-07 Thread Deepa Dinamani
CURRENT_TIME_SEC is not y2038 safe.

Replace use of CURRENT_TIME_SEC with ktime_get_real_seconds
in segment timestamps used by GC algorithm including the
segment mtime timestamps.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
---
 fs/f2fs/segment.c | 2 +-
 fs/f2fs/segment.h | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 010324c..0531500 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2678,7 +2678,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
sit_i->dirty_sentries = 0;
sit_i->sents_per_block = SIT_ENTRY_PER_BLOCK;
sit_i->elapsed_time = le64_to_cpu(sbi->ckpt->elapsed_time);
-   sit_i->mounted_time = CURRENT_TIME_SEC.tv_sec;
+   sit_i->mounted_time = ktime_get_real_seconds();
mutex_init(&sit_i->sentry_lock);
return 0;
 }
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 57e36c1..156afc3 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -692,8 +692,9 @@ static inline void set_to_next_sit(struct sit_info *sit_i, 
unsigned int start)
 static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi)
 {
struct sit_info *sit_i = SIT_I(sbi);
-   return sit_i->elapsed_time + CURRENT_TIME_SEC.tv_sec -
-   sit_i->mounted_time;
+   time64_t now = ktime_get_real_seconds();
+
+   return sit_i->elapsed_time + now - sit_i->mounted_time;
 }
 
 static inline void set_summary(struct f2fs_summary *sum, nid_t nid,
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel