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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 296A9C43458 for ; Thu, 9 Jul 2026 02:38:51 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4gwfKj6Rnmz3cMB; Thu, 09 Jul 2026 12:38:49 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=113.46.200.221 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1783564729; cv=none; b=aCD63ePkbOV916aVIzUeMdVQYjF5um98885DVzol/QmFkBkz9AZaBH2YHX6yBMdZ7ft2NNBZvu2OBLyiiqLb4CkpqPoIbWXFDznAmfLdkujXEjBr30Lug53v+ALQE1Fo/khrFqZ+LJfweffVAUyzr83yCRjTr6mY/GLOMUQsaDhpLzX807OXO2l+uB0kHmRon4kugiRq4fshJG0lLRNKw5RyUEFQdzkhZ9YkaqGc17bwchKv+sjZ+BV4JI6FRqpXbCgmXTd2RJsGyuAxaBXXLTnhgUh37kJvbVV5C3E2nh8mRXwcOaMa8ginkX2aAXMTNDFgEWrj1e0qe6dwnLMOPw== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1783564729; c=relaxed/relaxed; bh=27oh/guBtTfnUBgdaNEr/LbTAoCq6bl6NgpseSHT8oU=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=RuHwGQrfyhDqBZyXMsC0tG4uQaI/9qASy/q6uLjoqFnjDxElPXhMI+FwnwqxTl5ZdpUiH0P1mFgXFbbQ83GXjjDp7JXH9k8GbI1PnZFMeQr0CF4pwd/TFnnoR0G6ghVqZCNji6Gt1s5JHaJjQaT5fRcEmk1uzzo0LrNRwZjfjNxfEf61Qdum3lYMm810OTzU5tfYfR8oYVoQJ7kMNJpWj/oesveXHL0BtLqhfDUvmjyhibacQb6/umLg4ZqFzM6MPgYi2aiPXaaLQ3m8gOhwWF/758YxeKQpTsuaWEda3piH4Ros57VuYSeJXpPMnfoAjxwxuCs57OkR/PnDOoBjzw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; dkim=pass (1024-bit key; unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=vGoA/w/p; dkim-atps=neutral; spf=pass (client-ip=113.46.200.221; helo=canpmsgout06.his.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) smtp.mailfrom=huawei.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=vGoA/w/p; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=113.46.200.221; helo=canpmsgout06.his.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) Received: from canpmsgout06.his.huawei.com (canpmsgout06.his.huawei.com [113.46.200.221]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4gwfKj00Nsz3by8 for ; Thu, 09 Jul 2026 12:38:48 +1000 (AEST) dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=27oh/guBtTfnUBgdaNEr/LbTAoCq6bl6NgpseSHT8oU=; b=vGoA/w/p4eUg8DNq/3WU+BV9x0rMzwDw5QP7EYutczAClZ4+mdj6bnoPheODPMa6wMbnfjdQ2 76A++7vhs3N+il4cnpPW4KAtvIWbCxDL6ZftoDprJV4SqRjFZvkoFT7nu7RU0PuLKOibD+IThcP Au2m9NXMaV/JIUvkeNEHfXA= Received: from mail.maildlp.com (unknown [172.19.162.140]) by canpmsgout06.his.huawei.com (SkyGuard) with ESMTPS id 4gwf6x5fhjzRhQx; Thu, 9 Jul 2026 10:29:29 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id F1E7C2012A; Thu, 9 Jul 2026 10:38:42 +0800 (CST) Received: from [10.67.109.254] (10.67.109.254) by dggpemf500011.china.huawei.com (7.185.36.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 9 Jul 2026 10:38:40 +0800 Message-ID: <5b07cec9-8b47-4074-8347-8b6187778e65@huawei.com> Date: Thu, 9 Jul 2026 10:38:38 +0800 X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [patch 06/18] riscv/syscall: Use syscall_enter_from_user_mode_randomize_stack() To: Thomas Gleixner , LKML CC: Peter Zijlstra , Paul Walmsley , Palmer Dabbelt , , Michael Ellerman , Shrikanth Hegde , , Kees Cook , Huacai Chen , , Sven Schnelle , , , Mark Rutland , Andy Lutomirski , Oleg Nesterov , Richard Henderson , Russell King , Catalin Marinas , Guo Ren , Geert Uytterhoeven , Thomas Bogendoerfer , Helge Deller , Yoshinori Sato , Richard Weinberger , Chris Zankel , , , , , , , , , Arnd Bergmann , Vineet Gupta , Will Deacon , Brian Cain , Michal Simek , Dinh Nguyen , "David S. Miller" , Andreas Larsson , , , , , , =?UTF-8?Q?Michal_Such=C3=A1nek?= , Jonathan Corbet , References: <20260707181957.433213175@kernel.org> <20260707190253.974626922@kernel.org> From: Jinjie Ruan In-Reply-To: <20260707190253.974626922@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.109.254] X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To dggpemf500011.china.huawei.com (7.185.36.131) On 7/8/2026 3:06 AM, Thomas Gleixner wrote: > syscall_enter_from_user_mode_randomize_stack() replaces > syscall_enter_from_user_mode() and the subsequent invocation of > add_random_kstack_offset(). > > The advantage is that it applies the stack randomization right after > enter_from_user_mode() and thereby avoids the overhead of get/put_cpu_var() > as that code is invoked with interrupts disabled. > > No functional change. > > Signed-off-by: Thomas Gleixner > Cc: Paul Walmsley > Cc: Palmer Dabbelt > Cc: linux-riscv@lists.infradead.org > --- > arch/riscv/kernel/traps.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > --- a/arch/riscv/kernel/traps.c > +++ b/arch/riscv/kernel/traps.c > @@ -7,7 +7,6 @@ > #include > #include > #include > -#include > #include > #include > #include > @@ -333,9 +332,7 @@ void do_trap_ecall_u(struct pt_regs *reg > > riscv_v_vstate_discard(regs); > > - syscall = syscall_enter_from_user_mode(regs, syscall); > - > - add_random_kstack_offset(); > + syscall = syscall_enter_from_user_mode_randomize_stack(regs, syscall); Reviewed-by: Jinjie Ruan > > if (syscall >= 0 && syscall < NR_syscalls) { > syscall = array_index_nospec(syscall, NR_syscalls); >