arm64: asm: vdso: gettimeofday: export common variables
Subsystems (2)
PATCH 1/1 arm64: asm: vdso: gettimeofday: export common variables
When building the kernel with sparse enabled 'C=1' the following warnings can be seen:
arch/arm64/kernel/vdso/vgettimeofday.c:9:5: warning: symbol '__kernel_clock_gettime' was not declared. Should it be static? arch/arm64/kernel/vdso/vgettimeofday.c:15:5: warning: symbol '__kernel_gettimeofday' was not declared. Should it be static? arch/arm64/kernel/vdso/vgettimeofday.c:21:5: warning: symbol '__kernel_clock_getres' was not declared. Should it be static?
Rework so the variables are exported, since these variables are created and used in vdso/vgettimeofday.c, also used in vdso.lds.S.
--- arch/arm64/include/asm/vdso/gettimeofday.h | 7 +++++++ arch/arm64/kernel/vdso/vgettimeofday.c | 1 + 2 files changed, 8 insertions(+)
arch/arm64/include/asm/vdso/gettimeofday.h +7 -0
@@ -12,6 +12,13 @@#define VDSO_HAS_CLOCK_GETRES 1 +extern int __kernel_clock_gettime (clockid_t clock, +struct __kernel_timespec *ts); +extern int __kernel_gettimeofday (struct __kernel_old_timeval *tv, +struct timezone *tz); +extern int __kernel_clock_getres (clockid_t clock_id, +struct __kernel_timespec *res); +static __always_inline int gettimeofday_fallback(struct __kernel_old_timeval *_tv,struct timezone *_tz)
arch/arm64/kernel/vdso/vgettimeofday.c +1 -0
@@ -5,6 +5,7 @@* Copyright (C) 2018 ARM Limited * */ +#include <asm/vdso/gettimeofday.h> int __kernel_clock_gettime (clockid_t clock,struct __kernel_timespec *ts)
Signature · 1 line
2.33.0
Will Deacon
maintainerQuoted 9 lines · Anders Roxell
When building the kernel with sparse enabled 'C=1' the following warnings can be seen:
arch/arm64/kernel/vdso/vgettimeofday.c:9:5: warning: symbol '__kernel_clock_gettime' was not declared. Should it be static?arch/arm64/kernel/vdso/vgettimeofday.c:15:5: warning: symbol '__kernel_gettimeofday' was not declared. Should it be static?arch/arm64/kernel/vdso/vgettimeofday.c:21:5: warning: symbol '__kernel_clock_getres' was not declared. Should it be static?Rework so the variables are exported, since these variables are created and used in
vdso/vgettimeofday.c, also used invdso.lds.S.
Hmm, these functions are part of the vDSO and shouldn't be called from the kernel, so I don't think it makes sense to add prototypes for them to a kernel header, to be honest.
Will
Quoted 9 lines · Will Deacon
Quoted 7 lines · Anders Roxell
When building the kernel with sparse enabled 'C=1' the following warnings can be seen:
arch/arm64/kernel/vdso/vgettimeofday.c:9:5: warning: symbol '__kernel_clock_gettime' was not declared. Should it be static?arch/arm64/kernel/vdso/vgettimeofday.c:15:5: warning: symbol '__kernel_gettimeofday' was not declared. Should it be static?arch/arm64/kernel/vdso/vgettimeofday.c:21:5: warning: symbol '__kernel_clock_getres' was not declared. Should it be static?
Quoted 6 lines
Quoted 2 lines
Rework so the variables are exported, since these variables are created and used in
vdso/vgettimeofday.c, also used invdso.lds.S.Hmm, these functions are part of the vDSO and shouldn't be called from the kernel, so I don't think it makes sense to add prototypes for them to a kernel header, to be honest.
It's a recurring problem, and I have recommended this method to Anders as I don't see any of the alternatives as better.
The thing is that both sparse (with make C=1) and gcc/clang (with make W=1) warn about missing prototypes, and this catches a lot of real bugs. I hope that we can eventually get to the point of enabling the warning by default for all files, but that means we need a declaration for each global function and variable.
It's possible to work around this by adding a declaration just before the function definition to shut up those warnings, but I think that's worse because we should not encourage having declarations in .c files where they may get out of sync with a definition in another file. It's also possible that some of the tools will start warning about extern declarations in .c files for this reason, so it would end up as double work to add them here and move them later.
Arnd
Catalin Marinas
maintainerQuoted 16 lines · Arnd Bergmann
Quoted 8 lines · Will Deacon
Quoted 7 lines · Anders Roxell
When building the kernel with sparse enabled 'C=1' the following warnings can be seen:
arch/arm64/kernel/vdso/vgettimeofday.c:9:5: warning: symbol '__kernel_clock_gettime' was not declared. Should it be static?arch/arm64/kernel/vdso/vgettimeofday.c:15:5: warning: symbol '__kernel_gettimeofday' was not declared. Should it be static?arch/arm64/kernel/vdso/vgettimeofday.c:21:5: warning: symbol '__kernel_clock_getres' was not declared. Should it be static?Quoted 6 lines
Quoted 2 lines
Rework so the variables are exported, since these variables are created and used in
vdso/vgettimeofday.c, also used invdso.lds.S.Hmm, these functions are part of the vDSO and shouldn't be called from the kernel, so I don't think it makes sense to add prototypes for them to a kernel header, to be honest.
Quoted 8 lines
It's a recurring problem, and I have recommended this method to Anders as I don't see any of the alternatives as better.
The thing is that both sparse (with make C=1) and gcc/clang (with make W=1) warn about missing prototypes, and this catches a lot of real bugs. I hope that we can eventually get to the point of enabling the warning by default for all files, but that means we need a declaration for each global function and variable.
I don't think there's anything in the asm/vdso/gettimeofday.h that is required by the kernel. However, it gets dragged in via the datapage.h. If I got it right, something like this should avoid it and we can include the prototypes:
include/vdso/datapage.h +0 -16
@@ -121,22 +121,6 @@ struct vdso_data { extern struct vdso_data _vdso_data[CS_BASES] __attribute__((visibility("hidden"))); extern struct vdso_data _timens_data[CS_BASES] __attribute__((visibility("hidden"))); -/* -* The generic vDSO implementation requires that gettimeofday.h -* provides: -* - __arch_get_vdso_data(): to get the vdso datapage. -* - __arch_get_hw_counter(): to get the hw counter based on the -* clock_mode. -* - gettimeofday_fallback(): fallback for gettimeofday. -* - clock_gettime_fallback(): fallback for clock_gettime. -* - clock_getres_fallback(): fallback for clock_getres. -*/ -#ifdef ENABLE_COMPAT_VDSO -#include <asm/vdso/compat_gettimeofday.h> -#else -#include <asm/vdso/gettimeofday.h> -#endif /* ENABLE_COMPAT_VDSO */ -#endif /* !__ASSEMBLY__ */ #endif /* __VDSO_DATAPAGE_H */
include/vdso/gettimeofday.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* The generic vDSO implementation requires that gettimeofday.h +* provides: +* - __arch_get_vdso_data(): to get the vdso datapage. +* - __arch_get_hw_counter(): to get the hw counter based on the +* clock_mode. +* - gettimeofday_fallback(): fallback for gettimeofday. +* - clock_gettime_fallback(): fallback for clock_gettime. +* - clock_getres_fallback(): fallback for clock_getres. +*/ +#ifdef ENABLE_COMPAT_VDSO +#include <asm/vdso/compat_gettimeofday.h> +#else +#include <asm/vdso/gettimeofday.h> +#endif /* ENABLE_COMPAT_VDSO */
include/vdso/helpers.h +2 -0
@@ -6,6 +6,8 @@#include <vdso/datapage.h> +#include <asm/barrier.h> + static __always_inline u32 vdso_read_begin(const struct vdso_data *vd) {u32 seq;
lib/vdso/gettimeofday.c +1 -0
@@ -3,6 +3,7 @@* Generic userspace implementations of gettimeofday() and similar. */ #include <vdso/datapage.h> +#include <vdso/gettimeofday.h> #include <vdso/helpers.h> #ifndef vdso_calc_delta
Signature · 1 line
Catalin
Hi Catalin,
Quoted 26 lines · Arnd Bergmann
Quoted 16 lines · Will Deacon
Quoted 8 lines · Anders Roxell
Quoted 7 lines
When building the kernel with sparse enabled 'C=1' the following warnings can be seen:
arch/arm64/kernel/vdso/vgettimeofday.c:9:5: warning: symbol '__kernel_clock_gettime' was not declared. Should it be static?arch/arm64/kernel/vdso/vgettimeofday.c:15:5: warning: symbol '__kernel_gettimeofday' was not declared. Should it be static?arch/arm64/kernel/vdso/vgettimeofday.c:21:5: warning: symbol '__kernel_clock_getres' was not declared. Should it be static?Quoted 6 lines
Quoted 2 lines
Rework so the variables are exported, since these variables are created and used in
vdso/vgettimeofday.c, also used invdso.lds.S.Hmm, these functions are part of the vDSO and shouldn't be called from the kernel, so I don't think it makes sense to add prototypes for them to a kernel header, to be honest.
Quoted 8 lines
It's a recurring problem, and I have recommended this method to Anders as I don't see any of the alternatives as better.
The thing is that both sparse (with make C=1) and gcc/clang (with make W=1) warn about missing prototypes, and this catches a lot of real bugs. I hope that we can eventually get to the point of enabling the warning by default for all files, but that means we need a declaration for each global function and variable.
Quoted 6 lines
I don't think there's anything in the
asm/vdso/gettimeofday.hthat is required by the kernel. However, it gets dragged in via thedatapage.h. If I got it right, something like this should avoid it and we can include the prototypes:
I tested your patch and I still got the same sparse error. So I was thinking that we should keep Anders' arm64/include/asm/vdso/gettimeofday.h part.
The following patch works for me (tested with C=1, ARCH=arm64 defconfig)
arch/arm64/include/asm/vdso/gettimeofday.h +7 -0
@@ -14,6 +14,13 @@#define VDSO_HAS_CLOCK_GETRES 1 +extern int __kernel_clock_gettime (clockid_t clock, +struct __kernel_timespec *ts); +extern int __kernel_gettimeofday (struct __kernel_old_timeval *tv, +struct timezone *tz); +extern int __kernel_clock_getres (clockid_t clock_id, +struct __kernel_timespec *res); +static __always_inline int gettimeofday_fallback(struct __kernel_old_timeval *_tv,struct timezone *_tz)
include/vdso/datapage.h +0 -16
@@ -121,22 +121,6 @@ struct vdso_data { extern struct vdso_data _vdso_data[CS_BASES] __attribute__((visibility("hidden"))); extern struct vdso_data _timens_data[CS_BASES] __attribute__((visibility("hidden"))); -/* -* The generic vDSO implementation requires that gettimeofday.h -* provides: -* - __arch_get_vdso_data(): to get the vdso datapage. -* - __arch_get_hw_counter(): to get the hw counter based on the -* clock_mode. -* - gettimeofday_fallback(): fallback for gettimeofday. -* - clock_gettime_fallback(): fallback for clock_gettime. -* - clock_getres_fallback(): fallback for clock_getres. -*/ -#ifdef ENABLE_COMPAT_VDSO -#include <asm/vdso/compat_gettimeofday.h> -#else -#include <asm/vdso/gettimeofday.h> -#endif /* ENABLE_COMPAT_VDSO */ -#endif /* !__ASSEMBLY__ */ #endif /* __VDSO_DATAPAGE_H */
include/vdso/gettimeofday.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* The generic vDSO implementation requires that gettimeofday.h +* provides: +* - __arch_get_vdso_data(): to get the vdso datapage. +* - __arch_get_hw_counter(): to get the hw counter based on the +* clock_mode. +* - gettimeofday_fallback(): fallback for gettimeofday. +* - clock_gettime_fallback(): fallback for clock_gettime. +* - clock_getres_fallback(): fallback for clock_getres. +*/ +#ifdef ENABLE_COMPAT_VDSO +#include <asm/vdso/compat_gettimeofday.h> +#else +#include <asm/vdso/gettimeofday.h> +#endif /* ENABLE_COMPAT_VDSO */
include/vdso/helpers.h +2 -0
@@ -6,6 +6,8 @@#include <vdso/datapage.h> +#include <asm/barrier.h> + static __always_inline u32 vdso_read_begin(const struct vdso_data *vd) {u32 seq;
lib/vdso/gettimeofday.c +1 -0
@@ -3,6 +3,7 @@* Generic userspace implementations of gettimeofday() and similar. */ #include <vdso/datapage.h> +#include <vdso/gettimeofday.h> #include <vdso/helpers.h> #ifndef vdso_calc_delta
thanks,
Miles
Signature · 1 line
2.18.0