From nobody Fri May 17 05:00:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+86203+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86203+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1643469239; cv=none; d=zohomail.com; s=zohoarc; b=A+8GBLhXBc20nbnAwApz/oU6WF15/84vkAt0XOU/Sfqo+cUEZ9c+z5161zRA44iNvNgJWUN2Qt2jsbPRIs8m8T9FJtCcGhtUV/Xu/Fn/wXHc9/EdjnRkFL9Tvp4Ek1VlchhreK14K6nWWsF92E2fYAGm41vkc1aEW7y6ti5+I8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643469239; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=V995chLATgcAfxkrccBXemeO3Nn08e95s1lqg0wodNY=; b=UWpsGQY57Kvh7282HH3BJjF9kk4O6Ip0uzFafJbG4YlOBO3UQeGXgAdjc2rmj3eHlMxlFTpGijZWt9mLcM491rR9/tD+uZ2qQa3IN4nzYVV8+qX6E30yc5zV5MEzKqnaVqkPKDz0U6MwzP2CERBaz/LCRxHIpvI5IqNWZuvGsas= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86203+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1643469239630966.78352638853; Sat, 29 Jan 2022 07:13:59 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id p36kYY1788612xL9N3kgyWJG; Sat, 29 Jan 2022 07:13:58 -0800 X-Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web09.6909.1643469237861286824 for ; Sat, 29 Jan 2022 07:13:58 -0800 X-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 5F000B827CC; Sat, 29 Jan 2022 15:13:55 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEB76C340E5; Sat, 29 Jan 2022 15:13:52 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, sami.mujawar@arm.com, Ard Biesheuvel , Alexander Graf Subject: [edk2-devel] [PATCH] ArmVirtPkg/ArmVirtMemoryInitPeiLib: avoid redundant cache invalidation Date: Sat, 29 Jan 2022 16:13:46 +0100 Message-Id: <20220129151346.4120964-1-ardb@kernel.org> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ardb@kernel.org X-Gm-Message-State: 98fZcvyXAoZia2ya1ZhhAzpXx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1643469238; bh=8I2B/ZUEDhUCtcW8tmsE3OR4XL6jDh+laF0nNF94vbg=; h=Cc:Date:From:Reply-To:Subject:To; b=XNRsxi0TRkX3I1MRCqUlv1u5T/nQ1eE4hdCRfhB9zJuqeC0nATTWVfByNVUw4LpSaMh q4cUx5eHgagMUKgzG4FS0OOKTJpEnTig3lDKyBzda7I/MkaZp+ixNqjJoS8EHdpegAPPi 4jl17F8Z+YiN9CnIPAkXeat7Zu5zF9gaHU4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1643469242051100003 Content-Type: text/plain; charset="utf-8" Alex reports that the cache invalidation performed by ArmVirtMemoryInitPeiLib takes a non-negligible amount of time at boot. This cache invalidation used to be necessary to avoid inconsistencies between the CPU's cached and uncached views of the permanent PEI memory region, given that the PEI phase is where the MMU gets enabled. The only allocations done from permanent PEI memory with the MMU off are pages used for page tables, and since commit 748fea6279ef ("ArmPkg/ArmMmuLib AARCH64: invalidate page tables before populating them"), each of those is invalidated in the caches explicitly, for reasons described in the patch's commit log. All other allocations done in PEI are either from temporary PEI memory, which includes the stack, or from permanent PEI memory but after the MMU has been enabled. This means that the cache invalidation in ArmVirtMemoryInitPeiLib is no longer necessary, and can simply be dropped. Cc: Alexander Graf Signed-off-by: Ard Biesheuvel Reported-by: Alexander Graf Reviewed-by: Alexander Graf Reviewed-by: Leif Lindholm --- .../ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPe= iLib.c b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib= .c index 022e13e762b6..98d90ad4200d 100644 --- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c +++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c @@ -91,15 +91,6 @@ MemoryPeim ( ); } =20 - // - // When running under virtualization, the PI/UEFI memory region may be - // clean but not invalidated in system caches or in lower level caches - // on other CPUs. So invalidate the region by virtual address, to ensure - // that the contents we put there with the caches and MMU off will still - // be visible after turning them on. - // - InvalidateDataCacheRange ((VOID *)(UINTN)UefiMemoryBase, UefiMemorySize); - // Build Memory Allocation Hob InitMmu (); =20 --=20 2.30.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#86203): https://edk2.groups.io/g/devel/message/86203 Mute This Topic: https://groups.io/mt/88767635/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-