[PATCH v2] powerpc/vdso: fix clock_gettime_fallback for vdso32

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE2041d

4 messages, 3 authors, 2021-01-12 · open the first message on its own page

[PATCH v2] powerpc/vdso: fix clock_gettime_fallback for vdso32

From: Christophe Leroy <hidden>
Date: 2021-01-11 16:53:42

From: Andreas Schwab <redacted>

The second argument of __kernel_clock_gettime64 points to a struct
__kernel_timespec, with 64-bit time_t, so use the clock_gettime64 syscall
in the fallback function for the 32-bit vdso.  Similarily,
clock_getres_fallback should use the clock_getres_time64 syscall, though
it isn't yet called from the 32-bit vdso.

Signed-off-by: Andreas Schwab <redacted>
[chleroy: Moved into the #ifdef CONFIG_VDSO32 block]
Fixes: d0e3fc69d00d ("powerpc/vdso: Provide __kernel_clock_gettime64() on vdso32")
Signed-off-by: Christophe Leroy <redacted>
---
 arch/powerpc/include/asm/vdso/gettimeofday.h | 27 +++++++++++++++-----
 1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/include/asm/vdso/gettimeofday.h b/arch/powerpc/include/asm/vdso/gettimeofday.h
index 7a215cc5da77..3ecddd9c6302 100644
--- a/arch/powerpc/include/asm/vdso/gettimeofday.h
+++ b/arch/powerpc/include/asm/vdso/gettimeofday.h
@@ -102,22 +102,22 @@ int gettimeofday_fallback(struct __kernel_old_timeval *_tv, struct timezone *_tz
 	return do_syscall_2(__NR_gettimeofday, (unsigned long)_tv, (unsigned long)_tz);
 }
 
+#ifdef CONFIG_VDSO32
+
+#define BUILD_VDSO32		1
+
 static __always_inline
 int clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
 {
-	return do_syscall_2(__NR_clock_gettime, _clkid, (unsigned long)_ts);
+	return do_syscall_2(__NR_clock_gettime64, _clkid, (unsigned long)_ts);
 }
 
 static __always_inline
 int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
 {
-	return do_syscall_2(__NR_clock_getres, _clkid, (unsigned long)_ts);
+	return do_syscall_2(__NR_clock_getres_time64, _clkid, (unsigned long)_ts);
 }
 
-#ifdef CONFIG_VDSO32
-
-#define BUILD_VDSO32		1
-
 static __always_inline
 int clock_gettime32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
 {
@@ -129,6 +129,21 @@ int clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
 {
 	return do_syscall_2(__NR_clock_getres, _clkid, (unsigned long)_ts);
 }
+
+#else
+
+static __always_inline
+int clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
+{
+	return do_syscall_2(__NR_clock_gettime, _clkid, (unsigned long)_ts);
+}
+
+static __always_inline
+int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
+{
+	return do_syscall_2(__NR_clock_getres, _clkid, (unsigned long)_ts);
+}
+
 #endif
 
 static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
-- 
2.25.0

Re: [PATCH v2] powerpc/vdso: fix clock_gettime_fallback for vdso32

From: kernel test robot <hidden>
Date: 2021-01-11 22:21:08

Hi Christophe,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on v5.11-rc3 next-20210111]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Christophe-Leroy/powerpc-vdso-fix-clock_gettime_fallback-for-vdso32/20210112-005359
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-allyesconfig (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/49b084da4df1e1cf12240826b7d6db743c761e7c
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Christophe-Leroy/powerpc-vdso-fix-clock_gettime_fallback-for-vdso32/20210112-005359
        git checkout 49b084da4df1e1cf12240826b7d6db743c761e7c
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <redacted>

All errors (new ones prefixed by >>):

   In file included from include/vdso/datapage.h:137,
                    from arch/powerpc/include/asm/vdso_datapage.h:39,
                    from arch/powerpc/kernel/asm-offsets.c:37:
   arch/powerpc/include/asm/vdso/gettimeofday.h: In function 'clock_gettime_fallback':
quoted
arch/powerpc/include/asm/vdso/gettimeofday.h:113:22: error: '__NR_clock_gettime64' undeclared (first use in this function)
     113 |  return do_syscall_2(__NR_clock_gettime64, _clkid, (unsigned long)_ts);
         |                      ^~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/vdso/gettimeofday.h:113:22: note: each undeclared identifier is reported only once for each function it appears in
   arch/powerpc/include/asm/vdso/gettimeofday.h: In function 'clock_getres_fallback':
quoted
arch/powerpc/include/asm/vdso/gettimeofday.h:119:22: error: '__NR_clock_getres_time64' undeclared (first use in this function)
     119 |  return do_syscall_2(__NR_clock_getres_time64, _clkid, (unsigned long)_ts);
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~
--
   In file included from include/vdso/datapage.h:137,
                    from arch/powerpc/include/asm/vdso_datapage.h:39,
                    from arch/powerpc/kernel/asm-offsets.c:37:
   arch/powerpc/include/asm/vdso/gettimeofday.h: In function 'clock_gettime_fallback':
quoted
arch/powerpc/include/asm/vdso/gettimeofday.h:113:22: error: '__NR_clock_gettime64' undeclared (first use in this function)
     113 |  return do_syscall_2(__NR_clock_gettime64, _clkid, (unsigned long)_ts);
         |                      ^~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/vdso/gettimeofday.h:113:22: note: each undeclared identifier is reported only once for each function it appears in
   arch/powerpc/include/asm/vdso/gettimeofday.h: In function 'clock_getres_fallback':
quoted
arch/powerpc/include/asm/vdso/gettimeofday.h:119:22: error: '__NR_clock_getres_time64' undeclared (first use in this function)
     119 |  return do_syscall_2(__NR_clock_getres_time64, _clkid, (unsigned long)_ts);
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~
   make[2]: *** [scripts/Makefile.build:117: arch/powerpc/kernel/asm-offsets.s] Error 1
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [Makefile:1206: prepare0] Error 2
   make[1]: Target 'modules_prepare' not remade because of errors.
   make: *** [Makefile:185: __sub-make] Error 2
   make: Target 'modules_prepare' not remade because of errors.
--
   In file included from include/vdso/datapage.h:137,
                    from arch/powerpc/include/asm/vdso_datapage.h:39,
                    from arch/powerpc/kernel/asm-offsets.c:37:
   arch/powerpc/include/asm/vdso/gettimeofday.h: In function 'clock_gettime_fallback':
quoted
arch/powerpc/include/asm/vdso/gettimeofday.h:113:22: error: '__NR_clock_gettime64' undeclared (first use in this function)
     113 |  return do_syscall_2(__NR_clock_gettime64, _clkid, (unsigned long)_ts);
         |                      ^~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/vdso/gettimeofday.h:113:22: note: each undeclared identifier is reported only once for each function it appears in
   arch/powerpc/include/asm/vdso/gettimeofday.h: In function 'clock_getres_fallback':
quoted
arch/powerpc/include/asm/vdso/gettimeofday.h:119:22: error: '__NR_clock_getres_time64' undeclared (first use in this function)
     119 |  return do_syscall_2(__NR_clock_getres_time64, _clkid, (unsigned long)_ts);
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~
   make[2]: *** [scripts/Makefile.build:117: arch/powerpc/kernel/asm-offsets.s] Error 1
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [Makefile:1206: prepare0] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [Makefile:185: __sub-make] Error 2
   make: Target 'prepare' not remade because of errors.


vim +/__NR_clock_gettime64 +113 arch/powerpc/include/asm/vdso/gettimeofday.h

   109	
   110	static __always_inline
   111	int clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
   112	{
 > 113		return do_syscall_2(__NR_clock_gettime64, _clkid, (unsigned long)_ts);
   114	}
   115	
   116	static __always_inline
   117	int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
   118	{
 > 119		return do_syscall_2(__NR_clock_getres_time64, _clkid, (unsigned long)_ts);
   120	}
   121	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Re: [PATCH v2] powerpc/vdso: fix clock_gettime_fallback for vdso32

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2021-01-12 01:14:16

Christophe Leroy [off-list ref] writes:
From: Andreas Schwab <redacted>

The second argument of __kernel_clock_gettime64 points to a struct
__kernel_timespec, with 64-bit time_t, so use the clock_gettime64 syscall
in the fallback function for the 32-bit vdso.  Similarily,
clock_getres_fallback should use the clock_getres_time64 syscall, though
it isn't yet called from the 32-bit vdso.

Signed-off-by: Andreas Schwab <redacted>
[chleroy: Moved into the #ifdef CONFIG_VDSO32 block]
That doesn't build for 64-bit with compat VDSO. Should I just take
Andreas' version, or do you want to send a v3?

cheers
quoted hunk
Fixes: d0e3fc69d00d ("powerpc/vdso: Provide __kernel_clock_gettime64() on vdso32")
Signed-off-by: Christophe Leroy <redacted>
---
 arch/powerpc/include/asm/vdso/gettimeofday.h | 27 +++++++++++++++-----
 1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/include/asm/vdso/gettimeofday.h b/arch/powerpc/include/asm/vdso/gettimeofday.h
index 7a215cc5da77..3ecddd9c6302 100644
--- a/arch/powerpc/include/asm/vdso/gettimeofday.h
+++ b/arch/powerpc/include/asm/vdso/gettimeofday.h
@@ -102,22 +102,22 @@ int gettimeofday_fallback(struct __kernel_old_timeval *_tv, struct timezone *_tz
 	return do_syscall_2(__NR_gettimeofday, (unsigned long)_tv, (unsigned long)_tz);
 }
 
+#ifdef CONFIG_VDSO32
+
+#define BUILD_VDSO32		1
+
 static __always_inline
 int clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
 {
-	return do_syscall_2(__NR_clock_gettime, _clkid, (unsigned long)_ts);
+	return do_syscall_2(__NR_clock_gettime64, _clkid, (unsigned long)_ts);
 }
 
 static __always_inline
 int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
 {
-	return do_syscall_2(__NR_clock_getres, _clkid, (unsigned long)_ts);
+	return do_syscall_2(__NR_clock_getres_time64, _clkid, (unsigned long)_ts);
 }
 
-#ifdef CONFIG_VDSO32
-
-#define BUILD_VDSO32		1
-
 static __always_inline
 int clock_gettime32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
 {
@@ -129,6 +129,21 @@ int clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
 {
 	return do_syscall_2(__NR_clock_getres, _clkid, (unsigned long)_ts);
 }
+
+#else
+
+static __always_inline
+int clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
+{
+	return do_syscall_2(__NR_clock_gettime, _clkid, (unsigned long)_ts);
+}
+
+static __always_inline
+int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
+{
+	return do_syscall_2(__NR_clock_getres, _clkid, (unsigned long)_ts);
+}
+
 #endif
 
 static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
-- 
2.25.0

Re: [PATCH v2] powerpc/vdso: fix clock_gettime_fallback for vdso32

From: Christophe Leroy <hidden>
Date: 2021-01-12 12:49:25


Le 12/01/2021 à 02:13, Michael Ellerman a écrit :
Christophe Leroy [off-list ref] writes:
quoted
From: Andreas Schwab <redacted>

The second argument of __kernel_clock_gettime64 points to a struct
__kernel_timespec, with 64-bit time_t, so use the clock_gettime64 syscall
in the fallback function for the 32-bit vdso.  Similarily,
clock_getres_fallback should use the clock_getres_time64 syscall, though
it isn't yet called from the 32-bit vdso.

Signed-off-by: Andreas Schwab <redacted>
[chleroy: Moved into the #ifdef CONFIG_VDSO32 block]
That doesn't build for 64-bit with compat VDSO. Should I just take
Andreas' version, or do you want to send a v3?
Yes, that #ifdef CONFIG_VDSO32 is crazy, should use __powerpc64__ instead, or __VDSO32__ but that 
one is defined in asflags-y so not sure we have it in C.

I sent v3 just before lunch.

Christophe
cheers
quoted
Fixes: d0e3fc69d00d ("powerpc/vdso: Provide __kernel_clock_gettime64() on vdso32")
Signed-off-by: Christophe Leroy <redacted>
---
  arch/powerpc/include/asm/vdso/gettimeofday.h | 27 +++++++++++++++-----
  1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/include/asm/vdso/gettimeofday.h b/arch/powerpc/include/asm/vdso/gettimeofday.h
index 7a215cc5da77..3ecddd9c6302 100644
--- a/arch/powerpc/include/asm/vdso/gettimeofday.h
+++ b/arch/powerpc/include/asm/vdso/gettimeofday.h
@@ -102,22 +102,22 @@ int gettimeofday_fallback(struct __kernel_old_timeval *_tv, struct timezone *_tz
  	return do_syscall_2(__NR_gettimeofday, (unsigned long)_tv, (unsigned long)_tz);
  }
  
+#ifdef CONFIG_VDSO32
+
+#define BUILD_VDSO32		1
+
  static __always_inline
  int clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
  {
-	return do_syscall_2(__NR_clock_gettime, _clkid, (unsigned long)_ts);
+	return do_syscall_2(__NR_clock_gettime64, _clkid, (unsigned long)_ts);
  }
  
  static __always_inline
  int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
  {
-	return do_syscall_2(__NR_clock_getres, _clkid, (unsigned long)_ts);
+	return do_syscall_2(__NR_clock_getres_time64, _clkid, (unsigned long)_ts);
  }
  
-#ifdef CONFIG_VDSO32
-
-#define BUILD_VDSO32		1
-
  static __always_inline
  int clock_gettime32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
  {
@@ -129,6 +129,21 @@ int clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
  {
  	return do_syscall_2(__NR_clock_getres, _clkid, (unsigned long)_ts);
  }
+
+#else
+
+static __always_inline
+int clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
+{
+	return do_syscall_2(__NR_clock_gettime, _clkid, (unsigned long)_ts);
+}
+
+static __always_inline
+int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
+{
+	return do_syscall_2(__NR_clock_getres, _clkid, (unsigned long)_ts);
+}
+
  #endif
  
  static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
-- 
2.25.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help