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

Configure Feed

Select the types of activity you want to include in your feed.

y2038: vdso: powerpc: avoid timespec references

As a preparation to stop using 'struct timespec' in the kernel,
change the powerpc vdso implementation:

- split up the vdso data definition to have equivalent members
for seconds and nanoseconds instead of an xtime structure

- use timespec64 as an intermediate for the xtime update

- change the asm-offsets definition to be based the appropriate
fixed-length types

This is only a temporary fix for changing the types, in order
to actually support a 64-bit safe vdso32 version of clock_gettime(),
the entire powerpc vdso should be replaced with the generic
lib/vdso/ implementation. If that happens first, this patch
becomes obsolete.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+18 -21
+4 -2
arch/powerpc/include/asm/vdso_datapage.h
··· 81 81 __u32 stamp_sec_fraction; /* fractional seconds of stamp_xtime */ 82 82 __s32 wtom_clock_nsec; /* Wall to monotonic clock nsec */ 83 83 __s64 wtom_clock_sec; /* Wall to monotonic clock sec */ 84 - struct timespec stamp_xtime; /* xtime as at tb_orig_stamp */ 84 + __s64 stamp_xtime_sec; /* xtime secs as at tb_orig_stamp */ 85 + __s64 stamp_xtime_nsec; /* xtime nsecs as at tb_orig_stamp */ 85 86 __u32 syscall_map_64[SYSCALL_MAP_SIZE]; /* map of syscalls */ 86 87 __u32 syscall_map_32[SYSCALL_MAP_SIZE]; /* map of syscalls */ 87 88 }; ··· 102 101 __u32 tz_dsttime; /* Type of dst correction 0x5C */ 103 102 __s32 wtom_clock_sec; /* Wall to monotonic clock */ 104 103 __s32 wtom_clock_nsec; 105 - struct timespec stamp_xtime; /* xtime as at tb_orig_stamp */ 104 + __s32 stamp_xtime_sec; /* xtime seconds as at tb_orig_stamp */ 105 + __s32 stamp_xtime_nsec; /* xtime nsecs as at tb_orig_stamp */ 106 106 __u32 stamp_sec_fraction; /* fractional seconds of stamp_xtime */ 107 107 __u32 syscall_map_32[SYSCALL_MAP_SIZE]; /* map of syscalls */ 108 108 __u32 dcache_block_size; /* L1 d-cache block size */
+5 -9
arch/powerpc/kernel/asm-offsets.c
··· 385 385 OFFSET(CFG_SYSCALL_MAP32, vdso_data, syscall_map_32); 386 386 OFFSET(WTOM_CLOCK_SEC, vdso_data, wtom_clock_sec); 387 387 OFFSET(WTOM_CLOCK_NSEC, vdso_data, wtom_clock_nsec); 388 - OFFSET(STAMP_XTIME, vdso_data, stamp_xtime); 388 + OFFSET(STAMP_XTIME_SEC, vdso_data, stamp_xtime_sec); 389 + OFFSET(STAMP_XTIME_NSEC, vdso_data, stamp_xtime_nsec); 389 390 OFFSET(STAMP_SEC_FRAC, vdso_data, stamp_sec_fraction); 390 391 OFFSET(CFG_ICACHE_BLOCKSZ, vdso_data, icache_block_size); 391 392 OFFSET(CFG_DCACHE_BLOCKSZ, vdso_data, dcache_block_size); ··· 396 395 OFFSET(CFG_SYSCALL_MAP64, vdso_data, syscall_map_64); 397 396 OFFSET(TVAL64_TV_SEC, __kernel_old_timeval, tv_sec); 398 397 OFFSET(TVAL64_TV_USEC, __kernel_old_timeval, tv_usec); 398 + #endif 399 + OFFSET(TSPC64_TV_SEC, __kernel_timespec, tv_sec); 400 + OFFSET(TSPC64_TV_NSEC, __kernel_timespec, tv_nsec); 399 401 OFFSET(TVAL32_TV_SEC, old_timeval32, tv_sec); 400 402 OFFSET(TVAL32_TV_USEC, old_timeval32, tv_usec); 401 - OFFSET(TSPC64_TV_SEC, timespec, tv_sec); 402 - OFFSET(TSPC64_TV_NSEC, timespec, tv_nsec); 403 403 OFFSET(TSPC32_TV_SEC, old_timespec32, tv_sec); 404 404 OFFSET(TSPC32_TV_NSEC, old_timespec32, tv_nsec); 405 - #else 406 - OFFSET(TVAL32_TV_SEC, __kernel_old_timeval, tv_sec); 407 - OFFSET(TVAL32_TV_USEC, __kernel_old_timeval, tv_usec); 408 - OFFSET(TSPC32_TV_SEC, timespec, tv_sec); 409 - OFFSET(TSPC32_TV_NSEC, timespec, tv_nsec); 410 - #endif 411 405 /* timeval/timezone offsets for use by vdso */ 412 406 OFFSET(TZONE_TZ_MINWEST, timezone, tz_minuteswest); 413 407 OFFSET(TZONE_TZ_DSTTIME, timezone, tz_dsttime);
+3 -2
arch/powerpc/kernel/time.c
··· 885 885 886 886 void update_vsyscall(struct timekeeper *tk) 887 887 { 888 - struct timespec xt; 888 + struct timespec64 xt; 889 889 struct clocksource *clock = tk->tkr_mono.clock; 890 890 u32 mult = tk->tkr_mono.mult; 891 891 u32 shift = tk->tkr_mono.shift; ··· 957 957 vdso_data->tb_to_xs = new_tb_to_xs; 958 958 vdso_data->wtom_clock_sec = tk->wall_to_monotonic.tv_sec; 959 959 vdso_data->wtom_clock_nsec = tk->wall_to_monotonic.tv_nsec; 960 - vdso_data->stamp_xtime = xt; 960 + vdso_data->stamp_xtime_sec = xt.tv_sec; 961 + vdso_data->stamp_xtime_nsec = xt.tv_nsec; 961 962 vdso_data->stamp_sec_fraction = frac_sec; 962 963 smp_wmb(); 963 964 ++(vdso_data->tb_update_count);
+2 -4
arch/powerpc/kernel/vdso32/gettimeofday.S
··· 15 15 /* Offset for the low 32-bit part of a field of long type */ 16 16 #ifdef CONFIG_PPC64 17 17 #define LOPART 4 18 - #define TSPEC_TV_SEC TSPC64_TV_SEC+LOPART 19 18 #else 20 19 #define LOPART 0 21 - #define TSPEC_TV_SEC TSPC32_TV_SEC 22 20 #endif 23 21 24 22 .text ··· 190 192 bl __get_datapage@local 191 193 mr r9, r3 /* datapage ptr in r9 */ 192 194 193 - lwz r3,STAMP_XTIME+TSPEC_TV_SEC(r9) 195 + lwz r3,STAMP_XTIME_SEC+LOWPART(r9) 194 196 195 197 cmplwi r11,0 /* check if t is NULL */ 196 198 beq 2f ··· 266 268 * as a 32.32 fixed-point number in r3 and r4. 267 269 * Load & add the xtime stamp. 268 270 */ 269 - lwz r5,STAMP_XTIME+TSPEC_TV_SEC(r9) 271 + lwz r5,STAMP_XTIME_SEC+LOWPART(r9) 270 272 lwz r6,STAMP_SEC_FRAC(r9) 271 273 addc r4,r4,r6 272 274 adde r3,r3,r5
+4 -4
arch/powerpc/kernel/vdso64/gettimeofday.S
··· 116 116 * CLOCK_REALTIME_COARSE, below values are needed for MONOTONIC_COARSE 117 117 * too 118 118 */ 119 - ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3) 120 - ld r5,STAMP_XTIME+TSPC64_TV_NSEC(r3) 119 + ld r4,STAMP_XTIME_SEC(r3) 120 + ld r5,STAMP_XTIME_NSEC(r3) 121 121 bne cr6,75f 122 122 123 123 /* CLOCK_MONOTONIC_COARSE */ ··· 220 220 mr r11,r3 /* r11 holds t */ 221 221 bl V_LOCAL_FUNC(__get_datapage) 222 222 223 - ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3) 223 + ld r4,STAMP_XTIME_SEC(r3) 224 224 225 225 cmpldi r11,0 /* check if t is NULL */ 226 226 beq 2f ··· 265 265 mulhdu r6,r6,r5 /* in units of 2^-32 seconds */ 266 266 267 267 /* Add stamp since epoch */ 268 - ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3) 268 + ld r4,STAMP_XTIME_SEC(r3) 269 269 lwz r5,STAMP_SEC_FRAC(r3) 270 270 or r0,r4,r5 271 271 or r0,r0,r6