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 7515AC433EF for ; Fri, 4 Mar 2022 17:59:17 +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=lkOVRsO39Sg3EXgDzrRmQj0adAWR2THnWF1szT9A66g=; b=mAbOvu5b5NlU9z do6pSgiHygXJXzPAUWD6SpZq3EiCQ/l9mF1yWJAa26yQgQMkxNBdRyMIO64aqUk7doPFxLxgyjxNJ QDpfPUkREXwob6DJAtfwefyZy3zj/XGqyz3Em97lydWBAeI42hkReRWXJnmtriT+JS2HM1IhmkkKV J2FzUKwJaxKRDDrcOOWdyC/4P/x9xlRATFrN2SnSEp3FbFYrsPwyJ/XTi1izGCUfTz99Vtlk+ffiS UPcxirUvo121c4zzEC7kfsE0GtSOjaP3INTKHPACSY7CEuPZRd4nuJSLMszTlGeLQKTKlBJe9wmnk oeYpOmRp7jgyPTvhK9sQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQCBo-00BSyA-1Y; Fri, 04 Mar 2022 17:58:04 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQCBQ-00BSqU-PW for linux-arm-kernel@lists.infradead.org; Fri, 04 Mar 2022 17:57:42 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 5F5AA60B70; Fri, 4 Mar 2022 17:57:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70BB5C340F3; Fri, 4 Mar 2022 17:57:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646416659; bh=q6OVzR7VMjvKvzoxyOf1cVRnqMPYgwdAEA/10Tfz4EQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NPnSdlVkSHTooeDzctwEuSZW6YbdKx5ObWfEhDyGIVR3TPvrwDOweC+rOZHa1vmWV cptuMLNXUPYgy6gszko0QGRESMtCUGmrj7LLL58we1tkkuV4Q/o3GZ7SXUCV+XZpuX NC9JUG78TSKW3cXbvV30+iJciXKwUZSY6Y9n212u+T1Nuyych7Fe5kl7p9mPsGPLJH ryPQPFsZAkyPBh5JkTv+WG04Q3eLOSmqezJ4TYajeb7fTh4M71RpqMbGeUKIeWFcSQ 6oDIIMzAKvp/H/ygRz2rfNWeKafuXHOLxHev2bQ+eHrWnn6nYkmsfZYZBP/acg2kT+ h1lngGDVtuL1w== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: mark.rutland@arm.com, android-kvm@google.com, Ard Biesheuvel , Marc Zyngier , Will Deacon Subject: [RFC PATCH 2/8] arm64: head: record the MMU state at primary entry Date: Fri, 4 Mar 2022 18:56:51 +0100 Message-Id: <20220304175657.2744400-3-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220304175657.2744400-1-ardb@kernel.org> References: <20220304175657.2744400-1-ardb@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_095740_888223_D0AED746 X-CRM114-Status: GOOD ( 11.33 ) 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 Prepare for being able to deal with primary entry with the MMU and caches enabled, by recording whether or not we entered at EL1 with the MMU on in register x25. While at it, add the disable_mmu_workaround macro invocation to init_kernel_el, as its manipulation of SCTLR_EL1 may come down to disabling of the MMU after subsequent patches. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/head.S | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 6a98f1a38c29..bec9c1483584 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -87,8 +87,10 @@ * x28 __create_page_tables() callee preserved temp register * x19/x20 __primary_switch() callee preserved temp registers * x24 __primary_switch() .. relocate_kernel() current RELR displacement + * x25 primary_entry() .. start_kernel() whether we entered at EL1 with the MMU on */ SYM_CODE_START(primary_entry) + bl record_mmu_state bl preserve_boot_args bl init_kernel_el // w0=cpu_boot_mode adrp x23, __PHYS_OFFSET @@ -105,6 +107,16 @@ SYM_CODE_START(primary_entry) b __primary_switch SYM_CODE_END(primary_entry) +SYM_CODE_START_LOCAL(record_mmu_state) + mrs x25, CurrentEL + cmp x25, #CurrentEL_EL2 + b.eq 0f + mrs x25, sctlr_el1 + tst x25, #SCTLR_ELx_M +0: cset w25, ne + ret +SYM_CODE_END(record_mmu_state) + /* * Preserve the arguments passed by the bootloader in x0 .. x3 */ @@ -500,6 +512,7 @@ SYM_FUNC_START(init_kernel_el) SYM_INNER_LABEL(init_el1, SYM_L_LOCAL) mov_q x0, INIT_SCTLR_EL1_MMU_OFF + pre_disable_mmu_workaround msr sctlr_el1, x0 isb mov_q x0, INIT_PSTATE_EL1 -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel