Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1198638ybl; Tue, 13 Aug 2019 08:51:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvK/VCJTSegykY1lYUJaOtfEnmvd8s4cQODgoNE0tJ0HaI/vbWMGA01OLjXZFWF++qZBnG X-Received: by 2002:a62:2f06:: with SMTP id v6mr41918571pfv.195.1565711476329; Tue, 13 Aug 2019 08:51:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565711476; cv=none; d=google.com; s=arc-20160816; b=gr+M57uLbc/HlBfsX3PH4xGtLnW+IkHHL2+kKfS8uqjxVl3qwEe662qaAd4olvLt13 bC7/gC8/LOS96CfD0IPhPlmAAMqhIhKQ35Eq4Ow1t+VmB7DoS2tKsmz8yZHVvrhqMPgU WVYPuVz7HSnKzsBnSLu+2K2oDZty9Zepg/eaolOcdWjixA5Rs2XlEC55Xw+tFJ3sffg2 sWOh7P/conyeTHqg3Ecq4QevpFp2RantsBjGLNiXqoHDpsqlS4KRyiwy0jxSfTpMWdoC UFF5tGz4b6as6zdE9VIdAY3jaDYfJtSr3TKdqKurij0wPhUPFr+p3OuI7QnimB3XxuLy zzFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cfGR43GsDljmM8dFTM8JWcg4vdYoI1COaqr1g9mXt+Y=; b=pbbtWZgFaty6bigXTkA6t48dQqxmfakjQT64yY2F87WdbhYca5sttr8qL/wr25aj1/ ZIeEl6H2bPafSO7ynvacYS2kB6VMUfyCxOWyTAgIOndzEcddTMvBb6U1Y5DVZ3So4Nej 19LZZBhI+4Q4Jbe00+IOuBJqlMEZiRVNrcXJGLHYpj2fiGEfu/gbP81mft/VWvj030Wr KD2Uv4GTnuNolFlu6tFWmxhIgn4Q7Jfk/e6CdO/C77oQAb4vlYQ1mOjqOZzVMve3ZNvO ZRO1GBq+apjL30uiMAa9ZTMGjr6s4nB+4MQm5J6XpX4s8NkC6CBi6jNGmDh5PcsN/dOd VRwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=QOZ0pZcd; 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 q7si1190146pjv.36.2019.08.13.08.51.00; Tue, 13 Aug 2019 08:51:16 -0700 (PDT) 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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=QOZ0pZcd; 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 S1730202AbfHMPsM (ORCPT + 99 others); Tue, 13 Aug 2019 11:48:12 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:44644 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730194AbfHMPsK (ORCPT ); Tue, 13 Aug 2019 11:48:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cfGR43GsDljmM8dFTM8JWcg4vdYoI1COaqr1g9mXt+Y=; b=QOZ0pZcdUpGbicU439RrT2tjKM JDYc/QmHefFpDB/pjo08eUGSEXbDNkG3PoGQRk9RJhUN3yEFqBgGNCrqrjXN2VmIO6EmYv37esTUo MBuNmFEC8nwknutBxCArSTKaw51W1/hznne9i1+RLDsAYSKbSiu3341sCRFhENYBFgyEU/S5H9LW+ mAlgkYHemjVcBwqMcLTdnOgr33dEq3/RL/WSUcF9VY+O2T0IU/7kGjfiMN2g7eSLUllt/mgOwobvj 2M8LlBbWxlKmKZeZbv3cirZ0gW74lFwNm5/Nqq6xtE0RzuSROmEYzR6TM+obIYZbvyj4oqaa+RSFz khNQuVBQ==; Received: from [2001:4bb8:180:1ec3:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hxZ1s-0004zn-L0; Tue, 13 Aug 2019 15:48:09 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Damien Le Moal , Atish Patra Subject: [PATCH 07/15] riscv: read the hart ID from mhartid on boot Date: Tue, 13 Aug 2019 17:47:39 +0200 Message-Id: <20190813154747.24256-8-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190813154747.24256-1-hch@lst.de> References: <20190813154747.24256-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Damien Le Moal When in M-Mode, we can use the mhartid CSR to get the ID of the running HART. Doing so, direct M-Mode boot without firmware is possible. Signed-off-by: Damien Le Moal Signed-off-by: Christoph Hellwig Reviewed-by: Atish Patra --- arch/riscv/include/asm/csr.h | 1 + arch/riscv/kernel/head.S | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h index 53d7ce74b447..64f8fe84b88f 100644 --- a/arch/riscv/include/asm/csr.h +++ b/arch/riscv/include/asm/csr.h @@ -81,6 +81,7 @@ #define SIE_SEIE (_AC(0x1, UL) << IRQ_S_EXT) /* symbolic CSR names: */ +#define CSR_MHARTID 0xf14 #define CSR_MSTATUS 0x300 #define CSR_MIE 0x304 #define CSR_MTVEC 0x305 diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index bb96bb7b95d2..275c2ab1e990 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -50,6 +50,14 @@ _start_kernel: csrw CSR_XIE, zero csrw CSR_XIP, zero +#ifdef CONFIG_M_MODE + /* + * The hartid in a0 is expected later on, and we have no firmware + * to hand it to us. + */ + csrr a0, CSR_MHARTID +#endif + /* Load the global pointer */ .option push .option norelax -- 2.20.1