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 DB636C433EF for ; Mon, 10 Jan 2022 08:06:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235907AbiAJIGi (ORCPT ); Mon, 10 Jan 2022 03:06:38 -0500 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:44877 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239639AbiAJIER (ORCPT ); Mon, 10 Jan 2022 03:04:17 -0500 Received: (Authenticated sender: alex@ghiti.fr) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 6A184240003; Mon, 10 Jan 2022 08:03:50 +0000 (UTC) Message-ID: <44e6e00e-0b80-8329-bcc9-820940e02023@ghiti.fr> Date: Mon, 10 Jan 2022 09:03:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 Subject: Re: [PATCH v3 12/13] riscv: Initialize thread pointer before calling C functions Content-Language: en-US To: Alexandre Ghiti , Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Zong Li , Anup Patel , Atish Patra , Christoph Hellwig , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Ard Biesheuvel , Arnd Bergmann , Kees Cook , Guo Ren , Heinrich Schuchardt , Mayuresh Chitale , panqinglin2020@iscas.ac.cn, linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-efi@vger.kernel.org, linux-arch@vger.kernel.org References: <20211206104657.433304-1-alexandre.ghiti@canonical.com> <20211206104657.433304-13-alexandre.ghiti@canonical.com> From: Alexandre ghiti In-Reply-To: <20211206104657.433304-13-alexandre.ghiti@canonical.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Palmer, I fell onto this issue again today, do you think you could take this patch in for-next? Because I assume it is too late now to take the sv48 patchset: if not, I can respin it today or tomorrow. Thanks, Alex On 12/6/21 11:46, Alexandre Ghiti wrote: > Because of the stack canary feature that reads from the current task > structure the stack canary value, the thread pointer register "tp" must > be set before calling any C function from head.S: by chance, setup_vm > and all the functions that it calls does not seem to be part of the > functions where the canary check is done, but in the following commits, > some functions will. > > Fixes: f2c9699f65557a31 ("riscv: Add STACKPROTECTOR supported") > Signed-off-by: Alexandre Ghiti > --- > arch/riscv/kernel/head.S | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S > index c3c0ed559770..86f7ee3d210d 100644 > --- a/arch/riscv/kernel/head.S > +++ b/arch/riscv/kernel/head.S > @@ -302,6 +302,7 @@ clear_bss_done: > REG_S a0, (a2) > > /* Initialize page tables and relocate to virtual addresses */ > + la tp, init_task > la sp, init_thread_union + THREAD_SIZE > XIP_FIXUP_OFFSET sp > #ifdef CONFIG_BUILTIN_DTB