From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web10.75328.1656957198518255551 for ; Mon, 04 Jul 2022 10:53:18 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lwj3KMps; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) 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 10825615F4; Mon, 4 Jul 2022 17:53:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AB22C341CB; Mon, 4 Jul 2022 17:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656957197; bh=MUfuCNyFZFJuoqukOBeZNKSp/ekP0f8aaaJA8xTmZ5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lwj3KMps33MVx5uV1IW2Krh/mFsQHwzsMBbYJGkvzBz6Koc0IzMbmS9ro3qog/lw3 KvxkhTfBSTwIk/RC2Yh0BN6FUNtsgOVFbgvqBYZuGvvJi7wwCy0t6oy5ZMqumBpYBO pJ5z41M1ddekwwdhpswMvHQFeeIyylfOuP04tBCc0YWWMhy9uEfR4YhSiolExoUnzv RoZj+ar1cjkSx7uYnb0hMuVkmzpLidlQ8JQ1wj4Dwerqej8Tan790N1L4nge8X5X6o +u+EZYsXJZ0Tvj1mG+b0HffqxZcrJzoagIcXfmuWJv65P1gBzHK5CHRgxBIyoltSbN QMaUpCBswFupQ== From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: quic_llindhol@quicinc.com, sami.mujawar@arm.com, Ard Biesheuvel , Marc Zyngier , Alexander Graf Subject: [PATCH 4/7] ArmPlatformPkg/PrePeiCore: permit entry with the MMU enabled Date: Mon, 4 Jul 2022 19:52:49 +0200 Message-Id: <20220704175252.4015120-5-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220704175252.4015120-1-ardb@kernel.org> References: <20220704175252.4015120-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Some platforms may set up a preliminary ID map in flash and enter EFI with the MMU and caches enabled, as this removes a lot of the complexity around cache coherency. Let's take this into account, and avoid touching the MMU controls or perform cache invalidation when the MMU is enabled at entry. Signed-off-by: Ard Biesheuvel --- ArmPlatformPkg/PrePeiCore/PrePeiCore.c | 22 +++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCore.c b/ArmPlatformPkg/PrePei= Core/PrePeiCore.c index 6dd9bcdea24f..d56918365f71 100644 --- a/ArmPlatformPkg/PrePeiCore/PrePeiCore.c +++ b/ArmPlatformPkg/PrePeiCore/PrePeiCore.c @@ -58,17 +58,19 @@ CEntryPoint ( IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint=0D )=0D {=0D - // Data Cache enabled on Primary core when MMU is enabled.=0D - ArmDisableDataCache ();=0D - // Invalidate instruction cache=0D - ArmInvalidateInstructionCache ();=0D - // Enable Instruction Caches on all cores.=0D - ArmEnableInstructionCache ();=0D + if (!ArmMmuEnabled ()) {=0D + // Data Cache enabled on Primary core when MMU is enabled.=0D + ArmDisableDataCache ();=0D + // Invalidate instruction cache=0D + ArmInvalidateInstructionCache ();=0D + // Enable Instruction Caches on all cores.=0D + ArmEnableInstructionCache ();=0D =0D - InvalidateDataCacheRange (=0D - (VOID *)(UINTN)PcdGet64 (PcdCPUCoresStackBase),=0D - PcdGet32 (PcdCPUCorePrimaryStackSize)=0D - );=0D + InvalidateDataCacheRange (=0D + (VOID *)(UINTN)PcdGet64 (PcdCPUCoresStackBase),=0D + PcdGet32 (PcdCPUCorePrimaryStackSize)=0D + );=0D + }=0D =0D //=0D // Note: Doesn't have to Enable CPU interface in non-secure world,=0D --=20 2.35.1