* [PATCH] clocksource/drivers/arm_arch_timer: Force inlining of erratum_set_next_event_generic()
@ 2021-11-17 11:35 Marc Zyngier
2021-11-17 16:40 ` Sami Tolvanen
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Marc Zyngier @ 2021-11-17 11:35 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel
Cc: kernel-team, Greg Kroah-Hartman, Mark Rutland, Daniel Lezcano,
Sami Tolvanen, Nick Desaulniers
With some specific kernel configuration and Clang, the kernel fails
to like with something like:
ld.lld: error: undefined symbol: __compiletime_assert_200
>>> referenced by arch_timer.h:156 (./arch/arm64/include/asm/arch_timer.h:156)
>>> clocksource/arm_arch_timer.o:(erratum_set_next_event_generic) in archive drivers/built-in.a
ld.lld: error: undefined symbol: __compiletime_assert_197
>>> referenced by arch_timer.h:133 (./arch/arm64/include/asm/arch_timer.h:133)
>>> clocksource/arm_arch_timer.o:(erratum_set_next_event_generic) in archive drivers/built-in.a
make: *** [Makefile:1161: vmlinux] Error 1
These are due to the BUILD_BUG() macros contained in the low-level
accessors (arch_timer_reg_{write,read}_cp15) being emitted, as the
access type wasn't known at compile time.
Fix this by making erratum_set_next_event_generic() __force_inline,
resulting in the 'access' parameter to be resolved at compile time,
similarly to what is already done for set_next_event().
Fixes: 4775bc63f880 ("Add build-time guards for unhandled register accesses")
Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Sami Tolvanen <samitolvanen@google.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
---
drivers/clocksource/arm_arch_timer.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 9a04eacc4412..1ecd52f903b8 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -394,8 +394,13 @@ EXPORT_SYMBOL_GPL(timer_unstable_counter_workaround);
static atomic_t timer_unstable_counter_workaround_in_use = ATOMIC_INIT(0);
-static void erratum_set_next_event_generic(const int access, unsigned long evt,
- struct clock_event_device *clk)
+/*
+ * Force the inlining of this function so that the register accesses
+ * can be themselves correctly inlined.
+ */
+static __always_inline
+void erratum_set_next_event_generic(const int access, unsigned long evt,
+ struct clock_event_device *clk)
{
unsigned long ctrl;
u64 cval;
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] clocksource/drivers/arm_arch_timer: Force inlining of erratum_set_next_event_generic()
2021-11-17 11:35 [PATCH] clocksource/drivers/arm_arch_timer: Force inlining of erratum_set_next_event_generic() Marc Zyngier
@ 2021-11-17 16:40 ` Sami Tolvanen
2021-11-17 19:24 ` Nathan Chancellor
2021-12-11 13:05 ` [tip: timers/urgent] " tip-bot2 for Marc Zyngier
2 siblings, 0 replies; 4+ messages in thread
From: Sami Tolvanen @ 2021-11-17 16:40 UTC (permalink / raw)
To: Marc Zyngier
Cc: linux-kernel, linux-arm-kernel, kernel-team, Greg Kroah-Hartman,
Mark Rutland, Daniel Lezcano, Nick Desaulniers
On Wed, Nov 17, 2021 at 3:35 AM Marc Zyngier <maz@kernel.org> wrote:
>
> With some specific kernel configuration and Clang, the kernel fails
> to like with something like:
>
> ld.lld: error: undefined symbol: __compiletime_assert_200
> >>> referenced by arch_timer.h:156 (./arch/arm64/include/asm/arch_timer.h:156)
> >>> clocksource/arm_arch_timer.o:(erratum_set_next_event_generic) in archive drivers/built-in.a
>
> ld.lld: error: undefined symbol: __compiletime_assert_197
> >>> referenced by arch_timer.h:133 (./arch/arm64/include/asm/arch_timer.h:133)
> >>> clocksource/arm_arch_timer.o:(erratum_set_next_event_generic) in archive drivers/built-in.a
> make: *** [Makefile:1161: vmlinux] Error 1
>
> These are due to the BUILD_BUG() macros contained in the low-level
> accessors (arch_timer_reg_{write,read}_cp15) being emitted, as the
> access type wasn't known at compile time.
>
> Fix this by making erratum_set_next_event_generic() __force_inline,
> resulting in the 'access' parameter to be resolved at compile time,
> similarly to what is already done for set_next_event().
>
> Fixes: 4775bc63f880 ("Add build-time guards for unhandled register accesses")
> Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Sami Tolvanen <samitolvanen@google.com>
> Cc: Nick Desaulniers <ndesaulniers@google.com>
> ---
> drivers/clocksource/arm_arch_timer.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
Thanks, Marc. I can confirm that this fixes the build issue for me.
Tested-by: Sami Tolvanen <samitolvanen@google.com>
Sami
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clocksource/drivers/arm_arch_timer: Force inlining of erratum_set_next_event_generic()
2021-11-17 11:35 [PATCH] clocksource/drivers/arm_arch_timer: Force inlining of erratum_set_next_event_generic() Marc Zyngier
2021-11-17 16:40 ` Sami Tolvanen
@ 2021-11-17 19:24 ` Nathan Chancellor
2021-12-11 13:05 ` [tip: timers/urgent] " tip-bot2 for Marc Zyngier
2 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2021-11-17 19:24 UTC (permalink / raw)
To: Marc Zyngier
Cc: linux-kernel, linux-arm-kernel, kernel-team, Greg Kroah-Hartman,
Mark Rutland, Daniel Lezcano, Sami Tolvanen, Nick Desaulniers
On Wed, Nov 17, 2021 at 11:35:32AM +0000, Marc Zyngier wrote:
> With some specific kernel configuration and Clang, the kernel fails
> to like with something like:
Specifically, CONFIG_CFI_CLANG=y from what I could tell from looking
into this: https://github.com/ClangBuiltLinux/linux/issues/1503
> ld.lld: error: undefined symbol: __compiletime_assert_200
> >>> referenced by arch_timer.h:156 (./arch/arm64/include/asm/arch_timer.h:156)
> >>> clocksource/arm_arch_timer.o:(erratum_set_next_event_generic) in archive drivers/built-in.a
>
> ld.lld: error: undefined symbol: __compiletime_assert_197
> >>> referenced by arch_timer.h:133 (./arch/arm64/include/asm/arch_timer.h:133)
> >>> clocksource/arm_arch_timer.o:(erratum_set_next_event_generic) in archive drivers/built-in.a
> make: *** [Makefile:1161: vmlinux] Error 1
>
> These are due to the BUILD_BUG() macros contained in the low-level
> accessors (arch_timer_reg_{write,read}_cp15) being emitted, as the
> access type wasn't known at compile time.
>
> Fix this by making erratum_set_next_event_generic() __force_inline,
> resulting in the 'access' parameter to be resolved at compile time,
> similarly to what is already done for set_next_event().
>
> Fixes: 4775bc63f880 ("Add build-time guards for unhandled register accesses")
It looks like the prefix was removed? Shouldn't it be:
Fixes: 4775bc63f880 ("clocksource/arm_arch_timer: Add build-time guards for unhandled register accesses")
> Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Sami Tolvanen <samitolvanen@google.com>
> Cc: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
> ---
> drivers/clocksource/arm_arch_timer.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> index 9a04eacc4412..1ecd52f903b8 100644
> --- a/drivers/clocksource/arm_arch_timer.c
> +++ b/drivers/clocksource/arm_arch_timer.c
> @@ -394,8 +394,13 @@ EXPORT_SYMBOL_GPL(timer_unstable_counter_workaround);
>
> static atomic_t timer_unstable_counter_workaround_in_use = ATOMIC_INIT(0);
>
> -static void erratum_set_next_event_generic(const int access, unsigned long evt,
> - struct clock_event_device *clk)
> +/*
> + * Force the inlining of this function so that the register accesses
> + * can be themselves correctly inlined.
> + */
> +static __always_inline
> +void erratum_set_next_event_generic(const int access, unsigned long evt,
> + struct clock_event_device *clk)
> {
> unsigned long ctrl;
> u64 cval;
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip: timers/urgent] clocksource/drivers/arm_arch_timer: Force inlining of erratum_set_next_event_generic()
2021-11-17 11:35 [PATCH] clocksource/drivers/arm_arch_timer: Force inlining of erratum_set_next_event_generic() Marc Zyngier
2021-11-17 16:40 ` Sami Tolvanen
2021-11-17 19:24 ` Nathan Chancellor
@ 2021-12-11 13:05 ` tip-bot2 for Marc Zyngier
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Marc Zyngier @ 2021-12-11 13:05 UTC (permalink / raw)
To: linux-tip-commits
Cc: Greg Kroah-Hartman, Marc Zyngier, Mark Rutland, Daniel Lezcano,
Sami Tolvanen, Nick Desaulniers, Nathan Chancellor, x86,
linux-kernel
The following commit has been merged into the timers/urgent branch of tip:
Commit-ID: 1edb7e74a7d3d64dc4e69e7059b4eea526d19a10
Gitweb: https://git.kernel.org/tip/1edb7e74a7d3d64dc4e69e7059b4eea526d19a10
Author: Marc Zyngier <maz@kernel.org>
AuthorDate: Wed, 17 Nov 2021 11:35:32
Committer: Daniel Lezcano <daniel.lezcano@linaro.org>
CommitterDate: Fri, 10 Dec 2021 17:47:00 +01:00
clocksource/drivers/arm_arch_timer: Force inlining of erratum_set_next_event_generic()
With some specific kernel configuration and Clang, the kernel fails
to like with something like:
ld.lld: error: undefined symbol: __compiletime_assert_200
>>> referenced by arch_timer.h:156 (./arch/arm64/include/asm/arch_timer.h:156)
>>> clocksource/arm_arch_timer.o:(erratum_set_next_event_generic) in archive drivers/built-in.a
ld.lld: error: undefined symbol: __compiletime_assert_197
>>> referenced by arch_timer.h:133 (./arch/arm64/include/asm/arch_timer.h:133)
>>> clocksource/arm_arch_timer.o:(erratum_set_next_event_generic) in archive drivers/built-in.a
make: *** [Makefile:1161: vmlinux] Error 1
These are due to the BUILD_BUG() macros contained in the low-level
accessors (arch_timer_reg_{write,read}_cp15) being emitted, as the
access type wasn't known at compile time.
Fix this by making erratum_set_next_event_generic() __force_inline,
resulting in the 'access' parameter to be resolved at compile time,
similarly to what is already done for set_next_event().
Fixes: 4775bc63f880 ("Add build-time guards for unhandled register accesses")
Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Sami Tolvanen <samitolvanen@google.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211117113532.3895208-1-maz@kernel.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/clocksource/arm_arch_timer.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 9a04eac..1ecd52f 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -394,8 +394,13 @@ EXPORT_SYMBOL_GPL(timer_unstable_counter_workaround);
static atomic_t timer_unstable_counter_workaround_in_use = ATOMIC_INIT(0);
-static void erratum_set_next_event_generic(const int access, unsigned long evt,
- struct clock_event_device *clk)
+/*
+ * Force the inlining of this function so that the register accesses
+ * can be themselves correctly inlined.
+ */
+static __always_inline
+void erratum_set_next_event_generic(const int access, unsigned long evt,
+ struct clock_event_device *clk)
{
unsigned long ctrl;
u64 cval;
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-11 13:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-17 11:35 [PATCH] clocksource/drivers/arm_arch_timer: Force inlining of erratum_set_next_event_generic() Marc Zyngier
2021-11-17 16:40 ` Sami Tolvanen
2021-11-17 19:24 ` Nathan Chancellor
2021-12-11 13:05 ` [tip: timers/urgent] " tip-bot2 for Marc Zyngier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).