Re: [PATCH 15/22] arch: vdso: consolidate gettime prototypes
On Wed, Nov 08, 2023 at 01:58:36PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann > > The VDSO functions are defined as globals in the kernel sources but intended > to be called from userspace, so there is no need to declare them in a kernel > side header. This is in -next as commit 42874e4eb35bdfc54f8514685e50434098ba4f6c and breaks an arm64 defconfig build, the 32 bit vDSO build is broken: /build/stage/linux/arch/arm64/kernel/vdso32/vgettimeofday.c:10:5: error: conflic ting types for ‘__vdso_clock_gettime’; have ‘int(clockid_t, struct old_timespec 32 *)’ {aka ‘int(int, struct old_timespec32 *)’} 10 | int __vdso_clock_gettime(clockid_t clock, | ^~~~ In file included from /build/stage/linux/arch/arm64/kernel/vdso32/vgettimeofday. c:8: /build/stage/linux/include/vdso/gettime.h:16:5: note: previous declaration of ‘__vdso_clock_gettime’ with type ‘int(clockid_t, struct __kernel_timespec *)’ {aka ‘int(int, struct __kernel_timespec *)’} 16 | int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts); | ^~~~ /build/stage/linux/arch/arm64/kernel/vdso32/vgettimeofday.c:28:5: error: conflicting types for ‘__vdso_clock_getres’; have ‘int(clockid_t, struct old_timespec32 *)’ {aka ‘int(int, struct old_timespec32 *)’} 28 | int __vdso_clock_getres(clockid_t clock_id, | ^~~ /build/stage/linux/include/vdso/gettime.h:15:5: note: previous declaration of ‘__vdso_clock_getres’ with type ‘int(clockid_t, struct __kernel_timespec *)’ {aka ‘int(int, struct __kernel_timespec *)’} 15 | int __vdso_clock_getres(clockid_t clock, struct __kernel_timespec *res); | ^~~ signature.asc Description: PGP signature ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH 15/22] arch: vdso: consolidate gettime prototypes
Hi Arnd, On 11/8/23 12:58, Arnd Bergmann wrote: > From: Arnd Bergmann > > The VDSO functions are defined as globals in the kernel sources but intended > to be called from userspace, so there is no need to declare them in a kernel > side header. > > Without a prototype, this now causes warnings such as > > arch/mips/vdso/vgettimeofday.c:14:5: error: no previous prototype for > '__vdso_clock_gettime' [-Werror=missing-prototypes] > arch/mips/vdso/vgettimeofday.c:28:5: error: no previous prototype for > '__vdso_gettimeofday' [-Werror=missing-prototypes] > arch/mips/vdso/vgettimeofday.c:36:5: error: no previous prototype for > '__vdso_clock_getres' [-Werror=missing-prototypes] > arch/mips/vdso/vgettimeofday.c:42:5: error: no previous prototype for > '__vdso_clock_gettime64' [-Werror=missing-prototypes] > arch/sparc/vdso/vclock_gettime.c:254:1: error: no previous prototype for > '__vdso_clock_gettime' [-Werror=missing-prototypes] > arch/sparc/vdso/vclock_gettime.c:282:1: error: no previous prototype for > '__vdso_clock_gettime_stick' [-Werror=missing-prototypes] > arch/sparc/vdso/vclock_gettime.c:307:1: error: no previous prototype for > '__vdso_gettimeofday' [-Werror=missing-prototypes] > arch/sparc/vdso/vclock_gettime.c:343:1: error: no previous prototype for > '__vdso_gettimeofday_stick' [-Werror=missing-prototypes] > > Most architectures have already added workarounds for these by adding > declarations somewhere, but since these are all compatible, we should > really just have one copy, with an #ifdef check for the 32-bit vs > 64-bit variant and use that everywhere. > I agree, it is a good idea to have a single header for this purpose. > Unfortunately, the sparc version is currently incompatible since > that never added support for __vdso_clock_gettime64() in 32-bit > userland. For the moment, I'm leaving this one out, as I can't > easily test it and it requires a larger rework. > > Signed-off-by: Arnd Bergmann Reviewed-by: Vincenzo Frascino > --- > arch/arm/include/asm/vdso.h | 5 - > arch/arm/vdso/vgettimeofday.c| 1 + > arch/arm64/kernel/vdso32/vgettimeofday.c | 1 + > arch/csky/kernel/vdso/vgettimeofday.c| 11 +-- > arch/loongarch/vdso/vgettimeofday.c | 7 +-- > arch/mips/vdso/vgettimeofday.c | 1 + > arch/riscv/kernel/vdso/vgettimeofday.c | 7 +-- > arch/x86/entry/vdso/vclock_gettime.c | 10 +- > arch/x86/include/asm/vdso/gettimeofday.h | 2 -- > arch/x86/um/vdso/um_vdso.c | 1 + > include/vdso/gettime.h | 23 +++ > 11 files changed, 31 insertions(+), 38 deletions(-) > create mode 100644 include/vdso/gettime.h > > diff --git a/arch/arm/include/asm/vdso.h b/arch/arm/include/asm/vdso.h > index 422c3afa806a..5b85889f82ee 100644 > --- a/arch/arm/include/asm/vdso.h > +++ b/arch/arm/include/asm/vdso.h > @@ -24,11 +24,6 @@ static inline void arm_install_vdso(struct mm_struct *mm, > unsigned long addr) > > #endif /* CONFIG_VDSO */ > > -int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts); > -int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts); > -int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone > *tz); > -int __vdso_clock_getres(clockid_t clock_id, struct old_timespec32 *res); > - > #endif /* __ASSEMBLY__ */ > > #endif /* __KERNEL__ */ > diff --git a/arch/arm/vdso/vgettimeofday.c b/arch/arm/vdso/vgettimeofday.c > index a003beacac76..3554aa35f1ba 100644 > --- a/arch/arm/vdso/vgettimeofday.c > +++ b/arch/arm/vdso/vgettimeofday.c > @@ -8,6 +8,7 @@ > #include > #include > #include > +#include > > int __vdso_clock_gettime(clockid_t clock, >struct old_timespec32 *ts) > diff --git a/arch/arm64/kernel/vdso32/vgettimeofday.c > b/arch/arm64/kernel/vdso32/vgettimeofday.c > index 5acff29c5991..e23c7f4ef26b 100644 > --- a/arch/arm64/kernel/vdso32/vgettimeofday.c > +++ b/arch/arm64/kernel/vdso32/vgettimeofday.c > @@ -5,6 +5,7 @@ > * Copyright (C) 2018 ARM Limited > * > */ > +#include > > int __vdso_clock_gettime(clockid_t clock, >struct old_timespec32 *ts) > diff --git a/arch/csky/kernel/vdso/vgettimeofday.c > b/arch/csky/kernel/vdso/vgettimeofday.c > index c4831145eed5..55af30e83752 100644 > --- a/arch/csky/kernel/vdso/vgettimeofday.c > +++ b/arch/csky/kernel/vdso/vgettimeofday.c > @@ -2,36 +2,27 @@ > > #include > #include > +#include > > extern > -int __vdso_clock_gettime(clockid_t clock, > - struct old_timespec32 *ts); > int __vdso_clock_gettime(clockid_t clock, >struct old_timespec32 *ts) > { > return __cvdso_clock_gettime32(clock, ts); > } > > -int __vdso_clock_gettime64(clockid_t clock, > -struct __kernel_timespec *ts); > int __vdso_clock_gettime64(clockid_t clock, > struct __kernel_timespec *ts) > { >
Re: [PATCH 15/22] arch: vdso: consolidate gettime prototypes
Christophe Leroy writes: > Le 09/11/2023 à 11:18, Michael Ellerman a écrit : >> "Arnd Bergmann" writes: >>> On Wed, Nov 8, 2023, at 19:31, Christophe Leroy wrote: Le 08/11/2023 à 13:58, Arnd Bergmann a écrit : >>> powerpc has functions doing more or less the same, they are called __c_kernel_clock_gettime() and alike with their prototypes siting in arch/powerpc/include/asm/vdso/gettimeofday.h Should those prototypes be moved to include/vdso/gettime.h too and eventually renamed, or are they considered too powerpc specific ? >>> >>> I don't actually know, my initial interpretation was that >>> these function names are part of the user ABI for the vdso, >>> but I never looked closely enough at how vdso works to >>> be sure what the actual ABI is. >> >> AFAIK the ABI is just the symbols we export, as defined in the linker >> script: >> >> /* >> * This controls what symbols we export from the DSO. >> */ >> VERSION >> { >> VDSO_VERSION_STRING { >> global: >> __kernel_get_syscall_map; >> __kernel_gettimeofday; >> __kernel_clock_gettime; >> __kernel_clock_getres; >> __kernel_get_tbfreq; >> __kernel_sync_dicache; >> __kernel_sigtramp_rt64; >> __kernel_getcpu; >> __kernel_time; >> >>
Re: [PATCH 15/22] arch: vdso: consolidate gettime prototypes
Le 09/11/2023 à 11:18, Michael Ellerman a écrit : > "Arnd Bergmann" writes: >> On Wed, Nov 8, 2023, at 19:31, Christophe Leroy wrote: >>> Le 08/11/2023 à 13:58, Arnd Bergmann a écrit : >> >>> powerpc has functions doing more or less the same, they are called >>> __c_kernel_clock_gettime() and alike with their prototypes siting in >>> arch/powerpc/include/asm/vdso/gettimeofday.h >>> >>> Should those prototypes be moved to include/vdso/gettime.h too and >>> eventually renamed, or are they considered too powerpc specific ? >> >> I don't actually know, my initial interpretation was that >> these function names are part of the user ABI for the vdso, >> but I never looked closely enough at how vdso works to >> be sure what the actual ABI is. > > AFAIK the ABI is just the symbols we export, as defined in the linker > script: > > /* > * This controls what symbols we export from the DSO. > */ > VERSION > { > VDSO_VERSION_STRING { > global: > __kernel_get_syscall_map; > __kernel_gettimeofday; > __kernel_clock_gettime; > __kernel_clock_getres; > __kernel_get_tbfreq; > __kernel_sync_dicache; > __kernel_sigtramp_rt64; > __kernel_getcpu; > __kernel_time; > >
Re: [PATCH 15/22] arch: vdso: consolidate gettime prototypes
"Arnd Bergmann" writes: > On Wed, Nov 8, 2023, at 19:31, Christophe Leroy wrote: >> Le 08/11/2023 à 13:58, Arnd Bergmann a écrit : > >> powerpc has functions doing more or less the same, they are called >> __c_kernel_clock_gettime() and alike with their prototypes siting in >> arch/powerpc/include/asm/vdso/gettimeofday.h >> >> Should those prototypes be moved to include/vdso/gettime.h too and >> eventually renamed, or are they considered too powerpc specific ? > > I don't actually know, my initial interpretation was that > these function names are part of the user ABI for the vdso, > but I never looked closely enough at how vdso works to > be sure what the actual ABI is. AFAIK the ABI is just the symbols we export, as defined in the linker script: /* * This controls what symbols we export from the DSO. */ VERSION { VDSO_VERSION_STRING { global: __kernel_get_syscall_map; __kernel_gettimeofday; __kernel_clock_gettime; __kernel_clock_getres; __kernel_get_tbfreq; __kernel_sync_dicache; __kernel_sigtramp_rt64; __kernel_getcpu; __kernel_time;
Re: [PATCH 15/22] arch: vdso: consolidate gettime prototypes
Le 08/11/2023 à 20:37, Arnd Bergmann a écrit : > On Wed, Nov 8, 2023, at 19:31, Christophe Leroy wrote: >> Le 08/11/2023 à 13:58, Arnd Bergmann a écrit : > >> powerpc has functions doing more or less the same, they are called >> __c_kernel_clock_gettime() and alike with their prototypes siting in >> arch/powerpc/include/asm/vdso/gettimeofday.h >> >> Should those prototypes be moved to include/vdso/gettime.h too and >> eventually renamed, or are they considered too powerpc specific ? > > I don't actually know, my initial interpretation was that > these function names are part of the user ABI for the vdso, > but I never looked closely enough at how vdso works to > be sure what the actual ABI is. > > If __c_kernel_clock_gettime() etc are not part of the user-facing > ABI, I think renaming them for consistency with the other > architectures would be best. > User-facing ABI function is __kernel_clock_gettime(), defined in arch/powerpc/kernel/vdso/gettimeofday.S , see man vdso. There is no prototype defined for it anywhere, obviously that's undetected because it is assembly. Should a prototype be added somewhere anyway ? __kernel_clock_gettime() sets up a stack frame, retrieves the address of the datapage then calls __c_kernel_clock_gettime() which then calls __cvdso_clock_gettime_data() which is part of the generic CVDSO. Maybe that's too different from what other architectures do ? Christophe ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH 15/22] arch: vdso: consolidate gettime prototypes
On Wed, Nov 8, 2023, at 19:31, Christophe Leroy wrote: > Le 08/11/2023 à 13:58, Arnd Bergmann a écrit : > powerpc has functions doing more or less the same, they are called > __c_kernel_clock_gettime() and alike with their prototypes siting in > arch/powerpc/include/asm/vdso/gettimeofday.h > > Should those prototypes be moved to include/vdso/gettime.h too and > eventually renamed, or are they considered too powerpc specific ? I don't actually know, my initial interpretation was that these function names are part of the user ABI for the vdso, but I never looked closely enough at how vdso works to be sure what the actual ABI is. If __c_kernel_clock_gettime() etc are not part of the user-facing ABI, I think renaming them for consistency with the other architectures would be best. Arnd ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH 15/22] arch: vdso: consolidate gettime prototypes
Hi Arnd, Le 08/11/2023 à 13:58, Arnd Bergmann a écrit : > From: Arnd Bergmann > > The VDSO functions are defined as globals in the kernel sources but intended > to be called from userspace, so there is no need to declare them in a kernel > side header. > > Without a prototype, this now causes warnings such as > > arch/mips/vdso/vgettimeofday.c:14:5: error: no previous prototype for > '__vdso_clock_gettime' [-Werror=missing-prototypes] > arch/mips/vdso/vgettimeofday.c:28:5: error: no previous prototype for > '__vdso_gettimeofday' [-Werror=missing-prototypes] > arch/mips/vdso/vgettimeofday.c:36:5: error: no previous prototype for > '__vdso_clock_getres' [-Werror=missing-prototypes] > arch/mips/vdso/vgettimeofday.c:42:5: error: no previous prototype for > '__vdso_clock_gettime64' [-Werror=missing-prototypes] > arch/sparc/vdso/vclock_gettime.c:254:1: error: no previous prototype for > '__vdso_clock_gettime' [-Werror=missing-prototypes] > arch/sparc/vdso/vclock_gettime.c:282:1: error: no previous prototype for > '__vdso_clock_gettime_stick' [-Werror=missing-prototypes] > arch/sparc/vdso/vclock_gettime.c:307:1: error: no previous prototype for > '__vdso_gettimeofday' [-Werror=missing-prototypes] > arch/sparc/vdso/vclock_gettime.c:343:1: error: no previous prototype for > '__vdso_gettimeofday_stick' [-Werror=missing-prototypes] > > Most architectures have already added workarounds for these by adding > declarations somewhere, but since these are all compatible, we should > really just have one copy, with an #ifdef check for the 32-bit vs > 64-bit variant and use that everywhere. > > Unfortunately, the sparc version is currently incompatible since > that never added support for __vdso_clock_gettime64() in 32-bit > userland. For the moment, I'm leaving this one out, as I can't > easily test it and it requires a larger rework. > > Signed-off-by: Arnd Bergmann > --- > arch/arm/include/asm/vdso.h | 5 - > arch/arm/vdso/vgettimeofday.c| 1 + > arch/arm64/kernel/vdso32/vgettimeofday.c | 1 + > arch/csky/kernel/vdso/vgettimeofday.c| 11 +-- > arch/loongarch/vdso/vgettimeofday.c | 7 +-- > arch/mips/vdso/vgettimeofday.c | 1 + > arch/riscv/kernel/vdso/vgettimeofday.c | 7 +-- > arch/x86/entry/vdso/vclock_gettime.c | 10 +- > arch/x86/include/asm/vdso/gettimeofday.h | 2 -- > arch/x86/um/vdso/um_vdso.c | 1 + > include/vdso/gettime.h | 23 +++ > 11 files changed, 31 insertions(+), 38 deletions(-) > create mode 100644 include/vdso/gettime.h powerpc has functions doing more or less the same, they are called __c_kernel_clock_gettime() and alike with their prototypes siting in arch/powerpc/include/asm/vdso/gettimeofday.h Should those prototypes be moved to include/vdso/gettime.h too and eventually renamed, or are they considered too powerpc specific ? Christophe ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH 15/22] arch: vdso: consolidate gettime prototypes
From: Arnd Bergmann The VDSO functions are defined as globals in the kernel sources but intended to be called from userspace, so there is no need to declare them in a kernel side header. Without a prototype, this now causes warnings such as arch/mips/vdso/vgettimeofday.c:14:5: error: no previous prototype for '__vdso_clock_gettime' [-Werror=missing-prototypes] arch/mips/vdso/vgettimeofday.c:28:5: error: no previous prototype for '__vdso_gettimeofday' [-Werror=missing-prototypes] arch/mips/vdso/vgettimeofday.c:36:5: error: no previous prototype for '__vdso_clock_getres' [-Werror=missing-prototypes] arch/mips/vdso/vgettimeofday.c:42:5: error: no previous prototype for '__vdso_clock_gettime64' [-Werror=missing-prototypes] arch/sparc/vdso/vclock_gettime.c:254:1: error: no previous prototype for '__vdso_clock_gettime' [-Werror=missing-prototypes] arch/sparc/vdso/vclock_gettime.c:282:1: error: no previous prototype for '__vdso_clock_gettime_stick' [-Werror=missing-prototypes] arch/sparc/vdso/vclock_gettime.c:307:1: error: no previous prototype for '__vdso_gettimeofday' [-Werror=missing-prototypes] arch/sparc/vdso/vclock_gettime.c:343:1: error: no previous prototype for '__vdso_gettimeofday_stick' [-Werror=missing-prototypes] Most architectures have already added workarounds for these by adding declarations somewhere, but since these are all compatible, we should really just have one copy, with an #ifdef check for the 32-bit vs 64-bit variant and use that everywhere. Unfortunately, the sparc version is currently incompatible since that never added support for __vdso_clock_gettime64() in 32-bit userland. For the moment, I'm leaving this one out, as I can't easily test it and it requires a larger rework. Signed-off-by: Arnd Bergmann --- arch/arm/include/asm/vdso.h | 5 - arch/arm/vdso/vgettimeofday.c| 1 + arch/arm64/kernel/vdso32/vgettimeofday.c | 1 + arch/csky/kernel/vdso/vgettimeofday.c| 11 +-- arch/loongarch/vdso/vgettimeofday.c | 7 +-- arch/mips/vdso/vgettimeofday.c | 1 + arch/riscv/kernel/vdso/vgettimeofday.c | 7 +-- arch/x86/entry/vdso/vclock_gettime.c | 10 +- arch/x86/include/asm/vdso/gettimeofday.h | 2 -- arch/x86/um/vdso/um_vdso.c | 1 + include/vdso/gettime.h | 23 +++ 11 files changed, 31 insertions(+), 38 deletions(-) create mode 100644 include/vdso/gettime.h diff --git a/arch/arm/include/asm/vdso.h b/arch/arm/include/asm/vdso.h index 422c3afa806a..5b85889f82ee 100644 --- a/arch/arm/include/asm/vdso.h +++ b/arch/arm/include/asm/vdso.h @@ -24,11 +24,6 @@ static inline void arm_install_vdso(struct mm_struct *mm, unsigned long addr) #endif /* CONFIG_VDSO */ -int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts); -int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts); -int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz); -int __vdso_clock_getres(clockid_t clock_id, struct old_timespec32 *res); - #endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */ diff --git a/arch/arm/vdso/vgettimeofday.c b/arch/arm/vdso/vgettimeofday.c index a003beacac76..3554aa35f1ba 100644 --- a/arch/arm/vdso/vgettimeofday.c +++ b/arch/arm/vdso/vgettimeofday.c @@ -8,6 +8,7 @@ #include #include #include +#include int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) diff --git a/arch/arm64/kernel/vdso32/vgettimeofday.c b/arch/arm64/kernel/vdso32/vgettimeofday.c index 5acff29c5991..e23c7f4ef26b 100644 --- a/arch/arm64/kernel/vdso32/vgettimeofday.c +++ b/arch/arm64/kernel/vdso32/vgettimeofday.c @@ -5,6 +5,7 @@ * Copyright (C) 2018 ARM Limited * */ +#include int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) diff --git a/arch/csky/kernel/vdso/vgettimeofday.c b/arch/csky/kernel/vdso/vgettimeofday.c index c4831145eed5..55af30e83752 100644 --- a/arch/csky/kernel/vdso/vgettimeofday.c +++ b/arch/csky/kernel/vdso/vgettimeofday.c @@ -2,36 +2,27 @@ #include #include +#include extern -int __vdso_clock_gettime(clockid_t clock, -struct old_timespec32 *ts); int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) { return __cvdso_clock_gettime32(clock, ts); } -int __vdso_clock_gettime64(clockid_t clock, - struct __kernel_timespec *ts); int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts) { return __cvdso_clock_gettime(clock, ts); } -extern -int __vdso_gettimeofday(struct __kernel_old_timeval *tv, - struct timezone *tz); int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) { return __cvdso_gettimeofday(tv, tz); } -extern -int __vdso_clock_getres(clockid_t clock_id, -