From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout06.his.huawei.com (canpmsgout06.his.huawei.com [113.46.200.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFEDE33BBBA; Thu, 9 Jul 2026 02:38:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.221 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783564730; cv=none; b=JK50K3zxPW9uQQJ7/jdC/RnEsJv6x4DTeUTvoe3d37cDCgpZGqveLx03of0ETHW1aasAaGfNrNOZtiqD0f5a5leKdDxDCFB0GQY1yuZS/w6EAQQpKhq0LCmY8iqOpO6vUyT2bfh0OM9Nx94E6LXlv9pLyBPa7Y0/eSZzrR5imKM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783564730; c=relaxed/simple; bh=vLYwWUN6CUzP47lmyazmqRdHeAc9h+HZpwA6l4WLoTU=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=Hf+6VJBuuqPwCQh8MyIwDLXtpbtYRZy3iDpcb9v9Ryv3r2EU03Iq7sPeAdpqJCYFdCKwbyz5gFqg3FTIWwUZ5inuj9pAHsKKP5/Qm2xmbDsZuIjCpzzEbz5VUXQDCf/DjU80NPuwpPiZYenFJZEupxcEmvuEQ/vDn0zhiMWWqzE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=vGoA/w/p; arc=none smtp.client-ip=113.46.200.221 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="vGoA/w/p" 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 Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-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); >