From mboxrd@z Thu Jan 1 00:00:00 1970 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 35BA5C433EF for ; Thu, 30 Jun 2022 16:09:14 +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=wckofOfJlKUHDnIs3ip34QXDVWIWGQt9sbWizV1wUls=; b=ytDxxDY/KA3lUz q/q+BlmfCeT6HNt+2ioCXdQ2IlQv2t7pRynUIQenNT4dF4DiazO+xgRAuRTLjNkkMwiTELALe832H 1ETHHw3aGNffjZF5M5ZW8atx/VN1nMtodxSxY+Y1lXcSORDGBvx2OkWMOvn9zfbYE1gxgkQWoTDM5 tp3xthtaD2sEXt0EimBzYzI5RUt1bQpmxgqiJp0RyxBj4Eyv2YpH2R7AosOQWPjgHYkhqqkSQ5hrC Ot/zYhEBpI+rYNNrKNTS7ACQK5hl0XiisHhcW7jZKEJCUGvj/+4T6MpZ1pzyECj6AV5SiFVImc0n8 9p/VIJ84DYuUIQGkWOTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6whs-000W3G-RA; Thu, 30 Jun 2022 16:07:53 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6wfV-000UvM-5U for linux-arm-kernel@lists.infradead.org; Thu, 30 Jun 2022 16:05:27 +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 B4DD9B82959; Thu, 30 Jun 2022 16:05:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2866C341D0; Thu, 30 Jun 2022 16:05:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656605121; bh=xD18TmjfR68YYMEAw1Glq8dH2D4OAeZ/jQCtG2I/RDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M9FtvznNN5DccGGmT64RmpR2X4Zvd3kMe3AT5A4IksZdV0bcmSg4nOTHGuSVA3hfP HeNwXDlEe5LJRUxWPFboQZmXHOoYYwW2GHA3hU8OR4bQcmPf3Gugwlz2BbEHanLEn8 UYccYq8/K3I9WU5OgvhUdDEKQs0CmtqK5E7bl4vWDG3kNzgF4vB/tRaleY5WBTAO/q 4SaNE67PjlKnCffpkAoyuODf6BVULWxCJSpmrt/evbHiCMWdlVuSjyrN4LrVCyAtme a+ukt53u3OU9UvgU3n3tI5gbKjznv1X2Un18Dm1bbxk0p1gAz9DkkO1RmlQgPm7Fzf PGweYcoXQhAmA== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1o6wfP-004OGk-NB; Thu, 30 Jun 2022 17:05:19 +0100 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org Cc: Will Deacon , Catalin Marinas , Mark Rutland , Ard Biesheuvel , broonie@kernel.org, danielmentz@google.com, saravanak@google.com, kernel-team@android.com Subject: [PATCH v2 3/9] arm64: Allow sticky E2H when entering EL1 Date: Thu, 30 Jun 2022 17:04:54 +0100 Message-Id: <20220630160500.1536744-4-maz@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220630160500.1536744-1-maz@kernel.org> References: <20220630160500.1536744-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, ardb@kernel.org, broonie@kernel.org, danielmentz@google.com, saravanak@google.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220630_090525_563169_0841DD14 X-CRM114-Status: GOOD ( 16.53 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org For CPUs that have the unfortunate mis-feature to be stuck in VHE mode, we perform a funny dance where we completely shortcut the normal boot process to enable VHE and run the kernel at EL2, and only then start booting the kernel. Not only this is pretty ugly, but it means that the EL2 finalisation occurs before we have processed the sysreg override. Instead, start executing the kernel as if it was an EL1 guest and rely on the normal EL2 finalisation to go back to EL2. Signed-off-by: Marc Zyngier --- arch/arm64/kernel/head.S | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 053cd6803147..fbdb651c090f 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -501,6 +501,8 @@ SYM_INNER_LABEL(init_el2, SYM_L_LOCAL) msr vbar_el2, x0 isb + mov_q x1, INIT_SCTLR_EL1_MMU_OFF + /* * Fruity CPUs seem to have HCR_EL2.E2H set to RES1, * making it impossible to start in nVHE mode. Is that @@ -510,35 +512,19 @@ SYM_INNER_LABEL(init_el2, SYM_L_LOCAL) and x0, x0, #HCR_E2H cbz x0, 1f - /* Switching to VHE requires a sane SCTLR_EL1 as a start */ - mov_q x0, INIT_SCTLR_EL1_MMU_OFF - msr_s SYS_SCTLR_EL12, x0 - - /* - * Force an eret into a helper "function", and let it return - * to our original caller... This makes sure that we have - * initialised the basic PSTATE state. - */ - mov x0, #INIT_PSTATE_EL2 - msr spsr_el1, x0 - adr x0, __cpu_stick_to_vhe - msr elr_el1, x0 - eret + /* Set a sane SCTLR_EL1, the VHE way */ + msr_s SYS_SCTLR_EL12, x1 + mov x2, #BOOT_CPU_FLAG_E2H + b 2f 1: - mov_q x0, INIT_SCTLR_EL1_MMU_OFF - msr sctlr_el1, x0 - + msr sctlr_el1, x1 + mov x2, xzr +2: msr elr_el2, lr mov w0, #BOOT_CPU_MODE_EL2 + orr x0, x0, x2 eret - -__cpu_stick_to_vhe: - mov x0, #HVC_FINALISE_EL2 - hvc #0 - mov x0, #BOOT_CPU_MODE_EL2 - orr x0, x0, #BOOT_CPU_FLAG_E2H - ret SYM_FUNC_END(init_kernel_el) /* -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel