Skip to contentSkip to conversation

s390: convert to GENERIC_VDSO

RFC PATCH New Sven Schnelle 4 participants 9 messages Aug 4, 2020 – Aug 6, 2020

Subsystems (8)
Arm (32-bit) x86 MIPS RISC-V +4 more subsystems
lore
Share & tools
lore

Sven Schnelle

author reviewer
#0 lore raw

RFC PATCH v3 1/1 s390: convert to GENERIC_VDSO

here's the third version of the generic vdso patchset for s390.

Changes in v3;
- update the architecture specific data patch to the correct one.

Changes in v2:
- added patch from Thomas that adds vdso_update_begin()/vdso_update_end()
- changed the s390 code to use the vdso update functions
- changed the name of the architecture specific data to 'arch_data'

author reviewer
#1 lore raw

PATCH v3 1/3 vdso: allow to add architecture-specific vdso data

Add the possibility to add architecture specific vDSO
data to struct vdso_data. This is useful if the arch specific user space VDSO code needs additional data during execution. If CONFIG_ARCH_HAS_VDSO_DATA is defined, the generic code will include asm/vdso/data.h which should contain 'struct arch_vdso_data'. This structure will be embedded in the generic vDSO data.

---
 arch/Kconfig            | 3 +++
 include/vdso/datapage.h | 9 +++++++++
 2 files changed, 12 insertions(+)
arch/Kconfig +3 -0
index 8cc35dc556c7..e1017ce979e2 100644
@@ -979,6 +979,9 @@ config HAVE_SPARSE_SYSCALL_NR
 	  entries at 4000, 5000 and 6000 locations. This option turns on syscall
 	  related optimizations for a given architecture.
 
+config ARCH_HAS_VDSO_DATA
+	bool
+
 source "kernel/gcov/Kconfig"
 
 source "scripts/gcc-plugins/Kconfig"
include/vdso/datapage.h +9 -0
index 7955c56d6b3c..a11e89e2f547 100644
@@ -19,6 +19,12 @@
 #include <vdso/time32.h>
 #include <vdso/time64.h>
 
+#ifdef CONFIG_ARCH_HAS_VDSO_DATA
+#include <asm/vdso/data.h>
+#else
+struct arch_vdso_data {};
+#endif
+
 #define VDSO_BASES	(CLOCK_TAI + 1)
 #define VDSO_HRES	(BIT(CLOCK_REALTIME)		| \
 			 BIT(CLOCK_MONOTONIC)		| \
@@ -64,6 +70,7 @@ struct vdso_timestamp {
  * @tz_dsttime:		type of DST correction
  * @hrtimer_res:	hrtimer resolution
  * @__unused:		unused
+ * @arch_data:		architecture specific data
  *
  * vdso_data will be accessed by 64 bit and compat code at the same time
  * so we should be careful before modifying this structure.
@@ -97,6 +104,8 @@ struct vdso_data {
 	s32			tz_dsttime;
 	u32			hrtimer_res;
 	u32			__unused;
+
+	struct arch_vdso_data	arch_data;
 };
 
 /*
Signature · 1 line
2.17.1
merge bot Applied
#2 lore raw

[tip: timers/urgent] lib/vdso: Allow to add architecture-specific vdso data

The following commit has been merged into the timers/urgent branch of tip:

The following commit has been merged into the timers/urgent branch of tip:

Commit-ID:     d60d7de3e16d7cea998bad17d87366a359625894
Gitweb:        https://git.kernel.org/tip/d60d7de3e16d7cea998bad17d87366a359625894
Author:        Sven Schnelle <[email protected]>
AuthorDate:    Tue, 04 Aug 2020 17:01:22 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Thu, 06 Aug 2020 10:57:30 +02:00

lib/vdso: Allow to add architecture-specific vdso data

The initial assumption that all VDSO related data can be completely generic does not hold. S390 needs architecture specific storage to access the clock steering information.

Add struct arch_vdso_data to the vdso data struct. For architectures which do not need extra data this defaults to an empty struct. Architectures which require it, enable CONFIG_ARCH_HAS_VDSO_DATA and provide their specific struct in asm/vdso/data.h.

---
 arch/Kconfig            |  3 +++
 include/vdso/datapage.h | 10 ++++++++++
 2 files changed, 13 insertions(+)
arch/Kconfig +3 -0
index a112448..b44dd6b 100644
@@ -975,6 +975,9 @@ config HAVE_SPARSE_SYSCALL_NR
 	  entries at 4000, 5000 and 6000 locations. This option turns on syscall
 	  related optimizations for a given architecture.
 
+config ARCH_HAS_VDSO_DATA
+	bool
+
 source "kernel/gcov/Kconfig"
 
 source "scripts/gcc-plugins/Kconfig"
include/vdso/datapage.h +10 -0
index ee810ca..73eb622 100644
@@ -19,6 +19,12 @@
 #include <vdso/time32.h>
 #include <vdso/time64.h>
 
+#ifdef CONFIG_ARCH_HAS_VDSO_DATA
+#include <asm/vdso/data.h>
+#else
+struct arch_vdso_data {};
+#endif
+
 #define VDSO_BASES	(CLOCK_TAI + 1)
 #define VDSO_HRES	(BIT(CLOCK_REALTIME)		| \
 			 BIT(CLOCK_MONOTONIC)		| \
@@ -64,6 +70,8 @@ struct vdso_timestamp {
  * @tz_dsttime:		type of DST correction
  * @hrtimer_res:	hrtimer resolution
  * @__unused:		unused
+ * @arch_data:		architecture specific data (optional, defaults
+ *			to an empty struct)
  *
  * vdso_data will be accessed by 64 bit and compat code at the same time
  * so we should be careful before modifying this structure.
@@ -97,6 +105,8 @@ struct vdso_data {
 	s32			tz_dsttime;
 	u32			hrtimer_res;
 	u32			__unused;
+
+	struct arch_vdso_data	arch_data;
 };
 
 /*
author reviewer
#3 lore raw

PATCH v3 2/3 timekeeping/vsyscall: Provide vdso_update_begin/end()

In reply to Sven Schnelle

From: Thomas Gleixner <[email protected]>

Architectures can have the requirement to add additional architecture specific data to the VDSO data page which needs to be updated independent of the timekeeper updates.

To protect these updates vs. concurrent readers and a conflicting update through timekeeping, provide helper functions to make such updates safe.

vdso_update_begin() takes the timekeeper_lock to protect against a potential update from timekeeper code and increments the VDSO sequence count to signal data inconsistency to concurrent readers. vdso_update_end() makes the sequence count even again to signal data consistency and drops the timekeeper lock.

---
 include/vdso/vsyscall.h            |  3 +++
 kernel/time/timekeeping.c          |  2 +-
 kernel/time/timekeeping_internal.h | 11 +++++++---
 kernel/time/vsyscall.c             | 32 ++++++++++++++++++++++++++++++
 4 files changed, 44 insertions(+), 4 deletions(-)
include/vdso/vsyscall.h +3 -0
index 2c6134e0c23d..b0fdc9c6bf43 100644
@@ -6,6 +6,9 @@
 
 #include <asm/vdso/vsyscall.h>
 
+unsigned long vdso_update_begin(void);
+void vdso_update_end(unsigned long flags);
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __VDSO_VSYSCALL_H */
kernel/time/timekeeping.c +1 -1
index d20d489841c8..8459aa87986f 100644
@@ -50,7 +50,7 @@ static struct {
 	.seq = SEQCNT_ZERO(tk_core.seq),
 };
 
-static DEFINE_RAW_SPINLOCK(timekeeper_lock);
+DEFINE_RAW_SPINLOCK(timekeeper_lock);
 static struct timekeeper shadow_timekeeper;
 
 /**
kernel/time/timekeeping_internal.h +8 -3
index bcbb52db2256..4ca2787d1642 100644
@@ -1,12 +1,14 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #ifndef _TIMEKEEPING_INTERNAL_H
 #define _TIMEKEEPING_INTERNAL_H
-/*
- * timekeeping debug functions
- */
+
 #include <linux/clocksource.h>
+#include <linux/spinlock.h>
 #include <linux/time.h>
 
+/*
+ * timekeeping debug functions
+ */
 #ifdef CONFIG_DEBUG_FS
 extern void tk_debug_account_sleep_time(const struct timespec64 *t);
 #else
@@ -31,4 +33,7 @@ static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
 }
 #endif
 
+/* Semi public for serialization of non timekeeper VDSO updates. */
+extern raw_spinlock_t timekeeper_lock;
+
 #endif /* _TIMEKEEPING_INTERNAL_H */
kernel/time/vsyscall.c +32 -0
index 54ce6eb2ca36..e8806eda6874 100644
@@ -13,6 +13,8 @@
 #include <vdso/helpers.h>
 #include <vdso/vsyscall.h>
 
+#include "timekeeping_internal.h"
+
 static inline void update_vdso_data(struct vdso_data *vdata,
 				    struct timekeeper *tk)
 {
@@ -127,3 +129,33 @@ void update_vsyscall_tz(void)
 
 	__arch_sync_vdso_data(vdata);
 }
+
+/**
+ * vdso_update_begin - Start of a VDSO update section
+ *
+ * Allows architecture code to safely update the architecture specific VDSO
+ * data.
+ */
+unsigned long vdso_update_begin(void)
+{
+	struct vdso_data *vdata = __arch_get_k_vdso_data();
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&timekeeper_lock, flags);
+	vdso_write_begin(vdata);
+	return flags;
+}
+
+/**
+ * vdso_update_end - End of a VDSO update section
+ *
+ * Pairs with vdso_update_begin().
+ */
+void vdso_update_end(unsigned long flags)
+{
+	struct vdso_data *vdata = __arch_get_k_vdso_data();
+
+	vdso_write_end(vdata);
+	__arch_sync_vdso_data(vdata);
+	raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
+}
Signature · 1 line
2.17.1
#4 lore raw

[tip: timers/urgent] timekeeping/vsyscall: Provide vdso_update_begin/end()

The following commit has been merged into the timers/urgent branch of tip:

The following commit has been merged into the timers/urgent branch of tip:

Commit-ID:     19d0070a2792181f79df01277fe00b83b9f7eda7
Gitweb:        https://git.kernel.org/tip/19d0070a2792181f79df01277fe00b83b9f7eda7
Author:        Thomas Gleixner <[email protected]>
AuthorDate:    Tue, 04 Aug 2020 17:01:23 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Thu, 06 Aug 2020 10:57:30 +02:00

timekeeping/vsyscall: Provide vdso_update_begin/end()

Architectures can have the requirement to add additional architecture specific data to the VDSO data page which needs to be updated independent of the timekeeper updates.

To protect these updates vs. concurrent readers and a conflicting update through timekeeping, provide helper functions to make such updates safe.

vdso_update_begin() takes the timekeeper_lock to protect against a potential update from timekeeper code and increments the VDSO sequence count to signal data inconsistency to concurrent readers. vdso_update_end() makes the sequence count even again to signal data consistency and drops the timekeeper lock.

[ Sven: Add interrupt disable handling to the functions ]

---
 include/vdso/vsyscall.h            |  3 ++-
 kernel/time/timekeeping.c          |  2 +-
 kernel/time/timekeeping_internal.h | 11 +++++---
 kernel/time/vsyscall.c             | 41 +++++++++++++++++++++++++++++-
 4 files changed, 53 insertions(+), 4 deletions(-)
include/vdso/vsyscall.h +3 -0
index 2c6134e..b0fdc9c 100644
@@ -6,6 +6,9 @@
 
 #include <asm/vdso/vsyscall.h>
 
+unsigned long vdso_update_begin(void);
+void vdso_update_end(unsigned long flags);
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __VDSO_VSYSCALL_H */
kernel/time/timekeeping.c +1 -1
index 63a632f..4c7212f 100644
@@ -50,7 +50,7 @@ static struct {
 	.seq = SEQCNT_ZERO(tk_core.seq),
 };
 
-static DEFINE_RAW_SPINLOCK(timekeeper_lock);
+DEFINE_RAW_SPINLOCK(timekeeper_lock);
 static struct timekeeper shadow_timekeeper;
 
 /**
kernel/time/timekeeping_internal.h +8 -3
index bcbb52d..4ca2787 100644
@@ -1,12 +1,14 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #ifndef _TIMEKEEPING_INTERNAL_H
 #define _TIMEKEEPING_INTERNAL_H
-/*
- * timekeeping debug functions
- */
+
 #include <linux/clocksource.h>
+#include <linux/spinlock.h>
 #include <linux/time.h>
 
+/*
+ * timekeeping debug functions
+ */
 #ifdef CONFIG_DEBUG_FS
 extern void tk_debug_account_sleep_time(const struct timespec64 *t);
 #else
