From patchwork Fri Jan 7 19:43:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 12707013 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 03912C433F5 for ; Fri, 7 Jan 2022 19:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=6qgp86N6JdzrPd2F+ZTtmVBHbO5QKvl86xZqRZtugi0=; b=22EpKa9xcBQH72 2/WMCSHacI0X7zrbrZUjHna0lDYDm3yiR43D0nRUtQxlNHBnM+ibiZuqR8GEYqZtq9L+dv5TsLFAs RTzVutfE5Qd20d5aBLgCcOw0PTp3fpraC5JUWtJVZKtue0E3xO5q/Uafjp7Ct+DD/qdCWCsu/IfTL gMIyYoCeO7xUJOGhLt0WA9KWYNpfCHJs+daoMheO5Qg3gHJ/w0On6EYsejJl5wF/D/69afsZbBkgo SsCYCUCTGLntx7ZP3+HLB/5Aef6iYJmffECO+9C9VLLlNfuYk83+Pjk1lbrKkl1OHyU2GgSWkbKaw 7q2IiaZHLRVNm5K8WZbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5vAG-0056VO-LY; Fri, 07 Jan 2022 19:44:40 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5v9h-0056LA-UZ for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 19:44:07 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B283BB82765; Fri, 7 Jan 2022 19:44:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58F80C36AED; Fri, 7 Jan 2022 19:44:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641584644; bh=GO9iL6Qi1ajaccImX9GcZ0L+1uDe8ATmtJQ1yhUiskc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FdHb8k14YHP2arXIYvO53uNJtJ/AGs0FKgM+Ddpjyh6/rQ/uQoSFxMHmpP+JUXxfs G87IB4eDF8GPCQTExwyXpCtvlOVIRobDAdmNCWT312YtpcftbxxO9dGRsj/TVQWTX7 BgApLX1YFxCJ5A1x6vZtORG3tzbPWwvbO1KdOFSh9fXM3CMlcP65OzfLerB/trfJms bnTz73Q3W8tqjHIghJDQkqZqhDOEofvYNbSFGIkaLUL4bd5jqqEyLJ28n+tYLXdwpB Td8p0DsyaT/o64uTdcuAhhUylQHK2sD333vG4jdaypOnboTg1SPglHQPUKRnEasrWu odBJjYwtp/E0A== From: Nathan Chancellor To: Greg Kroah-Hartman , Sasha Levin , Catalin Marinas , Will Deacon Cc: Mark Rutland , Marc Zyngier , Nick Desaulniers , linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH RFC 4.9 4/5] arm64: move !VHE work to end of el2_setup Date: Fri, 7 Jan 2022 12:43:34 -0700 Message-Id: <20220107194335.3090066-5-nathan@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220107194335.3090066-1-nathan@kernel.org> References: <20220107194335.3090066-1-nathan@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220107_114406_296912_578CD76F X-CRM114-Status: GOOD ( 15.83 ) 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 From: Mark Rutland commit d61c97a7773d0848b4bf5c4697855c7ce117362c upstream. We only need to initialise sctlr_el1 if we're installing an EL2 stub, so we may as well defer this until we're doing so. Similarly, we can defer intialising CPTR_EL2 until then, as we do not access any trapped functionality as part of el2_setup. This patch modified el2_setup accordingly, allowing us to remove a branch and simplify the code flow. Acked-by: Marc Zyngier Signed-off-by: Mark Rutland Cc: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Nathan Chancellor --- arch/arm64/kernel/head.S | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index b15abc6ae4af..c067b13e93cc 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -553,26 +553,6 @@ set_hcr: msr vpidr_el2, x0 msr vmpidr_el2, x1 - /* - * When VHE is not in use, early init of EL2 and EL1 needs to be - * done here. - * When VHE _is_ in use, EL1 will not be used in the host and - * requires no configuration, and all non-hyp-specific EL2 setup - * will be done via the _EL1 system register aliases in __cpu_setup. - */ - cbnz x2, 1f - - /* sctlr_el1 */ - mov x0, #0x0800 // Set/clear RES{1,0} bits -CPU_BE( movk x0, #0x33d0, lsl #16 ) // Set EE and E0E on BE systems -CPU_LE( movk x0, #0x30d0, lsl #16 ) // Clear EE and E0E on LE systems - msr sctlr_el1, x0 - - /* Coprocessor traps. */ - mov x0, #0x33ff - msr cptr_el2, x0 // Disable copro. traps to EL2 -1: - #ifdef CONFIG_COMPAT msr hstr_el2, xzr // Disable CP15 traps to EL2 #endif @@ -598,6 +578,23 @@ CPU_LE( movk x0, #0x30d0, lsl #16 ) // Clear EE and E0E on LE systems ret install_el2_stub: + /* + * When VHE is not in use, early init of EL2 and EL1 needs to be + * done here. + * When VHE _is_ in use, EL1 will not be used in the host and + * requires no configuration, and all non-hyp-specific EL2 setup + * will be done via the _EL1 system register aliases in __cpu_setup. + */ + /* sctlr_el1 */ + mov x0, #0x0800 // Set/clear RES{1,0} bits +CPU_BE( movk x0, #0x33d0, lsl #16 ) // Set EE and E0E on BE systems +CPU_LE( movk x0, #0x30d0, lsl #16 ) // Clear EE and E0E on LE systems + msr sctlr_el1, x0 + + /* Coprocessor traps. */ + mov x0, #0x33ff + msr cptr_el2, x0 // Disable copro. traps to EL2 + /* Hypervisor stub */ adrp x0, __hyp_stub_vectors add x0, x0, #:lo12:__hyp_stub_vectors