Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp825059pxb; Wed, 29 Sep 2021 10:24:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynKRwv9EZSRa9WXISOn4GYVLP3yMaISExuuZSRBEsrgfpvfyYZFw7jFBI3q1j1TvxRW8KZ X-Received: by 2002:a17:906:b098:: with SMTP id x24mr1139805ejy.88.1632936268409; Wed, 29 Sep 2021 10:24:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632936268; cv=none; d=google.com; s=arc-20160816; b=GnwjfCF1pVVqYQiahmVhQFv/F9hXK090b6fBs4BnMmpb+O1/LzdARJFAkIfQ064Y7q neaQjp85Ixdn00AZkaTlO1gHl5Zuk+0v/4K2yQuNCSchSI1diOujtksVnXN1dAplPpFY qYCbfUukiJHpLtC/AV+9GTDUzHsupVUNjb9pythZcy3WgaaIIq6lPXw7CkG/6OQIlmJv 0Ajo8yoZry82dYNqvTJuZuKJ1oVZ9dSJBhFflfsePIh/QDccB66giQ/YG0t3LA4XyM+w RQUzyylqLIOq2pG1kltSbxW6b5Guf14cLbfU4vMexdjT09H6ZP7iJwwqLcAMoIzNA6DN Cg9g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vJN7Ck0uNCFG+Ctq/qAp6lWVQYR8Vj2mrO3VtePHdDo=; b=uMzSxR39Koqaru+prVWzBwR7vFFG4z087rUoQVpJi7RIot2qKWsruvjV9nNjeNK8V9 RFxEWJZTqUTaPgHxFoPFVYbVlOTb3XJZjjCW6P9yvEhRh2umilU/jpyp0xXvyIZYWPp3 N2emnsoa4sp7KJyKmUX25IsaGiVBt1QWfwe7kD9TnZeNjOaiEcsJcd1BQ8/N2Y4HL9yd SnFV7vHg6mxyV6KLZfWcWHcbqrGaeARbc7U1TqP35uh6sfJqivc+uB4Zm5L0UimH/Cq2 W0UxAQczxo7nK52k5DrRZS8OPpmbPmhEl7h/FOR1BEZ8m2GxpzhuswWHHhllyykHxaZO zrKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=CdndsxOn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d21si541647edn.278.2021.09.29.10.24.03; Wed, 29 Sep 2021 10:24:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=CdndsxOn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344936AbhI2PCb (ORCPT + 99 others); Wed, 29 Sep 2021 11:02:31 -0400 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]:60814 "EHLO smtp-relay-internal-0.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344934AbhI2PC3 (ORCPT ); Wed, 29 Sep 2021 11:02:29 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (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 smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 8016A40603 for ; Wed, 29 Sep 2021 15:00:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1632927647; bh=vJN7Ck0uNCFG+Ctq/qAp6lWVQYR8Vj2mrO3VtePHdDo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CdndsxOn2Q+HxgVi+RJAQYf0h3YtqonFisO24TFMTMd3xeuqhyo3398X6/Y2eYMZb t8+ZMLRPl2Y9rhk0n//d9ffe3YtUO1ugv5Cvy269sOglS5amFiITcl3ao9qNGghf57 lwVl87qvCCfyaWuSfgrjDRgGUr1r0VxwfpjagziSYPop+bgx6vjgWayvW0CrWLb7/q F66Lcb8ndK1Y/5vNQcr2b/y/XnOfNVBUMXRZ6x8VRCEg8qzgW1RM070HqkyUqPKApR lg1qksiVb4bpUcdQA0egCsdari18BmNoV2uyz3EH8urBTh96xN4FwVUlcgDYPyRtsL DS0LLVif79q9Q== Received: by mail-wm1-f71.google.com with SMTP id y23-20020a05600c365700b003015b277f98so950011wmq.2 for ; Wed, 29 Sep 2021 08:00:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vJN7Ck0uNCFG+Ctq/qAp6lWVQYR8Vj2mrO3VtePHdDo=; b=3hNAIBgnhDVUpSHrIub0WDfoYnw80bgkXPSxDiU738R3Pf/GtMvrBXuHVVW9FD2s2s PoPKzI9+loALlZ7c+/uGS9ULy6KvYBHsgyWapkB4MGZRHKnmCfN6dU55HesNfraJxyiF 5vY2YZWHPe9YM0XP8wJwVxE17kVTodYnuAEP4Tdz+wtM9qOPzYDzH8Qxcd1nE5LWVSDW xElEsMDRypRtDJpYKYuYg+jJIRg5QYIzNp3oTTP1HRULszwkt7MtW0fAs3I9n4Qkjn4W rhlEd3z7BACkEew/43q6f0Dwkb78gzxJ4s6xiX9R9xm2HqfM5+7xDGwLkTdbIxtvy9nu tPWg== X-Gm-Message-State: AOAM531DlPCfSkOZ2fRfPs2xVaYG3cSYlATnmZtU0AzJ7ltGR1YnRS+N F56z4DASds7EqsMuMDPUD2ATTNnK4Kao4ix1Jpg+GkjcxYI+u0JO6oiOw5UVQt783Mstne+Ydch 934AsExx9iXXIKMrLckMPFeQwxpyOJJhPcNhtI9xLOg== X-Received: by 2002:adf:d4cb:: with SMTP id w11mr327562wrk.125.1632927646707; Wed, 29 Sep 2021 08:00:46 -0700 (PDT) X-Received: by 2002:adf:d4cb:: with SMTP id w11mr327526wrk.125.1632927646559; Wed, 29 Sep 2021 08:00:46 -0700 (PDT) Received: from alex.home (lfbn-lyo-1-470-249.w2-7.abo.wanadoo.fr. [2.7.60.249]) by smtp.gmail.com with ESMTPSA id e8sm142306wrr.42.2021.09.29.08.00.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 08:00:46 -0700 (PDT) From: Alexandre Ghiti To: 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 , 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 Cc: Alexandre Ghiti Subject: [PATCH v2 09/10] riscv: Initialize thread pointer before calling C functions Date: Wed, 29 Sep 2021 16:51:12 +0200 Message-Id: <20210929145113.1935778-10-alexandre.ghiti@canonical.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210929145113.1935778-1-alexandre.ghiti@canonical.com> References: <20210929145113.1935778-1-alexandre.ghiti@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 8f21ef339c68..892a25c6079d 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -301,6 +301,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 -- 2.30.2