From patchwork Fri May 21 10:48:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaxson Han X-Patchwork-Id: 12272909 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ECA1C433ED for ; Fri, 21 May 2021 10:51:55 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C94936108D for ; Fri, 21 May 2021 10:51:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C94936108D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NyptQ0AT9aHf+ppKwNY7D3Ozt19Pch/rgS0AWMurX6k=; b=atENihKZB4jCJTD9UvEseUJLXH Jy8lo4FtImlGcWmxh7facpY7JIcArHyNpNozRKpRLKvjcD13H1Pet+ntb0ZArZO0qjLobKMOfE/qA 4Q85u+t+VmwfqdeUMBwOJODtBRAGj7Ad05JRKWxHpBGIpX1XpNTMd6YleIiSaHJNpSc0AJjNR00Av GO9y1kVSv9i+8da2UEIM78zPKPxMkL3I1cO1gAlCixmFk9gdGxBX/qAHdMVPVEhzXne/Kfh/HTx/n QHC3cG8Rqlm7qMxpsJ6kDCFip0RqsnXrSokbFbIC6yWLfH2marpp53SuJ5hNDxMUEVhCZQdfjcOX3 V1NWsPUA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk2ii-0050TS-9J; Fri, 21 May 2021 10:49:32 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk2ho-005070-Gf for linux-arm-kernel@desiato.infradead.org; Fri, 21 May 2021 10:48:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; 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; bh=5X92pcB78TCtdiHmdQN/7SWTQ87VG7xvJ3LF48iZihg=; b=dXTVaRPAm/3YYpOD8AWpo8glmi puQoCyersy4LKNuqsK/6AWprujrrdiq+lYMoqOzND30d+vTEBoGX/rUtRX/03E0IGdpdBXSj/ySmn snGFo8a+EK5sOXMbpIYRg456CpH0ANi0SfSE9J2zYyuFMz8u0ga0pMbWn0bOFiCGyM35jnntercE2 uGmYS4SneLPsfFBUsMsuQ8q5DPDWjq53hT1R/fbCH1V/WmrcNm/KcWSnCvVUYMOPh2ZvNMGQj1qhu l/rKAv0ZXlFI7wpimSkEryPZoeBUPWyJmqt3hJ5h62FvNYXjesXBr93eYYTWuBCdT/wjXOnpuYVys nvUd3sZQ==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lk2hl-00H38v-PR for linux-arm-kernel@lists.infradead.org; Fri, 21 May 2021 10:48:35 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E5F131480; Fri, 21 May 2021 03:48:32 -0700 (PDT) Received: from optiplex-7070.shanghai.arm.com (optiplex-7070.shanghai.arm.com [10.169.188.115]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 139FA3F73D; Fri, 21 May 2021 03:48:30 -0700 (PDT) From: Jaxson Han To: mark.rutland@arm.com, andre.przywara@arm.com Cc: linux-arm-kernel@lists.infradead.org, wei.chen@arm.com, jaxson.han@arm.com Subject: [boot-wrapper PATCH v2 5/8] aarch64: Prepare for lower EL booting Date: Fri, 21 May 2021 18:48:04 +0800 Message-Id: <20210521104807.138269-6-jaxson.han@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210521104807.138269-1-jaxson.han@arm.com> References: <20210521104807.138269-1-jaxson.han@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210521_034833_887356_357B450B X-CRM114-Status: UNSURE ( 8.72 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Save SPSR_KERNEL into spsr_to_elx during el3_init. The jump_kernel will load spsr_to_elx into spsr_el3. This change will make it easier to control whether drop to lower EL before jumping to the kernel. Signed-off-by: Jaxson Han Reviewed-by: Andre Przywara --- arch/aarch64/boot.S | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S index b8f9e4e..5600859 100644 --- a/arch/aarch64/boot.S +++ b/arch/aarch64/boot.S @@ -118,7 +118,16 @@ el3_init: mov x0, #ZCR_EL3_LEN_MASK // SVE: Enable full vector len msr ZCR_EL3, x0 // for EL2. -1: + /* + * Save SPSR_KERNEL into spsr_to_elx. + * The jump_kernel will load spsr_to_elx into spsr_el3 + */ +1: mov w0, #SPSR_KERNEL + ldr x1, =spsr_to_elx + str w0, [x1] + b el_max_init + +el_max_init: ldr x0, =CNTFRQ msr cntfrq_el0, x0 @@ -166,7 +175,7 @@ jump_kernel: b.eq 1f br x19 // Keep current EL -1: ldr w4, #SPSR_KERNEL +1: ldr w4, spsr_to_elx /* * If bit 0 of the kernel address is set, we're entering in AArch32 @@ -184,3 +193,5 @@ jump_kernel: .align 3 flag_keep_el: .long 0 +spsr_to_elx: + .long 0