Hi, Qing,
On Mon, Aug 1, 2022 at 8:17 PM Qing Zhang <zhangqing@xxxxxxxxxxx> wrote:
Why this? Does it have something to do with stacktrace?
Use common arch_stack_walk infrastructure to avoid duplicated code and
avoid taking care of the stack storage and filtering.
Add sra (means __schedule return address) and scfa (means __schedule call
frame address) to thread_info and store it in switch_to().
Now we can print the process stack by cat /proc/*/stack and can better
support ftrace.
Signed-off-by: Qing Zhang <zhangqing@xxxxxxxxxxx>
---
arch/loongarch/Kconfig | 5 ++++
arch/loongarch/include/asm/processor.h | 9 +++++++
arch/loongarch/include/asm/switch_to.h | 14 ++++++----
arch/loongarch/include/asm/uaccess.h | 4 +--
arch/loongarch/kernel/Makefile | 1 +
arch/loongarch/kernel/asm-offsets.c | 2 ++
arch/loongarch/kernel/process.c | 3 +++
arch/loongarch/kernel/stacktrace.c | 37 ++++++++++++++++++++++++++
arch/loongarch/kernel/switch.S | 2 ++
9 files changed, 70 insertions(+), 7 deletions(-)
create mode 100644 arch/loongarch/kernel/stacktrace.c
diff --git a/arch/loongarch/include/asm/uaccess.h b/arch/loongarch/include/asm/uaccess.h
index 2b44edc604a2..a8ae2af4025a 100644
--- a/arch/loongarch/include/asm/uaccess.h
+++ b/arch/loongarch/include/asm/uaccess.h
@@ -229,13 +229,13 @@ extern unsigned long __copy_user(void *to, const void *from, __kernel_size_t n);
static inline unsigned long __must_check
raw_copy_from_user(void *to, const void __user *from, unsigned long n)
{
- return __copy_user(to, from, n);
+ return __copy_user(to, (__force const void *)from, n);
}
static inline unsigned long __must_check
raw_copy_to_user(void __user *to, const void *from, unsigned long n)
{
- return __copy_user(to, from, n);
+ return __copy_user((__force void *)to, from, n);
Huacai