* [PATCH] arm64: ftrace: forbid CALL_OPS with CC_OPTIMIZE_FOR_SIZE
@ 2023-02-27 11:58 Mark Rutland
2023-02-27 19:56 ` Florian Fainelli
2023-02-28 13:54 ` Catalin Marinas
0 siblings, 2 replies; 3+ messages in thread
From: Mark Rutland @ 2023-02-27 11:58 UTC (permalink / raw)
To: linux-arm-kernel
Cc: catalin.marinas, f.fainelli, mark.rutland, maz, rostedt,
stefan.wahren, will
Florian reports that when building with CONFIG_CC_OPTIMIZE_FOR_SIZE=y,
he sees "Misaligned patch-site" warnings at boot, e.g.
| Misaligned patch-site bcm2836_arm_irqchip_handle_irq+0x0/0x88
| WARNING: CPU: 0 PID: 0 at arch/arm64/kernel/ftrace.c:120 ftrace_call_adjust+0x4c/0x70
This is because GCC will silently ignore `-falign-functions=N` when
passed `-Os`, resulting in functions not being aligned as we expect.
This is a known issue, and to account for this we modified the kernel to
avoid `-Os` generally. Unfortunately we forgot to account for
CONFIG_CC_OPTIMIZE_FOR_SIZE.
Forbid the use of CALL_OPS with CONFIG_CC_OPTIMIZE_FOR_SIZE=y to prevent
this issue. All exising ftrace features will work as before, though
without the performance benefit of CALL_OPS.
Reported-by: Florian Fainelli <f.fainelli@gmail.com>
Link: http://lore.kernel.org/linux-arm-kernel/2d9284c3-3805-402b-5423-520ced56d047@gmail.com
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Stefan Wahren <stefan.wahren@i2se.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Will Deacon <will@kernel.org>
---
arch/arm64/Kconfig | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 27b2592698b0..318c61730d44 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -187,7 +187,8 @@ config ARM64
select HAVE_DMA_CONTIGUOUS
select HAVE_DYNAMIC_FTRACE
select HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS \
- if (DYNAMIC_FTRACE_WITH_ARGS && !CFI_CLANG)
+ if (DYNAMIC_FTRACE_WITH_ARGS && !CFI_CLANG && \
+ !CC_OPTIMIZE_FOR_SIZE)
select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY \
if DYNAMIC_FTRACE_WITH_ARGS
select HAVE_EFFICIENT_UNALIGNED_ACCESS
--
2.30.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] arm64: ftrace: forbid CALL_OPS with CC_OPTIMIZE_FOR_SIZE
2023-02-27 11:58 [PATCH] arm64: ftrace: forbid CALL_OPS with CC_OPTIMIZE_FOR_SIZE Mark Rutland
@ 2023-02-27 19:56 ` Florian Fainelli
2023-02-28 13:54 ` Catalin Marinas
1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2023-02-27 19:56 UTC (permalink / raw)
To: Mark Rutland, linux-arm-kernel
Cc: catalin.marinas, maz, rostedt, stefan.wahren, will
On 2/27/2023 3:58 AM, Mark Rutland wrote:
> Florian reports that when building with CONFIG_CC_OPTIMIZE_FOR_SIZE=y,
> he sees "Misaligned patch-site" warnings at boot, e.g.
>
> | Misaligned patch-site bcm2836_arm_irqchip_handle_irq+0x0/0x88
> | WARNING: CPU: 0 PID: 0 at arch/arm64/kernel/ftrace.c:120 ftrace_call_adjust+0x4c/0x70
>
> This is because GCC will silently ignore `-falign-functions=N` when
> passed `-Os`, resulting in functions not being aligned as we expect.
> This is a known issue, and to account for this we modified the kernel to
> avoid `-Os` generally. Unfortunately we forgot to account for
> CONFIG_CC_OPTIMIZE_FOR_SIZE.
>
> Forbid the use of CALL_OPS with CONFIG_CC_OPTIMIZE_FOR_SIZE=y to prevent
> this issue. All exising ftrace features will work as before, though
> without the performance benefit of CALL_OPS.
>
> Reported-by: Florian Fainelli <f.fainelli@gmail.com>
> Link: http://lore.kernel.org/linux-arm-kernel/2d9284c3-3805-402b-5423-520ced56d047@gmail.com
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Stefan Wahren <stefan.wahren@i2se.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Will Deacon <will@kernel.org>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Thanks Mark!
--
Florian
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] arm64: ftrace: forbid CALL_OPS with CC_OPTIMIZE_FOR_SIZE
2023-02-27 11:58 [PATCH] arm64: ftrace: forbid CALL_OPS with CC_OPTIMIZE_FOR_SIZE Mark Rutland
2023-02-27 19:56 ` Florian Fainelli
@ 2023-02-28 13:54 ` Catalin Marinas
1 sibling, 0 replies; 3+ messages in thread
From: Catalin Marinas @ 2023-02-28 13:54 UTC (permalink / raw)
To: linux-arm-kernel, Mark Rutland
Cc: Will Deacon, f.fainelli, maz, rostedt, stefan.wahren
On Mon, 27 Feb 2023 11:58:19 +0000, Mark Rutland wrote:
> Florian reports that when building with CONFIG_CC_OPTIMIZE_FOR_SIZE=y,
> he sees "Misaligned patch-site" warnings at boot, e.g.
>
> | Misaligned patch-site bcm2836_arm_irqchip_handle_irq+0x0/0x88
> | WARNING: CPU: 0 PID: 0 at arch/arm64/kernel/ftrace.c:120 ftrace_call_adjust+0x4c/0x70
>
> This is because GCC will silently ignore `-falign-functions=N` when
> passed `-Os`, resulting in functions not being aligned as we expect.
> This is a known issue, and to account for this we modified the kernel to
> avoid `-Os` generally. Unfortunately we forgot to account for
> CONFIG_CC_OPTIMIZE_FOR_SIZE.
>
> [...]
Applied to arm64 (for-next/core), thanks!
[1/1] arm64: ftrace: forbid CALL_OPS with CC_OPTIMIZE_FOR_SIZE
https://git.kernel.org/arm64/c/b3f11af9b2ce
--
Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-28 13:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-27 11:58 [PATCH] arm64: ftrace: forbid CALL_OPS with CC_OPTIMIZE_FOR_SIZE Mark Rutland
2023-02-27 19:56 ` Florian Fainelli
2023-02-28 13:54 ` Catalin Marinas
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).