Skip to contentSkip to conversation

arm64: ftrace: forbid CALL_OPS with CC_OPTIMIZE_FOR_SIZE

PATCH Applied Mark Rutland 3 participants 3 messages Feb 27, 2023 – Feb 28, 2023 arm64

lore
Share & tools
lore

Mark Rutland

author reviewer
#0 lore raw

PATCH 1/1 arm64: ftrace: forbid CALL_OPS with CC_OPTIMIZE_FOR_SIZE

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.

---
 arch/arm64/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/Kconfig +2 -1
index 27b2592698b0..318c61730d44 100644
@@ -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
Signature · 7 lines
2.30.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Tested-by on v1 1/1
#1 lore raw
Quoted 16 lines · Mark Rutland

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.

Quoted 8 lines

Thanks Mark!

Signature · 6 lines
Florian

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer Applied
#2 lore raw
In reply to Mark Rutland
Quoted 6 lines · Mark Rutland

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

Quoted 7 lines

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
Signature · 7 lines
Catalin


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel