From nobody Thu Apr 2 23:01:51 2026 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 760F6C6FA8E for ; Tue, 20 Sep 2022 15:16:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231321AbiITPQF (ORCPT ); Tue, 20 Sep 2022 11:16:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231340AbiITPPu (ORCPT ); Tue, 20 Sep 2022 11:15:50 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC28060535; Tue, 20 Sep 2022 08:15:48 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MX4lD0zS9zmVjB; Tue, 20 Sep 2022 23:11:52 +0800 (CST) Received: from dggpemm500013.china.huawei.com (7.185.36.172) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 20 Sep 2022 23:15:46 +0800 Received: from ubuntu1804.huawei.com (10.67.175.36) by dggpemm500013.china.huawei.com (7.185.36.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 20 Sep 2022 23:15:46 +0800 From: Chen Zhongjin To: , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 4/7] riscv: syscall: Don't clobber s0 when syscall Date: Tue, 20 Sep 2022 23:11:59 +0800 Message-ID: <20220920151202.180057-5-chenzhongjin@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220920151202.180057-1-chenzhongjin@huawei.com> References: <20220920151202.180057-1-chenzhongjin@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.175.36] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500013.china.huawei.com (7.185.36.172) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" syscall uses s0 to load address of sys_call_table. Since now we uses s0 to save pt_regs for unwinding, clobber s0 can make unwinder treat s0 as pt_regs address. Use s1 for this job. Signed-off-by: Chen Zhongjin --- arch/riscv/kernel/entry.S | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S index ecb15c7430b4..a3b14a649782 100644 --- a/arch/riscv/kernel/entry.S +++ b/arch/riscv/kernel/entry.S @@ -205,33 +205,33 @@ handle_syscall: check_syscall_nr: /* Check to make sure we don't jump to a bogus syscall number. */ li t0, __NR_syscalls - la s0, sys_ni_syscall + la s1, sys_ni_syscall /* * Syscall number held in a7. * If syscall number is above allowed value, redirect to ni_syscall. */ bgeu a7, t0, 3f #ifdef CONFIG_COMPAT - REG_L s0, PT_STATUS(sp) - srli s0, s0, SR_UXL_SHIFT - andi s0, s0, (SR_UXL >> SR_UXL_SHIFT) + REG_L s1, PT_STATUS(sp) + srli s1, s1, SR_UXL_SHIFT + andi s1, s1, (SR_UXL >> SR_UXL_SHIFT) li t0, (SR_UXL_32 >> SR_UXL_SHIFT) - sub t0, s0, t0 + sub t0, s1, t0 bnez t0, 1f =20 /* Call compat_syscall */ - la s0, compat_sys_call_table + la s1, compat_sys_call_table j 2f 1: #endif /* Call syscall */ - la s0, sys_call_table + la s1, sys_call_table 2: slli t0, a7, RISCV_LGPTR - add s0, s0, t0 - REG_L s0, 0(s0) + add s1, s1, t0 + REG_L s1, 0(s1) 3: - jalr s0 + jalr s1 =20 ret_from_syscall: /* Set user a0 to kernel a0 */ --=20 2.17.1