@@ -31,4 +33,7 @@ static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
 }
 #endif
 
+/* Semi public for serialization of non timekeeper VDSO updates. */
+extern raw_spinlock_t timekeeper_lock;
+
 #endif /* _TIMEKEEPING_INTERNAL_H */
kernel/time/vsyscall.c +41 -0

50 lines not on this page · raw message

author reviewer
#5 lore raw

PATCH v3 3/3 s390: convert to GENERIC_VDSO

In reply to Sven Schnelle

This patch converts s390 to the generic vDSO. There are a few special things on s390:

- vDSO can be called without a stack frame - glibc did this in the past. So we need to allocate a stackframe on our own.

- The former assembly code used stcke to get the TOD clock and applied time steering to it. We need to do the same in the new code. This is done in the architecture specific __arch_get_hw_counter function. The steering information is stored in an architecure specific area in the vDSO data.

- CPUCLOCK_VIRT is now handled with a syscall fallback, which might be slower/less accurate than the old implementation.

The getcpu() function stays as an assembly function because there is no generic implementation and the code is just a few lines.

Performance number from my system do 100 mio gettimeofday() calls:

Plain syscall: 8.6s
Generic VDSO:  1.3s
old ASM VDSO:  1s

So it's a bit slower but still much faster than syscalls.

---
 arch/s390/Kconfig                           |   3 +
 arch/s390/include/asm/clocksource.h         |   7 +
 arch/s390/include/asm/vdso.h                |  25 +--
 arch/s390/include/asm/vdso/clocksource.h    |   8 +
 arch/s390/include/asm/vdso/data.h           |  13 ++
 arch/s390/include/asm/vdso/gettimeofday.h   |  71 +++++++++
 arch/s390/include/asm/vdso/processor.h      |   5 +
 arch/s390/include/asm/vdso/vdso.h           |   0
 arch/s390/include/asm/vdso/vsyscall.h       |  26 ++++
 arch/s390/kernel/asm-offsets.c              |  20 ---
 arch/s390/kernel/entry.S                    |   6 -
 arch/s390/kernel/setup.c                    |   1 -
 arch/s390/kernel/time.c                     |  66 ++------
 arch/s390/kernel/vdso.c                     |  29 +---
 arch/s390/kernel/vdso64/Makefile            |  19 ++-
 arch/s390/kernel/vdso64/clock_getres.S      |  50 ------
 arch/s390/kernel/vdso64/clock_gettime.S     | 163 --------------------
 arch/s390/kernel/vdso64/gettimeofday.S      |  71 ---------
 arch/s390/kernel/vdso64/vdso64_generic.c    |  18 +++
 arch/s390/kernel/vdso64/vdso_user_wrapper.S |  38 +++++
 20 files changed, 219 insertions(+), 420 deletions(-)
 create mode 100644 arch/s390/include/asm/clocksource.h
 create mode 100644 arch/s390/include/asm/vdso/clocksource.h
 create mode 100644 arch/s390/include/asm/vdso/data.h
 create mode 100644 arch/s390/include/asm/vdso/gettimeofday.h
 create mode 100644 arch/s390/include/asm/vdso/processor.h
 create mode 100644 arch/s390/include/asm/vdso/vdso.h
 create mode 100644 arch/s390/include/asm/vdso/vsyscall.h
 delete mode 100644 arch/s390/kernel/vdso64/clock_getres.S
 delete mode 100644 arch/s390/kernel/vdso64/clock_gettime.S
 delete mode 100644 arch/s390/kernel/vdso64/gettimeofday.S
 create mode 100644 arch/s390/kernel/vdso64/vdso64_generic.c
 create mode 100644 arch/s390/kernel/vdso64/vdso_user_wrapper.S
arch/s390/Kconfig +3 -0
index c7d7ede6300c..eb50f748e151 100644
@@ -73,6 +73,7 @@ config S390
 	select ARCH_HAS_STRICT_MODULE_RWX
 	select ARCH_HAS_SYSCALL_WRAPPER
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
+	select ARCH_HAS_VDSO_DATA
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select ARCH_INLINE_READ_LOCK
 	select ARCH_INLINE_READ_LOCK_BH
@@ -118,6 +119,7 @@ config S390
 	select GENERIC_CPU_AUTOPROBE
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_FIND_FIRST_BIT
+	select GENERIC_GETTIMEOFDAY
 	select GENERIC_SMP_IDLE_THREAD
 	select GENERIC_TIME_VSYSCALL
 	select HAVE_ALIGNED_STRUCT_PAGE if SLUB
@@ -149,6 +151,7 @@ config S390
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FUTEX_CMPXCHG if FUTEX
 	select HAVE_GCC_PLUGINS
+	select HAVE_GENERIC_VDSO
 	select HAVE_KERNEL_BZIP2
 	select HAVE_KERNEL_GZIP
 	select HAVE_KERNEL_LZ4
arch/s390/include/asm/clocksource.h new file +7 -0
new file mode 100644
index 000000000000..03434369fce4
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* s390-specific clocksource additions */
+
+#ifndef _ASM_S390_CLOCKSOURCE_H
+#define _ASM_S390_CLOCKSOURCE_H
+
+#endif /* _ASM_S390_CLOCKSOURCE_H */
arch/s390/include/asm/vdso.h +2 -23
index 0cd085cdeb4f..82f86b3c394b 100644
@@ -2,6 +2,8 @@
 #ifndef __S390_VDSO_H__
 #define __S390_VDSO_H__
 
+#include <vdso/datapage.h>
+
 /* Default link addresses for the vDSOs */
 #define VDSO32_LBASE	0
 #define VDSO64_LBASE	0
@@ -18,30 +20,7 @@
  * itself and may change without notice.
  */
 
-struct vdso_data {
-	__u64 tb_update_count;		/* Timebase atomicity ctr	0x00 */
-	__u64 xtime_tod_stamp;		/* TOD clock for xtime		0x08 */
-	__u64 xtime_clock_sec;		/* Kernel time			0x10 */
-	__u64 xtime_clock_nsec;		/*				0x18 */
-	__u64 xtime_coarse_sec;		/* Coarse kernel time		0x20 */
-	__u64 xtime_coarse_nsec;	/*				0x28 */
-	__u64 wtom_clock_sec;		/* Wall to monotonic clock	0x30 */
-	__u64 wtom_clock_nsec;		/*				0x38 */
-	__u64 wtom_coarse_sec;		/* Coarse wall to monotonic	0x40 */
-	__u64 wtom_coarse_nsec;		/*				0x48 */
-	__u32 tz_minuteswest;		/* Minutes west of Greenwich	0x50 */
-	__u32 tz_dsttime;		/* Type of dst correction	0x54 */
-	__u32 ectg_available;		/* ECTG instruction present	0x58 */
-	__u32 tk_mult;			/* Mult. used for xtime_nsec	0x5c */
-	__u32 tk_shift;			/* Shift used for xtime_nsec	0x60 */
-	__u32 ts_dir;			/* TOD steering direction	0x64 */
-	__u64 ts_end;			/* TOD steering end		0x68 */
-	__u32 hrtimer_res;		/* hrtimer resolution		0x70 */
-};
-
 struct vdso_per_cpu_data {
-	__u64 ectg_timer_base;
-	__u64 ectg_user_time;
 	/*
 	 * Note: node_id and cpu_nr must be at adjacent memory locations.
 	 * VDSO userspace must read both values with a single instruction.
arch/s390/include/asm/vdso/clocksource.h new file +8 -0
new file mode 100644
index 000000000000..a93eda0ce7bb
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_VDSO_CLOCKSOURCE_H
+#define __ASM_VDSO_CLOCKSOURCE_H
+
+#define VDSO_ARCH_CLOCKMODES	\
+	VDSO_CLOCKMODE_TOD
+
+#endif /* __ASM_VDSO_CLOCKSOURCE_H */
arch/s390/include/asm/vdso/data.h new file +13 -0
new file mode 100644
index 000000000000..7b3cdb4a5f48
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __S390_ASM_VDSO_DATA_H
+#define __S390_ASM_VDSO_DATA_H
+
+#include <linux/types.h>
+#include <vdso/datapage.h>
+
+struct arch_vdso_data {
+	__u64 tod_steering_delta;
+	__u64 tod_steering_end;
+};
+
+#endif /* __S390_ASM_VDSO_DATA_H */
arch/s390/include/asm/vdso/gettimeofday.h new file +71 -0

71 lines not on this page · raw message

arch/s390/include/asm/vdso/processor.h new file +5 -0
new file mode 100644
index 000000000000..c47deb472e2a
@@ -0,0 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_VDSO_PROCESSOR_H
+#define __ASM_VDSO_PROCESSOR_H
+
+#endif /* __ASM_VDSO_PROCESSOR_H */
arch/s390/include/asm/vdso/vdso.h new file +0 -0
new file mode 100644
index 000000000000..e69de29bb2d1
arch/s390/include/asm/vdso/vsyscall.h new file +26 -0
new file mode 100644
index 000000000000..6c67c08cefdd
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_VDSO_VSYSCALL_H
+#define __ASM_VDSO_VSYSCALL_H
+
+#ifndef __ASSEMBLY__
+
+#include <linux/hrtimer.h>
+#include <linux/timekeeper_internal.h>
+#include <vdso/datapage.h>
+#include <asm/vdso.h>
+/*
+ * Update the vDSO data page to keep in sync with kernel timekeeping.
+ */
+
+static __always_inline struct vdso_data *__s390_get_k_vdso_data(void)
+{
+	return vdso_data;
+}
+#define __arch_get_k_vdso_data __s390_get_k_vdso_data
+
+/* The asm-generic header needs to be included after the definitions above */
+#include <asm-generic/vdso/vsyscall.h>
+
+#endif /* !__ASSEMBLY__ */
+
+#endif /* __ASM_VDSO_VSYSCALL_H */
arch/s390/kernel/asm-offsets.c +0 -20
index 5d8cc1864566..ece58f2217cb 100644
@@ -59,26 +59,6 @@ int main(void)
 	OFFSET(__SF_SIE_REASON, stack_frame, empty1[2]);
 	OFFSET(__SF_SIE_FLAGS, stack_frame, empty1[3]);
 	BLANK();
-	/* timeval/timezone offsets for use by vdso */
-	OFFSET(__VDSO_UPD_COUNT, vdso_data, tb_update_count);
-	OFFSET(__VDSO_XTIME_STAMP, vdso_data, xtime_tod_stamp);
-	OFFSET(__VDSO_XTIME_SEC, vdso_data, xtime_clock_sec);
-	OFFSET(__VDSO_XTIME_NSEC, vdso_data, xtime_clock_nsec);
-	OFFSET(__VDSO_XTIME_CRS_SEC, vdso_data, xtime_coarse_sec);
-	OFFSET(__VDSO_XTIME_CRS_NSEC, vdso_data, xtime_coarse_nsec);
-	OFFSET(__VDSO_WTOM_SEC, vdso_data, wtom_clock_sec);
-	OFFSET(__VDSO_WTOM_NSEC, vdso_data, wtom_clock_nsec);
-	OFFSET(__VDSO_WTOM_CRS_SEC, vdso_data, wtom_coarse_sec);
-	OFFSET(__VDSO_WTOM_CRS_NSEC, vdso_data, wtom_coarse_nsec);
-	OFFSET(__VDSO_TIMEZONE, vdso_data, tz_minuteswest);
-	OFFSET(__VDSO_ECTG_OK, vdso_data, ectg_available);
-	OFFSET(__VDSO_TK_MULT, vdso_data, tk_mult);
-	OFFSET(__VDSO_TK_SHIFT, vdso_data, tk_shift);
-	OFFSET(__VDSO_TS_DIR, vdso_data, ts_dir);
-	OFFSET(__VDSO_TS_END, vdso_data, ts_end);
-	OFFSET(__VDSO_CLOCK_REALTIME_RES, vdso_data, hrtimer_res);
-	OFFSET(__VDSO_ECTG_BASE, vdso_per_cpu_data, ectg_timer_base);
-	OFFSET(__VDSO_ECTG_USER, vdso_per_cpu_data, ectg_user_time);
 	OFFSET(__VDSO_GETCPU_VAL, vdso_per_cpu_data, getcpu_val);
 	BLANK();
 	/* constants used by the vdso */
arch/s390/kernel/entry.S +0 -6
index 969b35b177dd..5de00e1f8830 100644
@@ -435,10 +435,8 @@ ENTRY(system_call)
 	jz	.Lsysc_skip_fpu
 	brasl	%r14,load_fpu_regs
 .Lsysc_skip_fpu:
-	lg	%r14,__LC_VDSO_PER_CPU
 	mvc	__LC_RETURN_PSW(16),__PT_PSW(%r11)
 	stpt	__LC_EXIT_TIMER
-	mvc	__VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
 	lmg	%r0,%r15,__PT_R0(%r11)
 	b	__LC_RETURN_LPSWE
 
@@ -797,13 +795,11 @@ ENTRY(io_int_handler)
 	TRACE_IRQS_ON
 0:
 #endif
-	lg	%r14,__LC_VDSO_PER_CPU
 	mvc	__LC_RETURN_PSW(16),__PT_PSW(%r11)
 	tm	__PT_PSW+1(%r11),0x01	# returning to user ?
 	jno	.Lio_exit_kernel
 	BPEXIT	__TI_flags(%r12),_TIF_ISOLATE_BP
 	stpt	__LC_EXIT_TIMER
-	mvc	__VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
 .Lio_exit_kernel:
 	lmg	%r0,%r15,__PT_R0(%r11)
 	b	__LC_RETURN_LPSWE
@@ -1213,14 +1209,12 @@ ENTRY(mcck_int_handler)
 	brasl	%r14,s390_handle_mcck
 	TRACE_IRQS_ON
 .Lmcck_return:
-	lg	%r14,__LC_VDSO_PER_CPU
 	lmg	%r0,%r10,__PT_R0(%r11)
 	mvc	__LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
 	tm	__LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
 	jno	0f
 	BPEXIT	__TI_flags(%r12),_TIF_ISOLATE_BP
 	stpt	__LC_EXIT_TIMER
-	mvc	__VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
 0:	lmg	%r11,%r15,__PT_R11(%r11)
 	b	__LC_RETURN_MCCK_LPSWE
 
arch/s390/kernel/setup.c +0 -1
index 07aa15ba43b3..0a5cb423aae2 100644
@@ -402,7 +402,6 @@ static void __init setup_lowcore_dat_off(void)
 	memcpy(lc->alt_stfle_fac_list, S390_lowcore.alt_stfle_fac_list,
 	       sizeof(lc->alt_stfle_fac_list));
 	nmi_alloc_boot_cpu(lc);
-	vdso_alloc_boot_cpu(lc);
 	lc->sync_enter_timer = S390_lowcore.sync_enter_timer;
 	lc->async_enter_timer = S390_lowcore.async_enter_timer;
 	lc->exit_timer = S390_lowcore.exit_timer;
arch/s390/kernel/time.c +10 -56

120 lines not on this page · raw message

arch/s390/kernel/vdso.c +3 -26
index c4baefaa6e34..f9da5b149141 100644
@@ -20,6 +20,8 @@
 #include <linux/security.h>
 #include <linux/memblock.h>
 #include <linux/compat.h>
+#include <linux/binfmts.h>
+#include <vdso/datapage.h>
 #include <asm/asm-offsets.h>
 #include <asm/processor.h>
 #include <asm/mmu.h>
@@ -96,35 +98,12 @@ static union {
 	struct vdso_data	data;
 	u8			page[PAGE_SIZE];
 } vdso_data_store __page_aligned_data;
-struct vdso_data *vdso_data = &vdso_data_store.data;
-
-/*
- * Setup vdso data page.
- */
-static void __init vdso_init_data(struct vdso_data *vd)
-{
-	vd->ectg_available = test_facility(31);
-}
-
+struct vdso_data *vdso_data = (struct vdso_data *)&vdso_data_store.data;
 /*
  * Allocate/free per cpu vdso data.
  */
 #define SEGMENT_ORDER	2
 
-/*
- * The initial vdso_data structure for the boot CPU. Eventually
- * it is replaced with a properly allocated structure in vdso_init.
- * This is necessary because a valid S390_lowcore.vdso_per_cpu_data
- * pointer is required to be able to return from an interrupt or
- * program check. See the exit paths in entry.S.
- */
-struct vdso_data boot_vdso_data __initdata;
-
-void __init vdso_alloc_boot_cpu(struct lowcore *lowcore)
-{
-	lowcore->vdso_per_cpu_data = (unsigned long) &boot_vdso_data;
-}
-
 int vdso_alloc_per_cpu(struct lowcore *lowcore)
 {
 	unsigned long segment_table, page_table, page_frame;
@@ -246,8 +225,6 @@ static int __init vdso_init(void)
 {
 	int i;
 
-	vdso_init_data(vdso_data);
-
 	/* Calculate the size of the 64 bit vDSO */
 	vdso64_pages = ((&vdso64_end - &vdso64_start
 			 + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1;
arch/s390/kernel/vdso64/Makefile +15 -4
index 4a66a1cb919b..f1c0570780d1 100644
@@ -1,14 +1,20 @@
 # SPDX-License-Identifier: GPL-2.0
-# List of files in the vdso, has to be asm only for now
+# List of files in the vdso
 
 KCOV_INSTRUMENT := n
+ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE
+ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT
 
-obj-vdso64 = gettimeofday.o clock_getres.o clock_gettime.o note.o getcpu.o
+include $(srctree)/lib/vdso/Makefile
+obj-vdso64 = vdso_user_wrapper.o note.o getcpu.o
+obj-cvdso64 = vdso64_generic.o
+CFLAGS_REMOVE_vdso64_generic.o = -pg $(CC_FLAGS_FTRACE) $(CC_FLAGS_EXPOLINE)
 
 # Build rules
 
-targets := $(obj-vdso64) vdso64.so vdso64.so.dbg
+targets := $(obj-vdso64) $(obj-cvdso64) vdso64.so vdso64.so.dbg
 obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
+obj-cvdso64 := $(addprefix $(obj)/, $(obj-cvdso64))
 
 KBUILD_AFLAGS += -DBUILD_VDSO
 KBUILD_CFLAGS += -DBUILD_VDSO
@@ -37,7 +43,7 @@ KASAN_SANITIZE := n
 $(obj)/vdso64_wrapper.o : $(obj)/vdso64.so
 
 # link rule for the .so file, .lds has to be first
-$(obj)/vdso64.so.dbg: $(obj)/vdso64.lds $(obj-vdso64) FORCE
+$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) $(obj-cvdso64) FORCE
 	$(call if_changed,ld)
 
 # strip rule for the .so file
@@ -49,9 +55,14 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE
 $(obj-vdso64): %.o: %.S FORCE
 	$(call if_changed_dep,vdso64as)
 
+$(obj-cvdso64): %.o: %.c FORCE
+	$(call if_changed_dep,vdso64cc)
+
 # actual build commands
 quiet_cmd_vdso64as = VDSO64A $@
       cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $<
+quiet_cmd_vdso64cc = VDSO64C $@
+      cmd_vdso64cc = $(CC) $(c_flags) -c -o $@ $<
 
 # install commands for the unstripped file
 quiet_cmd_vdso_install = INSTALL $@
arch/s390/kernel/vdso64/clock_getres.S deleted +0 -50

50 lines not on this page · raw message

arch/s390/kernel/vdso64/clock_gettime.S deleted +0 -163

163 lines not on this page · raw message

arch/s390/kernel/vdso64/gettimeofday.S deleted +0 -71

71 lines not on this page · raw message

arch/s390/kernel/vdso64/vdso64_generic.c new file +18 -0
new file mode 100644
index 000000000000..a8cef7e4d137
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "../../../../lib/vdso/gettimeofday.c"
+
+int __s390_vdso_gettimeofday(struct __kernel_old_timeval *tv,
+			     struct timezone *tz)
+{
+	return __cvdso_gettimeofday(tv, tz);
+}
+
+int __s390_vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts)
+{
+	return __cvdso_clock_gettime(clock, ts);
+}
+
+int __s390_vdso_clock_getres(clockid_t clock, struct __kernel_timespec *ts)
+{
+	return __cvdso_clock_getres(clock, ts);
+}
arch/s390/kernel/vdso64/vdso_user_wrapper.S new file +38 -0
new file mode 100644
index 000000000000..a775d7e52872
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#include <asm/vdso.h>
+#include <asm/unistd.h>
+#include <asm/asm-offsets.h>
+#include <asm/dwarf.h>
+#include <asm/ptrace.h>
+
+#define WRAPPER_FRAME_SIZE (STACK_FRAME_OVERHEAD+8)
+
+/*
+ * Older glibc version called vdso without allocating a stackframe. This wrapper
+ * is just used to allocate a stackframe. See
+ * https://sourceware.org/git/?p=glibc.git;a=commit;h=478593e6374f3818da39332260dc453cb19cfa1e
+ * for details.
+ */
+.macro vdso_func func
+	.globl __kernel_\func
+	.type  __kernel_\func,@function
+	.align 8
+__kernel_\func:
+	CFI_STARTPROC
+	aghi	%r15,-WRAPPER_FRAME_SIZE
+	CFI_DEF_CFA_OFFSET (STACK_FRAME_OVERHEAD + WRAPPER_FRAME_SIZE)
+	CFI_VAL_OFFSET 15, -STACK_FRAME_OVERHEAD
+	stg	%r14,STACK_FRAME_OVERHEAD(%r15)
+	brasl	%r14,__s390_vdso_\func
+	lg	%r14,STACK_FRAME_OVERHEAD(%r15)
+	aghi	%r15,WRAPPER_FRAME_SIZE
+	CFI_DEF_CFA_OFFSET STACK_FRAME_OVERHEAD
+	CFI_RESTORE 15
+	br	%r14
+	CFI_ENDPROC
+	.size	__kernel_\func,.-__kernel_\func
+.endm
+
+vdso_func gettimeofday
+vdso_func clock_getres
+vdso_func clock_gettime
Signature · 1 line
2.17.1
#6 lore raw
Thank you for the patch! Yet something to improve:

Hi Sven,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on s390/features]
[also build test ERROR on tip/timers/core linus/master v5.8 next-20200804] [cannot apply to tip/timers/vdso]
[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/Sven-Schnelle/vdso-allow-to-add-architecture-specific-vdso-data/20200805-000148
base:   https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features
config: s390-allyesconfig (attached as .config)
compiler: s390-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
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=s390

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from include/vdso/datapage.h:136,

                    from arch/s390/include/asm/vdso.h:5,
                    from arch/s390/include/asm/elf.h:147,
                    from include/linux/elf.h:6,
                    from include/linux/module.h:18,
                    from arch/s390/include/asm/kvm_host.h:21,
                    from include/linux/kvm_host.h:36,
                    from arch/s390/kernel/asm-offsets.c:11:
   arch/s390/include/asm/vdso/gettimeofday.h: In function '__arch_get_hw_counter':
>> arch/s390/include/asm/vdso/gettimeofday.h:31:12: error: 'const struct vdso_data' has no member named 'arch'
      31 |  adj = vdso->arch.tod_steering_end - now;
         |            ^~
   arch/s390/include/asm/vdso/gettimeofday.h:33:15: error: 'const struct vdso_data' has no member named 'arch'
      33 |   now += (vdso->arch.tod_steering_delta < 0) ? (adj >> 15) : -(adj >> 15);
         |               ^~

make[2]: *** [scripts/Makefile.build:114: arch/s390/kernel/asm-offsets.s] Error 1 make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1176: 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 +31 arch/s390/include/asm/vdso/gettimeofday.h

    24	
    25	static inline u64 __arch_get_hw_counter(s32 clock_mode)
    26	{
    27		const struct vdso_data *vdso = __arch_get_vdso_data();
    28		u64 adj, now;
    29	
    30		now = get_tod_clock();
  > 31		adj = vdso->arch.tod_steering_end - now;
    32		if (unlikely((s64) adj > 0))
    33			now += (vdso->arch.tod_steering_delta < 0) ? (adj >> 15) : -(adj >> 15);
    34		return now;
    35	}
    36	

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

#7 lore raw
In reply to Sven Schnelle

Sven,

arch/s390/include/asm/vdso/data.h line 6

Quoted 9 lines · Sven Schnelle
arch/s390/include/asm/vdso/data.h new file +6 -0
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __S390_ASM_VDSO_DATA_H
+#define __S390_ASM_VDSO_DATA_H
+
+#include <linux/types.h>
+#include <vdso/datapage.h>

I don't think this header needs vdso/datapage.h

arch/s390/include/asm/vdso/gettimeofday.h

Quoted 13 lines
arch/s390/include/asm/vdso/data.h new file +6 -0
+struct arch_vdso_data {
+	__u64 tod_steering_delta;
+	__u64 tod_steering_end;
+};
+
+#endif /* __S390_ASM_VDSO_DATA_H */
arch/s390/include/asm/vdso/gettimeofday.h new file +3 -0
 
+static inline u64 __arch_get_hw_counter(s32 clock_mode)
+{
+	const struct vdso_data *vdso = __arch_get_vdso_data();

If you go and implement time namespace support for VDSO then this becomes a problem. See do_hres_timens().

As we did not expect that this function needs vdso_data we should just add a vdso_data pointer argument to __arch_get_hw_counter(). And while looking at it you're not the first one. MIPS already uses it and because it does not support time namespaces so far nobody noticed yet.

That's fine for all others because the compiler will optimize it out when it's unused. If the compiler fails to do so, then this is the least of our worries :)

As there is no new VDSO conversion pending in next, I can just queue that (see below) along with #1 and #2 of this series and send it to Linus by end of the week.

Quoted 13 lines
arch/s390/include/asm/vdso/gettimeofday.h new file +8 -0
+	u64 adj, now;
+
+	now = get_tod_clock();
+	adj = vdso->arch.tod_steering_end - now;
+	if (unlikely((s64) adj > 0))
+		now += (vdso->arch.tod_steering_delta < 0) ? (adj >> 15) : -(adj >> 15);
+	return now;
+}

arch/s390/include/asm/vdso/processor.h line 5

Quoted 5 lines
arch/s390/include/asm/vdso/processor.h new file +5 -0
@@ -0,0 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_VDSO_PROCESSOR_H
+#define __ASM_VDSO_PROCESSOR_H
+
+#endif /* __ASM_VDSO_PROCESSOR_H */

The idea of this file was to provide cpu_relax() self contained without pulling in tons of other things from asm/processor.h.

Quoted 9 lines
arch/s390/include/asm/vdso/vdso.h new file +0 -0
new file mode 100644
index 000000000000..e69de29bb2d1
arch/s390/include/asm/vdso/vsyscall.h new file +0 -0
new file mode 100644
index 000000000000..6c67c08cefdd

arch/s390/include/asm/vdso/vsyscall.h line 8

Quoted 8 lines
arch/s390/include/asm/vdso/vsyscall.h new file +8 -0
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_VDSO_VSYSCALL_H
+#define __ASM_VDSO_VSYSCALL_H
+
+#ifndef __ASSEMBLY__
+
+#include <linux/hrtimer.h>
+#include <linux/timekeeper_internal.h>

I know you copied that from x86 or some other architecture, but thinking about the above these two includes are not required for building VDSO itself. Only the kernel update side needs them and they are included already there. I'm going to remove them from x86 as well.

arch/s390/include/asm/vdso/vsyscall.h static void clock_sync_global(unsigned long long delta) · line 399

Quoted 8 lines
arch/s390/include/asm/vdso/vsyscall.h new file +1 -3
@@ -443,9 +396,8 @@ static void clock_sync_global(unsigned long long delta)
 		panic("TOD clock sync offset %lli is too large to drift\n",
 		      tod_steering_delta);
 	tod_steering_end = now + (abs(tod_steering_delta) << 15);
-	vdso_data->ts_dir = (tod_steering_delta < 0) ? 0 : 1;
-	vdso_data->ts_end = tod_steering_end;
-	vdso_data->tb_update_count++;
+	vdso_data->arch.tod_steering_end = tod_steering_end;

Leftover from the previous version. Should be arch_data.tod....

Heiko, do you consider this 5.9 material or am I right to assume that this targets 5.10?

Thanks,

tglx
-----
Subject: vdso/treewide: Add vdso_data pointer argument to __arch_get_hw_counter()
From: Thomas Gleixner <[email protected]>
Date: Tue, 04 Aug 2020 22:17:44 +0200

MIPS already uses and S390 will need the vdso data pointer in __arch_get_hw_counter().

This works nicely as long as the architecture does not support time namespaces in the VDSO. With time namespaces enabled the regular accessor to the vdso data pointer __arch_get_vdso_data() will return the namespace specific VDSO data page for tasks which are part of a non-root time namespace. This would cause the architectures which need the vdso data pointer in __arch_get_hw_counter() to access the wrong vdso data page.

Add a vdso_data pointer argument to __arch_get_hw_counter() and hand it in from the call sites in the core code. For architectures which do not need the data pointer in their counter accessor inline function the compiler will just optimize it out.

Fix up all existing architecture implementations and make MIPS utilize the pointer instead of invoking the accessor function.

No functional change and no change in the resulting object code (except MIPS).

---
 arch/arm/include/asm/vdso/gettimeofday.h          |    3 ++-
 arch/arm64/include/asm/vdso/compat_gettimeofday.h |    3 ++-
 arch/arm64/include/asm/vdso/gettimeofday.h        |    3 ++-
 arch/mips/include/asm/vdso/gettimeofday.h         |    5 +++--
 arch/riscv/include/asm/vdso/gettimeofday.h        |    3 ++-
 arch/x86/include/asm/vdso/gettimeofday.h          |    3 ++-
 lib/vdso/gettimeofday.c                           |    4 ++--
 7 files changed, 15 insertions(+), 9 deletions(-)
arch/arm/include/asm/vdso/gettimeofday.h +2 -1
@@ -112,7 +112,8 @@ static inline bool arm_vdso_hres_capable
 }
 #define __arch_vdso_hres_capable arm_vdso_hres_capable
 
-static __always_inline u64 __arch_get_hw_counter(int clock_mode)
+static __always_inline u64 __arch_get_hw_counter(int clock_mode,
+						 const struct vdso_data *vd)
 {
 #ifdef CONFIG_ARM_ARCH_TIMER
 	u64 cycle_now;
arch/arm64/include/asm/vdso/compat_gettimeofday.h +2 -1
@@ -102,7 +102,8 @@ int clock_getres32_fallback(clockid_t _c
 	return ret;
 }
 
-static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
+static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
+						 const struct vdso_data *vd)
 {
 	u64 res;
 
arch/arm64/include/asm/vdso/gettimeofday.h +2 -1
@@ -63,7 +63,8 @@ int clock_getres_fallback(clockid_t _clk
 	return ret;
 }
 
-static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
+static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
+						 const struct vdso_data *vd)
 {
 	u64 res;
 
arch/mips/include/asm/vdso/gettimeofday.h +3 -2
@@ -167,7 +167,8 @@ static __always_inline u64 read_gic_coun
 
 #endif
 
-static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
+static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
+						 const struct vdso_data *vd)
 {
 #ifdef CONFIG_CSRC_R4K
 	if (clock_mode == VDSO_CLOCKMODE_R4K)
@@ -175,7 +176,7 @@ static __always_inline u64 __arch_get_hw
 #endif
 #ifdef CONFIG_CLKSRC_MIPS_GIC
 	if (clock_mode == VDSO_CLOCKMODE_GIC)
-		return read_gic_count(get_vdso_data());
+		return read_gic_count(vd);
 #endif
 	/*
 	 * Core checks mode already. So this raced against a concurrent
arch/riscv/include/asm/vdso/gettimeofday.h +2 -1
@@ -59,7 +59,8 @@ int clock_getres_fallback(clockid_t _clk
 	return ret;
 }
 
-static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
+static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
+						 const struct vdso_data *vd)
 {
 	/*
 	 * The purpose of csr_read(CSR_TIME) is to trap the system into
arch/x86/include/asm/vdso/gettimeofday.h +2 -1
@@ -241,7 +241,8 @@ static u64 vread_hvclock(void)
 }
 #endif
 
-static inline u64 __arch_get_hw_counter(s32 clock_mode)
+static inline u64 __arch_get_hw_counter(s32 clock_mode,
+					const struct vdso_data *vd)
 {
 	if (likely(clock_mode == VDSO_CLOCKMODE_TSC))
 		return (u64)rdtsc_ordered();
lib/vdso/gettimeofday.c +2 -2
@@ -68,7 +68,7 @@ static int do_hres_timens(const struct v
 		if (unlikely(!vdso_clocksource_ok(vd)))
 			return -1;
 
-		cycles = __arch_get_hw_counter(vd->clock_mode);
+		cycles = __arch_get_hw_counter(vd->clock_mode, vd);
 		if (unlikely(!vdso_cycles_ok(cycles)))
 			return -1;
 		ns = vdso_ts->nsec;
@@ -138,7 +138,7 @@ static __always_inline int do_hres(const
 		if (unlikely(!vdso_clocksource_ok(vd)))
 			return -1;
 
-		cycles = __arch_get_hw_counter(vd->clock_mode);
+		cycles = __arch_get_hw_counter(vd->clock_mode, vd);
 		if (unlikely(!vdso_cycles_ok(cycles)))
 			return -1;
 		ns = vdso_ts->nsec;
author reviewer
#8 lore raw

Hi Thomas,

Quoted 12 lines · Thomas Gleixner

arch/s390/include/asm/vdso/data.h line 6

Quoted 9 lines · Sven Schnelle
arch/s390/include/asm/vdso/data.h new file +6 -0
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __S390_ASM_VDSO_DATA_H
+#define __S390_ASM_VDSO_DATA_H
+
+#include <linux/types.h>
+#include <vdso/datapage.h>

I don't think this header needs vdso/datapage.h

Agreed.

Quoted 22 lines

arch/s390/include/asm/vdso/gettimeofday.h

Quoted 13 lines
arch/s390/include/asm/vdso/data.h new file +6 -0
+struct arch_vdso_data {
+	__u64 tod_steering_delta;
+	__u64 tod_steering_end;
+};
+
+#endif /* __S390_ASM_VDSO_DATA_H */
arch/s390/include/asm/vdso/gettimeofday.h new file +3 -0
 
+static inline u64 __arch_get_hw_counter(s32 clock_mode)
+{
+	const struct vdso_data *vdso = __arch_get_vdso_data();

If you go and implement time namespace support for VDSO then this becomes a problem. See do_hres_timens().

As we did not expect that this function needs vdso_data we should just add a vdso_data pointer argument to __arch_get_hw_counter(). And while looking at it you're not the first one. MIPS already uses it and because it does not support time namespaces so far nobody noticed yet.

Quoted 7 lines

That's fine for all others because the compiler will optimize it out when it's unused. If the compiler fails to do so, then this is the least of our worries :)

As there is no new VDSO conversion pending in next, I can just queue that (see below) along with #1 and #2 of this series and send it to Linus by end of the week.

Fine with me.

Quoted 10 lines
Quoted 8 lines
arch/s390/include/asm/vdso/gettimeofday.h new file +8 -0
+	u64 adj, now;
+
+	now = get_tod_clock();
+	adj = vdso->arch.tod_steering_end - now;
+	if (unlikely((s64) adj > 0))
+		now += (vdso->arch.tod_steering_delta < 0) ? (adj >> 15) : -(adj >> 15);
+	return now;
+}
Quoted 11 lines

arch/s390/include/asm/vdso/processor.h line 5

Quoted 8 lines
arch/s390/include/asm/vdso/processor.h new file +5 -0
@@ -0,0 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_VDSO_PROCESSOR_H
+#define __ASM_VDSO_PROCESSOR_H
+
+#endif /* __ASM_VDSO_PROCESSOR_H */

The idea of this file was to provide cpu_relax() self contained without pulling in tons of other things from asm/processor.h.

Thanks, i'll add that.

Quoted 14 lines
Quoted 14 lines
arch/s390/include/asm/vdso/vdso.h new file +0 -0
new file mode 100644
index 000000000000..e69de29bb2d1
arch/s390/include/asm/vdso/vsyscall.h new file +5 -0
new file mode 100644
index 000000000000..6c67c08cefdd
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_VDSO_VSYSCALL_H
+#define __ASM_VDSO_VSYSCALL_H
+
+#ifndef __ASSEMBLY__
Quoted 8 lines

arch/s390/include/asm/vdso/vsyscall.h line 8

Quoted 3 lines
arch/s390/include/asm/vdso/vsyscall.h new file +3 -0
+
+#include <linux/hrtimer.h>
+#include <linux/timekeeper_internal.h>

I know you copied that from x86 or some other architecture, but thinking about the above these two includes are not required for building VDSO itself. Only the kernel update side needs them and they are included already there. I'm going to remove them from x86 as well.

Thanks, i removed them from my patch.

Quoted 10 lines

arch/s390/include/asm/vdso/vsyscall.h static void clock_sync_global(unsigned long long delta) · line 399

Quoted 8 lines
arch/s390/include/asm/vdso/vsyscall.h new file +1 -3
@@ -443,9 +396,8 @@ static void clock_sync_global(unsigned long long delta)
 		panic("TOD clock sync offset %lli is too large to drift\n",
 		      tod_steering_delta);
 	tod_steering_end = now + (abs(tod_steering_delta) << 15);
-	vdso_data->ts_dir = (tod_steering_delta < 0) ? 0 : 1;
-	vdso_data->ts_end = tod_steering_end;
-	vdso_data->tb_update_count++;
+	vdso_data->arch.tod_steering_end = tod_steering_end;

Leftover from the previous version. Should be arch_data.tod....

Oops, indeed.

Quoted 2 lines

Heiko, do you consider this 5.9 material or am I right to assume that this targets 5.10?

I talked to Heiko yesterday and we agreed that it's to late for 5.9, so we target 5.10.

Thanks,
Sven