powerpc: switch VDSO to C implementation.
Subsystems (3)
v5 cover powerpc: switch VDSO to C implementation.
This is a fifth version of a series to switch powerpc VDSO to generic C implementation. All previous where RFCs. This one has reached a mature status.
It is tested on PPC32 (mpc885 and mpc8321E). It is build tested on kisskb
(http://kisskb.ellerman.id.au/kisskb/head/abf15916bd65f808b07fe9a2377db965a37071e4/)
In PPC64 mode it now builds both VDSO64 and VDSO32.
The two first patches are optimisation around the way vdso datapage is handled. They are worth merging now even if we want to wait a little more for the entire series.
The next three patches are optimisations to the GENERIC C VDSO code. Without them, the performance of the VDSO time functions are too degraded compared to the current ASM version to be worth switching the C VDSO.
This series applies on today's powerpc/merge branch.
See the last patch for details on changes and performance.
Christophe Leroy (6):
powerpc/vdso64: Switch from __get_datapage() to get_datapage inline
macro
powerpc/vdso: Remove __kernel_datapage_offset and simplify
__get_datapage()
lib/vdso: Allow architectures to provide the vdso data pointer lib/vdso: Allow fixed clock mode
lib/vdso: Allow architectures to override the ns shift operation powerpc/vdso: Switch VDSO to generic C implementation.
arch/powerpc/Kconfig | 2 + arch/powerpc/include/asm/vdso/gettimeofday.h | 158 ++++++++++ arch/powerpc/include/asm/vdso/vsyscall.h | 25 ++ arch/powerpc/include/asm/vdso_datapage.h | 51 ++-- arch/powerpc/kernel/asm-offsets.c | 49 +--- arch/powerpc/kernel/time.c | 90 ------ arch/powerpc/kernel/vdso.c | 58 +--- arch/powerpc/kernel/vdso32/Makefile | 32 +- arch/powerpc/kernel/vdso32/cacheflush.S | 2 +- arch/powerpc/kernel/vdso32/config-fake32.h | 34 +++ arch/powerpc/kernel/vdso32/datapage.S | 7 +- arch/powerpc/kernel/vdso32/gettimeofday.S | 291 +------------------ arch/powerpc/kernel/vdso32/vdso32.lds.S | 7 +- arch/powerpc/kernel/vdso32/vgettimeofday.c | 29 ++ arch/powerpc/kernel/vdso64/Makefile | 23 +- arch/powerpc/kernel/vdso64/cacheflush.S | 9 +- arch/powerpc/kernel/vdso64/datapage.S | 31 +- arch/powerpc/kernel/vdso64/gettimeofday.S | 243 +--------------- arch/powerpc/kernel/vdso64/vdso64.lds.S | 7 +- arch/powerpc/kernel/vdso64/vgettimeofday.c | 29 ++ lib/vdso/gettimeofday.c | 98 +++++-- 21 files changed, 467 insertions(+), 808 deletions(-) create mode 100644 arch/powerpc/include/asm/vdso/gettimeofday.h create mode 100644 arch/powerpc/include/asm/vdso/vsyscall.h create mode 100644 arch/powerpc/kernel/vdso32/config-fake32.h create mode 100644 arch/powerpc/kernel/vdso32/vgettimeofday.c create mode 100644 arch/powerpc/kernel/vdso64/vgettimeofday.c
Signature · 1 line
2.25.0
PATCH v5 1/6 powerpc/vdso64: Switch from __get_datapage() to get_datapage inline macro
On the same way as already done on PPC32, drop __get_datapage() function and use get_datapage inline macro instead.
See commit ec0895f08f99 ("powerpc/vdso32: inline __get_datapage()")
--- arch/powerpc/kernel/vdso64/cacheflush.S | 9 ++++---- arch/powerpc/kernel/vdso64/datapage.S | 28 +++-------------------- arch/powerpc/kernel/vdso64/gettimeofday.S | 8 +++---- 3 files changed, 11 insertions(+), 34 deletions(-)
arch/powerpc/kernel/vdso64/cacheflush.S +4 -5
@@ -8,6 +8,7 @@ #include <asm/processor.h> #include <asm/ppc_asm.h> #include <asm/vdso.h> +#include <asm/vdso_datapage.h> #include <asm/asm-offsets.h> .text
@@ -24,14 +25,12 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache) .cfi_startproc mflr r12 .cfi_register lr,r12 - mr r11,r3 - bl V_LOCAL_FUNC(__get_datapage) + get_datapage r10, r0 mtlr r12 - mr r10,r3 lwz r7,CFG_DCACHE_BLOCKSZ(r10) addi r5,r7,-1 - andc r6,r11,r5 /* round low to line bdy */ + andc r6,r3,r5 /* round low to line bdy */ subf r8,r6,r4 /* compute length */ add r8,r8,r5 /* ensure we get enough */ lwz r9,CFG_DCACHE_LOGBLOCKSZ(r10)
@@ -48,7 +47,7 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache) lwz r7,CFG_ICACHE_BLOCKSZ(r10) addi r5,r7,-1 - andc r6,r11,r5 /* round low to line bdy */ + andc r6,r3,r5 /* round low to line bdy */ subf r8,r6,r4 /* compute length */ add r8,r8,r5 lwz r9,CFG_ICACHE_LOGBLOCKSZ(r10)
arch/powerpc/kernel/vdso64/datapage.S +3 -25
@@ -10,35 +10,13 @@ #include <asm/asm-offsets.h> #include <asm/unistd.h> #include <asm/vdso.h> +#include <asm/vdso_datapage.h> .text .global __kernel_datapage_offset; __kernel_datapage_offset: .long 0 -V_FUNCTION_BEGIN(__get_datapage) - .cfi_startproc - /* We don't want that exposed or overridable as we want other objects - * to be able to bl directly to here - */ - .protected __get_datapage - .hidden __get_datapage - - mflr r0 - .cfi_register lr,r0 - - bcl 20,31,data_page_branch -data_page_branch: - mflr r3 - mtlr r0 - addi r3, r3, __kernel_datapage_offset-data_page_branch - lwz r0,0(r3) - .cfi_restore lr - add r3,r0,r3 - blr - .cfi_endproc -V_FUNCTION_END(__get_datapage) - /* * void *__kernel_get_syscall_map(unsigned int *syscall_count) ; *
@@ -53,7 +31,7 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map) mflr r12 .cfi_register lr,r12 mr r4,r3 - bl V_LOCAL_FUNC(__get_datapage) + get_datapage r3, r0 mtlr r12 addi r3,r3,CFG_SYSCALL_MAP64 cmpldi cr0,r4,0
@@ -75,7 +53,7 @@ V_FUNCTION_BEGIN(__kernel_get_tbfreq) .cfi_startproc mflr r12 .cfi_register lr,r12 - bl V_LOCAL_FUNC(__get_datapage) + get_datapage r3, r0 ld r3,CFG_TB_TICKS_PER_SEC(r3) mtlr r12 crclr cr0*4+so
arch/powerpc/kernel/vdso64/gettimeofday.S +4 -4
@@ -26,7 +26,7 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday) mr r11,r3 /* r11 holds tv */ mr r10,r4 /* r10 holds tz */ - bl V_LOCAL_FUNC(__get_datapage) /* get data page */ + get_datapage r3, r0 cmpldi r11,0 /* check if tv is NULL */ beq 2f lis r7,1000000@ha /* load up USEC_PER_SEC */
@@ -71,7 +71,7 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime) mflr r12 /* r12 saves lr */ .cfi_register lr,r12 mr r11,r4 /* r11 saves tp */ - bl V_LOCAL_FUNC(__get_datapage) /* get data page */ + get_datapage r3, r0 lis r7,NSEC_PER_SEC@h /* want nanoseconds */ ori r7,r7,NSEC_PER_SEC@l beq cr5,70f
@@ -188,7 +188,7 @@ V_FUNCTION_BEGIN(__kernel_clock_getres) mflr r12 .cfi_register lr,r12 - bl V_LOCAL_FUNC(__get_datapage) + get_datapage r3, r0 lwz r5, CLOCK_HRTIMER_RES(r3) mtlr r12 li r3,0
@@ -221,7 +221,7 @@ V_FUNCTION_BEGIN(__kernel_time) .cfi_register lr,r12 mr r11,r3 /* r11 holds t */ - bl V_LOCAL_FUNC(__get_datapage) + get_datapage r3, r0 ld r4,STAMP_XTIME_SEC(r3)
Signature · 1 line
2.25.0
PATCH v5 2/6 powerpc/vdso: Remove __kernel_datapage_offset and simplify __get_datapage()
In reply to Christophe LeroyThe VDSO datapage and the text pages are always located immediately next to each other, so it can be hardcoded without an indirection through __kernel_datapage_offset
In order to ease things, move the data page in front like other arches, that way there is no need to know the size of the library to locate the data page.
Before:
clock-getres-realtime-coarse: vdso: 714 nsec/call clock-gettime-realtime-coarse: vdso: 792 nsec/call clock-gettime-realtime: vdso: 1243 nsec/call
After:
clock-getres-realtime-coarse: vdso: 699 nsec/call clock-gettime-realtime-coarse: vdso: 784 nsec/call clock-gettime-realtime: vdso: 1231 nsec/call
In the mean time, allow users to pass a constant offset to get_datapage macro. That offset will be integrated to the calculation to directly get the address of the given object inside the VDSO datapage. This avoids having to perform a subsequent addition.
--- arch/powerpc/include/asm/vdso_datapage.h | 11 ++--- arch/powerpc/kernel/vdso.c | 53 +++-------------------- arch/powerpc/kernel/vdso32/cacheflush.S | 2 +- arch/powerpc/kernel/vdso32/datapage.S | 7 +-- arch/powerpc/kernel/vdso32/gettimeofday.S | 8 ++-- arch/powerpc/kernel/vdso32/vdso32.lds.S | 7 +-- arch/powerpc/kernel/vdso64/cacheflush.S | 2 +- arch/powerpc/kernel/vdso64/datapage.S | 7 +-- arch/powerpc/kernel/vdso64/gettimeofday.S | 8 ++-- arch/powerpc/kernel/vdso64/vdso64.lds.S | 7 +-- 10 files changed, 31 insertions(+), 81 deletions(-)
arch/powerpc/include/asm/vdso_datapage.h +6 -5
@@ -116,12 +116,13 @@ extern struct vdso_data *vdso_data; #else /* __ASSEMBLY__ */ -.macro get_datapage ptr, tmp +.macro get_datapage ptr, offset=0 bcl 20, 31, .+4 - mflr \ptr - addi \ptr, \ptr, (__kernel_datapage_offset - (.-4))@l - lwz \tmp, 0(\ptr) - add \ptr, \tmp, \ptr +999: mflr \ptr +#if CONFIG_PPC_PAGE_SHIFT > 14 + addis \ptr, \ptr, (_vdso_datapage + \offset - 999b)@ha +#endif + addi \ptr, \ptr, (_vdso_datapage + \offset - 999b)@l .endm #endif /* __ASSEMBLY__ */
arch/powerpc/kernel/vdso.c +7 -46
91 lines not on this page · raw message
arch/powerpc/kernel/vdso32/cacheflush.S +1 -1
@@ -27,7 +27,7 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache) #ifdef CONFIG_PPC64 mflr r12 .cfi_register lr,r12 - get_datapage r10, r0 + get_datapage r10 mtlr r12 #endif
arch/powerpc/kernel/vdso32/datapage.S +2 -5
@@ -13,9 +13,6 @@ #include <asm/vdso_datapage.h> .text - .global __kernel_datapage_offset; -__kernel_datapage_offset: - .long 0 /* * void *__kernel_get_syscall_map(unsigned int *syscall_count) ;
@@ -31,7 +28,7 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map) mflr r12 .cfi_register lr,r12 mr. r4,r3 - get_datapage r3, r0 + get_datapage r3 mtlr r12 addi r3,r3,CFG_SYSCALL_MAP32 beqlr
@@ -52,7 +49,7 @@ V_FUNCTION_BEGIN(__kernel_get_tbfreq) .cfi_startproc mflr r12 .cfi_register lr,r12 - get_datapage r3, r0 + get_datapage r3 lwz r4,(CFG_TB_TICKS_PER_SEC + 4)(r3) lwz r3,CFG_TB_TICKS_PER_SEC(r3) mtlr r12
arch/powerpc/kernel/vdso32/gettimeofday.S +4 -4
@@ -34,7 +34,7 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday) mr. r10,r3 /* r10 saves tv */ mr r11,r4 /* r11 saves tz */ - get_datapage r9, r0 + get_datapage r9 beq 3f LOAD_REG_IMMEDIATE(r7, 1000000) /* load up USEC_PER_SEC */ bl __do_get_tspec@local /* get sec/usec from tb & kernel */
@@ -79,7 +79,7 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime) mflr r12 /* r12 saves lr */ .cfi_register lr,r12 mr r11,r4 /* r11 saves tp */ - get_datapage r9, r0 + get_datapage r9 LOAD_REG_IMMEDIATE(r7, NSEC_PER_SEC) /* load up NSEC_PER_SEC */ beq cr5, .Lcoarse_clocks .Lprecise_clocks:
@@ -206,7 +206,7 @@ V_FUNCTION_BEGIN(__kernel_clock_getres) mflr r12 .cfi_register lr,r12 - get_datapage r3, r0 + get_datapage r3 lwz r5, CLOCK_HRTIMER_RES(r3) mtlr r12 1: li r3,0
@@ -240,7 +240,7 @@ V_FUNCTION_BEGIN(__kernel_time) .cfi_register lr,r12 mr r11,r3 /* r11 holds t */ - get_datapage r9, r0 + get_datapage r9 lwz r3,STAMP_XTIME_SEC+LOPART(r9)
arch/powerpc/kernel/vdso32/vdso32.lds.S +2 -5
@@ -4,6 +4,7 @@ * library */ #include <asm/vdso.h> +#include <asm/page.h> #ifdef __LITTLE_ENDIAN__ OUTPUT_FORMAT("elf32-powerpcle", "elf32-powerpcle", "elf32-powerpcle")
@@ -15,6 +16,7 @@ ENTRY(_start) SECTIONS { + PROVIDE(_vdso_datapage = . - PAGE_SIZE); . = VDSO32_LBASE + SIZEOF_HEADERS; .hash : { *(.hash) } :text
@@ -138,11 +140,6 @@ VERSION { VDSO_VERSION_STRING { global: - /* - * Has to be there for the kernel to find - */ - __kernel_datapage_offset; - __kernel_get_syscall_map; #ifndef CONFIG_PPC_BOOK3S_601 __kernel_gettimeofday;
arch/powerpc/kernel/vdso64/cacheflush.S +1 -1
@@ -25,7 +25,7 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache) .cfi_startproc mflr r12 .cfi_register lr,r12 - get_datapage r10, r0 + get_datapage r10 mtlr r12 lwz r7,CFG_DCACHE_BLOCKSZ(r10)
arch/powerpc/kernel/vdso64/datapage.S +2 -5
@@ -13,9 +13,6 @@ #include <asm/vdso_datapage.h> .text -.global __kernel_datapage_offset; -__kernel_datapage_offset: - .long 0 /* * void *__kernel_get_syscall_map(unsigned int *syscall_count) ;
@@ -31,7 +28,7 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map) mflr r12 .cfi_register lr,r12 mr r4,r3 - get_datapage r3, r0 + get_datapage r3 mtlr r12 addi r3,r3,CFG_SYSCALL_MAP64 cmpldi cr0,r4,0
@@ -53,7 +50,7 @@ V_FUNCTION_BEGIN(__kernel_get_tbfreq) .cfi_startproc mflr r12 .cfi_register lr,r12 - get_datapage r3, r0 + get_datapage r3 ld r3,CFG_TB_TICKS_PER_SEC(r3) mtlr r12 crclr cr0*4+so
arch/powerpc/kernel/vdso64/gettimeofday.S +4 -4
@@ -26,7 +26,7 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday) mr r11,r3 /* r11 holds tv */ mr r10,r4 /* r10 holds tz */ - get_datapage r3, r0 + get_datapage r3 cmpldi r11,0 /* check if tv is NULL */ beq 2f lis r7,1000000@ha /* load up USEC_PER_SEC */
@@ -71,7 +71,7 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime) mflr r12 /* r12 saves lr */ .cfi_register lr,r12 mr r11,r4 /* r11 saves tp */ - get_datapage r3, r0 + get_datapage r3 lis r7,NSEC_PER_SEC@h /* want nanoseconds */ ori r7,r7,NSEC_PER_SEC@l beq cr5,70f
@@ -188,7 +188,7 @@ V_FUNCTION_BEGIN(__kernel_clock_getres) mflr r12 .cfi_register lr,r12 - get_datapage r3, r0 + get_datapage r3 lwz r5, CLOCK_HRTIMER_RES(r3) mtlr r12 li r3,0
@@ -221,7 +221,7 @@ V_FUNCTION_BEGIN(__kernel_time) .cfi_register lr,r12 mr r11,r3 /* r11 holds t */ - get_datapage r3, r0 + get_datapage r3 ld r4,STAMP_XTIME_SEC(r3)
arch/powerpc/kernel/vdso64/vdso64.lds.S +2 -5
@@ -4,6 +4,7 @@ * library */ #include <asm/vdso.h> +#include <asm/page.h> #ifdef __LITTLE_ENDIAN__ OUTPUT_FORMAT("elf64-powerpcle", "elf64-powerpcle", "elf64-powerpcle")
@@ -15,6 +16,7 @@ ENTRY(_start) SECTIONS { + PROVIDE(_vdso_datapage = . - PAGE_SIZE); . = VDSO64_LBASE + SIZEOF_HEADERS; .hash : { *(.hash) } :text
@@ -138,11 +140,6 @@ VERSION { VDSO_VERSION_STRING { global: - /* - * Has to be there for the kernel to find - */ - __kernel_datapage_offset; - __kernel_get_syscall_map; __kernel_gettimeofday; __kernel_clock_gettime;
Signature · 1 line
2.25.0
PATCH v5 3/6 lib/vdso: Allow architectures to provide the vdso data pointer
In reply to Christophe LeroyOn powerpc, __arch_get_vdso_data() clobbers the link register, requiring the caller to save it.
As the parent function already has to set a stack frame and saves the link register before calling the C vdso function, retriving the vdso data pointer there is lighter.
Give architectures the opportunity to hand the vdso data pointer to C vdso functions.
--- lib/vdso/gettimeofday.c | 83 +++++++++++++++++++++++++++++++++-------- 1 file changed, 67 insertions(+), 16 deletions(-)
lib/vdso/gettimeofday.c +67 -16
@@ -206,9 +206,9 @@ static __always_inline int do_coarse(const struct vdso_data *vd, clockid_t clk, }static __maybe_unused int -__cvdso_clock_gettime_common (clockid_t clock,struct __kernel_timespec *ts) +__cvdso_clock_gettime_common (const struct vdso_data *vd,clockid_t clock, +struct __kernel_timespec *ts) { -const struct vdso_data *vd =__arch_get_vdso_data ();u32 msk;/* Check for negative values or invalid clocks */
@@ -233,23 +233,33 @@ __cvdso_clock_gettime_common(clockid_t clock, struct __kernel_timespec *ts) }static __maybe_unused int -__cvdso_clock_gettime (clockid_t clock,struct __kernel_timespec *ts) +__cvdso_clock_gettime_data (const struct vdso_data *vd,clockid_t clock, +struct __kernel_timespec *ts) { -int ret =__cvdso_clock_gettime_common (clock, ts); +int ret =__cvdso_clock_gettime_common (vd, clock, ts);if (unlikely (ret))return clock_gettime_fallback (clock, ts);return 0 ; } +static __maybe_unused int +__cvdso_clock_gettime (clockid_t clock,struct __kernel_timespec *ts) +{ +const struct vdso_data *vd =__arch_get_vdso_data (); + +return __cvdso_clock_gettime_data (vd, clock, ts); +} +#ifdef BUILD_VDSO32 static __maybe_unused int -__cvdso_clock_gettime32 (clockid_t clock,struct old_timespec32 *res) +__cvdso_clock_gettime32_data (const struct vdso_data *vd,clockid_t clock, +struct old_timespec32 *res) {struct __kernel_timespec ts;int ret; - ret =__cvdso_clock_gettime_common (clock, &ts); + ret =__cvdso_clock_gettime_common (vd, clock, &ts);if (unlikely (ret))return clock_gettime32_fallback (clock, res);
@@ -260,13 +270,21 @@ __cvdso_clock_gettime32(clockid_t clock, struct old_timespec32 *res) return ret; } -#endif /* BUILD_VDSO32 */ static __maybe_unused int -__cvdso_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz) +__cvdso_clock_gettime32 (clockid_t clock,struct old_timespec32 *res) {const struct vdso_data *vd =__arch_get_vdso_data (); +return __cvdso_clock_gettime32_data (vd, clock, res); +} +#endif /* BUILD_VDSO32 */ + +static __maybe_unused int +__cvdso_gettimeofday_data (const struct vdso_data *vd, +struct __kernel_old_timeval *tv,struct timezone *tz) +{ +if (likely (tv !=NULL )) {struct __kernel_timespec ts;
@@ -289,10 +307,18 @@ __cvdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)return 0 ; } -#ifdef VDSO_HAS_TIME -static __maybe_unused __kernel_old_time_t __cvdso_time (__kernel_old_time_t *time) +static __maybe_unused int +__cvdso_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz) {const struct vdso_data *vd =__arch_get_vdso_data (); + +return __cvdso_gettimeofday_data (vd, tv, tz); +} + +#ifdef VDSO_HAS_TIME +static __maybe_unused __kernel_old_time_t +__cvdso_time_data (const struct vdso_data *vd,__kernel_old_time_t *time) +{__kernel_old_time_t t;if (IS_ENABLED (CONFIG_TIME_NS ) && vd->clock_mode ==VCLOCK_TIMENS )
@@ -305,13 +331,20 @@ static __maybe_unused __kernel_old_time_t __cvdso_time(__kernel_old_time_t *timereturn t; } + +static __maybe_unused __kernel_old_time_t __cvdso_time (__kernel_old_time_t *time) +{ +const struct vdso_data *vd =__arch_get_vdso_data (); + +return __cvdso_time_data (vd, time); +}#endif /* VDSO_HAS_TIME */ #ifdef VDSO_HAS_CLOCK_GETRES static __maybe_unused -int __cvdso_clock_getres_common (clockid_t clock,struct __kernel_timespec *res) +int __cvdso_clock_getres_common (const struct vdso_data *vd,clockid_t clock, +struct __kernel_timespec *res) { -const struct vdso_data *vd =__arch_get_vdso_data ();u32 msk;u64 ns;
@@ -349,23 +382,33 @@ int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res) }static __maybe_unused -int __cvdso_clock_getres (clockid_t clock,struct __kernel_timespec *res) +int __cvdso_clock_getres_data (const struct vdso_data *vd,clockid_t clock, +struct __kernel_timespec *res) { -int ret =__cvdso_clock_getres_common (clock, res); +int ret =__cvdso_clock_getres_common (vd, clock, res);if (unlikely (ret))return clock_getres_fallback (clock, res);return 0 ; } +static __maybe_unused +int __cvdso_clock_getres (clockid_t clock,struct __kernel_timespec *res) +{ +const struct vdso_data *vd =__arch_get_vdso_data (); + +return __cvdso_clock_getres_data (vd, clock, res); +} +#ifdef BUILD_VDSO32 static __maybe_unused int -__cvdso_clock_getres_time32 (clockid_t clock,struct old_timespec32 *res) +__cvdso_clock_getres_time32_data (const struct vdso_data *vd,clockid_t clock, +struct old_timespec32 *res) {struct __kernel_timespec ts;int ret; - ret =__cvdso_clock_getres_common (clock, &ts); + ret =__cvdso_clock_getres_common (vd, clock, &ts);if (unlikely (ret))return clock_getres32_fallback (clock, res);
@@ -376,5 +419,13 @@ __cvdso_clock_getres_time32(clockid_t clock, struct old_timespec32 *res) }return ret; } + +static __maybe_unused int +__cvdso_clock_getres_time32 (clockid_t clock,struct old_timespec32 *res) +{ +const struct vdso_data *vd =__arch_get_vdso_data (); + +return __cvdso_clock_getres_time32_data (vd, clock, res); +}#endif /* BUILD_VDSO32 */ #endif /* VDSO_HAS_CLOCK_GETRES */
Signature · 1 line
2.25.0
PATCH v5 4/6 lib/vdso: Allow fixed clock mode
In reply to Christophe LeroySome architectures have a fixed clocksource which is known at compile time and cannot be replaced or disabled at runtime, e.g. timebase on PowerPC. For such cases the clock mode check in the VDSO code is pointless.
Therefore, give architectures the opportunity to redefine the way clock_mode is checked by moving the check into an __arch_vdso_capable() macro.
--- lib/vdso/gettimeofday.c | 6 ++++++ 1 file changed, 6 insertions(+)
lib/vdso/gettimeofday.c +6 -0
@@ -120,12 +120,18 @@ static __always_inline int do_hres(const struct vdso_data *vd, clockid_t clk,cpu_relax (); }smp_rmb (); +#ifdef __arch_vdso_capable +if (unlikely (!__arch_vdso_capable (vd->clock_mode))) +return -1 ; +#endif cycles =__arch_get_hw_counter (vd->clock_mode); ns = vdso_ts->nsec; last = vd->cycle_last; +#ifndef __arch_vdso_capableif (unlikely ((s64 )cycles <0 ))return -1 ; +#endif ns +=vdso_calc_delta (cycles, last, vd->mask, vd->mult); ns >>= vd->shift;
Signature · 1 line
2.25.0
PATCH v5 5/6 lib/vdso: Allow architectures to override the ns shift operation
In reply to Christophe LeroyOn powerpc/32, GCC (8.1) generates pretty bad code for the ns >>= vd->shift operation taking into account that the shift is always <= 32 and the upper part of the result is likely to be nul. GCC makes reversed assumptions considering the shift to be likely >= 32 and the upper part to be like not nul.
unsigned long long shift(unsigned long long x, unsigned char s)
{
return x >> s;
}results in:
00000018 <shift>:
18: 35 25 ff e0 addic. r9,r5,-32 1c: 41 80 00 10 blt 2c <shift+0x14> 20: 7c 64 4c 30 srw r4,r3,r9 24: 38 60 00 00 li r3,0 28: 4e 80 00 20 blr 2c: 54 69 08 3c rlwinm r9,r3,1,0,30 30: 21 45 00 1f subfic r10,r5,31 34: 7c 84 2c 30 srw r4,r4,r5 38: 7d 29 50 30 slw r9,r9,r10 3c: 7c 63 2c 30 srw r3,r3,r5 40: 7d 24 23 78 or r4,r9,r4
44: 4e 80 00 20 blr
Even when forcing the shift with an &= 31, it still considers the shift as likely >= 32.
Define a vdso_shift_ns() macro that can be overriden by architectures.
--- lib/vdso/gettimeofday.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
lib/vdso/gettimeofday.c +8 -1
@@ -38,6 +38,13 @@ u64 vdso_calc_delta(u64 cycles, u64 last, u64 mask, u32 mult) }#endif +#ifndef vdso_shift_ns +static __always_inline u64 vdso_shift_ns(u64 ns, unsigned long shift) +{ +return ns >> shift; +} +#endif +#ifdef CONFIG_TIME_NS static int do_hres_timens (const struct vdso_data *vdns,clockid_t clk,struct __kernel_timespec *ts)
@@ -134,7 +141,7 @@ static __always_inline int do_hres(const struct vdso_data *vd, clockid_t clk,#endif ns +=vdso_calc_delta (cycles, last, vd->mask, vd->mult); - ns >>= vd->shift; + ns =vdso_shift_ns (ns, vd->shift); sec = vdso_ts->sec; }while (unlikely (vdso_read_retry (vd, seq)));
Signature · 1 line
2.25.0
PATCH v5 6/6 powerpc/vdso: Switch VDSO to generic C implementation.
In reply to Christophe Leroypowerpc is a bit special for VDSO as well as system calls in the way that it requires setting CR SO bit which cannot be done in C. Therefore, entry/exit needs to be performed in ASM.
Implementing __arch_get_vdso_data() would clobbers the link register, requiring the caller to save it. As the ASM calling function already has to set a stack frame and saves the link register before calling the C vdso function, retriving the vdso data pointer there is lighter.
Implement __arch_vdso_capable() and:
- When the timebase is used, make it always return true.
- When the RTC clock is used, make it always return false.
Provide vdso_shift_ns(), as the generic x >> s gives the following bad result:
18: 35 25 ff e0 addic. r9,r5,-32 1c: 41 80 00 10 blt 2c <shift+0x14> 20: 7c 64 4c 30 srw r4,r3,r9 24: 38 60 00 00 li r3,0 ... 2c: 54 69 08 3c rlwinm r9,r3,1,0,30 30: 21 45 00 1f subfic r10,r5,31 34: 7c 84 2c 30 srw r4,r4,r5 38: 7d 29 50 30 slw r9,r9,r10 3c: 7c 63 2c 30 srw r3,r3,r5 40: 7d 24 23 78 or r4,r9,r4
In our case the shift is always <= 32. In addition, the upper 32 bits of the result are likely nul. Lets GCC know it, it also optimises the following calculations.
With the patch, we get:
0: 21 25 00 20 subfic r9,r5,32 4: 7c 69 48 30 slw r9,r3,r9 8: 7c 84 2c 30 srw r4,r4,r5 c: 7d 24 23 78 or r4,r9,r4 10: 7c 63 2c 30 srw r3,r3,r5
For VDSO32 on PPC64, we create a fake 32 bits config, on the same principle as MIPS architecture, in order to get the correct parts of the different asm header files.
With the C VDSO, the performance is slightly lower, but it is worth it as it will ease maintenance and evolution, and also brings clocks that are not supported with the ASM VDSO.
On an 8xx at 132 MHz, vdsotest with the ASM VDSO:
gettimeofday: vdso: 828 nsec/call clock-getres-realtime-coarse: vdso: 391 nsec/call clock-gettime-realtime-coarse: vdso: 614 nsec/call clock-getres-realtime: vdso: 460 nsec/call clock-gettime-realtime: vdso: 876 nsec/call clock-getres-monotonic-coarse: vdso: 399 nsec/call clock-gettime-monotonic-coarse: vdso: 691 nsec/call clock-getres-monotonic: vdso: 460 nsec/call clock-gettime-monotonic: vdso: 1026 nsec/call
On an 8xx at 132 MHz, vdsotest with the C VDSO:
gettimeofday: vdso: 955 nsec/call clock-getres-realtime-coarse: vdso: 545 nsec/call clock-gettime-realtime-coarse: vdso: 592 nsec/call clock-getres-realtime: vdso: 545 nsec/call clock-gettime-realtime: vdso: 941 nsec/call clock-getres-monotonic-coarse: vdso: 545 nsec/call clock-gettime-monotonic-coarse: vdso: 591 nsec/call clock-getres-monotonic: vdso: 545 nsec/call clock-gettime-monotonic: vdso: 940 nsec/call
It is even better for gettime with monotonic clocks.
Unsupported clocks with ASM VDSO:
clock-gettime-boottime: vdso: 3851 nsec/call clock-gettime-tai: vdso: 3852 nsec/call clock-gettime-monotonic-raw: vdso: 3396 nsec/call
Same clocks with C VDSO:
clock-gettime-tai: vdso: 941 nsec/call clock-gettime-monotonic-raw: vdso: 1001 nsec/call clock-gettime-monotonic-coarse: vdso: 591 nsec/call
On an 8321E at 333 MHz, vdsotest with the ASM VDSO:
gettimeofday: vdso: 220 nsec/call clock-getres-realtime-coarse: vdso: 102 nsec/call clock-gettime-realtime-coarse: vdso: 178 nsec/call clock-getres-realtime: vdso: 129 nsec/call clock-gettime-realtime: vdso: 235 nsec/call clock-getres-monotonic-coarse: vdso: 105 nsec/call clock-gettime-monotonic-coarse: vdso: 208 nsec/call clock-getres-monotonic: vdso: 129 nsec/call clock-gettime-monotonic: vdso: 274 nsec/call
On an 8321E at 333 MHz, vdsotest with the C VDSO:
gettimeofday: vdso: 272 nsec/call clock-getres-realtime-coarse: vdso: 160 nsec/call clock-gettime-realtime-coarse: vdso: 184 nsec/call clock-getres-realtime: vdso: 166 nsec/call clock-gettime-realtime: vdso: 281 nsec/call clock-getres-monotonic-coarse: vdso: 160 nsec/call clock-gettime-monotonic-coarse: vdso: 184 nsec/call clock-getres-monotonic: vdso: 169 nsec/call clock-gettime-monotonic: vdso: 275 nsec/call
--- arch/powerpc/Kconfig | 2 + arch/powerpc/include/asm/vdso/gettimeofday.h | 158 ++++++++++ arch/powerpc/include/asm/vdso/vsyscall.h | 25 ++ arch/powerpc/include/asm/vdso_datapage.h | 40 +-- arch/powerpc/kernel/asm-offsets.c | 49 +--- arch/powerpc/kernel/time.c | 90 ------ arch/powerpc/kernel/vdso.c | 5 +- arch/powerpc/kernel/vdso32/Makefile | 32 +- arch/powerpc/kernel/vdso32/config-fake32.h | 34 +++ arch/powerpc/kernel/vdso32/gettimeofday.S | 291 +------------------ arch/powerpc/kernel/vdso32/vgettimeofday.c | 29 ++ arch/powerpc/kernel/vdso64/Makefile | 23 +- arch/powerpc/kernel/vdso64/gettimeofday.S | 243 +--------------- arch/powerpc/kernel/vdso64/vgettimeofday.c | 29 ++ 14 files changed, 359 insertions(+), 691 deletions(-) create mode 100644 arch/powerpc/include/asm/vdso/gettimeofday.h create mode 100644 arch/powerpc/include/asm/vdso/vsyscall.h create mode 100644 arch/powerpc/kernel/vdso32/config-fake32.h create mode 100644 arch/powerpc/kernel/vdso32/vgettimeofday.c create mode 100644 arch/powerpc/kernel/vdso64/vgettimeofday.c
arch/powerpc/Kconfig +2 -0
@@ -165,6 +165,7 @@ config PPC select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER select GENERIC_TIME_VSYSCALL + select GENERIC_GETTIMEOFDAY select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_HUGE_VMAP if PPC_BOOK3S_64 && PPC_RADIX_MMU select HAVE_ARCH_JUMP_LABEL
@@ -195,6 +196,7 @@ config PPC select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_TRACER select HAVE_GCC_PLUGINS if GCC_VERSION >= 50200 # plugin support on gcc <= 5.1 is buggy on PPC + select HAVE_GENERIC_VDSO select HAVE_HW_BREAKPOINT if PERF_EVENTS && (PPC_BOOK3S || PPC_8xx) select HAVE_IDE select HAVE_IOREMAP_PROT
arch/powerpc/include/asm/vdso/gettimeofday.h new file +158 -0
158 lines not on this page · raw message
arch/powerpc/include/asm/vdso/vsyscall.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_VDSO_VSYSCALL_H +#define __ASM_VDSO_VSYSCALL_H + +#ifndef __ASSEMBLY__ + +#include <linux/timekeeper_internal.h> +#include <asm/vdso_datapage.h> + +/* +* Update the vDSO data page to keep in sync with kernel timekeeping. +*/ +static __always_inline +struct vdso_data *__arch_get_k_vdso_data(void) +{ +return vdso_data->data; +} +#define __arch_get_k_vdso_data __arch_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/powerpc/include/asm/vdso_datapage.h +13 -27
@@ -36,6 +36,7 @@#include <linux/unistd.h> #include <linux/time.h> +#include <vdso/datapage.h> #define SYSCALL_MAP_SIZE ((NR_syscalls + 31) / 32)
@@ -45,7 +46,7 @@ #ifdef CONFIG_PPC64 -struct vdso_data { +struct vdso_arch_data { __u8 eye_catcher[16]; /* Eyecatcher: SYSTEMCFG:PPC64 0x00 */ struct { /* Systemcfg version numbers */ __u32 major; /* Major number 0x10 */
@@ -59,13 +60,13 @@ struct vdso_data {__u32 processor;/* Processor type 0x1C */ __u64 processorCount;/* # of physical processors 0x20 */ __u64 physicalMemorySize;/* Size of real memory(B) 0x28 */ -__u64 tb_orig_stamp;/* Timebase at boot 0x30 */ +__u64 tb_orig_stamp;/* (NU) Timebase at boot 0x30 */ __u64 tb_ticks_per_sec;/* Timebase tics / sec 0x38 */ -__u64 tb_to_xs;/* Inverse of TB to 2^20 0x40 */ -__u64 stamp_xsec;/* 0x48 */ -__u64 tb_update_count;/* Timebase atomicity ctr 0x50 */ -__u32 tz_minuteswest;/* Minutes west of Greenwich 0x58 */ -__u32 tz_dsttime;/* Type of dst correction 0x5C */ +__u64 tb_to_xs;/* (NU) Inverse of TB to 2^20 0x40 */ +__u64 stamp_xsec;/* (NU) 0x48 */ +__u64 tb_update_count;/* (NU) Timebase atomicity ctr 0x50 */ +__u32 tz_minuteswest;/* (NU) Min. west of Greenwich 0x58 */ +__u32 tz_dsttime;/* (NU) Type of dst correction 0x5C */ __u32 dcache_size;/* L1 d-cache size 0x60 */ __u32 dcache_line_size;/* L1 d-cache line size 0x64 */ __u32 icache_size;/* L1 i-cache size 0x68 */
@@ -78,14 +79,10 @@ struct vdso_data {__u32 icache_block_size;/* L1 i-cache block size */ __u32 dcache_log_block_size;/* L1 d-cache log block size */ __u32 icache_log_block_size;/* L1 i-cache log block size */ -__u32 stamp_sec_fraction;/* fractional seconds of stamp_xtime */ -__s32 wtom_clock_nsec;/* Wall to monotonic clock nsec */ -__s64 wtom_clock_sec;/* Wall to monotonic clock sec */ -__s64 stamp_xtime_sec;/* xtime secs as at tb_orig_stamp */ -__s64 stamp_xtime_nsec;/* xtime nsecs as at tb_orig_stamp */ -__u32 hrtimer_res;/* hrtimer resolution */ __u32 syscall_map_64[SYSCALL_MAP_SIZE ];/* map of syscalls */ __u32 syscall_map_32[SYSCALL_MAP_SIZE ];/* map of syscalls */ + + struct vdso_data data[CS_BASES]; };#else /* CONFIG_PPC64 */
@@ -93,26 +90,15 @@ struct vdso_data {/* * And here is the simpler 32 bits version */ -struct vdso_data { -__u64 tb_orig_stamp;/* Timebase at boot 0x30 */ +struct vdso_arch_data {__u64 tb_ticks_per_sec;/* Timebase tics / sec 0x38 */ -__u64 tb_to_xs;/* Inverse of TB to 2^20 0x40 */ -__u64 stamp_xsec;/* 0x48 */ -__u32 tb_update_count;/* Timebase atomicity ctr 0x50 */ -__u32 tz_minuteswest;/* Minutes west of Greenwich 0x58 */ -__u32 tz_dsttime;/* Type of dst correction 0x5C */ -__s32 wtom_clock_sec;/* Wall to monotonic clock */ -__s32 wtom_clock_nsec; -__s32 stamp_xtime_sec;/* xtime seconds as at tb_orig_stamp */ -__s32 stamp_xtime_nsec;/* xtime nsecs as at tb_orig_stamp */ -__u32 stamp_sec_fraction;/* fractional seconds of stamp_xtime */ -__u32 hrtimer_res;/* hrtimer resolution */ __u32 syscall_map_32[SYSCALL_MAP_SIZE ];/* map of syscalls */ +struct vdso_data data[CS_BASES ]; };#endif /* CONFIG_PPC64 */ -extern struct vdso_data *vdso_data; +extern struct vdso_arch_data *vdso_data;#else /* __ASSEMBLY__ */
arch/powerpc/kernel/asm-offsets.c +9 -40
56 lines not on this page · raw message
arch/powerpc/kernel/time.c +0 -90
102 lines not on this page · raw message
arch/powerpc/kernel/vdso.c +3 -2
@@ -17,6 +17,7 @@#include <linux/elf.h> #include <linux/security.h> #include <linux/memblock.h> +#include <vdso/datapage.h> #include <asm/pgtable.h> #include <asm/processor.h>
@@ -71,10 +72,10 @@ static int vdso_ready;* with it, it will become dynamically allocated */ static union { -struct vdso_data data; +struct vdso_arch_data data;u8 page[PAGE_SIZE ]; } vdso_data_store __page_aligned_data; -struct vdso_data *vdso_data = &vdso_data_store.data; +struct vdso_arch_data *vdso_data = &vdso_data_store.data;/* Format of the patch table */ struct vdso_patch_def
arch/powerpc/kernel/vdso32/Makefile +27 -5
@@ -2,7 +2,23 @@ # List of files in the vdso, has to be asm only for now -obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o getcpu.o +ARCH_REL_TYPE_ABS := R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN +include $(srctree)/lib/vdso/Makefile + +obj-vdso32 = sigtramp.o datapage.o cacheflush.o note.o getcpu.o $(obj-vdso32-y) +obj-vdso32 += gettimeofday.o + +ifneq ($(c-gettimeofday-y),) + ifdef CONFIG_PPC64 + CFLAGS_vgettimeofday.o += -include $(srctree)/$(src)/config-fake32.h + endif + CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y) + CFLAGS_vgettimeofday.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) + CFLAGS_vgettimeofday.o += $(call cc-option, -fno-stack-protector) + CFLAGS_vgettimeofday.o += -DDISABLE_BRANCH_PROFILING + CFLAGS_vgettimeofday.o += -ffreestanding + CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) +endif # Build rules
@@ -15,6 +31,7 @@ endif CC32FLAGS := ifdef CONFIG_PPC64 CC32FLAGS += -m32 +KBUILD_CFLAGS := $(filter-out -mcmodel=medium,$(KBUILD_CFLAGS)) endif targets := $(obj-vdso32) vdso32.so vdso32.so.dbg
@@ -23,6 +40,7 @@ obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32)) GCOV_PROFILE := n KCOV_INSTRUMENT := n UBSAN_SANITIZE := n +KASAN_SANITIZE := n ccflags-y := -shared -fno-common -fno-builtin -nostdlib \ -Wl,-soname=linux-vdso32.so.1 -Wl,--hash-style=both
@@ -36,8 +54,8 @@ CPPFLAGS_vdso32.lds += -P -C -Upowerpc $(obj)/vdso32_wrapper.o : $(obj)/vdso32.so # link rule for the .so file, .lds has to be first -$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) FORCE - $(call if_changed,vdso32ld) +$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday.o FORCE + $(call if_changed,vdso32ld_and_check) # strip rule for the .so file $(obj)/%.so: OBJCOPYFLAGS := -S
@@ -47,12 +65,16 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE # assembly rules for the .S files $(obj-vdso32): %.o: %.S FORCE $(call if_changed_dep,vdso32as) +$(obj)/vgettimeofday.o: %.o: %.c FORCE + $(call if_changed_dep,vdso32cc) # actual build commands -quiet_cmd_vdso32ld = VDSO32L $@ - cmd_vdso32ld = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) +quiet_cmd_vdso32ld_and_check = VDSO32L $@ + cmd_vdso32ld_and_check = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check) quiet_cmd_vdso32as = VDSO32A $@ cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) -c -o $@ $< +quiet_cmd_vdso32cc = VDSO32C $@ + cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $< # install commands for the unstripped file quiet_cmd_vdso_install = INSTALL $@
arch/powerpc/kernel/vdso32/config-fake32.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* In case of a 32 bit VDSO for a 64 bit kernel fake a 32 bit kernel +* configuration. +*/ + +#undef CONFIG_PPC64 +#undef CONFIG_64BIT +#define CONFIG_PPC32 +#define CONFIG_32BIT 1 +#define CONFIG_GENERIC_ATOMIC64 1 + +#ifdef CONFIG_PPC_BOOK3S_64 +#undef CONFIG_PPC_BOOK3S_64 +#undef CONFIG_PPC_PSERIES +#define CONFIG_PPC_BOOK3S_32 +#else +#define CONFIG_PPC_MMU_NOHASH_32 +#define CONFIG_FSL_BOOKE +#endif + +#define CONFIG_TASK_SIZE 0 +#undef CONFIG_MMIOWB +#undef CONFIG_PPC_SPLPAR +#undef CONFIG_SPARSEMEM +#undef CONFIG_PGTABLE_LEVELS +#define CONFIG_PGTABLE_LEVELS 2 +#undef CONFIG_TRANSPARENT_HUGEPAGE +#undef CONFIG_SPARSEMEM_VMEMMAP +#undef CONFIG_FLATMEM +#define CONFIG_FLATMEM +#undef CONFIG_PPC_INDIRECT_MMIO +#undef CONFIG_PPC_INDIRECT_PIO +#undef CONFIG_EEH
arch/powerpc/kernel/vdso32/gettimeofday.S +5 -286
319 lines not on this page · raw message
arch/powerpc/kernel/vdso32/vgettimeofday.c new file +29 -0
@@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Powerpc userspace implementations of gettimeofday() and similar. +*/ +#include <linux/time.h> +#include <linux/types.h> + +int __c_kernel_clock_gettime (clockid_t clock,struct old_timespec32 *ts, +const struct vdso_data *vd) +{ +return __cvdso_clock_gettime32_data (vd, clock, ts); +} + +int __c_kernel_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz, +const struct vdso_data *vd) +{ +return __cvdso_gettimeofday_data (vd, tv, tz); +} + +int __c_kernel_clock_getres (clockid_t clock_id,struct old_timespec32 *res, +const struct vdso_data *vd) +{ +return __cvdso_clock_getres_time32_data (vd, clock_id, res); +} + +time_t __c_kernel_time (time_t *time,const struct vdso_data *vd) +{ +return __cvdso_time_data (vd, time); +}
arch/powerpc/kernel/vdso64/Makefile +19 -4
@@ -1,8 +1,20 @@ # SPDX-License-Identifier: GPL-2.0 # List of files in the vdso, has to be asm only for now +ARCH_REL_TYPE_ABS := R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN +include $(srctree)/lib/vdso/Makefile + obj-vdso64 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o getcpu.o +ifneq ($(c-gettimeofday-y),) + CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y) + CFLAGS_vgettimeofday.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) + CFLAGS_vgettimeofday.o += $(call cc-option, -fno-stack-protector) + CFLAGS_vgettimeofday.o += -DDISABLE_BRANCH_PROFILING + CFLAGS_vgettimeofday.o += -ffreestanding + CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) +endif + # Build rules targets := $(obj-vdso64) vdso64.so vdso64.so.dbg
@@ -11,6 +23,7 @@ obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64)) GCOV_PROFILE := n KCOV_INSTRUMENT := n UBSAN_SANITIZE := n +KASAN_SANITIZE := n ccflags-y := -shared -fno-common -fno-builtin -nostdlib \ -Wl,-soname=linux-vdso64.so.1 -Wl,--hash-style=both
@@ -20,12 +33,14 @@ obj-y += vdso64_wrapper.o extra-y += vdso64.lds CPPFLAGS_vdso64.lds += -P -C -U$(ARCH) +$(obj)/vgettimeofday.o: %.o: %.c FORCE + # Force dependency (incbin is bad) $(obj)/vdso64_wrapper.o : $(obj)/vdso64.so # link rule for the .so file, .lds has to be first -$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) FORCE - $(call if_changed,vdso64ld) +$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) $(obj)/vgettimeofday.o FORCE + $(call if_changed,vdso64ld_and_check) # strip rule for the .so file $(obj)/%.so: OBJCOPYFLAGS := -S
@@ -33,8 +48,8 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE $(call if_changed,objcopy) # actual build commands -quiet_cmd_vdso64ld = VDSO64L $@ - cmd_vdso64ld = $(CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) +quiet_cmd_vdso64ld_and_check = VDSO64L $@ + cmd_vdso64ld_and_check = $(CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check) # install commands for the unstripped file quiet_cmd_vdso_install = INSTALL $@
arch/powerpc/kernel/vdso64/gettimeofday.S +6 -237
273 lines not on this page · raw message
arch/powerpc/kernel/vdso64/vgettimeofday.c new file +29 -0
@@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Powerpc userspace implementations of gettimeofday() and similar. +*/ +#include <linux/time.h> +#include <linux/types.h> + +int __c_kernel_clock_gettime (clockid_t clock,struct __kernel_timespec *ts, +const struct vdso_data *vd) +{ +return __cvdso_clock_gettime_data (vd, clock, ts); +} + +int __c_kernel_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz, +const struct vdso_data *vd) +{ +return __cvdso_gettimeofday_data (vd, tv, tz); +} + +int __c_kernel_clock_getres (clockid_t clock_id,struct __kernel_timespec *res, +const struct vdso_data *vd) +{ +return __cvdso_clock_getres_data (vd, clock_id, res); +} + +time_t __c_kernel_time (time_t *time,const struct vdso_data *vd) +{ +return __cvdso_time_data (vd, time); +}
Signature · 1 line
2.25.0
kbuild test robot
build botRe: [PATCH v5 6/6] powerpc/vdso: Switch VDSO to generic C implementation.
Thank you for the patch! Yet something to improve:
Hi Christophe,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on next-20200130]
[cannot apply to powerpc/next tip/timers/vdso mpe/next v5.5 v5.5-rc7 v5.5-rc6 v5.5] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Christophe-Leroy/powerpc-switch-VDSO-to-C-implementation/20200202-175410 base: c32e1d01a152aee976763ccf7c7ced53ca45b78f config: powerpc-defconfig (attached as .config) compiler: powerpc64-linux-gcc (GCC) 7.5.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
GCC_VERSION=7.5.0 make.cross ARCH=powerpc
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
>> arch/powerpc/kernel/vdso32/vgettimeofday.c:26:1: error: unknown type name 'time_t'; did you mean 'ktime_t'?
time_t __c_kernel_time(time_t *time, const struct vdso_data *vd)
^~~~~~
ktime_t
arch/powerpc/kernel/vdso32/vgettimeofday.c:26:24: error: unknown type name 'time_t'; did you mean 'ktime_t'?
time_t __c_kernel_time(time_t *time, const struct vdso_data *vd)
^~~~~~
ktime_t
--
>> arch/powerpc/kernel/vdso64/vgettimeofday.c:26:1: error: unknown type name 'time_t'; did you mean 'ktime_t'?
time_t __c_kernel_time(time_t *time, const struct vdso_data *vd)
^~~~~~
ktime_t
arch/powerpc/kernel/vdso64/vgettimeofday.c:26:24: error: unknown type name 'time_t'; did you mean 'ktime_t'?
time_t __c_kernel_time(time_t *time, const struct vdso_data *vd)
^~~~~~
ktime_t
vim +26 arch/powerpc/kernel/vdso32/vgettimeofday.c
25 > 26 time_t __c_kernel_time(time_t *time, const struct vdso_data *vd)
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
Re: [PATCH v5 6/6] powerpc/vdso: Switch VDSO to generic C implementation.
Quoted 10 lines · kbuild test robot
If you fix the issue, kindly add following tag
Reported-by kbuild test robot <[email protected]>All errors (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
arch/powerpc/kernel/vdso32/vgettimeofday.c:26:1: error: unknown type name 'time_t'; did you mean 'ktime_t'?
time_t__c_kernel_time(time_t *time, const struct vdso_data *vd)^~~~~~
ktime_t
time_t is no longer available in linux-next, so this has to use __kernel_old_time_t.
Arnd