From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4876C00144 for ; Tue, 2 Aug 2022 01:20:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234151AbiHBBUK (ORCPT ); Mon, 1 Aug 2022 21:20:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231653AbiHBBUE (ORCPT ); Mon, 1 Aug 2022 21:20:04 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E76801B79D for ; Mon, 1 Aug 2022 18:20:02 -0700 (PDT) Received: from [10.130.0.63] (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9BxHOS6e+hiV+EAAA--.4933S3; Tue, 02 Aug 2022 09:19:55 +0800 (CST) Subject: Re: [PATCH 3/4] LoongArch: Add stacktrace support To: Huacai Chen Cc: WANG Xuerui , loongarch@lists.linux.dev, LKML , Jiaxun Yang , Jinyang He References: <20220801121726.9681-1-zhangqing@loongson.cn> <20220801121726.9681-4-zhangqing@loongson.cn> From: zhangqing Message-ID: <3cc6aebc-87e7-f0d0-2a88-e7e742e1e5ee@loongson.cn> Date: Tue, 2 Aug 2022 09:19:54 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf9BxHOS6e+hiV+EAAA--.4933S3 X-Coremail-Antispam: 1UD129KBjvJXoWxurWUZrWfuFy5Z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X-Mailing-List: linux-kernel@vger.kernel.org On 2022/8/1 下午11:30, Huacai Chen wrote: > Hi, Qing, > > On Mon, Aug 1, 2022 at 8:17 PM Qing Zhang wrote: >> >> 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 >> --- >> 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); > Why this? Does it have something to do with stacktrace? > > Huacai Hi, huacai This is kernel test robot report sparse warnings: I reproduced locally and found that other architectures calling __copy_user also use __force conversion, Is this modification appropriate? kernel/trace/trace_events_user.c: note: in included file (through include/linux/uaccess.h, include/linux/sched/task.h, include/linux/sched/signal.h, ...): arch/loongarch/include/asm/uaccess.h:232:32: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const *from @@ got void const [noderef] __user *from @@ arch/loongarch/include/asm/uaccess.h:232:32: sparse: expected void const *from arch/loongarch/include/asm/uaccess.h:232:32: sparse: got void const [noderef] __user *from Thanks, -Qing