+++ /dev/null
-From ee2f47969656f7ab507c4c3f776f28ea6067bb58 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 2 May 2022 22:50:10 +1000
-Subject: powerpc/vdso: Fix incorrect CFI in gettimeofday.S
-
-From: Michael Ellerman <mpe@ellerman.id.au>
-
-[ Upstream commit 6d65028eb67dbb7627651adfc460d64196d38bd8 ]
-
-As reported by Alan, the CFI (Call Frame Information) in the VDSO time
-routines is incorrect since commit ce7d8056e38b ("powerpc/vdso: Prepare
-for switching VDSO to generic C implementation.").
-
-DWARF has a concept called the CFA (Canonical Frame Address), which on
-powerpc is calculated as an offset from the stack pointer (r1). That
-means when the stack pointer is changed there must be a corresponding
-CFI directive to update the calculation of the CFA.
-
-The current code is missing those directives for the changes to r1,
-which prevents gdb from being able to generate a backtrace from inside
-VDSO functions, eg:
-
- Breakpoint 1, 0x00007ffff7f804dc in __kernel_clock_gettime ()
- (gdb) bt
- #0 0x00007ffff7f804dc in __kernel_clock_gettime ()
- #1 0x00007ffff7d8872c in clock_gettime@@GLIBC_2.17 () from /lib64/libc.so.6
- #2 0x00007fffffffd960 in ?? ()
- #3 0x00007ffff7d8872c in clock_gettime@@GLIBC_2.17 () from /lib64/libc.so.6
- Backtrace stopped: frame did not save the PC
-
-Alan helpfully describes some rules for correctly maintaining the CFI information:
-
- 1) Every adjustment to the current frame address reg (ie. r1) must be
- described, and exactly at the instruction where r1 changes. Why?
- Because stack unwinding might want to access previous frames.
-
- 2) If a function changes LR or any non-volatile register, the save
- location for those regs must be given. The CFI can be at any
- instruction after the saves up to the point that the reg is
- changed.
- (Exception: LR save should be described before a bl. not after)
-
- 3) If asychronous unwind info is needed then restores of LR and
- non-volatile regs must also be described. The CFI can be at any
- instruction after the reg is restored up to the point where the
- save location is (potentially) trashed.
-
-Fix the inability to backtrace by adding CFI directives describing the
-changes to r1, ie. satisfying rule 1.
-
-Also change the information for LR to point to the copy saved on the
-stack, not the value in r0 that will be overwritten by the function
-call.
-
-Finally, add CFI directives describing the save/restore of r2.
-
-With the fix gdb can correctly back trace and navigate up and down the stack:
-
- Breakpoint 1, 0x00007ffff7f804dc in __kernel_clock_gettime ()
- (gdb) bt
- #0 0x00007ffff7f804dc in __kernel_clock_gettime ()
- #1 0x00007ffff7d8872c in clock_gettime@@GLIBC_2.17 () from /lib64/libc.so.6
- #2 0x0000000100015b60 in gettime ()
- #3 0x000000010000c8bc in print_long_format ()
- #4 0x000000010000d180 in print_current_files ()
- #5 0x00000001000054ac in main ()
- (gdb) up
- #1 0x00007ffff7d8872c in clock_gettime@@GLIBC_2.17 () from /lib64/libc.so.6
- (gdb)
- #2 0x0000000100015b60 in gettime ()
- (gdb)
- #3 0x000000010000c8bc in print_long_format ()
- (gdb)
- #4 0x000000010000d180 in print_current_files ()
- (gdb)
- #5 0x00000001000054ac in main ()
- (gdb)
- Initial frame selected; you cannot go up.
- (gdb) down
- #4 0x000000010000d180 in print_current_files ()
- (gdb)
- #3 0x000000010000c8bc in print_long_format ()
- (gdb)
- #2 0x0000000100015b60 in gettime ()
- (gdb)
- #1 0x00007ffff7d8872c in clock_gettime@@GLIBC_2.17 () from /lib64/libc.so.6
- (gdb)
- #0 0x00007ffff7f804dc in __kernel_clock_gettime ()
- (gdb)
-
-Fixes: ce7d8056e38b ("powerpc/vdso: Prepare for switching VDSO to generic C implementation.")
-Cc: stable@vger.kernel.org # v5.11+
-Reported-by: Alan Modra <amodra@gmail.com>
-Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-Reviewed-by: Segher Boessenkool <segher@kernel.crashing.org>
-Link: https://lore.kernel.org/r/20220502125010.1319370-1-mpe@ellerman.id.au
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/powerpc/kernel/vdso32/gettimeofday.S | 9 +++++++--
- 1 file changed, 7 insertions(+), 2 deletions(-)
-
-diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S
-index dd2099128b8f..42d40f895c1f 100644
---- a/arch/powerpc/kernel/vdso32/gettimeofday.S
-+++ b/arch/powerpc/kernel/vdso32/gettimeofday.S
-@@ -22,12 +22,15 @@
- .macro cvdso_call funct call_time=0
- .cfi_startproc
- PPC_STLU r1, -PPC_MIN_STKFRM(r1)
-+ .cfi_adjust_cfa_offset PPC_MIN_STKFRM
- mflr r0
-- .cfi_register lr, r0
- PPC_STLU r1, -PPC_MIN_STKFRM(r1)
-+ .cfi_adjust_cfa_offset PPC_MIN_STKFRM
- PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
-+ .cfi_rel_offset lr, PPC_MIN_STKFRM + PPC_LR_STKOFF
- #ifdef __powerpc64__
- PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1)
-+ .cfi_rel_offset r2, PPC_MIN_STKFRM + STK_GOT
- #endif
- get_datapage r5
- .ifeq \call_time
-@@ -39,13 +42,15 @@
- PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
- #ifdef __powerpc64__
- PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1)
-+ .cfi_restore r2
- #endif
- .ifeq \call_time
- cmpwi r3, 0
- .endif
- mtlr r0
-- .cfi_restore lr
- addi r1, r1, 2 * PPC_MIN_STKFRM
-+ .cfi_restore lr
-+ .cfi_def_cfa_offset 0
- crclr so
- .ifeq \call_time
- beqlr+
---
-2.35.1
-
+++ /dev/null
-From 0b7cd13fa76cd848aad5f2f2298615e8b616e0ff Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 21 Jan 2022 16:30:34 +0000
-Subject: powerpc/vdso: Move cvdso_call macro into gettimeofday.S
-
-From: Christophe Leroy <christophe.leroy@csgroup.eu>
-
-[ Upstream commit 692b21d78046851e75dc25bba773189c670b49c2 ]
-
-Now that gettimeofday.S is unique, move cvdso_call macro
-into that file which is the only user.
-
-Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
-Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-Link: https://lore.kernel.org/r/72720359d4c58e3a3b96dd74952741225faac3de.1642782130.git.christophe.leroy@csgroup.eu
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/powerpc/include/asm/vdso/gettimeofday.h | 52 +-------------------
- arch/powerpc/kernel/vdso32/gettimeofday.S | 44 ++++++++++++++++-
- 2 files changed, 45 insertions(+), 51 deletions(-)
-
-diff --git a/arch/powerpc/include/asm/vdso/gettimeofday.h b/arch/powerpc/include/asm/vdso/gettimeofday.h
-index df00e91c9a90..f0a4cf01e85c 100644
---- a/arch/powerpc/include/asm/vdso/gettimeofday.h
-+++ b/arch/powerpc/include/asm/vdso/gettimeofday.h
-@@ -2,57 +2,9 @@
- #ifndef _ASM_POWERPC_VDSO_GETTIMEOFDAY_H
- #define _ASM_POWERPC_VDSO_GETTIMEOFDAY_H
-
--#include <asm/page.h>
--
--#ifdef __ASSEMBLY__
--
--#include <asm/ppc_asm.h>
--
--/*
-- * The macro sets two stack frames, one for the caller and one for the callee
-- * because there are no requirement for the caller to set a stack frame when
-- * calling VDSO so it may have omitted to set one, especially on PPC64
-- */
--
--.macro cvdso_call funct call_time=0
-- .cfi_startproc
-- PPC_STLU r1, -PPC_MIN_STKFRM(r1)
-- mflr r0
-- .cfi_register lr, r0
-- PPC_STLU r1, -PPC_MIN_STKFRM(r1)
-- PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
--#ifdef __powerpc64__
-- PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1)
--#endif
-- get_datapage r5
-- .ifeq \call_time
-- addi r5, r5, VDSO_DATA_OFFSET
-- .else
-- addi r4, r5, VDSO_DATA_OFFSET
-- .endif
-- bl DOTSYM(\funct)
-- PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
--#ifdef __powerpc64__
-- PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1)
--#endif
-- .ifeq \call_time
-- cmpwi r3, 0
-- .endif
-- mtlr r0
-- .cfi_restore lr
-- addi r1, r1, 2 * PPC_MIN_STKFRM
-- crclr so
-- .ifeq \call_time
-- beqlr+
-- crset so
-- neg r3, r3
-- .endif
-- blr
-- .cfi_endproc
--.endm
--
--#else
-+#ifndef __ASSEMBLY__
-
-+#include <asm/page.h>
- #include <asm/vdso/timebase.h>
- #include <asm/barrier.h>
- #include <asm/unistd.h>
-diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S
-index 9b3ac09423c8..dd2099128b8f 100644
---- a/arch/powerpc/kernel/vdso32/gettimeofday.S
-+++ b/arch/powerpc/kernel/vdso32/gettimeofday.S
-@@ -12,7 +12,49 @@
- #include <asm/vdso_datapage.h>
- #include <asm/asm-offsets.h>
- #include <asm/unistd.h>
--#include <asm/vdso/gettimeofday.h>
-+
-+/*
-+ * The macro sets two stack frames, one for the caller and one for the callee
-+ * because there are no requirement for the caller to set a stack frame when
-+ * calling VDSO so it may have omitted to set one, especially on PPC64
-+ */
-+
-+.macro cvdso_call funct call_time=0
-+ .cfi_startproc
-+ PPC_STLU r1, -PPC_MIN_STKFRM(r1)
-+ mflr r0
-+ .cfi_register lr, r0
-+ PPC_STLU r1, -PPC_MIN_STKFRM(r1)
-+ PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
-+#ifdef __powerpc64__
-+ PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1)
-+#endif
-+ get_datapage r5
-+ .ifeq \call_time
-+ addi r5, r5, VDSO_DATA_OFFSET
-+ .else
-+ addi r4, r5, VDSO_DATA_OFFSET
-+ .endif
-+ bl DOTSYM(\funct)
-+ PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
-+#ifdef __powerpc64__
-+ PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1)
-+#endif
-+ .ifeq \call_time
-+ cmpwi r3, 0
-+ .endif
-+ mtlr r0
-+ .cfi_restore lr
-+ addi r1, r1, 2 * PPC_MIN_STKFRM
-+ crclr so
-+ .ifeq \call_time
-+ beqlr+
-+ crset so
-+ neg r3, r3
-+ .endif
-+ blr
-+ .cfi_endproc
-+.endm
-
- .text
- /*
---
-2.35.1
-
+++ /dev/null
-From cdba38a2a3d85a93e10553e853efff9cf09c10cf Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 21 Jan 2022 16:30:30 +0000
-Subject: powerpc/vdso: Remove cvdso_call_time macro
-
-From: Christophe Leroy <christophe.leroy@csgroup.eu>
-
-[ Upstream commit 9b97bea90072a075363a200dd7b54ad4a24e9491 ]
-
-cvdso_call_time macro is very similar to cvdso_call macro.
-
-Add a call_time argument to cvdso_call which is 0 by default
-and set to 1 when using cvdso_call to call __c_kernel_time().
-
-Return returned value as is with CR[SO] cleared when it is used
-for time().
-
-Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
-Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-Link: https://lore.kernel.org/r/837a260ad86fc1ce297a562c2117fd69be5f7b5c.1642782130.git.christophe.leroy@csgroup.eu
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/powerpc/include/asm/vdso/gettimeofday.h | 37 ++++++--------------
- arch/powerpc/kernel/vdso32/gettimeofday.S | 2 +-
- 2 files changed, 11 insertions(+), 28 deletions(-)
-
-diff --git a/arch/powerpc/include/asm/vdso/gettimeofday.h b/arch/powerpc/include/asm/vdso/gettimeofday.h
-index 1faff0be1111..df00e91c9a90 100644
---- a/arch/powerpc/include/asm/vdso/gettimeofday.h
-+++ b/arch/powerpc/include/asm/vdso/gettimeofday.h
-@@ -9,12 +9,12 @@
- #include <asm/ppc_asm.h>
-
- /*
-- * The macros sets two stack frames, one for the caller and one for the callee
-+ * The macro sets two stack frames, one for the caller and one for the callee
- * because there are no requirement for the caller to set a stack frame when
- * calling VDSO so it may have omitted to set one, especially on PPC64
- */
-
--.macro cvdso_call funct
-+.macro cvdso_call funct call_time=0
- .cfi_startproc
- PPC_STLU r1, -PPC_MIN_STKFRM(r1)
- mflr r0
-@@ -25,45 +25,28 @@
- PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1)
- #endif
- get_datapage r5
-+ .ifeq \call_time
- addi r5, r5, VDSO_DATA_OFFSET
-+ .else
-+ addi r4, r5, VDSO_DATA_OFFSET
-+ .endif
- bl DOTSYM(\funct)
- PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
- #ifdef __powerpc64__
- PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1)
- #endif
-+ .ifeq \call_time
- cmpwi r3, 0
-+ .endif
- mtlr r0
- .cfi_restore lr
- addi r1, r1, 2 * PPC_MIN_STKFRM
- crclr so
-+ .ifeq \call_time
- beqlr+
- crset so
- neg r3, r3
-- blr
-- .cfi_endproc
--.endm
--
--.macro cvdso_call_time funct
-- .cfi_startproc
-- PPC_STLU r1, -PPC_MIN_STKFRM(r1)
-- mflr r0
-- .cfi_register lr, r0
-- PPC_STLU r1, -PPC_MIN_STKFRM(r1)
-- PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
--#ifdef __powerpc64__
-- PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1)
--#endif
-- get_datapage r4
-- addi r4, r4, VDSO_DATA_OFFSET
-- bl DOTSYM(\funct)
-- PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
--#ifdef __powerpc64__
-- PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1)
--#endif
-- crclr so
-- mtlr r0
-- .cfi_restore lr
-- addi r1, r1, 2 * PPC_MIN_STKFRM
-+ .endif
- blr
- .cfi_endproc
- .endm
-diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S
-index d21d08140a5e..9b3ac09423c8 100644
---- a/arch/powerpc/kernel/vdso32/gettimeofday.S
-+++ b/arch/powerpc/kernel/vdso32/gettimeofday.S
-@@ -63,7 +63,7 @@ V_FUNCTION_END(__kernel_clock_getres)
- *
- */
- V_FUNCTION_BEGIN(__kernel_time)
-- cvdso_call_time __c_kernel_time
-+ cvdso_call __c_kernel_time call_time=1
- V_FUNCTION_END(__kernel_time)
-
- /* Routines for restoring integer registers, called by the compiler. */
---
-2.35.1
-
mm-hwpoison-fix-race-between-hugetlb-free-demotion-a.patch
tty-n_gsm-fix-invalid-use-of-msc-in-advanced-option.patch
tty-n_gsm-fix-sometimes-uninitialized-warning-in-gsm.patch
-powerpc-vdso-remove-cvdso_call_time-macro.patch
-powerpc-vdso-move-cvdso_call-macro-into-gettimeofday.patch
-powerpc-vdso-fix-incorrect-cfi-in-gettimeofday.s.patch
serial-8250_mtk-make-sure-to-select-the-right-featur.patch
tty-n_gsm-fix-invalid-gsmtty_write_room-result.patch
drm-amd-refactor-amdgpu_aspm-to-be-evaluated-per-dev.patch