From: Greg Kroah-Hartman Date: Thu, 14 Apr 2022 14:21:15 +0000 (+0200) Subject: drop arm-ftrace-avoid-redundant-loads-or-clobbering-ip.patch X-Git-Tag: v4.19.238~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e94c669dc271bf08fc28b4d147849107dae90226;p=thirdparty%2Fkernel%2Fstable-queue.git drop arm-ftrace-avoid-redundant-loads-or-clobbering-ip.patch --- diff --git a/queue-4.14/arm-ftrace-avoid-redundant-loads-or-clobbering-ip.patch b/queue-4.14/arm-ftrace-avoid-redundant-loads-or-clobbering-ip.patch deleted file mode 100644 index eb5a47f199f..00000000000 --- a/queue-4.14/arm-ftrace-avoid-redundant-loads-or-clobbering-ip.patch +++ /dev/null @@ -1,135 +0,0 @@ -From 7901783d3ec767ec9071be56943ced4ec4ad8d7f Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Sun, 23 Jan 2022 20:18:33 +0100 -Subject: ARM: ftrace: avoid redundant loads or clobbering IP - -From: Ard Biesheuvel - -[ Upstream commit d11967870815b5ab89843980e35aab616c97c463 ] - -Tweak the ftrace return paths to avoid redundant loads of SP, as well as -unnecessary clobbering of IP. - -This also fixes the inconsistency of using MOV to perform a function -return, which is sub-optimal on recent micro-architectures but more -importantly, does not perform an interworking return, unlike compiler -generated function returns in Thumb2 builds. - -Let's fix this by popping PC from the stack like most ordinary code -does. - -Signed-off-by: Ard Biesheuvel -Reviewed-by: Steven Rostedt (Google) -Signed-off-by: Sasha Levin ---- - arch/arm/kernel/entry-ftrace.S | 51 +++++++++++++++------------------- - 1 file changed, 22 insertions(+), 29 deletions(-) - -diff --git a/arch/arm/kernel/entry-ftrace.S b/arch/arm/kernel/entry-ftrace.S -index 1acf4d05e94c..393c342ecd51 100644 ---- a/arch/arm/kernel/entry-ftrace.S -+++ b/arch/arm/kernel/entry-ftrace.S -@@ -41,10 +41,7 @@ - * mcount can be thought of as a function called in the middle of a subroutine - * call. As such, it needs to be transparent for both the caller and the - * callee: the original lr needs to be restored when leaving mcount, and no -- * registers should be clobbered. (In the __gnu_mcount_nc implementation, we -- * clobber the ip register. This is OK because the ARM calling convention -- * allows it to be clobbered in subroutines and doesn't use it to hold -- * parameters.) -+ * registers should be clobbered. - * - * When using dynamic ftrace, we patch out the mcount call by a "mov r0, r0" - * for the mcount case, and a "pop {lr}" for the __gnu_mcount_nc case (see -@@ -96,26 +93,25 @@ - - .macro __ftrace_regs_caller - -- sub sp, sp, #8 @ space for PC and CPSR OLD_R0, -+ str lr, [sp, #-8]! @ store LR as PC and make space for CPSR/OLD_R0, - @ OLD_R0 will overwrite previous LR - -- add ip, sp, #12 @ move in IP the value of SP as it was -- @ before the push {lr} of the mcount mechanism -+ ldr lr, [sp, #8] @ get previous LR - -- str lr, [sp, #0] @ store LR instead of PC -+ str r0, [sp, #8] @ write r0 as OLD_R0 over previous LR - -- ldr lr, [sp, #8] @ get previous LR -+ str lr, [sp, #-4]! @ store previous LR as LR - -- str r0, [sp, #8] @ write r0 as OLD_R0 over previous LR -+ add lr, sp, #16 @ move in LR the value of SP as it was -+ @ before the push {lr} of the mcount mechanism - -- stmdb sp!, {ip, lr} -- stmdb sp!, {r0-r11, lr} -+ push {r0-r11, ip, lr} - - @ stack content at this point: - @ 0 4 48 52 56 60 64 68 72 -- @ R0 | R1 | ... | LR | SP + 4 | previous LR | LR | PSR | OLD_R0 | -+ @ R0 | R1 | ... | IP | SP + 4 | previous LR | LR | PSR | OLD_R0 | - -- mov r3, sp @ struct pt_regs* -+ mov r3, sp @ struct pt_regs* - - ldr r2, =function_trace_op - ldr r2, [r2] @ pointer to the current -@@ -138,11 +134,9 @@ ftrace_graph_regs_call: - #endif - - @ pop saved regs -- ldmia sp!, {r0-r12} @ restore r0 through r12 -- ldr ip, [sp, #8] @ restore PC -- ldr lr, [sp, #4] @ restore LR -- ldr sp, [sp, #0] @ restore SP -- mov pc, ip @ return -+ pop {r0-r11, ip, lr} @ restore r0 through r12 -+ ldr lr, [sp], #4 @ restore LR -+ ldr pc, [sp], #12 - .endm - - #ifdef CONFIG_FUNCTION_GRAPH_TRACER -@@ -158,11 +152,9 @@ ftrace_graph_regs_call: - bl prepare_ftrace_return - - @ pop registers saved in ftrace_regs_caller -- ldmia sp!, {r0-r12} @ restore r0 through r12 -- ldr ip, [sp, #8] @ restore PC -- ldr lr, [sp, #4] @ restore LR -- ldr sp, [sp, #0] @ restore SP -- mov pc, ip @ return -+ pop {r0-r11, ip, lr} @ restore r0 through r12 -+ ldr lr, [sp], #4 @ restore LR -+ ldr pc, [sp], #12 - - .endm - #endif -@@ -273,16 +265,17 @@ ENDPROC(ftrace_graph_caller_old) - .endm - - .macro mcount_exit -- ldmia sp!, {r0-r3, ip, lr} -- ret ip -+ ldmia sp!, {r0-r3} -+ ldr lr, [sp, #4] -+ ldr pc, [sp], #8 - .endm - - ENTRY(__gnu_mcount_nc) - UNWIND(.fnstart) - #ifdef CONFIG_DYNAMIC_FTRACE -- mov ip, lr -- ldmia sp!, {lr} -- ret ip -+ push {lr} -+ ldr lr, [sp, #4] -+ ldr pc, [sp], #8 - #else - __mcount - #endif --- -2.34.1 - diff --git a/queue-4.14/series b/queue-4.14/series index a6e688fd993..25c1326aa0e 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -170,7 +170,6 @@ video-fbdev-cirrusfb-check-pixclock-to-avoid-divide-.patch video-fbdev-omapfb-acx565akm-replace-snprintf-with-s.patch arm-dts-qcom-fix-gic_irq_domain_translate-warnings-f.patch arm-dts-bcm2837-add-the-missing-l1-l2-cache-informat.patch -arm-ftrace-avoid-redundant-loads-or-clobbering-ip.patch video-fbdev-omapfb-panel-dsi-cm-use-sysfs_emit-inste.patch video-fbdev-omapfb-panel-tpo-td043mtea1-use-sysfs_em.patch asoc-soc-core-skip-zero-num_dai-component-in-searchi.patch diff --git a/queue-4.19/arm-ftrace-avoid-redundant-loads-or-clobbering-ip.patch b/queue-4.19/arm-ftrace-avoid-redundant-loads-or-clobbering-ip.patch deleted file mode 100644 index 9cf90bf2708..00000000000 --- a/queue-4.19/arm-ftrace-avoid-redundant-loads-or-clobbering-ip.patch +++ /dev/null @@ -1,135 +0,0 @@ -From 84e5759501033fb4384127dd40f02f935be104d4 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Sun, 23 Jan 2022 20:18:33 +0100 -Subject: ARM: ftrace: avoid redundant loads or clobbering IP - -From: Ard Biesheuvel - -[ Upstream commit d11967870815b5ab89843980e35aab616c97c463 ] - -Tweak the ftrace return paths to avoid redundant loads of SP, as well as -unnecessary clobbering of IP. - -This also fixes the inconsistency of using MOV to perform a function -return, which is sub-optimal on recent micro-architectures but more -importantly, does not perform an interworking return, unlike compiler -generated function returns in Thumb2 builds. - -Let's fix this by popping PC from the stack like most ordinary code -does. - -Signed-off-by: Ard Biesheuvel -Reviewed-by: Steven Rostedt (Google) -Signed-off-by: Sasha Levin ---- - arch/arm/kernel/entry-ftrace.S | 51 +++++++++++++++------------------- - 1 file changed, 22 insertions(+), 29 deletions(-) - -diff --git a/arch/arm/kernel/entry-ftrace.S b/arch/arm/kernel/entry-ftrace.S -index 1acf4d05e94c..393c342ecd51 100644 ---- a/arch/arm/kernel/entry-ftrace.S -+++ b/arch/arm/kernel/entry-ftrace.S -@@ -41,10 +41,7 @@ - * mcount can be thought of as a function called in the middle of a subroutine - * call. As such, it needs to be transparent for both the caller and the - * callee: the original lr needs to be restored when leaving mcount, and no -- * registers should be clobbered. (In the __gnu_mcount_nc implementation, we -- * clobber the ip register. This is OK because the ARM calling convention -- * allows it to be clobbered in subroutines and doesn't use it to hold -- * parameters.) -+ * registers should be clobbered. - * - * When using dynamic ftrace, we patch out the mcount call by a "mov r0, r0" - * for the mcount case, and a "pop {lr}" for the __gnu_mcount_nc case (see -@@ -96,26 +93,25 @@ - - .macro __ftrace_regs_caller - -- sub sp, sp, #8 @ space for PC and CPSR OLD_R0, -+ str lr, [sp, #-8]! @ store LR as PC and make space for CPSR/OLD_R0, - @ OLD_R0 will overwrite previous LR - -- add ip, sp, #12 @ move in IP the value of SP as it was -- @ before the push {lr} of the mcount mechanism -+ ldr lr, [sp, #8] @ get previous LR - -- str lr, [sp, #0] @ store LR instead of PC -+ str r0, [sp, #8] @ write r0 as OLD_R0 over previous LR - -- ldr lr, [sp, #8] @ get previous LR -+ str lr, [sp, #-4]! @ store previous LR as LR - -- str r0, [sp, #8] @ write r0 as OLD_R0 over previous LR -+ add lr, sp, #16 @ move in LR the value of SP as it was -+ @ before the push {lr} of the mcount mechanism - -- stmdb sp!, {ip, lr} -- stmdb sp!, {r0-r11, lr} -+ push {r0-r11, ip, lr} - - @ stack content at this point: - @ 0 4 48 52 56 60 64 68 72 -- @ R0 | R1 | ... | LR | SP + 4 | previous LR | LR | PSR | OLD_R0 | -+ @ R0 | R1 | ... | IP | SP + 4 | previous LR | LR | PSR | OLD_R0 | - -- mov r3, sp @ struct pt_regs* -+ mov r3, sp @ struct pt_regs* - - ldr r2, =function_trace_op - ldr r2, [r2] @ pointer to the current -@@ -138,11 +134,9 @@ ftrace_graph_regs_call: - #endif - - @ pop saved regs -- ldmia sp!, {r0-r12} @ restore r0 through r12 -- ldr ip, [sp, #8] @ restore PC -- ldr lr, [sp, #4] @ restore LR -- ldr sp, [sp, #0] @ restore SP -- mov pc, ip @ return -+ pop {r0-r11, ip, lr} @ restore r0 through r12 -+ ldr lr, [sp], #4 @ restore LR -+ ldr pc, [sp], #12 - .endm - - #ifdef CONFIG_FUNCTION_GRAPH_TRACER -@@ -158,11 +152,9 @@ ftrace_graph_regs_call: - bl prepare_ftrace_return - - @ pop registers saved in ftrace_regs_caller -- ldmia sp!, {r0-r12} @ restore r0 through r12 -- ldr ip, [sp, #8] @ restore PC -- ldr lr, [sp, #4] @ restore LR -- ldr sp, [sp, #0] @ restore SP -- mov pc, ip @ return -+ pop {r0-r11, ip, lr} @ restore r0 through r12 -+ ldr lr, [sp], #4 @ restore LR -+ ldr pc, [sp], #12 - - .endm - #endif -@@ -273,16 +265,17 @@ ENDPROC(ftrace_graph_caller_old) - .endm - - .macro mcount_exit -- ldmia sp!, {r0-r3, ip, lr} -- ret ip -+ ldmia sp!, {r0-r3} -+ ldr lr, [sp, #4] -+ ldr pc, [sp], #8 - .endm - - ENTRY(__gnu_mcount_nc) - UNWIND(.fnstart) - #ifdef CONFIG_DYNAMIC_FTRACE -- mov ip, lr -- ldmia sp!, {lr} -- ret ip -+ push {lr} -+ ldr lr, [sp, #4] -+ ldr pc, [sp], #8 - #else - __mcount - #endif --- -2.34.1 - diff --git a/queue-4.19/series b/queue-4.19/series index cb680610a89..51314232de1 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -205,7 +205,6 @@ video-fbdev-cirrusfb-check-pixclock-to-avoid-divide-.patch video-fbdev-omapfb-acx565akm-replace-snprintf-with-s.patch arm-dts-qcom-fix-gic_irq_domain_translate-warnings-f.patch arm-dts-bcm2837-add-the-missing-l1-l2-cache-informat.patch -arm-ftrace-avoid-redundant-loads-or-clobbering-ip.patch video-fbdev-omapfb-panel-dsi-cm-use-sysfs_emit-inste.patch video-fbdev-omapfb-panel-tpo-td043mtea1-use-sysfs_em.patch video-fbdev-udlfb-replace-snprintf-in-show-functions.patch diff --git a/queue-5.4/arm-ftrace-avoid-redundant-loads-or-clobbering-ip.patch b/queue-5.4/arm-ftrace-avoid-redundant-loads-or-clobbering-ip.patch deleted file mode 100644 index 52b2066137e..00000000000 --- a/queue-5.4/arm-ftrace-avoid-redundant-loads-or-clobbering-ip.patch +++ /dev/null @@ -1,135 +0,0 @@ -From db35b8053101f689e113a794dcb40e8476f2e6a2 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Sun, 23 Jan 2022 20:18:33 +0100 -Subject: ARM: ftrace: avoid redundant loads or clobbering IP - -From: Ard Biesheuvel - -[ Upstream commit d11967870815b5ab89843980e35aab616c97c463 ] - -Tweak the ftrace return paths to avoid redundant loads of SP, as well as -unnecessary clobbering of IP. - -This also fixes the inconsistency of using MOV to perform a function -return, which is sub-optimal on recent micro-architectures but more -importantly, does not perform an interworking return, unlike compiler -generated function returns in Thumb2 builds. - -Let's fix this by popping PC from the stack like most ordinary code -does. - -Signed-off-by: Ard Biesheuvel -Reviewed-by: Steven Rostedt (Google) -Signed-off-by: Sasha Levin ---- - arch/arm/kernel/entry-ftrace.S | 51 +++++++++++++++------------------- - 1 file changed, 22 insertions(+), 29 deletions(-) - -diff --git a/arch/arm/kernel/entry-ftrace.S b/arch/arm/kernel/entry-ftrace.S -index f4886fb6e9ba..f33c171e3090 100644 ---- a/arch/arm/kernel/entry-ftrace.S -+++ b/arch/arm/kernel/entry-ftrace.S -@@ -22,10 +22,7 @@ - * mcount can be thought of as a function called in the middle of a subroutine - * call. As such, it needs to be transparent for both the caller and the - * callee: the original lr needs to be restored when leaving mcount, and no -- * registers should be clobbered. (In the __gnu_mcount_nc implementation, we -- * clobber the ip register. This is OK because the ARM calling convention -- * allows it to be clobbered in subroutines and doesn't use it to hold -- * parameters.) -+ * registers should be clobbered. - * - * When using dynamic ftrace, we patch out the mcount call by a "pop {lr}" - * instead of the __gnu_mcount_nc call (see arch/arm/kernel/ftrace.c). -@@ -70,26 +67,25 @@ - - .macro __ftrace_regs_caller - -- sub sp, sp, #8 @ space for PC and CPSR OLD_R0, -+ str lr, [sp, #-8]! @ store LR as PC and make space for CPSR/OLD_R0, - @ OLD_R0 will overwrite previous LR - -- add ip, sp, #12 @ move in IP the value of SP as it was -- @ before the push {lr} of the mcount mechanism -+ ldr lr, [sp, #8] @ get previous LR - -- str lr, [sp, #0] @ store LR instead of PC -+ str r0, [sp, #8] @ write r0 as OLD_R0 over previous LR - -- ldr lr, [sp, #8] @ get previous LR -+ str lr, [sp, #-4]! @ store previous LR as LR - -- str r0, [sp, #8] @ write r0 as OLD_R0 over previous LR -+ add lr, sp, #16 @ move in LR the value of SP as it was -+ @ before the push {lr} of the mcount mechanism - -- stmdb sp!, {ip, lr} -- stmdb sp!, {r0-r11, lr} -+ push {r0-r11, ip, lr} - - @ stack content at this point: - @ 0 4 48 52 56 60 64 68 72 -- @ R0 | R1 | ... | LR | SP + 4 | previous LR | LR | PSR | OLD_R0 | -+ @ R0 | R1 | ... | IP | SP + 4 | previous LR | LR | PSR | OLD_R0 | - -- mov r3, sp @ struct pt_regs* -+ mov r3, sp @ struct pt_regs* - - ldr r2, =function_trace_op - ldr r2, [r2] @ pointer to the current -@@ -112,11 +108,9 @@ ftrace_graph_regs_call: - #endif - - @ pop saved regs -- ldmia sp!, {r0-r12} @ restore r0 through r12 -- ldr ip, [sp, #8] @ restore PC -- ldr lr, [sp, #4] @ restore LR -- ldr sp, [sp, #0] @ restore SP -- mov pc, ip @ return -+ pop {r0-r11, ip, lr} @ restore r0 through r12 -+ ldr lr, [sp], #4 @ restore LR -+ ldr pc, [sp], #12 - .endm - - #ifdef CONFIG_FUNCTION_GRAPH_TRACER -@@ -132,11 +126,9 @@ ftrace_graph_regs_call: - bl prepare_ftrace_return - - @ pop registers saved in ftrace_regs_caller -- ldmia sp!, {r0-r12} @ restore r0 through r12 -- ldr ip, [sp, #8] @ restore PC -- ldr lr, [sp, #4] @ restore LR -- ldr sp, [sp, #0] @ restore SP -- mov pc, ip @ return -+ pop {r0-r11, ip, lr} @ restore r0 through r12 -+ ldr lr, [sp], #4 @ restore LR -+ ldr pc, [sp], #12 - - .endm - #endif -@@ -202,16 +194,17 @@ ftrace_graph_call\suffix: - .endm - - .macro mcount_exit -- ldmia sp!, {r0-r3, ip, lr} -- ret ip -+ ldmia sp!, {r0-r3} -+ ldr lr, [sp, #4] -+ ldr pc, [sp], #8 - .endm - - ENTRY(__gnu_mcount_nc) - UNWIND(.fnstart) - #ifdef CONFIG_DYNAMIC_FTRACE -- mov ip, lr -- ldmia sp!, {lr} -- ret ip -+ push {lr} -+ ldr lr, [sp, #4] -+ ldr pc, [sp], #8 - #else - __mcount - #endif --- -2.34.1 - diff --git a/queue-5.4/series b/queue-5.4/series index dc146541239..3af3807235c 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -295,7 +295,6 @@ video-fbdev-omapfb-acx565akm-replace-snprintf-with-s.patch arm-dts-qcom-fix-gic_irq_domain_translate-warnings-f.patch arm-dts-bcm2837-add-the-missing-l1-l2-cache-informat.patch asoc-madera-add-dependencies-on-mfd.patch -arm-ftrace-avoid-redundant-loads-or-clobbering-ip.patch video-fbdev-omapfb-panel-dsi-cm-use-sysfs_emit-inste.patch video-fbdev-omapfb-panel-tpo-td043mtea1-use-sysfs_em.patch video-fbdev-udlfb-replace-snprintf-in-show-functions.patch