Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lib/vdso: Add vdso_data pointer as input to __arch_get_timens_vdso_data()

For the same reason as commit e876f0b69dc9 ("lib/vdso: Allow
architectures to provide the vdso data pointer"), powerpc wants to
avoid calculation of relative position to code.

As the timens_vdso_data is next page to vdso_data, provide
vdso_data pointer to __arch_get_timens_vdso_data() in order
to ease the calculation on powerpc in following patches.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Acked-by: Andrei Vagin <avagin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/539c4204b1baa77c55f758904a1ea239abbc7a5c.1617209142.git.christophe.leroy@csgroup.eu

authored by

Christophe Leroy and committed by
Michael Ellerman
808094fc 58efe9f6

+16 -10
+2 -1
arch/arm64/include/asm/vdso/compat_gettimeofday.h
··· 155 155 } 156 156 157 157 #ifdef CONFIG_TIME_NS 158 - static __always_inline const struct vdso_data *__arch_get_timens_vdso_data(void) 158 + static __always_inline 159 + const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd) 159 160 { 160 161 const struct vdso_data *ret; 161 162
+1 -1
arch/arm64/include/asm/vdso/gettimeofday.h
··· 100 100 101 101 #ifdef CONFIG_TIME_NS 102 102 static __always_inline 103 - const struct vdso_data *__arch_get_timens_vdso_data(void) 103 + const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd) 104 104 { 105 105 return _timens_data; 106 106 }
+2 -1
arch/s390/include/asm/vdso/gettimeofday.h
··· 68 68 } 69 69 70 70 #ifdef CONFIG_TIME_NS 71 - static __always_inline const struct vdso_data *__arch_get_timens_vdso_data(void) 71 + static __always_inline 72 + const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd) 72 73 { 73 74 return _timens_data; 74 75 }
+2 -1
arch/x86/include/asm/vdso/gettimeofday.h
··· 58 58 #endif 59 59 60 60 #ifdef CONFIG_TIME_NS 61 - static __always_inline const struct vdso_data *__arch_get_timens_vdso_data(void) 61 + static __always_inline 62 + const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd) 62 63 { 63 64 return __timens_vdso_data; 64 65 }
+9 -6
lib/vdso/gettimeofday.c
··· 49 49 static __always_inline int do_hres_timens(const struct vdso_data *vdns, clockid_t clk, 50 50 struct __kernel_timespec *ts) 51 51 { 52 - const struct vdso_data *vd = __arch_get_timens_vdso_data(); 52 + const struct vdso_data *vd; 53 53 const struct timens_offset *offs = &vdns->offset[clk]; 54 54 const struct vdso_timestamp *vdso_ts; 55 55 u64 cycles, last, ns; 56 56 u32 seq; 57 57 s64 sec; 58 58 59 + vd = vdns - (clk == CLOCK_MONOTONIC_RAW ? CS_RAW : CS_HRES_COARSE); 60 + vd = __arch_get_timens_vdso_data(vd); 59 61 if (clk != CLOCK_MONOTONIC_RAW) 60 62 vd = &vd[CS_HRES_COARSE]; 61 63 else ··· 94 92 return 0; 95 93 } 96 94 #else 97 - static __always_inline const struct vdso_data *__arch_get_timens_vdso_data(void) 95 + static __always_inline 96 + const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd) 98 97 { 99 98 return NULL; 100 99 } ··· 165 162 static __always_inline int do_coarse_timens(const struct vdso_data *vdns, clockid_t clk, 166 163 struct __kernel_timespec *ts) 167 164 { 168 - const struct vdso_data *vd = __arch_get_timens_vdso_data(); 165 + const struct vdso_data *vd = __arch_get_timens_vdso_data(vdns); 169 166 const struct vdso_timestamp *vdso_ts = &vd->basetime[clk]; 170 167 const struct timens_offset *offs = &vdns->offset[clk]; 171 168 u64 nsec; ··· 313 310 if (unlikely(tz != NULL)) { 314 311 if (IS_ENABLED(CONFIG_TIME_NS) && 315 312 vd->clock_mode == VDSO_CLOCKMODE_TIMENS) 316 - vd = __arch_get_timens_vdso_data(); 313 + vd = __arch_get_timens_vdso_data(vd); 317 314 318 315 tz->tz_minuteswest = vd[CS_HRES_COARSE].tz_minuteswest; 319 316 tz->tz_dsttime = vd[CS_HRES_COARSE].tz_dsttime; ··· 336 333 337 334 if (IS_ENABLED(CONFIG_TIME_NS) && 338 335 vd->clock_mode == VDSO_CLOCKMODE_TIMENS) 339 - vd = __arch_get_timens_vdso_data(); 336 + vd = __arch_get_timens_vdso_data(vd); 340 337 341 338 t = READ_ONCE(vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec); 342 339 ··· 366 363 367 364 if (IS_ENABLED(CONFIG_TIME_NS) && 368 365 vd->clock_mode == VDSO_CLOCKMODE_TIMENS) 369 - vd = __arch_get_timens_vdso_data(); 366 + vd = __arch_get_timens_vdso_data(vd); 370 367 371 368 /* 372 369 * Convert the clockid to a bitmask and use it to check which