Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2489546rwi; Fri, 21 Oct 2022 04:36:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7jWbjRnopS5wwKHhb+C0P8jbJj/0zrlCVOTcmVzUNDTYPS4CRLLk9j9X6Z+upOitSWtUUi X-Received: by 2002:a65:4303:0:b0:439:f026:ccee with SMTP id j3-20020a654303000000b00439f026cceemr15889857pgq.322.1666352169188; Fri, 21 Oct 2022 04:36:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666352169; cv=none; d=google.com; s=arc-20160816; b=kQJRofxbaife7O2WlqUb6676v7LxqzVtwyeIyEvZlBlG4GOEXFwKT4+Z/vrV8xs9fw qrGy7PoWgSawc89T+fh40zF3+3catWDPRUhGt71shX8hOXLkl9V2nBEa8gyKCweE+nnN gHbc0CmlfLsZWd3IJcvtHfc+OTWnj5slRh6S2gwDosl4+CqVs2mIz7Xy3lyi3qVpmqMQ DuBYoLwkK31jhttaq7ymtyzvLpLkVMVh1g3irs01mS03fQ1UqIWrpU+AUYRJEPPQhiJJ 8lJp/NbcuYbGKhTYCiDNJEdUnhrZCDy/9fhBt06tUSoXcZQadX4a3xtz3vjBClifGJ+r N/tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=hmV1wJQ8e3s73/Yj3pQB1Q/jh0u41QYlu2EvMTj+ho0=; b=QcxFsI46vjd/1x3k2W/57jyQiqGjB/up9Y8W0LEJXBViEnEn6q/7IxDVI6xUAGT8BC Jyy9CHK8Gb6yOsJnq+56Br+v0gWFe1mqp3XnfoJX49p99Io1p/roWwRLpzxKUpzRnHOR YJ8ozmo3jHSKyr81mq/XLEWvHvAO9wNxmaaz3uuT7/XSUJgFIxaaIjQeaD+2BFOOMMfe Fbqvr8pVfsKOo4qCCTQvRg1HbqAsMnVwId/1AOYTJFVynSuM/MUQvQkRcADGBOrbAdEi LnLxRMOXFItotd/K3JDKRx8ZcAT828CgHinHM7VuHqaVkHmvTjDbOE7u+oyVu5+kuTXK l6gw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f30-20020a63101e000000b00434bfa4c2d7si26136286pgl.317.2022.10.21.04.35.55; Fri, 21 Oct 2022 04:36:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbiJULbr (ORCPT + 99 others); Fri, 21 Oct 2022 07:31:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbiJULb3 (ORCPT ); Fri, 21 Oct 2022 07:31:29 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AAF660686; Fri, 21 Oct 2022 04:31:19 -0700 (PDT) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Mv2N716f1zHv7t; Fri, 21 Oct 2022 19:31:03 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 21 Oct 2022 19:31:11 +0800 Received: from localhost.localdomain (10.175.112.125) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 21 Oct 2022 19:31:10 +0800 From: Tong Tiangen To: Guo Ren CC: , , Tong Tiangen , , Guohanjun Subject: [PATCH -next] csky: add arch support current_stack_pointer Date: Fri, 21 Oct 2022 11:56:54 +0000 Message-ID: <20221021115654.5278-1-tongtiangen@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To follow the existing per-arch conventions, using "current_stack_pointer" to set sp. This will let it be used in non-arch places(like HARDENED_USERCOPY). Signed-off-by: Tong Tiangen --- arch/csky/Kconfig | 1 + arch/csky/include/asm/processor.h | 2 ++ arch/csky/kernel/stacktrace.c | 6 ++---- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig index adee6ab36862..2236b5c0c213 100644 --- a/arch/csky/Kconfig +++ b/arch/csky/Kconfig @@ -9,6 +9,7 @@ config CSKY select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_QUEUED_RWLOCKS select ARCH_USE_QUEUED_SPINLOCKS + select ARCH_HAS_CURRENT_STACK_POINTER select ARCH_INLINE_READ_LOCK if !PREEMPTION select ARCH_INLINE_READ_LOCK_BH if !PREEMPTION select ARCH_INLINE_READ_LOCK_IRQ if !PREEMPTION diff --git a/arch/csky/include/asm/processor.h b/arch/csky/include/asm/processor.h index 63ad71fab30d..ea75d72dea86 100644 --- a/arch/csky/include/asm/processor.h +++ b/arch/csky/include/asm/processor.h @@ -84,4 +84,6 @@ unsigned long __get_wchan(struct task_struct *p); #define cpu_relax() barrier() +register unsigned long current_stack_pointer __asm__("sp"); + #endif /* __ASM_CSKY_PROCESSOR_H */ diff --git a/arch/csky/kernel/stacktrace.c b/arch/csky/kernel/stacktrace.c index 9f78f5d21511..27ecd63e321b 100644 --- a/arch/csky/kernel/stacktrace.c +++ b/arch/csky/kernel/stacktrace.c @@ -23,10 +23,9 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, sp = user_stack_pointer(regs); pc = instruction_pointer(regs); } else if (task == NULL || task == current) { - const register unsigned long current_sp __asm__ ("sp"); const register unsigned long current_fp __asm__ ("r8"); fp = current_fp; - sp = current_sp; + sp = current_stack_pointer; pc = (unsigned long)walk_stackframe; } else { /* task blocked in __switch_to */ @@ -68,8 +67,7 @@ static void notrace walk_stackframe(struct task_struct *task, sp = user_stack_pointer(regs); pc = instruction_pointer(regs); } else if (task == NULL || task == current) { - const register unsigned long current_sp __asm__ ("sp"); - sp = current_sp; + sp = current_stack_pointer; pc = (unsigned long)walk_stackframe; } else { /* task blocked in __switch_to */ -- 2.25.1