Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1594242ybl; Wed, 18 Dec 2019 22:55:48 -0800 (PST) X-Google-Smtp-Source: APXvYqw+w4rwLUGwDS3ovd1JNmLHiD3JHSj6L3QO+PGK298yMzUeA37OYCVqx/ZzEuogQtnB9V7/ X-Received: by 2002:a9d:7ada:: with SMTP id m26mr7421448otn.111.1576738548621; Wed, 18 Dec 2019 22:55:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576738548; cv=none; d=google.com; s=arc-20160816; b=pyveD03fs4Stg2XgnFRUhsafPSCPwhbaCR45a7QOaxvAelI4NU2ttHO5h8f+DnnkZM KrVilwbjDrmAOE3zAa/plRJ3I+x1YYP9mFzDIAHHDL9S2oXK2RigiSI5FxTGbU0JLFa7 HeYnvVOEKasf3ksQzngpNycB1AskiTF3q1JnWKX+p/FjTblYFw2kYLVGjm2gyJceGYiT Y3uNo2FYKGB/KEk5jlviui3YZj7l0UObUC0X6rcFaH0Gdqt1SGOwkzvgHCtJabAgUDsY 2P71DGXTUPablIS6ZV3M9v+IpaauaE+9Qe350g/b1Bqx2W8er/Iw/3yjv/QXnbEktwWa 8iiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=2ZYEST654EPj+GcWTNQOV1oMctV/osDgh0tGsFOxh10=; b=Ne2n8kuqXFVLdX+ivjBwKvxHuCjqgkHw7W3A9RhWAZ/Qn6Sl+LtJtFhr0qimNI51fg 1Er57uaF564QNoaFk7uuDaN4cgE1FPZE33xPZcyjhX1cUiO3fnox3/+06UU3k82v1MAY 6pX932rqaEedoEZGl5NASPk4tb+BielHtQ29W+BEfLYD+hHaDi+snv0U+gljr8qVCmVD HiiAh82BcNLj/iS4NwBZkpAS5l0dsyYrcTcaieI89lVo/i3eFOFLOFjXYFHnCFP5po1e ND3Vrnjm45+1TGz9478kPtWi4tdlm80P7LxXl4iZNqwx+UR5pVGrEw1wUg8okW3m2CeK bXRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=YDfSnniH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m4si572543otr.122.2019.12.18.22.55.36; Wed, 18 Dec 2019 22:55:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=YDfSnniH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726498AbfLSGyv (ORCPT + 99 others); Thu, 19 Dec 2019 01:54:51 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35296 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726155AbfLSGyv (ORCPT ); Thu, 19 Dec 2019 01:54:51 -0500 Received: by mail-wm1-f66.google.com with SMTP id p17so4431839wmb.0 for ; Wed, 18 Dec 2019 22:54:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2ZYEST654EPj+GcWTNQOV1oMctV/osDgh0tGsFOxh10=; b=YDfSnniHMo1ze5p//Ojnq6p+aH51B2xTum5mra74NQ7gI1fYwq8c8SbumlhaxTc5FP Hxul15bxq5xJrl4Nz4AXI3oIoZJ3i+E+QWBbcjPCVcFyf0CLhyswHOONKFQIDtNXlm3p XHonHMoygIaQj8ugJNmIJVYNIopO11p2TUJS/kx0DGzbSyiTpexkWyWMmhr65dtM+Z1Y C5kiwkyCP9WCyr2zvybPcTyVynRLUFTAFzlwjrWglx1CmUzvMxOSzbN2zNFdm1SEZhMf RFSs2lpQQ9HnSaAST5m9WXIbDq5XnV77+N3asSWnXc7RRIaBJdOy7jf2TPpf96G1XELc zg8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2ZYEST654EPj+GcWTNQOV1oMctV/osDgh0tGsFOxh10=; b=Mff7g+jNJGR7Ya4TtP90wIU45/6/JFeR8jp+33UcQyyBHwfOlPxvstDUVeOvxMktNB p+Zd2A6NoqKTfGH1Wl+OaxkXr8uGgs92iDzAo9dbmWETRCiayyDfGZNQ0bDihrsvTxbF TqSmQSqDfoB2hs0RxsQpZUXHqYREq/gSkx9fmhLmJVF6QlaI5FBudunsGjeV/XJuyCXu TpbnAn5mFDrxkFyrvB3h1md9U0YmnSGOITbWhkUsldJ/szllEYjYeAEkf0DNZM848mlr dv/oEjhBJSEBpZsGdQOJdF88X7V0J6YO/oXPVLy802jWiZDVwXyYJGFluQt8McXxbSoy KmNQ== X-Gm-Message-State: APjAAAVysEiedTHHE/QSZR4TNkjEFJWcAlw4/jl63flN246KB0GRu9uJ HmrrLSTB+FNIF02jlIhK697bQulYtTN8unBT0hqAnw== X-Received: by 2002:a1c:66d5:: with SMTP id a204mr7793295wmc.64.1576738488999; Wed, 18 Dec 2019 22:54:48 -0800 (PST) MIME-Version: 1.0 References: <20191219064459.20790-1-greentime.hu@sifive.com> In-Reply-To: <20191219064459.20790-1-greentime.hu@sifive.com> From: Anup Patel Date: Thu, 19 Dec 2019 12:24:37 +0530 Message-ID: Subject: Re: [PATCH] riscv: fix scratch register clearing in M-mode. To: Greentime Hu Cc: Greentime Hu , greentime@kernel.org, Christoph Hellwig , Paul Walmsley , Palmer Dabbelt , linux-riscv , "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 19, 2019 at 12:15 PM Greentime Hu wrote: > > This patch fixes that the sscratch register clearing in M-mode. It cleared > sscratch register in M-mode, but it should clear mscratch register. That will > cause kernel trap if the CPU core doesn't support S-mode when trying to access > sscratch. > > Fixes: 9e80635619b5 ("riscv: clear the instruction cache and all registers when booting") > Signed-off-by: Greentime Hu In any case, we should always prefer accessing CSRs using CSR_xyz defines. Looks good to me. Reviewed-by: Anup Patel Regards, Anup > --- > arch/riscv/kernel/head.S | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S > index 84a6f0a4b120..797802c73dee 100644 > --- a/arch/riscv/kernel/head.S > +++ b/arch/riscv/kernel/head.S > @@ -246,7 +246,7 @@ ENTRY(reset_regs) > li t4, 0 > li t5, 0 > li t6, 0 > - csrw sscratch, 0 > + csrw CSR_SCRATCH, 0 > > #ifdef CONFIG_FPU > csrr t0, CSR_MISA > -- > 2.17.1 > >