From nobody Tue May 14 17:51:23 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+94324+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+94324+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180723; cv=none; d=zohomail.com; s=zohoarc; b=DVFlLIaMvH7IeqNtP/yTcDrry5KbYVcD2nBQXjanC6Uzy/aWj120KUnbQcRXGgT9qyeBXqCvSpHJFZ3OEIFMJjXOuDJLsfpt2CPLxzVWbgFBCP5uCxPW3rQpPtCMjjgaO5dY1+lrYRJjEvzqahdD4uvh04MnqRbI9SprTV2xuMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180723; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=V1CtUkvL3GYIbtA6NjeLA1+SkK9RRTYP/67fkpXYz8o=; b=fZkUrfwTk2QG1XCH2FVyGQsnns98CzRB/AYMdlqhj866ghmuhEQPiVDRGUQKMcAmGJUW6fwO1q/qA9jYfG+y2mAa0tmftAzKSxw1Fgf0BKGQ6Zinz8zObakFM3rlHw3P6qFcpLSxkYVHQXe40XM/d81NYL5t33xbM5xjuHASqS0= 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+94324+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 1664180723873264.1591132908716; Mon, 26 Sep 2022 01:25:23 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id u2CEYY1788612xOLobcriqfq; Mon, 26 Sep 2022 01:25:23 -0700 X-Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web08.25928.1664180722356018723 for ; Mon, 26 Sep 2022 01:25:22 -0700 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 AE27DB8199C; Mon, 26 Sep 2022 08:25:20 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75CC2C433B5; Mon, 26 Sep 2022 08:25:18 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 01/16] ArmVirtPkg: remove EbcDxe from all platforms Date: Mon, 26 Sep 2022 10:24:56 +0200 Message-Id: <20220926082511.2110797-2-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: laOv1hCBodOhxLmUVhkX4r6Vx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180723; bh=YR9A+7vDD1pH9OskrbOZkP58bRHJhEr1Ga9Y2i6milc=; h=Cc:Date:From:Reply-To:Subject:To; b=BdMxzKsWmZ/ekraYE5+wjzRvMQDhLJ+W/YoQvNGH6jtlfBCwFe09F9Xj3AXYSSnYcCF rotW4IDP3SX1Yg3DMLKk6xkcxNhcttOPCjRTNAihBv6Uf3Pmfb5zQecWHuf1krLpUtNzX gMFTiVlB5WIbF/ohTGCXLyfJR2BBVpqw9cA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180724223100001 Content-Type: text/plain; charset="utf-8" The EBC interpreter is rarely, if ever, used on ARM, and is especially pointless on virtual machines. So let's drop it from the builds. Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirt.dsc.inc | 5 ----- ArmVirtPkg/ArmVirtCloudHv.fdf | 5 ----- ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 5 ----- ArmVirtPkg/ArmVirtXen.fdf | 5 ----- 4 files changed, 20 deletions(-) diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index c39e2506a3ea..34575585adbb 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -422,8 +422,3 @@ [Components.AARCH64] NULL|EmbeddedPkg/Library/PlatformHasAcpiLib/PlatformHasAcpiLib.inf } - - # - # EBC support - # - MdeModulePkg/Universal/EbcDxe/EbcDxe.inf diff --git a/ArmVirtPkg/ArmVirtCloudHv.fdf b/ArmVirtPkg/ArmVirtCloudHv.fdf index 81c539590a76..a5f172d79bfc 100644 --- a/ArmVirtPkg/ArmVirtCloudHv.fdf +++ b/ArmVirtPkg/ArmVirtCloudHv.fdf @@ -195,11 +195,6 @@ [FV.FvMain] INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphic= sResourceTableDxe.inf INF ArmVirtPkg/CloudHvAcpiPlatformDxe/CloudHvAcpiPlatformDxe.inf - - # - # EBC support - # - INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf !endif =20 # diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc b/ArmVirtPkg/ArmVirtQemuF= vMain.fdf.inc index d4df6dede0fe..787286133095 100644 --- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc +++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc @@ -146,11 +146,6 @@ [FV.FvMain] INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphic= sResourceTableDxe.inf INF OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf - - # - # EBC support - # - INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf !endif =20 # diff --git a/ArmVirtPkg/ArmVirtXen.fdf b/ArmVirtPkg/ArmVirtXen.fdf index 132480f03059..770fbf7289be 100644 --- a/ArmVirtPkg/ArmVirtXen.fdf +++ b/ArmVirtPkg/ArmVirtXen.fdf @@ -201,11 +201,6 @@ [FV.FvMain] !if $(ARCH) =3D=3D AARCH64 INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf INF ArmVirtPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf - - # - # EBC support - # - INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf !endif =20 # --=20 2.35.1 -=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 (#94324): https://edk2.groups.io/g/devel/message/94324 Mute This Topic: https://groups.io/mt/93922689/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- From nobody Tue May 14 17:51:23 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+94325+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+94325+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180724; cv=none; d=zohomail.com; s=zohoarc; b=QFyK3lZ1/jtFSfyfaVuDxhESC5AvPwKBRrOXpDQMICE4xEEi1kC5fJweOOXBNs/sNslEjmOM2PVBG3qoPiGB1v8FV+e5r+yHcBXcEt2k13nL0Q+U6i14gZ8XAOObDKHfC0wDmD4wPKF5ZdJ0PXcL1KNCzmbJascxwqXYFl8G00c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180724; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=jJAPkP9FS6QEbhVh9fvJaPmHDeBRbGbxVUvsVdURcpc=; b=ezN/I8XSqAB7uyru49HrF4DH35W58fBorETg+ueGNrZfHCHn8Kyn4wcXzEO+t4/26/VTtQ0bJG413KEJZSiaKY5esfZyyQnCu+Itp2uxyM8LiK35tn5FEKCgfvss5uY++ha+j8iyweyIIjg7lvgr40THBY902SArwJHlsZP3+AI= 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+94325+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 1664180724302678.2200255620791; Mon, 26 Sep 2022 01:25:24 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id lOqqYY1788612xJFTVhum419; Mon, 26 Sep 2022 01:25:24 -0700 X-Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web11.26073.1664180722740406658 for ; Mon, 26 Sep 2022 01:25:23 -0700 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 3565EB81998; Mon, 26 Sep 2022 08:25:21 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE164C433D7; Mon, 26 Sep 2022 08:25:19 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 02/16] ArmVirtPkg: do not enable iSCSI driver by default Date: Mon, 26 Sep 2022 10:24:57 +0200 Message-Id: <20220926082511.2110797-3-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: xaUoX1racklfxRkMTUEZaywRx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180724; bh=k6DCXmLuSzQCoKaglFAhhx6K0DJnphSjI5B5wGlifYk=; h=Cc:Date:From:Reply-To:Subject:To; b=mRsVRqq1tyICchY4XOz/lqCiUqa70+NrgXPLJCbqlRpDouzfqDKlA4CIyxZ8JrtUa9o jLoZ3oQbG/9uukqZdt6sQJx+Z+Ixhl+bcNA8Yq9OdKh1GacCqJ3N1LoDXpvZg5SqaofDA OL3TMRx/Q0EuBRCRZA4L3CU8OAZ/l+W+klM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180726197100007 Content-Type: text/plain; charset="utf-8" The iSCSI driver slows down the boot on a pristine variable store flash image, as it creates a couple of large EFI non-volatile variables to preserve state between boots. Since iSCSI boot for VMs is kind of niche anyway, let's default to disabled. If someone needs it in their build, they can use the -D build command option to re-enable it on the fly. Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirtQemu.dsc | 1 - ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 - 2 files changed, 2 deletions(-) diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index 9369a88858fd..45c4a8fc84e0 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -40,7 +40,6 @@ [Defines] DEFINE NETWORK_SNP_ENABLE =3D FALSE DEFINE NETWORK_TLS_ENABLE =3D FALSE DEFINE NETWORK_ALLOW_HTTP_CONNECTIONS =3D TRUE - DEFINE NETWORK_ISCSI_ENABLE =3D TRUE =20 !if $(NETWORK_SNP_ENABLE) =3D=3D TRUE !error "NETWORK_SNP_ENABLE is IA32/X64/EBC only" diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKerne= l.dsc index 7f7d15d6eee3..66039f07f41b 100644 --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc @@ -38,7 +38,6 @@ [Defines] DEFINE NETWORK_SNP_ENABLE =3D FALSE DEFINE NETWORK_TLS_ENABLE =3D FALSE DEFINE NETWORK_ALLOW_HTTP_CONNECTIONS =3D TRUE - DEFINE NETWORK_ISCSI_ENABLE =3D TRUE =20 !if $(NETWORK_SNP_ENABLE) =3D=3D TRUE !error "NETWORK_SNP_ENABLE is IA32/X64/EBC only" --=20 2.35.1 -=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 (#94325): https://edk2.groups.io/g/devel/message/94325 Mute This Topic: https://groups.io/mt/93922690/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- From nobody Tue May 14 17:51:23 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+94326+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+94326+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180726; cv=none; d=zohomail.com; s=zohoarc; b=BK4I/xq9ALdnxa0azAMpPUSxYorQPZE7k1PvhoUnoXk1hgSC22OBNAVERaRBQBbjmrjgTlre/+Ska/Sp1BloKVD13rH/e240bYrd/zdjMvYpzUecWykm8+HNZ82TOqI+HDLbC+x6nsXoUMILUoM0aaudD/E8OeO1cdBzef6wHx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180726; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=J2U9NTGy/vT6yZ+1NdLtwbhUczDq9Ns8OTJyqguNalk=; b=BUG02qUwyV/8P+FFEYfc2+cI3LGUltIsx1GTgzU6rmm/zcRRrde1LCmrfrM8b3Dgb8dC5bpU4+g5n7ykaBEsiQS/vzjbMPkl10L7PU4JQYfHgi5XJblICh6XhZIuxIYcoETxgM0T5fwunTkfU52lqZYHARR1jgPYjlgA9PlIQuM= 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+94326+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 166418072669749.189237935274946; Mon, 26 Sep 2022 01:25:26 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id mDtEYY1788612xwz6euVfwj9; Mon, 26 Sep 2022 01:25:24 -0700 X-Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web08.25929.1664180724031195019 for ; Mon, 26 Sep 2022 01:25:24 -0700 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 9C9F3B8199F; Mon, 26 Sep 2022 08:25:22 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52652C433D6; Mon, 26 Sep 2022 08:25:21 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 03/16] ArmVirtPkg: make EFI_LOADER_DATA non-executable Date: Mon, 26 Sep 2022 10:24:58 +0200 Message-Id: <20220926082511.2110797-4-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: YUiDHxh4TSNAZtScsNJ5qiIax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180724; bh=u+iq2BvciEXnblkqXPflJ/8r6gk9bHagQs0iq+Uqh70=; h=Cc:Date:From:Reply-To:Subject:To; b=GRVcQNOnxi+40yOczZ6e2XBUijuKheB9Zh3pGiWCp5SjPfJ+tdc9h+bUA885GLb2BmY InXuahE2H3KovJOhPdecXGZj7LONLJ1t0BAvTJ49EWUEKOXOerD8zEaecCZQcGRIDFph3 pMBIKGYfMj2Z2Q+QteV1UfVIjgAg01n1Sko= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180728204100014 Content-Type: text/plain; charset="utf-8" When the memory protections were implemented and enabled on ArmVirtQemu 5+ years ago, we had to work around the fact that GRUB at the time expected EFI_LOADER_DATA to be executable, as that is the memory type it allocates when loading its modules. This has been fixed in GRUB in August 2017, so by now, we should be able to tighten this, and remove execute permissions from EFI_LOADER_DATA allocations. Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- ArmVirtPkg/ArmVirt.dsc.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index 34575585adbb..462073517a22 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -368,7 +368,7 @@ [PcdsFixedAtBuild.common] # reserved ones, with the exception of LoaderData regions, of which OS l= oaders # (i.e., GRUB) may assume that its contents are executable. # - gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy|0xC0000000= 00007FD1 + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy|0xC0000000= 00007FD5 =20 [Components.common] # --=20 2.35.1 -=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 (#94326): https://edk2.groups.io/g/devel/message/94326 Mute This Topic: https://groups.io/mt/93922691/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- From nobody Tue May 14 17:51:23 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+94328+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+94328+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180731; cv=none; d=zohomail.com; s=zohoarc; b=XgK0qVMPpjn3yEd2zP9KlbfdnHkXI3qHiQfDbQGbai3fzsWFkHLzQlLKl2LO3geTft+oMJvv+H+LNyjy4UNtohTCtovFeIAWsko+qJGFwZ7Ujw828o5/05jUjiLBaCN3jB4O/w6mE2K/fez4bRlPU0jDx6BtF6XpB6UU4b0HQSE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180731; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=hWPvTVFbd0FrIqkjzOD1YauIVT1d7eu7APgv5shp34s=; b=BEnxz8BeuDkKqOOTphJFj4pG5FggJeUMGswa7bQY8yqx3WKmibFg7FEWuWgOef/lAVuJTYFMYTqo+Zih4pynXnwn5m+o68wzUP1mfypKC9s/+5gnYY7HqBI3m6Fdp5KfdXL5qvh3Eq+KVA1iM2jfOYyVWI+yWFFK415qJ2FiWYU= 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+94328+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 166418073108437.885220000378354; Mon, 26 Sep 2022 01:25:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id n4tLYY1788612xO75DDRCUOy; Mon, 26 Sep 2022 01:25:29 -0700 X-Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by mx.groups.io with SMTP id smtpd.web12.26319.1664180728672879512 for ; Mon, 26 Sep 2022 01:25:29 -0700 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 sin.source.kernel.org (Postfix) with ESMTPS id 4E264CE0E11; Mon, 26 Sep 2022 08:25:25 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAA77C433C1; Mon, 26 Sep 2022 08:25:22 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 04/16] ArmVirtPkg/ArmVirtQemu: wire up timeout PCD to Timeout variable Date: Mon, 26 Sep 2022 10:24:59 +0200 Message-Id: <20220926082511.2110797-5-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: PGaL0XDrY3yCnJY1ppOTjhSZx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180729; bh=vBnYerZl7kBVn9aHwItGHP1xJJc9M1EiJcyuJZmiOVk=; h=Cc:Date:From:Reply-To:Subject:To; b=VpZothtYxlD//cuIJ6L6xhdI0Qhhf/QLKy3I7pYnyB1DuAkpE8DkZRNuHThsDE36MaR r1zVQTWOMZE5PLWZE+OkAJSQ66Oh6kJs3kkKajoBC4SQxFG1AKyrxuT1wRASHqVacm4UN oM5PDykGUaa6XX+EUqFO16b37kXbFjW4cpo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180732314100003 Content-Type: text/plain; charset="utf-8" Use the appropriate PCD definition in the ArmVirtQemu DSC so that the boot timeout is taken from the Timeout variable automatically, which is what Linux tools such as efibootmgr expect. Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirtQemu.dsc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index 45c4a8fc84e0..302c0d2a4e29 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -292,6 +292,8 @@ [PcdsDynamicHii] gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiTableRev|L"TCG2_VERSION"|gTcg2C= onfigFormSetGuid|0x8|3|NV,BS !endif =20 + gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVar= iableGuid|0x0|5 + ##########################################################################= ###### # # Components Section - list of all EDK II Modules needed by this Platform --=20 2.35.1 -=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 (#94328): https://edk2.groups.io/g/devel/message/94328 Mute This Topic: https://groups.io/mt/93922694/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- From nobody Tue May 14 17:51:23 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+94327+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+94327+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180727; cv=none; d=zohomail.com; s=zohoarc; b=JwOqfpNjSYSqQiLBfSFULiMVRb0hNrcMWw9+m/Sn5L/eey8gUrfyc9FHn3zLVH+Cn1XV0rZO4LkjZocazdtDb7jYYtkx2bluIT46N2upj7wu2N0NnkXkfEacGvEew5+K/26pbR5QFE7WU7NdFVGgtzctCGQw+v+tsKT7Qra+FTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180727; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ArZ1k+5CnR1mvdZRw/KIr7Klb2Wy+KSqXoUWkBoa/S4=; b=mrypTwcbA4lL31zoM1N9FSupebfjwLW4lDOEZ+Dh7v0ZCqf8kR3ksf68EzxJyYCFfUon2hPGvQBHkoqxZQOjhA+CjXHcEAbnRtN0m+Flv0pz7p6qPeG6z0TBjo/GaTeS9eAUDak975nh9LJhYm+cH0+vkM0PugG1V3CTDocyDzc= 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+94327+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 1664180727681262.9350689129516; Mon, 26 Sep 2022 01:25:27 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id O9XDYY1788612xuTvsmQzCOg; Mon, 26 Sep 2022 01:25:26 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web08.25931.1664180726255277846 for ; Mon, 26 Sep 2022 01:25:26 -0700 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 dfw.source.kernel.org (Postfix) with ESMTPS id BD41461902; Mon, 26 Sep 2022 08:25:25 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 304A2C433D6; Mon, 26 Sep 2022 08:25:24 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 05/16] ArmPkg/ArmMmuLib: don't replace table entries with block entries Date: Mon, 26 Sep 2022 10:25:00 +0200 Message-Id: <20220926082511.2110797-6-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: grZRzBO0uhReF09vXJB1ZV2Sx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180726; bh=i6/8SNY8npaaR4bXF7NLtrzXS6jfpO6Vl+rhLmaQwIY=; h=Cc:Date:From:Reply-To:Subject:To; b=dDTDf3d4dlazL6li2WITDmpB32t3HQj5S/Oi00RtvqcbgMtS0MJTu0FdVx3QUWl3Q3l C2U3scyDMbWGTG9IgQSogbhdxbD6z1eBmgiDZuY7hVVbSCjo2toZ/KnEYOONQr3qmGXcZ pHLvJ6hxaBMm2M5K1D/8CsadFb07gpIWZk4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180728237100016 Content-Type: text/plain; charset="utf-8" Drop the optimization that replaces table entries with block entries and frees the page tables in the subhierarchy that is being replaced. This rarely occurs in practice anyway, and will require more elaborate TLB maintenance once we switch to a different approach when running at EL1, where we no longer disable the MMU and nuke the TLB entirely every time we update a descriptor in a way that requires break-before-make (BBM). Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Libr= ary/ArmMmuLib/AArch64/ArmMmuLibCore.c index e5ecc7375153..34f1031c4de3 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c @@ -197,12 +197,9 @@ UpdateRegionMappingRecursive ( // than a block, and recurse to create the block or page entries at // the next level. No block mappings are allowed at all at level 0, // so in that case, we have to recurse unconditionally. - // If we are changing a table entry and the AttributeClearMask is non-= zero, - // we cannot replace it with a block entry without potentially losing - // attribute information, so keep the table entry in that case. // if ((Level =3D=3D 0) || (((RegionStart | BlockEnd) & BlockMask) !=3D 0= ) || - (IsTableEntry (*Entry, Level) && (AttributeClearMask !=3D 0))) + IsTableEntry (*Entry, Level)) { ASSERT (Level < 3); =20 @@ -294,20 +291,7 @@ UpdateRegionMappingRecursive ( EntryValue |=3D (Level =3D=3D 3) ? TT_TYPE_BLOCK_ENTRY_LEVEL3 : TT_TYPE_BLOCK_ENTRY; =20 - if (IsTableEntry (*Entry, Level)) { - // - // We are replacing a table entry with a block entry. This is only - // possible if we are keeping none of the original attributes. - // We can free the table entry's page table, and all the ones below - // it, since we are dropping the only possible reference to it. - // - ASSERT (AttributeClearMask =3D=3D 0); - TranslationTable =3D (VOID *)(UINTN)(*Entry & TT_ADDRESS_MASK_BLOC= K_ENTRY); - ReplaceTableEntry (Entry, EntryValue, RegionStart, TRUE); - FreePageTablesRecursive (TranslationTable, Level + 1); - } else { - ReplaceTableEntry (Entry, EntryValue, RegionStart, FALSE); - } + ReplaceTableEntry (Entry, EntryValue, RegionStart, FALSE); } } =20 --=20 2.35.1 -=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 (#94327): https://edk2.groups.io/g/devel/message/94327 Mute This Topic: https://groups.io/mt/93922693/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- From nobody Tue May 14 17:51:23 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+94331+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+94331+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180733; cv=none; d=zohomail.com; s=zohoarc; b=JfSB4ao/5S4Q4+cOa2upKaZHMoAh8ngumTOB5g3YtHr4jPcZkdznSwk8+XO4AtdDiq+RW1ppy/2xJ0sIRhHQA5NoyuqKYyzzOgJb5T9lWhNKrP2785UfPFuS27/FMnKxB83lZREmbXq1zxKNDJohUxAubDP4QBU8wj3eFjqf2P0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180733; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=JeYt1SVv48L4+zEEzgK89QU3Y9NooukINF1En9UomEg=; b=U9Lbusq0sWwJKQ1rHZGw+MD8qvUc3HwykdGRGUAZzUVtksGzrdmB5k2fZs9U7sy/lXAwsWyouZVoFTTEvSwDH2RO1GbHm/pqtPSJoR1Ax+k4JSF3yxm5pUPVlaF3D4C84WqAgdilk5tsnu1jM/O82SSVQLXiOnw3KZig92ZjL20= 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+94331+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 1664180733081279.3001906921413; Mon, 26 Sep 2022 01:25:33 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id CGwrYY1788612xwfpuY6Su2C; Mon, 26 Sep 2022 01:25:32 -0700 X-Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by mx.groups.io with SMTP id smtpd.web10.25936.1664180731372879402 for ; Mon, 26 Sep 2022 01:25:32 -0700 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 sin.source.kernel.org (Postfix) with ESMTPS id BE6C0CE1091; Mon, 26 Sep 2022 08:25:28 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98BCFC433C1; Mon, 26 Sep 2022 08:25:25 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 06/16] ArmPkg/ArmMmuLib: Disable and re-enable MMU only when needed Date: Mon, 26 Sep 2022 10:25:01 +0200 Message-Id: <20220926082511.2110797-7-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: Rdx70v1Y84b7ImcLUkOL0cHsx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180732; bh=DIRjx+Eckg+1oZ4tMYZRwHJtzzrRx7DrKGqA9TTKIks=; h=Cc:Date:From:Reply-To:Subject:To; b=G5oNR+hU9o2deSPy9w00zD0ajpWIm6Lbyimx5CUA+ZqtzTkeBqApMl0db96NZo57EBB 4pKRDoHWbtraS6sa0NN7CaMmdHp1zkEcK3CRPcVYut43k3bHQkMz06mDgUJbNGSRm2Vkh DmUvlhT2RtOyBuaVqipQwD8fqOgug0jX/Fk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180734582100002 Content-Type: text/plain; charset="utf-8" When updating a page table descriptor in a way that requires break before make, we temporarily disable the MMU to ensure that we don't unmap the memory region that the code itself is executing from. However, this is a condition we can check in a straight-forward manner, and if the regions are disjoint, we don't have to bother with the MMU controls, and we can just perform an ordinary break before make. Signed-off-by: Ard Biesheuvel Acked-by: Leif Lindholm --- ArmPkg/Include/Library/ArmMmuLib.h | 7 +- ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 102 +++++++++++= +++++---- ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S | 43 +++++++-- 3 files changed, 123 insertions(+), 29 deletions(-) diff --git a/ArmPkg/Include/Library/ArmMmuLib.h b/ArmPkg/Include/Library/Ar= mMmuLib.h index 7538a8274a72..b745e2230e7e 100644 --- a/ArmPkg/Include/Library/ArmMmuLib.h +++ b/ArmPkg/Include/Library/ArmMmuLib.h @@ -52,9 +52,10 @@ ArmClearMemoryRegionReadOnly ( VOID EFIAPI ArmReplaceLiveTranslationEntry ( - IN UINT64 *Entry, - IN UINT64 Value, - IN UINT64 RegionStart + IN UINT64 *Entry, + IN UINT64 Value, + IN UINT64 RegionStart, + IN BOOLEAN DisableMmu ); =20 EFI_STATUS diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Libr= ary/ArmMmuLib/AArch64/ArmMmuLibCore.c index 34f1031c4de3..4d75788ed2b2 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c @@ -18,6 +18,17 @@ #include #include #include +#include + +STATIC +VOID ( + EFIAPI *mReplaceLiveEntryFunc + )( + IN UINT64 *Entry, + IN UINT64 Value, + IN UINT64 RegionStart, + IN BOOLEAN DisableMmu + ) =3D ArmReplaceLiveTranslationEntry; =20 STATIC UINT64 @@ -83,14 +94,40 @@ ReplaceTableEntry ( IN UINT64 *Entry, IN UINT64 Value, IN UINT64 RegionStart, + IN UINT64 BlockMask, IN BOOLEAN IsLiveBlockMapping ) { - if (!ArmMmuEnabled () || !IsLiveBlockMapping) { + BOOLEAN DisableMmu; + + // + // Replacing a live block entry with a table entry (or vice versa) requi= res a + // break-before-make sequence as per the architecture. This means the ma= pping + // must be made invalid and cleaned from the TLBs first, and this is a b= it of + // a hassle if the mapping in question covers the code that is actually = doing + // the mapping and the unmapping, and so we only bother with this if act= ually + // necessary. + // + + if (!IsLiveBlockMapping || !ArmMmuEnabled ()) { + // If the mapping is not a live block mapping, or the MMU is not on ye= t, we + // can simply overwrite the entry. *Entry =3D Value; ArmUpdateTranslationTableEntry (Entry, (VOID *)(UINTN)RegionStart); } else { - ArmReplaceLiveTranslationEntry (Entry, Value, RegionStart); + // If the mapping in question does not cover the code that updates the + // entry in memory, or the entry that we are intending to update, we c= an + // use an ordinary break before make. Otherwise, we will need to + // temporarily disable the MMU. + DisableMmu =3D FALSE; + if ((((RegionStart ^ (UINTN)ArmReplaceLiveTranslationEntry) & ~BlockMa= sk) =3D=3D 0) || + (((RegionStart ^ (UINTN)Entry) & ~BlockMask) =3D=3D 0)) + { + DisableMmu =3D TRUE; + DEBUG ((DEBUG_WARN, "%a: splitting block entry with MMU disabled\n",= __FUNCTION__)); + } + + ArmReplaceLiveTranslationEntry (Entry, Value, RegionStart, DisableMmu); } } =20 @@ -155,12 +192,13 @@ IsTableEntry ( STATIC EFI_STATUS UpdateRegionMappingRecursive ( - IN UINT64 RegionStart, - IN UINT64 RegionEnd, - IN UINT64 AttributeSetMask, - IN UINT64 AttributeClearMask, - IN UINT64 *PageTable, - IN UINTN Level + IN UINT64 RegionStart, + IN UINT64 RegionEnd, + IN UINT64 AttributeSetMask, + IN UINT64 AttributeClearMask, + IN UINT64 *PageTable, + IN UINTN Level, + IN BOOLEAN TableIsLive ) { UINTN BlockShift; @@ -170,6 +208,7 @@ UpdateRegionMappingRecursive ( UINT64 EntryValue; VOID *TranslationTable; EFI_STATUS Status; + BOOLEAN NextTableIsLive; =20 ASSERT (((RegionStart | RegionEnd) & EFI_PAGE_MASK) =3D=3D 0); =20 @@ -198,7 +237,14 @@ UpdateRegionMappingRecursive ( // the next level. No block mappings are allowed at all at level 0, // so in that case, we have to recurse unconditionally. // + // One special case to take into account is any region that covers the= page + // table itself: if we'd cover such a region with block mappings, we a= re + // more likely to end up in the situation later where we need to disab= le + // the MMU in order to update page table entries safely, so prefer page + // mappings in that particular case. + // if ((Level =3D=3D 0) || (((RegionStart | BlockEnd) & BlockMask) !=3D 0= ) || + ((Level < 3) && (((UINT64)PageTable & ~BlockMask) =3D=3D RegionSta= rt)) || IsTableEntry (*Entry, Level)) { ASSERT (Level < 3); @@ -234,7 +280,8 @@ UpdateRegionMappingRecursive ( *Entry & TT_ATTRIBUTES_MASK, 0, TranslationTable, - Level + 1 + Level + 1, + FALSE ); if (EFI_ERROR (Status)) { // @@ -246,8 +293,11 @@ UpdateRegionMappingRecursive ( return Status; } } + + NextTableIsLive =3D FALSE; } else { TranslationTable =3D (VOID *)(UINTN)(*Entry & TT_ADDRESS_MASK_BLOC= K_ENTRY); + NextTableIsLive =3D TableIsLive; } =20 // @@ -259,7 +309,8 @@ UpdateRegionMappingRecursive ( AttributeSetMask, AttributeClearMask, TranslationTable, - Level + 1 + Level + 1, + NextTableIsLive ); if (EFI_ERROR (Status)) { if (!IsTableEntry (*Entry, Level)) { @@ -282,7 +333,8 @@ UpdateRegionMappingRecursive ( Entry, EntryValue, RegionStart, - IsBlockEntry (*Entry, Level) + BlockMask, + TableIsLive && IsBlockEntry (*Entry, Level) ); } } else { @@ -291,7 +343,7 @@ UpdateRegionMappingRecursive ( EntryValue |=3D (Level =3D=3D 3) ? TT_TYPE_BLOCK_ENTRY_LEVEL3 : TT_TYPE_BLOCK_ENTRY; =20 - ReplaceTableEntry (Entry, EntryValue, RegionStart, FALSE); + ReplaceTableEntry (Entry, EntryValue, RegionStart, BlockMask, FALSE); } } =20 @@ -301,10 +353,11 @@ UpdateRegionMappingRecursive ( STATIC EFI_STATUS UpdateRegionMapping ( - IN UINT64 RegionStart, - IN UINT64 RegionLength, - IN UINT64 AttributeSetMask, - IN UINT64 AttributeClearMask + IN UINT64 RegionStart, + IN UINT64 RegionLength, + IN UINT64 AttributeSetMask, + IN UINT64 AttributeClearMask, + IN BOOLEAN TableIsLive ) { UINTN T0SZ; @@ -321,7 +374,8 @@ UpdateRegionMapping ( AttributeSetMask, AttributeClearMask, ArmGetTTBR0BaseAddress (), - GetRootTableLevel (T0SZ) + GetRootTableLevel (T0SZ), + TableIsLive ); } =20 @@ -336,7 +390,8 @@ FillTranslationTable ( MemoryRegion->VirtualBase, MemoryRegion->Length, ArmMemoryAttributeToPageAttribute (MemoryRegion->Attributes) | = TT_AF, - 0 + 0, + FALSE ); } =20 @@ -410,7 +465,8 @@ ArmSetMemoryAttributes ( BaseAddress, Length, PageAttributes, - PageAttributeMask + PageAttributeMask, + TRUE ); } =20 @@ -423,7 +479,13 @@ SetMemoryRegionAttribute ( IN UINT64 BlockEntryMask ) { - return UpdateRegionMapping (BaseAddress, Length, Attributes, BlockEntryM= ask); + return UpdateRegionMapping ( + BaseAddress, + Length, + Attributes, + BlockEntryMask, + TRUE + ); } =20 EFI_STATUS diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S b/Arm= Pkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S index 66ebca571e63..e936a5be4e11 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S @@ -12,6 +12,14 @@ =20 .macro __replace_entry, el =20 + // check whether we should disable the MMU + cbz x3, .L1_\@ + + // clean and invalidate first so that we don't clobber + // adjacent entries that are dirty in the caches + dc civac, x0 + dsb nsh + // disable the MMU mrs x8, sctlr_el\el bic x9, x8, #CTRL_M_BIT @@ -38,8 +46,33 @@ // re-enable the MMU msr sctlr_el\el, x8 isb + b .L2_\@ + +.L1_\@: + // write invalid entry + str xzr, [x0] + dsb nshst + + // flush translations for the target address from the TLBs + lsr x2, x2, #12 + .if \el =3D=3D 1 + tlbi vaae1, x2 + .else + tlbi vae\el, x2 + .endif + dsb nsh + + // write updated entry + str x1, [x0] + dsb nshst + +.L2_\@: .endm =20 + // Align this routine to a log2 upper bound of its size, so that it is + // guaranteed not to cross a page or block boundary. + .balign 0x200 + //VOID //ArmReplaceLiveTranslationEntry ( // IN UINT64 *Entry, @@ -53,12 +86,7 @@ ASM_FUNC(ArmReplaceLiveTranslationEntry) msr daifset, #0xf isb =20 - // clean and invalidate first so that we don't clobber - // adjacent entries that are dirty in the caches - dc civac, x0 - dsb nsh - - EL1_OR_EL2_OR_EL3(x3) + EL1_OR_EL2_OR_EL3(x5) 1:__replace_entry 1 b 4f 2:__replace_entry 2 @@ -72,3 +100,6 @@ ASM_GLOBAL ASM_PFX(ArmReplaceLiveTranslationEntrySize) =20 ASM_PFX(ArmReplaceLiveTranslationEntrySize): .long . - ArmReplaceLiveTranslationEntry + + // Double check that we did not overrun the assumed maximum size + .org ArmReplaceLiveTranslationEntry + 0x200 --=20 2.35.1 -=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 (#94331): https://edk2.groups.io/g/devel/message/94331 Mute This Topic: https://groups.io/mt/93922697/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- From nobody Tue May 14 17:51:23 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+94329+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+94329+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180731; cv=none; d=zohomail.com; s=zohoarc; b=P0EXhIWMShnxTfvaRIYCIrKEd7cRyYBAHPEtzqE4FgPzmIv3mbBDXgnCU0uYc7PUI7MMQ6OYiIOxLnEA4ETs3eQVy8N7Hduiz6A7+q96G+fvCj3zTWmoWMU4+4KkQFrQPkJGL8Nphs4sW8Nm0jEI1F4PZ7MWLjeeS32zvweOwmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180731; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=xoRJieThTiPzgiXhAeM4kqbtoqLVSXsiZlw8jcs6Eck=; b=aScxBQ8yD/1ry/QnqqbmhBwaRfmIGnImvWh64SOT4wDfMzd8fdnMLz0oeRgcgsJYGdh6jabJT2VmT8Lo/bnUXy6ynOiJY+sLepFTLKlCsYckC7CwtyEIu+C7Ixgk8cFFFOA5t0QqyHZeCUlrHfHslc7R8lzVEt+PMsvL+1cDPsI= 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+94329+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 1664180731577199.861858642411; Mon, 26 Sep 2022 01:25:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id WIeZYY1788612xiwzrLkQ4wE; Mon, 26 Sep 2022 01:25:31 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web10.25935.1664180729537666112 for ; Mon, 26 Sep 2022 01:25:29 -0700 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 dfw.source.kernel.org (Postfix) with ESMTPS id EB7BA61904; Mon, 26 Sep 2022 08:25:28 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C214C4347C; Mon, 26 Sep 2022 08:25:26 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 07/16] ArmPkg/ArmMmuLib: permit initial configuration with MMU enabled Date: Mon, 26 Sep 2022 10:25:02 +0200 Message-Id: <20220926082511.2110797-8-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: 8RDprPCk2umiwVv5Ao02Xnu4x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180731; bh=Yh5PXofVPcwjx78OdGBP7Hk+CHt23lKdgOBYQQ35fcU=; h=Cc:Date:From:Reply-To:Subject:To; b=gOYo6Q6Bvmsbw5KXGAYxspr+9xFJ3APQe/nmGEaZy4hWvxUickctN/bdLNZ7Ao2XSxp rFl5ZAcnj5xlUoEtbCEvyVkTpq1Tf5kaQGQ/HLBzwgPg1f4VcyUk0b1Xkd0UpofS7etY7 0mWpoJmp6GVOs46ikpu2FzfM9fAroEksl4Y= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180732336100005 Content-Type: text/plain; charset="utf-8" Permit the use of this library with the MMU and caches already enabled. This removes the need for any cache maintenance for coherency, and is generally better for robustness and performance, especially when running under virtualization. Note that this means we have to defer assignment of TTBR0 until the page tables are ready to be used, and so UpdateRegionMapping() can no longer read back TTBR0 directly to discover the root table address. Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 48 +++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Libr= ary/ArmMmuLib/AArch64/ArmMmuLibCore.c index 4d75788ed2b2..ae59e9a7d04e 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c @@ -357,6 +357,7 @@ UpdateRegionMapping ( IN UINT64 RegionLength, IN UINT64 AttributeSetMask, IN UINT64 AttributeClearMask, + IN UINT64 *RootTable, IN BOOLEAN TableIsLive ) { @@ -373,7 +374,7 @@ UpdateRegionMapping ( RegionStart + RegionLength, AttributeSetMask, AttributeClearMask, - ArmGetTTBR0BaseAddress (), + RootTable, GetRootTableLevel (T0SZ), TableIsLive ); @@ -391,6 +392,7 @@ FillTranslationTable ( MemoryRegion->Length, ArmMemoryAttributeToPageAttribute (MemoryRegion->Attributes) | = TT_AF, 0, + RootTable, FALSE ); } @@ -466,6 +468,7 @@ ArmSetMemoryAttributes ( Length, PageAttributes, PageAttributeMask, + ArmGetTTBR0BaseAddress (), TRUE ); } @@ -484,6 +487,7 @@ SetMemoryRegionAttribute ( Length, Attributes, BlockEntryMask, + ArmGetTTBR0BaseAddress (), TRUE ); } @@ -675,14 +679,6 @@ ArmConfigureMmu ( return EFI_OUT_OF_RESOURCES; } =20 - // - // We set TTBR0 just after allocating the table to retrieve its location= from - // the subsequent functions without needing to pass this value across the - // functions. The MMU is only enabled after the translation tables are - // populated. - // - ArmSetTTBR0 (TranslationTable); - if (TranslationTableBase !=3D NULL) { *TranslationTableBase =3D TranslationTable; } @@ -691,14 +687,17 @@ ArmConfigureMmu ( *TranslationTableSize =3D RootTableEntryCount * sizeof (UINT64); } =20 - // - // Make sure we are not inadvertently hitting in the caches - // when populating the page tables. - // - InvalidateDataCacheRange ( - TranslationTable, - RootTableEntryCount * sizeof (UINT64) - ); + if (!ArmMmuEnabled ()) { + // + // Make sure we are not inadvertently hitting in the caches + // when populating the page tables. + // + InvalidateDataCacheRange ( + TranslationTable, + RootTableEntryCount * sizeof (UINT64) + ); + } + ZeroMem (TranslationTable, RootTableEntryCount * sizeof (UINT64)); =20 while (MemoryTable->Length !=3D 0) { @@ -723,12 +722,17 @@ ArmConfigureMmu ( MAIR_ATTR (TT_ATTR_INDX_MEMORY_WRITE_BACK, MAIR_ATTR_NORMAL_MEMORY_WRI= TE_BACK) ); =20 - ArmDisableAlignmentCheck (); - ArmEnableStackAlignmentCheck (); - ArmEnableInstructionCache (); - ArmEnableDataCache (); + ArmSetTTBR0 (TranslationTable); + + if (!ArmMmuEnabled ()) { + ArmDisableAlignmentCheck (); + ArmEnableStackAlignmentCheck (); + ArmEnableInstructionCache (); + ArmEnableDataCache (); + + ArmEnableMmu (); + } =20 - ArmEnableMmu (); return EFI_SUCCESS; =20 FreeTranslationTable: --=20 2.35.1 -=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 (#94329): https://edk2.groups.io/g/devel/message/94329 Mute This Topic: https://groups.io/mt/93922695/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- From nobody Tue May 14 17:51:23 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+94330+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+94330+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180731; cv=none; d=zohomail.com; s=zohoarc; b=RJH9+WVh7/tOJZjgGSZH9/bfbz5wLNq0MMpUPF68PeLmNCuwd8xDVpgy47Tn0vlwwgtodC571Qki2G8OwZCq13DXTJNnztTzvzzwHQ4jCKSVEnfRKiYjAoEuCokucrtTUeiPeslVoyR7gV3YTT860piMeBtV09S4+3A6pAFvyQQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180731; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=sT8RV6ibQMLjv/zT3TtykwZ5acqv0O5dUM4X7UFEPl8=; b=kV3oTuwxQc5829PShDbGz5VhpPnbwA6XDZj16MVlG1HQ9DIwkNPPlKu8n4Z/gQyGc+OBRhvRVPsHiGaXMcGhNu5K501KX25buA4Z+ixXlqk1EEfuHYBOQSmNYmtmIG+swTpqadaLj46xRfGnu7eT1p8kWGh2XlQ8mykaDrECpE4= 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+94330+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 166418073183290.21561768865797; Mon, 26 Sep 2022 01:25:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id LhNCYY1788612x4GuThHRmjg; Mon, 26 Sep 2022 01:25:31 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.26076.1664180730285594418 for ; Mon, 26 Sep 2022 01:25:30 -0700 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 dfw.source.kernel.org (Postfix) with ESMTPS id 9ED756190C; Mon, 26 Sep 2022 08:25:29 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 736F8C433D7; Mon, 26 Sep 2022 08:25:28 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 08/16] ArmPkg/ArmMmuLib: Reuse XIP MMU routines when splitting entries Date: Mon, 26 Sep 2022 10:25:03 +0200 Message-Id: <20220926082511.2110797-9-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: IdcV5Gdy0lbotyjnPcYSf8lxx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180731; bh=YzZehkBL1FTiwvcJvExynaMKp9rU6j/ox387hSsw27o=; h=Cc:Date:From:Reply-To:Subject:To; b=WmoUmsJseAFL+YtCFdjvhKwbNu9bxygemAR9lHCjVzUafg4lluu8aNyL2EM5FnNP9jF XwBpzOrQJsCTg7jgSmkMMtrJMAHrVou1khVGseDS18eNJsf/Kb1jfi5QrqBZZG2nTWSOu vfACzPwgno2W1zYbe89v/60pUqwv940Jo18= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180732368100006 Content-Type: text/plain; charset="utf-8" In order to reduce the likelihood that we will need to rely on the logic that disables and re-enables the MMU for updating a page table entry safely, expose the XIP version of the helper routine via a HOB and use it instead of the one that is copied into DRAM. Since the XIP copy is already clean to the PoC, and will never end up getting unmapped during a block entry split, we can use it safely without any cache maintenance, and without running the risk of pulling the rug from under our feet when updating an entry by going through an invalid mapping. Signed-off-by: Ard Biesheuvel Acked-by: Leif Lindholm --- ArmPkg/ArmPkg.dec | 2 ++ ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 27 ++++++++++= ++-------- ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c | 17 ++++++++++= ++ ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf | 4 +++ ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf | 4 +++ 5 files changed, 44 insertions(+), 10 deletions(-) diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index 9da1bbc9f216..cfb6fe602485 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -99,6 +99,8 @@ [Guids.common] # Include/Guid/ArmMpCoreInfo.h gArmMpCoreInfoGuid =3D { 0xa4ee0728, 0xe5d7, 0x4ac5, {0xb2, 0x1e, 0x65,= 0x8e, 0xd8, 0x57, 0xe8, 0x34} } =20 + gArmMmuReplaceLiveTranslationEntryFuncGuid =3D { 0xa8b50ff3, 0x08ec, 0x4= dd3, {0xbf, 0x04, 0x28, 0xbf, 0x71, 0x75, 0xc7, 0x4a} } + [Protocols.common] ## Arm System Control and Management Interface(SCMI) Base protocol ## ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Libr= ary/ArmMmuLib/AArch64/ArmMmuLibCore.c index ae59e9a7d04e..764c7d362e2e 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c @@ -10,6 +10,7 @@ **/ =20 #include +#include #include #include #include @@ -120,14 +121,14 @@ ReplaceTableEntry ( // use an ordinary break before make. Otherwise, we will need to // temporarily disable the MMU. DisableMmu =3D FALSE; - if ((((RegionStart ^ (UINTN)ArmReplaceLiveTranslationEntry) & ~BlockMa= sk) =3D=3D 0) || + if ((((RegionStart ^ (UINTN)mReplaceLiveEntryFunc) & ~BlockMask) =3D= =3D 0) || (((RegionStart ^ (UINTN)Entry) & ~BlockMask) =3D=3D 0)) { DisableMmu =3D TRUE; DEBUG ((DEBUG_WARN, "%a: splitting block entry with MMU disabled\n",= __FUNCTION__)); } =20 - ArmReplaceLiveTranslationEntry (Entry, Value, RegionStart, DisableMmu); + mReplaceLiveEntryFunc (Entry, Value, RegionStart, DisableMmu); } } =20 @@ -747,15 +748,21 @@ ArmMmuBaseLibConstructor ( ) { extern UINT32 ArmReplaceLiveTranslationEntrySize; + VOID *Hob; =20 - // - // The ArmReplaceLiveTranslationEntry () helper function may be invoked - // with the MMU off so we have to ensure that it gets cleaned to the PoC - // - WriteBackDataCacheRange ( - (VOID *)(UINTN)ArmReplaceLiveTranslationEntry, - ArmReplaceLiveTranslationEntrySize - ); + Hob =3D GetFirstGuidHob (&gArmMmuReplaceLiveTranslationEntryFuncGuid); + if (Hob !=3D NULL) { + mReplaceLiveEntryFunc =3D *(VOID **)GET_GUID_HOB_DATA (Hob); + } else { + // + // The ArmReplaceLiveTranslationEntry () helper function may be invoked + // with the MMU off so we have to ensure that it gets cleaned to the P= oC + // + WriteBackDataCacheRange ( + (VOID *)(UINTN)ArmReplaceLiveTranslationEntry, + ArmReplaceLiveTranslationEntrySize + ); + } =20 return RETURN_SUCCESS; } diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c b/A= rmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c index caace2c17cdc..5f50a605a338 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c @@ -12,6 +12,7 @@ #include #include #include +#include =20 EFI_STATUS EFIAPI @@ -21,6 +22,8 @@ ArmMmuPeiLibConstructor ( ) { extern UINT32 ArmReplaceLiveTranslationEntrySize; + VOID *ArmReplaceLiveTranslationEntryFunc; + VOID *Hob; =20 EFI_FV_FILE_INFO FileInfo; EFI_STATUS Status; @@ -42,6 +45,20 @@ ArmMmuPeiLibConstructor ( (UINTN)ArmReplaceLiveTranslationEntry + ArmReplaceLiveTranslationEn= trySize)) { DEBUG ((DEBUG_INFO, "ArmMmuLib: skipping cache maintenance on XIP PEIM= \n")); + + // + // Expose the XIP version of the ArmReplaceLiveTranslationEntry() rout= ine + // via a HOB so we can fall back to it later when we need to split blo= ck + // mappings in a way that adheres to break-before-make requirements. + // + ArmReplaceLiveTranslationEntryFunc =3D ArmReplaceLiveTranslationEntry; + + Hob =3D BuildGuidDataHob ( + &gArmMmuReplaceLiveTranslationEntryFuncGuid, + &ArmReplaceLiveTranslationEntryFunc, + sizeof ArmReplaceLiveTranslationEntryFunc + ); + ASSERT (Hob !=3D NULL); } else { DEBUG ((DEBUG_INFO, "ArmMmuLib: performing cache maintenance on shadow= ed PEIM\n")); // diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf b/ArmPkg/Library/Ar= mMmuLib/ArmMmuBaseLib.inf index 3d78e7dabf47..57cb71f90ee3 100644 --- a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf +++ b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf @@ -36,7 +36,11 @@ [Packages] [LibraryClasses] ArmLib CacheMaintenanceLib + HobLib MemoryAllocationLib =20 +[Guids] + gArmMmuReplaceLiveTranslationEntryFuncGuid + [Pcd.ARM] gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf b/ArmPkg/Library/Arm= MmuLib/ArmMmuPeiLib.inf index ce9674ea99ef..02f874a1a994 100644 --- a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf +++ b/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf @@ -29,4 +29,8 @@ [Packages] [LibraryClasses] ArmLib CacheMaintenanceLib + HobLib MemoryAllocationLib + +[Guids] + gArmMmuReplaceLiveTranslationEntryFuncGuid --=20 2.35.1 -=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 (#94330): https://edk2.groups.io/g/devel/message/94330 Mute This Topic: https://groups.io/mt/93922696/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- From nobody Tue May 14 17:51:23 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+94333+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+94333+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180735; cv=none; d=zohomail.com; s=zohoarc; b=U30HUBgU/9oCPrvmL0gYf+KrCgySCvXyIpKg2ugcVf84yJAwSgeInyLqU++zS43hio7PP8bbiU1GeC9iWjQcwBZA3TeRtFyCnIDIXRFRXTvRwv6v5TcD6SKhgtOk1baVri9NReCaLO1V1mH3Gy4gB94o3V1ooHzhgquGfqG0qUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180735; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=30IRruMtYHOcxTPn4umH4+k1WwSejBcp0OtpbzZAF44=; b=ikpjLYUHPFKbU12HHDbMVnAgHFapkWNqugtpK9pfqfFYjOi71QN3EFY/ZHerjTlVYEV44y8ye6XeuaSTaXVCht+AqV9KFqbS+ukzIu9Ymi5wc8lyjMfYjXcnQiAEtpCK7dlo76XUabTpsoYR02j917TC5+31BcXPWvK30nsWKuc= 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+94333+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 1664180735010796.6505865091232; Mon, 26 Sep 2022 01:25:35 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id r9bBYY1788612xTProHv75ln; Mon, 26 Sep 2022 01:25:34 -0700 X-Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web08.25932.1664180733681558031 for ; Mon, 26 Sep 2022 01:25:34 -0700 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 23473B819A0; Mon, 26 Sep 2022 08:25:32 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC1C2C433C1; Mon, 26 Sep 2022 08:25:29 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 09/16] ArmPlatformPkg/PrePeiCore: permit entry with the MMU enabled Date: Mon, 26 Sep 2022 10:25:04 +0200 Message-Id: <20220926082511.2110797-10-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: E0j0Z7ZZ8FsPbUUJpd9y3RGYx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180734; bh=Tmszfjnxh3+2hQoyGKTbW25nseDQdO4AIKrnue+j9Bk=; h=Cc:Date:From:Reply-To:Subject:To; b=mgiPzkXBZ3OaI89KH3ldei8T9pmHv4d57sx/4eIZvVf6p06yvOWeTuDSNKozfIEfkdf cH1O+6xcTCHB6XM8TemceE/RR5OfSH2EGnkGK1pSoZl+TGiBC2ur89U6peXAc7BS7g8MA MG+wiJE+MLKpQ2NriIqsNf1ltBvDpOlkzik= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180736370100006 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Leif Lindholm --- 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 9c4b25df953d..8b86c6e69abd 100644 --- a/ArmPlatformPkg/PrePeiCore/PrePeiCore.c +++ b/ArmPlatformPkg/PrePeiCore/PrePeiCore.c @@ -58,17 +58,19 @@ CEntryPoint ( IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint ) { - // Data Cache enabled on Primary core when MMU is enabled. - ArmDisableDataCache (); - // Invalidate instruction cache - ArmInvalidateInstructionCache (); - // Enable Instruction Caches on all cores. - ArmEnableInstructionCache (); + if (!ArmMmuEnabled ()) { + // Data Cache enabled on Primary core when MMU is enabled. + ArmDisableDataCache (); + // Invalidate instruction cache + ArmInvalidateInstructionCache (); + // Enable Instruction Caches on all cores. + ArmEnableInstructionCache (); =20 - InvalidateDataCacheRange ( - (VOID *)(UINTN)PcdGet64 (PcdCPUCoresStackBase), - PcdGet32 (PcdCPUCorePrimaryStackSize) - ); + InvalidateDataCacheRange ( + (VOID *)(UINTN)PcdGet64 (PcdCPUCoresStackBase), + PcdGet32 (PcdCPUCorePrimaryStackSize) + ); + } =20 // // Note: Doesn't have to Enable CPU interface in non-secure world, --=20 2.35.1 -=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 (#94333): https://edk2.groups.io/g/devel/message/94333 Mute This Topic: https://groups.io/mt/93922700/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- From nobody Tue May 14 17:51:23 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+94332+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+94332+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180734; cv=none; d=zohomail.com; s=zohoarc; b=MCcCatLSbeHy5cWb78KQzuNTmOEYIZ0K+xDPTCYNExY1WYFvQ3YWWgDv4CgysX7K+10oLJdv8RN2/cTAtw9C7b35pOdo23c60EiMl9D+jdsGQHrE7bJZAthAkTRLWJFmKqcJSgVO/RdNksx8d72znYzDnAqLEUj2hRtTAsC622I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180734; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=JLX6KqJbEu72gVaTlxpmqgIj3xB92xeN+iZzgKMBKm4=; b=dwfn74L5Jn4hFfmhHoL6O/g/v/G45yQPY5QaSb/L20uoQLDSUrwbhfGQsWlANxbGIdsXRNzDYmxvrMUFuftM6UCv7kT/GbbfAxlagAU8mFJ4BOKebHOG0SzAHJ8cw5LYORmXVvRGDL6M9699G/ZJgT1ycd9c70cNpYL/6yc9b9A= 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+94332+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 1664180734734139.9589283113944; Mon, 26 Sep 2022 01:25:34 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5yuTYY1788612xGciNkHDoPH; Mon, 26 Sep 2022 01:25:33 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web09.26234.1664180733006956333 for ; Mon, 26 Sep 2022 01:25:33 -0700 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 dfw.source.kernel.org (Postfix) with ESMTPS id 7AC1760E84; Mon, 26 Sep 2022 08:25:32 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F13FC43140; Mon, 26 Sep 2022 08:25:31 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 10/16] ArmVirtPkg/ArmVirtQemu: implement ArmPlatformLib with static ID map Date: Mon, 26 Sep 2022 10:25:05 +0200 Message-Id: <20220926082511.2110797-11-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: mWzQkm22iHXkDhxdfdYg5uEHx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180733; bh=exVz258uXedEf+mCZLtqNvVgr4MzKw8o5DCVyaa21Po=; h=Cc:Date:From:Reply-To:Subject:To; b=oWk9rE8vWl3vtG0zwB99wHDhoM5KCPcg9LsqiCInygzerjOMI//AOgose/vJdalR2hf q1mvrxtsnUR+VkxGzz3fPtoDnVA6DyT0mkdwTpmRQ3GEcW1bPrmtGNx/GoD5xo/8xi67H JuDNpO/0huNtDvIMfB/a3yCC97oKy3fLHws= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180736380100007 Content-Type: text/plain; charset="utf-8" To substantially reduce the amount of processing that takes place with the MMU and caches off, implement a version of ArmPlatformLib specific for QEMU/mach-virt in AArch64 mode that carries a statically allocated and populated ID map that covers the NOR flash and device region, and 128 MiB of DRAM at the base of memory (0x4000_0000). Note that 128 MiB has always been the minimum amount of DRAM we support for this configuration, and the existing code already ASSERT()s in DEBUG mode when booting with less. Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S | 115 ++= ++++++++++++++++++ ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.c | 64 ++= +++++++++ ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.inf | 40 ++= +++++ ArmVirtPkg/Library/ArmPlatformLibQemu/IdMap.S | 57 ++= ++++++++ 4 files changed, 276 insertions(+) diff --git a/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelpe= r.S b/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S new file mode 100644 index 000000000000..05ccc7f9f043 --- /dev/null +++ b/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S @@ -0,0 +1,115 @@ +// +// Copyright (c) 2022, Google LLC. All rights reserved. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// + +#include + + .macro mov_i, reg:req, imm:req + movz \reg, :abs_g3:\imm + movk \reg, :abs_g2_nc:\imm + movk \reg, :abs_g1_nc:\imm + movk \reg, :abs_g0_nc:\imm + .endm + + .set MAIR_DEV_nGnRnE, 0x00 + .set MAIR_MEM_NC, 0x44 + .set MAIR_MEM_WT, 0xbb + .set MAIR_MEM_WBWA, 0xff + .set mairval, MAIR_DEV_nGnRnE | (MAIR_MEM_NC << 8) | (MAIR_MEM_WT << 1= 6) | (MAIR_MEM_WBWA << 24) + + .set TCR_TG0_4KB, 0x0 << 14 + .set TCR_TG1_4KB, 0x2 << 30 + .set TCR_IPS_SHIFT, 32 + .set TCR_EPD1, 0x1 << 23 + .set TCR_SH_INNER, 0x3 << 12 + .set TCR_RGN_OWB, 0x1 << 10 + .set TCR_RGN_IWB, 0x1 << 8 + .set tcrval, TCR_TG0_4KB | TCR_TG1_4KB | TCR_EPD1 | TCR_RGN_OWB + .set tcrval, tcrval | TCR_RGN_IWB | TCR_SH_INNER + + .set SCTLR_ELx_I, 0x1 << 12 + .set SCTLR_ELx_SA, 0x1 << 3 + .set SCTLR_ELx_C, 0x1 << 2 + .set SCTLR_ELx_M, 0x1 << 0 + .set SCTLR_EL1_SPAN, 0x1 << 23 + .set SCTLR_EL1_WXN, 0x1 << 19 + .set SCTLR_EL1_SED, 0x1 << 8 + .set SCTLR_EL1_ITD, 0x1 << 7 + .set SCTLR_EL1_RES1, (0x1 << 11) | (0x1 << 20) | (0x1 << 22) | (0= x1 << 28) | (0x1 << 29) + .set sctlrval, SCTLR_ELx_M | SCTLR_ELx_C | SCTLR_ELx_SA | SCTLR_EL1_IT= D | SCTLR_EL1_SED + .set sctlrval, sctlrval | SCTLR_ELx_I | SCTLR_EL1_SPAN | SCTLR_EL1_RES1 + + +ASM_FUNC(ArmPlatformPeiBootAction) + mrs x0, CurrentEL // check current exception level + tbz x0, #3, 0f // bail if above EL1 + ret + +0:mov_i x0, mairval + mov_i x1, tcrval + adrp x2, idmap + orr x2, x2, #0xff << 48 // set non-zero ASID + mov_i x3, sctlrval + + mrs x6, id_aa64mmfr0_el1 // get the supported PA range + and x6, x6, #0xf // isolate PArange bits + cmp x6, #6 // 0b0110 =3D=3D 52 bits + sub x6, x6, #1 // subtract 1 + cinc x6, x6, ne // add back 1 unless PArange =3D=3D 52 bi= ts + bfi x1, x6, #32, #3 // copy updated PArange into TCR_EL1.IPS + + cmp x6, #3 // 0b0011 =3D=3D 42 bits + sub x6, x6, #1 // subtract 1 + cinc x6, x6, lt // add back 1 unless VA range >=3D 42 + + mov x7, #32 + sub x6, x7, x6, lsl #2 // T0SZ for PArange !=3D 42 + mov x7, #64 - 42 // T0SZ for PArange =3D=3D 42 + csel x6, x6, x7, ne + orr x1, x1, x6 // set T0SZ field in TCR + + cmp x6, #64 - 40 // VA size < 40 bits? + add x4, x2, #0x1000 // advance to level 1 descriptor + csel x2, x4, x2, gt + + msr mair_el1, x0 // set up the 1:1 mapping + msr tcr_el1, x1 + msr ttbr0_el1, x2 + isb + + tlbi vmalle1 // invalidate any cached translations + ic iallu // invalidate the I-cache + dsb nsh + isb + + msr sctlr_el1, x3 // enable MMU and caches + isb + ret + +//UINTN +//ArmPlatformGetCorePosition ( +// IN UINTN MpId +// ); +// With this function: CorePos =3D (ClusterId * 4) + CoreId +ASM_FUNC(ArmPlatformGetCorePosition) + mov x0, xzr + ret + +//UINTN +//ArmPlatformGetPrimaryCoreMpId ( +// VOID +// ); +ASM_FUNC(ArmPlatformGetPrimaryCoreMpId) + MOV32 (w0, FixedPcdGet32 (PcdArmPrimaryCore)) + ret + +//UINTN +//ArmPlatformIsPrimaryCore ( +// IN UINTN MpId +// ); +ASM_FUNC(ArmPlatformIsPrimaryCore) + mov x0, #1 + ret diff --git a/ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.c b/A= rmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.c new file mode 100644 index 000000000000..1de80422ee4c --- /dev/null +++ b/ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.c @@ -0,0 +1,64 @@ +/** @file + + Copyright (c) 2011-2012, ARM Limited. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include + +/** + Return the current Boot Mode. + + This function returns the boot reason on the platform + + @return Return the current Boot Mode of the platform + +**/ +EFI_BOOT_MODE +ArmPlatformGetBootMode ( + VOID + ) +{ + return BOOT_WITH_FULL_CONFIGURATION; +} + +/** + Initialize controllers that must setup in the normal world. + + This function is called by the ArmPlatformPkg/PrePi or + ArmPlatformPkg/PlatformPei in the PEI phase. + + @param[in] MpId ID of the calling CPU + + @return RETURN_SUCCESS unless the operation failed +**/ +RETURN_STATUS +ArmPlatformInitialize ( + IN UINTN MpId + ) +{ + return RETURN_SUCCESS; +} + +/** + Return the Platform specific PPIs. + + This function exposes the Platform Specific PPIs. They can be used by any + PrePi modules or passed to the PeiCore by PrePeiCore. + + @param[out] PpiListSize Size in Bytes of the Platform PPI List + @param[out] PpiList Platform PPI List + +**/ +VOID +ArmPlatformGetPlatformPpiList ( + OUT UINTN *PpiListSize, + OUT EFI_PEI_PPI_DESCRIPTOR **PpiList + ) +{ + *PpiListSize =3D 0; + *PpiList =3D NULL; +} diff --git a/ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.inf b= /ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.inf new file mode 100644 index 000000000000..b2ecdfa061cb --- /dev/null +++ b/ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.inf @@ -0,0 +1,40 @@ +## @file +# ArmPlatformLib implementation for QEMU/mach-virt on AArch64 that contai= ns a +# statically allocated 1:1 mapping of the first 128 MiB of DRAM, as well = as +# the NOR flash and the device region +# +# Copyright (c) 2011-2012, ARM Limited. All rights reserved. +# Copyright (c) 2022, Google LLC. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 1.27 + BASE_NAME =3D ArmPlatformLibQemu + FILE_GUID =3D 40af3a25-f02c-4aef-94ef-7ac0282d21d4 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ArmPlatformLib + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + +[LibraryClasses] + ArmLib + DebugLib + +[Sources.common] + ArmPlatformLibQemu.c + IdMap.S + +[Sources.AArch64] + AArch64/ArmPlatformHelper.S + +[FixedPcd] + gArmTokenSpaceGuid.PcdArmPrimaryCoreMask + gArmTokenSpaceGuid.PcdArmPrimaryCore diff --git a/ArmVirtPkg/Library/ArmPlatformLibQemu/IdMap.S b/ArmVirtPkg/Lib= rary/ArmPlatformLibQemu/IdMap.S new file mode 100644 index 000000000000..4a4b7b77ed83 --- /dev/null +++ b/ArmVirtPkg/Library/ArmPlatformLibQemu/IdMap.S @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: BSD-2-Clause-Patent +// Copyright 2022 Google LLC +// Author: Ard Biesheuvel + + .set TT_TYPE_BLOCK, 0x1 + .set TT_TYPE_PAGE, 0x3 + .set TT_TYPE_TABLE, 0x3 + + .set TT_AF, 0x1 << 10 + .set TT_NG, 0x1 << 11 + .set TT_RO, 0x2 << 6 + .set TT_XN, 0x3 << 53 + + .set TT_MT_DEV, 0x0 << 2 // MAIR #0 + .set TT_MT_MEM, (0x3 << 2) | (0x3 << 8) // MAIR #3 + + .set PAGE_XIP, TT_TYPE_PAGE | TT_MT_MEM | TT_AF | TT_RO | TT_NG + .set BLOCK_DEV, TT_TYPE_BLOCK | TT_MT_DEV | TT_AF | TT_XN | TT_NG + .set BLOCK_MEM, TT_TYPE_BLOCK | TT_MT_MEM | TT_AF | TT_XN | TT_NG + + .globl idmap + .section ".rodata.idmap", "a", %progbits + .align 12 + +idmap: /* level 0 */ + .quad 1f + TT_TYPE_TABLE + .fill 511, 8, 0x0 + +1: /* level 1 */ + .quad 20f + TT_TYPE_TABLE // 1 GB of flash and device mapp= ings + .quad 21f + TT_TYPE_TABLE // up to 1 GB of DRAM + .fill 510, 8, 0x0 // 510 GB of remaining VA space + +20: /* level 2 */ + .quad 3f + TT_TYPE_TABLE // up to 2 MB of flash + .fill 63, 8, 0x0 // 126 MB of unused flash + .set idx, 64 + .rept 448 + .quad BLOCK_DEV | (idx << 21) // 896 MB of RW- device mappings + .set idx, idx + 1 + .endr + +21: /* level 2 */ + .set idx, 0x40000000 >> 21 + .rept 64 + .quad BLOCK_MEM | (idx << 21) // 128 MB of RW- memory mappings + .set idx, idx + 1 + .endr + .fill 448, 8, 0x0 + +3: /* level 3 */ + .quad 0x0 // omit first 4k page + .set idx, 1 + .rept 511 + .quad PAGE_XIP | (idx << 12) // 2044 KiB of R-X flash mappings + .set idx, idx + 1 + .endr --=20 2.35.1 -=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 (#94332): https://edk2.groups.io/g/devel/message/94332 Mute This Topic: https://groups.io/mt/93922698/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- From nobody Tue May 14 17:51:23 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+94334+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+94334+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180735; cv=none; d=zohomail.com; s=zohoarc; b=O+l2z0fc5FtP5UR+EuAndbMU+ujUEmovVZmvxsyd9DaUN63plGPqHeZ1SSL3iyS1TpM5HxXHZb9xShI5bzvAZ9Kgp7nlpOH65PZOYedCt75aLGTbLNXd6b/ylJL57T/CENSjNIEFDYVeFErMu7PKCLXdf2howhQGfbIr9pkFAZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180735; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=hF8Gn4NZFrknocuOCav2qzgRIh9PCCId3gbBiAZ0d7w=; b=hFhjjvDCxwXG6hy1XlxWGRfFOotUnNZr/MCPULK8oyxbdad5OcWmTI4+kcdJtsSTTri7LBtc+LW0rwh4jzpRQa9wNUeh80LGY+sVldJzAEOEPEKOsqoQIfKnr82kkt4bpCCyaCbbria07LTb0JJ/UCgrfvaM8P/wUckFQ8rVNWA= 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+94334+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 1664180735970878.4850738465336; Mon, 26 Sep 2022 01:25:35 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id VuN7YY1788612xk1scPi6PN8; Mon, 26 Sep 2022 01:25:35 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web09.26236.1664180734504824694 for ; Mon, 26 Sep 2022 01:25:34 -0700 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 dfw.source.kernel.org (Postfix) with ESMTPS id E2C4461908; Mon, 26 Sep 2022 08:25:33 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6B7CC433D7; Mon, 26 Sep 2022 08:25:32 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 11/16] ArmVirtPkg/ArmVirtQemu: use first 128 MiB as permanent PEI memory Date: Mon, 26 Sep 2022 10:25:06 +0200 Message-Id: <20220926082511.2110797-12-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: DmynYxwhxJx5QnVLduSBfvF3x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180735; bh=6bidM8/EHaDAcY+1dtXVVcaeiZRwcFJlf7l0w/LLhr8=; h=Cc:Date:From:Reply-To:Subject:To; b=VCML26X7CbEfHujkf6e74h/g5OTl5B/cHhBe12aclJogMn3041OIPiQNsyVfw50KaLp 7Ri3XCLISOkmhcm25Y/SxL8bBc9vs7W+5ApllV0dGZ5F9eKn3BY6So+RHxbCUJav4wQqC sT53EStU9QwoO8iGozRdxjRzi5PVf4J0C+s= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180736388100008 Content-Type: text/plain; charset="utf-8" In order to allow booting with the MMU and caches enabled really early, we need to ensure that the code that populates the page tables can access those page tables with the statically defined ID map active. So let's put the permanent PEI RAM in the first 128 MiB of memory, which we will cover with this initial ID map (as it is the minimum supported DRAM size for ArmVirtQemu). Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c | 104 ++++++++++++++++++++ ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf | 59 +++++++++++ 2 files changed, 163 insertions(+) diff --git a/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c b/ArmVirtPkg/MemoryI= nitPei/MemoryInitPeim.c new file mode 100644 index 000000000000..ef88a9df1d62 --- /dev/null +++ b/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c @@ -0,0 +1,104 @@ +/** @file + + Copyright (c) 2011, ARM Limited. All rights reserved. + Copyright (c) 2022, Google LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include + +EFI_STATUS +EFIAPI +MemoryPeim ( + IN EFI_PHYSICAL_ADDRESS UefiMemoryBase, + IN UINT64 UefiMemorySize + ); + +/** + Build the memory type information HOB that describes how many pages of e= ach + type to preallocate when initializing the GCD memory map. +**/ +VOID +EFIAPI +BuildMemoryTypeInformationHob ( + VOID + ) +{ + EFI_MEMORY_TYPE_INFORMATION Info[10]; + + Info[0].Type =3D EfiACPIReclaimMemory; + Info[0].NumberOfPages =3D FixedPcdGet32 (PcdMemoryTypeEfiACPIReclaimMemo= ry); + Info[1].Type =3D EfiACPIMemoryNVS; + Info[1].NumberOfPages =3D FixedPcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS); + Info[2].Type =3D EfiReservedMemoryType; + Info[2].NumberOfPages =3D FixedPcdGet32 (PcdMemoryTypeEfiReservedMemoryT= ype); + Info[3].Type =3D EfiRuntimeServicesData; + Info[3].NumberOfPages =3D FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServices= Data); + Info[4].Type =3D EfiRuntimeServicesCode; + Info[4].NumberOfPages =3D FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServices= Code); + Info[5].Type =3D EfiBootServicesCode; + Info[5].NumberOfPages =3D FixedPcdGet32 (PcdMemoryTypeEfiBootServicesCod= e); + Info[6].Type =3D EfiBootServicesData; + Info[6].NumberOfPages =3D FixedPcdGet32 (PcdMemoryTypeEfiBootServicesDat= a); + Info[7].Type =3D EfiLoaderCode; + Info[7].NumberOfPages =3D FixedPcdGet32 (PcdMemoryTypeEfiLoaderCode); + Info[8].Type =3D EfiLoaderData; + Info[8].NumberOfPages =3D FixedPcdGet32 (PcdMemoryTypeEfiLoaderData); + + // Terminator for the list + Info[9].Type =3D EfiMaxMemoryType; + Info[9].NumberOfPages =3D 0; + + BuildGuidDataHob (&gEfiMemoryTypeInformationGuid, &Info, sizeof (Info)); +} + +/** + Module entry point. + + @param[in] FileHandle Handle of the file being invoked. + @param[in] PeiServices Describes the list of possible PEI Services. + + @return EFI_SUCCESS unless the operation failed. +**/ +EFI_STATUS +EFIAPI +InitializeMemory ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + UINTN UefiMemoryBase; + EFI_STATUS Status; + + ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) < (UINT64)MAX_ALLOC_ADDRESS); + + // + // Put the permanent PEI memory in the first 128 MiB of DRAM so that + // it is covered by the statically configured ID map. + // + UefiMemoryBase =3D (UINTN)FixedPcdGet64 (PcdSystemMemoryBase) + SIZE_128= MB + - FixedPcdGet32 (PcdSystemMemoryUefiRegionSize); + + Status =3D PeiServicesInstallPeiMemory ( + UefiMemoryBase, + FixedPcdGet32 (PcdSystemMemoryUefiRegionSize) + ); + ASSERT_EFI_ERROR (Status); + + Status =3D MemoryPeim ( + UefiMemoryBase, + FixedPcdGet32 (PcdSystemMemoryUefiRegionSize) + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf b/ArmVirtPkg/Memor= yInitPei/MemoryInitPeim.inf new file mode 100644 index 000000000000..2039f71a0ebe --- /dev/null +++ b/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf @@ -0,0 +1,59 @@ +## @file +# Implementation of MemoryInitPeim that uses the first 128 MiB at the bas= e of +# DRAM as permanent PEI memory +# +# Copyright (c) 2011-2014, ARM Ltd. All rights reserved.
+# Copyright (c) 2022, Google LLC. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 1.27 + BASE_NAME =3D MemoryInit + FILE_GUID =3D 0fbffd44-f98f-4e1c-9922-e9b21f13c3f8 + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D InitializeMemory + +[Sources] + MemoryInitPeim.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + +[LibraryClasses] + PeimEntryPoint + DebugLib + HobLib + ArmLib + ArmPlatformLib + MemoryInitPeiLib + +[Guids] + gEfiMemoryTypeInformationGuid + +[FeaturePcd] + gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob + +[FixedPcd] + gArmTokenSpaceGuid.PcdSystemMemoryBase + gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize + + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData + +[Depex] + TRUE --=20 2.35.1 -=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 (#94334): https://edk2.groups.io/g/devel/message/94334 Mute This Topic: https://groups.io/mt/93922701/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- From nobody Tue May 14 17:51:23 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+94335+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+94335+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180739; cv=none; d=zohomail.com; s=zohoarc; b=F6gKa5iuEDS//VNCTFZTLQrZPBrUhmi3aViadMOsrv87NaYaAcstBQgRJve+zgvZOG731LmZalG3dRnFfyS+vZ66VNbFuHuEvuMzuR9JWZrxdnFOf4dD44yOg/OR3P1QPYQOEXQbtcRFjwImNwLp8fOrA2sVGNytGSeFA0qQgF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180739; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=d/0jLZCtC9Y58f8+dVcZKlxb7Bqgu55LDRKTim5U9VY=; b=MXoeOR58wnmNbDg8P8oK7IJy/a1c7SDLCtNW+KxmNTMFiKg6hH2n/WYR3Ms0nWvZ4Axk5JErhg1UAuphiyG23HHTNjKfnTrNfsDuXBLg4fs87cWKO+Ni3/oO9PZkpogokRV2wz+AaT2g0hNY8nIrfC8KWmvaFK7lC229c3XuB9w= 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+94335+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 166418073940152.18462932382397; Mon, 26 Sep 2022 01:25:39 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 3YNLYY1788612xE0TnEkwvsY; Mon, 26 Sep 2022 01:25:38 -0700 X-Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web11.26078.1664180736898475529 for ; Mon, 26 Sep 2022 01:25:37 -0700 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 7339EB8091B; Mon, 26 Sep 2022 08:25:35 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AD82C43140; Mon, 26 Sep 2022 08:25:34 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 12/16] ArmVirtPkg/ArmVirtQemu: enable initial ID map at early boot Date: Mon, 26 Sep 2022 10:25:07 +0200 Message-Id: <20220926082511.2110797-13-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: xEMkTE6fnT0cDC0AMrsxm8L7x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180738; bh=eFFAmGvxuIlKm9n0l27cjKNPPNpSiY47SDE+OtGA/jg=; h=Cc:Date:From:Reply-To:Subject:To; b=r8cZePUsNDq4bSeMRW3Hrn1Exj+iNSDI36qsJCT9CqQOukiEdupAwWhCA+Izp9WFGwE XMnOnvlAkbgkl3Vsn+TornPB/KoNmyUfsi8wjo/l8Mgdy6uZIiZX82Fir31sd6qiCrCsz /zJHgjNgim/DJxyIoPNkVcqLs4/95RC66Dk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180740397100020 Content-Type: text/plain; charset="utf-8" Now that we have all the pieces in place, switch the AArch64 version of ArmVirtQemu to a mode where the first thing it does out of reset is enable a preliminary ID map that covers the NOR flash and sufficient DRAM to create the UEFI page tables as usual. The advantage of this is that no manipulation of memory occurs any longer before the MMU is enabled, which removes the need for explicit coherency management, which is cumbersome and bad for performance. It also means we no longer need to build all components that may execute with the MMU off (including BASE libraries) with strict alignment. Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirtQemu.dsc | 17 ++++++++++++++--- ArmVirtPkg/ArmVirtQemu.fdf | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index 302c0d2a4e29..21a321e35794 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -63,8 +63,6 @@ [LibraryClasses.common] QemuFwCfgSimpleParserLib|OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFw= CfgSimpleParserLib.inf QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoad= ImageLib.inf =20 - ArmPlatformLib|ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibN= ull.inf - TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf NorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.i= nf =20 @@ -92,6 +90,12 @@ [LibraryClasses.common] TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLi= bNull/PeiDxeTpmPlatformHierarchyLib.inf !endif =20 +[LibraryClasses.AARCH64] + ArmPlatformLib|ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.= inf + +[LibraryClasses.ARM] + ArmPlatformLib|ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibN= ull.inf + [LibraryClasses.common.PEIM] ArmVirtMemInfoLib|ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoP= eiLib.inf =20 @@ -112,6 +116,8 @@ [LibraryClasses.common.UEFI_DRIVER] UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf =20 [BuildOptions] + GCC:*_*_AARCH64_CC_XIPFLAGS =3D -mno-strict-align + !include NetworkPkg/NetworkBuildOptions.dsc.inc =20 ##########################################################################= ###### @@ -310,7 +316,12 @@ [Components.common] PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf } ArmPlatformPkg/PlatformPei/PlatformPeim.inf - ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf + ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf { + +!if $(ARCH) =3D=3D AARCH64 + ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf +!endif + } ArmPkg/Drivers/CpuPei/CpuPei.inf =20 MdeModulePkg/Universal/Variable/Pei/VariablePei.inf diff --git a/ArmVirtPkg/ArmVirtQemu.fdf b/ArmVirtPkg/ArmVirtQemu.fdf index b5e2253295fe..7f17aeb3ad0d 100644 --- a/ArmVirtPkg/ArmVirtQemu.fdf +++ b/ArmVirtPkg/ArmVirtQemu.fdf @@ -107,7 +107,7 @@ [FV.FVMAIN_COMPACT] INF ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf INF MdeModulePkg/Core/Pei/PeiMain.inf INF ArmPlatformPkg/PlatformPei/PlatformPeim.inf - INF ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf + INF ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf INF ArmPkg/Drivers/CpuPei/CpuPei.inf INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf --=20 2.35.1 -=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 (#94335): https://edk2.groups.io/g/devel/message/94335 Mute This Topic: https://groups.io/mt/93922702/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- From nobody Tue May 14 17:51:23 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+94336+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+94336+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180738; cv=none; d=zohomail.com; s=zohoarc; b=AUzsHhMMM/Kuz4H/7JSJC75vmiyzQln4vy5WQVaRoFwE2hYoAD7BypudGfwRq83rGqapRKGtlad2pq5ACUpBeIOBnQe72s2GgKfRke6jzNzNrTQ+kFwL5x+4U1mLr8HSjGdcFdszAEBJsOknkMOXqyfCWVXI9xr5YxSRWA9ivds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180738; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=TlHg+Z21E1WWPb6Zfmuq5+emGpDyoANUI3OJc3fGdVo=; b=QOqFoD3oQ7VcIwp0sGKdJqcxZWTqryNu4hNnW3I+J5NeHU70NrtMoqXQtqK/xn3I+NwAVnQGkMGOv7K9mJXaPfaEJqRBd6+tAYvancq1+CUrFEiZNuW2ZlcnmF1kCQe3eYLaG6oCLqXO4a1pSywBnaqA3YQYOt/9wmiTjNZogF0= 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+94336+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 1664180738737431.7879696301833; Mon, 26 Sep 2022 01:25:38 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6iQuYY1788612xHBsMokh7wl; Mon, 26 Sep 2022 01:25:38 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.26079.1664180737599695142 for ; Mon, 26 Sep 2022 01:25:37 -0700 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 dfw.source.kernel.org (Postfix) with ESMTPS id 2698D6190D; Mon, 26 Sep 2022 08:25:37 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 921E3C433C1; Mon, 26 Sep 2022 08:25:35 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 13/16] ArmVirtPkg/ArmVirtQemu: Drop unused variable PEIM Date: Mon, 26 Sep 2022 10:25:08 +0200 Message-Id: <20220926082511.2110797-14-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: Zt9NZlACkyfpPuAb6YW8Xd16x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180738; bh=+IMZYY8N/a0d6aWmqHBylzZw+T7MWQK2lxggbnos2Zc=; h=Cc:Date:From:Reply-To:Subject:To; b=E1ao7E0Yd/0hrAIll7Mhbczp7C4XpAd7tPngPN+0C7JEjmswZetINW1vyhZC+A9Q5l7 mUiqCf2nB2GHtLJaD4+V2dFcob5WjxT8BXEWmhpMenm9rPF0Xk5g8XLfPaArTiqkTSrTf bLXyqjlTjBFIVG1aMzVTBQb4DOmxDVpuUjU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180740367100017 Content-Type: text/plain; charset="utf-8" The variable PEIM is included in the build but its runtime prerequisites are absent so it is never dispatched. Just drop it. Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirtQemu.dsc | 2 -- ArmVirtPkg/ArmVirtQemu.fdf | 1 - 2 files changed, 3 deletions(-) diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index 21a321e35794..de34481673ea 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -324,8 +324,6 @@ [Components.common] } ArmPkg/Drivers/CpuPei/CpuPei.inf =20 - MdeModulePkg/Universal/Variable/Pei/VariablePei.inf - !if $(TPM2_ENABLE) =3D=3D TRUE MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf { diff --git a/ArmVirtPkg/ArmVirtQemu.fdf b/ArmVirtPkg/ArmVirtQemu.fdf index 7f17aeb3ad0d..c85e36b185d3 100644 --- a/ArmVirtPkg/ArmVirtQemu.fdf +++ b/ArmVirtPkg/ArmVirtQemu.fdf @@ -110,7 +110,6 @@ [FV.FVMAIN_COMPACT] INF ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf INF ArmPkg/Drivers/CpuPei/CpuPei.inf INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf - INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf =20 !if $(TPM2_ENABLE) =3D=3D TRUE --=20 2.35.1 -=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 (#94336): https://edk2.groups.io/g/devel/message/94336 Mute This Topic: https://groups.io/mt/93922703/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- From nobody Tue May 14 17:51:23 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+94337+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+94337+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180741; cv=none; d=zohomail.com; s=zohoarc; b=PxyXjgQec6AgN9d4BJ/URQ7d+eOPdCJk/vW8Ughp6brVFxcoYoeUL1KmwmHkzFzVJFvoGymIHsIchifrNySI9daJpU64zysAl13kih9T/i68OZc2oV65Ia2JMTmtY/DWOL9nt1IZroh3OgTuiymXfzflw9hKOlgn1/PF1WFxiPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180741; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=qW1dCoU7pLfO4RlxitFzRB3EaJykc88n0lKsU/37uvE=; b=R/paJiArbBq0erCcLgPcwPlWAy+1+age9IhbMyLEGgrvFHM+/k2a2zYEtmyfKdPY7zproXE0a50OW0T4rLMIjz0CKEGXEO4ifiv0FxhjRYGgt2LP23m+0Q//QknLn3y2BeEkJtmUq4bVbkp1wULFXs1wFyWKuU53acfimgGc8lE= 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+94337+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 1664180741547319.8042216042967; Mon, 26 Sep 2022 01:25:41 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id KNd8YY1788612xFmUh3iUzUD; Mon, 26 Sep 2022 01:25:39 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.26080.1664180739156276730 for ; Mon, 26 Sep 2022 01:25:39 -0700 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 dfw.source.kernel.org (Postfix) with ESMTPS id 8EA2E61910; Mon, 26 Sep 2022 08:25:38 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04E51C433D7; Mon, 26 Sep 2022 08:25:36 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 14/16] ArmVirtPkg/ArmVirtQemu: avoid shadowing PEIMs unless necessary Date: Mon, 26 Sep 2022 10:25:09 +0200 Message-Id: <20220926082511.2110797-15-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: iVY5VHOSW5E7og9aCSuCAy8hx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180739; bh=1cKriG2GDq+FmwNyZ3bYMn9iPa+veSfNLIrPy6WWvoY=; h=Cc:Date:From:Reply-To:Subject:To; b=Pm6fq+9iyqBkwcSbOtlVos1xWuNwPC/Mmi27mrKlIZj5iYdLz+8OMC9apZLDdkPf0jo pyRa2uw0CT5ntGzPZlBoZ7WS8NIgchxGlRZ0jzyXFTtamPnhVE14evk6Tof6eijE7s9p6 DFvra16fjzPC4t6efbNJ6MLWucMqfB6sit8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180742395100026 Content-Type: text/plain; charset="utf-8" Some PEIMs register for shadow execution explicitly, but others exist that don't care and can happily execute in place. Since the emulated NOR flash is just RAM, shadowing has no performance benefits so let's only do this if needed. Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirtQemu.dsc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index de34481673ea..c3d264077bce 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -217,6 +217,9 @@ [PcdsFixedAtBuild.common] gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|3 gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x20000 =20 + # Shadowing PEI modules is absolutely pointless when the NOR flash is em= ulated + gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot|FALSE + [PcdsFixedAtBuild.AARCH64] # Clearing BIT0 in this PCD prevents installing a 32-bit SMBIOS entry po= int, # if the entry point version is >=3D 3.0. AARCH64 OSes cannot assume the --=20 2.35.1 -=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 (#94337): https://edk2.groups.io/g/devel/message/94337 Mute This Topic: https://groups.io/mt/93922704/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- From nobody Tue May 14 17:51:23 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+94339+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+94339+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180746; cv=none; d=zohomail.com; s=zohoarc; b=jpNuwrl+u00zXqEKtUNK536NbnhdhVjSgKlI0LyIXiDPIPBSgIxRdlfzxSpNb7a1XA6vjp/lN6MqF8Zv0eEHZWbDfL9lRKFBY/c5sN6eB9c5+/MQvmqNYKxcpJvD7ihoP53d6+FLQEDeRsWAaycZETLrtSkMgqkiWZZkXn0tg8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180746; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=xKFQnCf4WdlbfFfBY0IdP7wLDubNVKfUNBoVA+yUv6A=; b=AEShiadQLhnTRvkSrTNMq+oZR5l4hbq+Tw+qD29aApi23c4XDduOh91/0GGaLpKxGyHS6Lkl+AfeZI4YQgAXmGej2O3hPu+HeGq4+dDs/qZ0YmG1rsKX4gJOnm5631uWVJ3euHFBkMirj+TI5y+stlRwXTzEbyAn/mDb/wQEdTg= 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+94339+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 1664180746454726.2316590291289; Mon, 26 Sep 2022 01:25:46 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id jCG0YY1788612xZc9B4IwPps; Mon, 26 Sep 2022 01:25:44 -0700 X-Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by mx.groups.io with SMTP id smtpd.web10.25938.1664180743575275382 for ; Mon, 26 Sep 2022 01:25:44 -0700 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 sin.source.kernel.org (Postfix) with ESMTPS id 04B35CE107C; Mon, 26 Sep 2022 08:25:41 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D799C4347C; Mon, 26 Sep 2022 08:25:38 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 15/16] ArmVirtPkg/QemuVirtMemInfoLib: use HOB not PCD to record the memory size Date: Mon, 26 Sep 2022 10:25:10 +0200 Message-Id: <20220926082511.2110797-16-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: 1vyFqY9fiq04SOIfCKanfrLmx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180744; bh=rbrhA75+iFdBLrSNq1ojeeoNaUFDDYf5IT74l5O0I6c=; h=Cc:Date:From:Reply-To:Subject:To; b=iSVlMEppKomqsW5fxHKyOyDjfTbMSGZAGARo0NNXMTeYc3ncv1m7HnPoERpEgYwjMcq ukLgbqHriLXtW2LgcWVGjKYReeJQzRoL9tZQ3uQ/md1ORvQUNidfXPo5qHkC9wUGb9HEo TEfAZboZkpyf70WYljXI/R7FZpu2r+NQbpk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180748455100033 Content-Type: text/plain; charset="utf-8" Due to the way we inherited the formerly fixed PCDs to describe the system memory base and size from ArmPlatformPkg, we ended up with a MemoryInit PEIM that relies on dynamic PCDs to communicate the size of system memory between the constructur of one of its library dependencies and the core module. This is unnecessary, and forces us to incorporate the PCD PEIM as well, for no good reason. So instead, let's use a HOB. Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirtPkg.dec |= 1 + ArmVirtPkg/ArmVirtQemu.dsc |= 6 ++-- ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c |= 14 ++++++-- ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf |= 1 + ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c |= 35 ++++++++++++++++++-- ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf |= 5 ++- ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf |= 8 ++--- ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibConstructor.c |= 30 ++++++++++------- 8 files changed, 75 insertions(+), 25 deletions(-) diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec index 4e165f6cd845..89d21ec3a364 100644 --- a/ArmVirtPkg/ArmVirtPkg.dec +++ b/ArmVirtPkg/ArmVirtPkg.dec @@ -32,6 +32,7 @@ [Guids.common] gArmVirtTokenSpaceGuid =3D { 0x0B6F5CA7, 0x4F53, 0x445A, { 0xB7, 0x6E, 0= x2E, 0x36, 0x5B, 0x80, 0x63, 0x66 } } gEarlyPL011BaseAddressGuid =3D { 0xB199DEA9, 0xFD5C, 0x4A84, { 0x8= 0, 0x82, 0x2F, 0x41, 0x70, 0x78, 0x03, 0x05 } } gEarly16550UartBaseAddressGuid =3D { 0xea67ca3e, 0x1f54, 0x436b, { 0x9= 7, 0x88, 0xd4, 0xeb, 0x29, 0xc3, 0x42, 0x67 } } + gArmVirtSystemMemorySizeGuid =3D { 0x504eccb9, 0x1bf0, 0x4420, { 0x8= 6, 0x5d, 0xdc, 0x66, 0x06, 0xd4, 0x13, 0xbf } } =20 gArmVirtVariableGuid =3D { 0x50bea1e5, 0xa2c5, 0x46e9, { 0x9b, 0x3a, 0= x59, 0x59, 0x65, 0x16, 0xb0, 0x0a } } =20 diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index c3d264077bce..43e19f605084 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -220,6 +220,9 @@ [PcdsFixedAtBuild.common] # Shadowing PEI modules is absolutely pointless when the NOR flash is em= ulated gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot|FALSE =20 + # System Memory Size -- 128 MB initially, actual size will be fetched fr= om DT + gArmTokenSpaceGuid.PcdSystemMemorySize|0x8000000 + [PcdsFixedAtBuild.AARCH64] # Clearing BIT0 in this PCD prevents installing a 32-bit SMBIOS entry po= int, # if the entry point version is >=3D 3.0. AARCH64 OSes cannot assume the @@ -236,9 +239,6 @@ [PcdsDynamicDefault.common] # enumeration to complete before installing ACPI tables. gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE =20 - # System Memory Size -- 1 MB initially, actual size will be fetched from= DT - gArmTokenSpaceGuid.PcdSystemMemorySize|0x00100000 - gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|0x0 gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|0x0 gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum|0x0 diff --git a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPe= iLib.c b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib= .c index 98d90ad4200d..72e5c65af79e 100644 --- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c +++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c @@ -52,10 +52,19 @@ MemoryPeim ( { EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttributes; UINT64 SystemMemoryTop; + UINT64 SystemMemorySize; + VOID *Hob; =20 // Ensure PcdSystemMemorySize has been set ASSERT (PcdGet64 (PcdSystemMemorySize) !=3D 0); =20 + SystemMemorySize =3D PcdGet64 (PcdSystemMemorySize); + + Hob =3D GetFirstGuidHob (&gArmVirtSystemMemorySizeGuid); + if (Hob !=3D NULL) { + SystemMemorySize =3D *(UINT64 *)GET_GUID_HOB_DATA (Hob); + } + // // Now, the permanent memory has been installed, we can call AllocatePag= es() // @@ -66,8 +75,7 @@ MemoryPeim ( EFI_RESOURCE_ATTRIBUTE_TESTED ); =20 - SystemMemoryTop =3D PcdGet64 (PcdSystemMemoryBase) + - PcdGet64 (PcdSystemMemorySize); + SystemMemoryTop =3D PcdGet64 (PcdSystemMemoryBase) + SystemMemorySize; =20 if (SystemMemoryTop - 1 > MAX_ALLOC_ADDRESS) { BuildResourceDescriptorHob ( @@ -87,7 +95,7 @@ MemoryPeim ( EFI_RESOURCE_SYSTEM_MEMORY, ResourceAttributes, PcdGet64 (PcdSystemMemoryBase), - PcdGet64 (PcdSystemMemorySize) + SystemMemorySize ); } =20 diff --git a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPe= iLib.inf b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiL= ib.inf index 21327f79f4b9..48d9c66b22db 100644 --- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf +++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf @@ -34,6 +34,7 @@ [LibraryClasses] CacheMaintenanceLib =20 [Guids] + gArmVirtSystemMemorySizeGuid gEfiMemoryTypeInformationGuid =20 [FeaturePcd] diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c b/A= rmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c index cf569bed99c4..9cf43f06c073 100644 --- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c @@ -6,10 +6,12 @@ =20 **/ =20 -#include +#include +#include #include #include #include +#include #include =20 // Number of Virtual Memory Map Descriptors @@ -24,6 +26,28 @@ #define MACH_VIRT_PERIPH_BASE 0x08000000 #define MACH_VIRT_PERIPH_SIZE SIZE_128MB =20 +/** + Default library constructur that obtains the memory size from a PCD. + + @return Always returns RETURN_SUCCESS + +**/ +RETURN_STATUS +EFIAPI +QemuVirtMemInfoLibConstructor ( + VOID + ) +{ + UINT64 Size; + VOID *Hob; + + Size =3D PcdGet64 (PcdSystemMemorySize); + Hob =3D BuildGuidDataHob (&gArmVirtSystemMemorySizeGuid, &Size, sizeof = Size); + ASSERT (Hob !=3D NULL); + + return RETURN_SUCCESS; +} + /** Return the Virtual Memory Map of your platform =20 @@ -43,9 +67,16 @@ ArmVirtGetMemoryMap ( ) { ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable; + VOID *MemorySizeHob; =20 ASSERT (VirtualMemoryMap !=3D NULL); =20 + MemorySizeHob =3D GetFirstGuidHob (&gArmVirtSystemMemorySizeGuid); + ASSERT (MemorySizeHob !=3D NULL); + if (MemorySizeHob =3D=3D NULL) { + return; + } + VirtualMemoryTable =3D AllocatePool ( sizeof (ARM_MEMORY_REGION_DESCRIPTOR) * MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS @@ -59,7 +90,7 @@ ArmVirtGetMemoryMap ( // System DRAM VirtualMemoryTable[0].PhysicalBase =3D PcdGet64 (PcdSystemMemoryBase); VirtualMemoryTable[0].VirtualBase =3D VirtualMemoryTable[0].PhysicalBas= e; - VirtualMemoryTable[0].Length =3D PcdGet64 (PcdSystemMemorySize); + VirtualMemoryTable[0].Length =3D *(UINT64 *)GET_GUID_HOB_DATA (Mem= orySizeHob); VirtualMemoryTable[0].Attributes =3D ARM_MEMORY_REGION_ATTRIBUTE_WRITE= _BACK; =20 DEBUG (( diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf b= /ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf index 7150de6c10d0..6acad8bbd7f3 100644 --- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf @@ -14,6 +14,7 @@ [Defines] MODULE_TYPE =3D BASE VERSION_STRING =3D 1.0 LIBRARY_CLASS =3D ArmVirtMemInfoLib + CONSTRUCTOR =3D QemuVirtMemInfoLibConstructor =20 [Sources] QemuVirtMemInfoLib.c @@ -30,7 +31,9 @@ [LibraryClasses] BaseMemoryLib DebugLib MemoryAllocationLib - PcdLib + +[Guids] + gArmVirtSystemMemorySizeGuid =20 [Pcd] gArmTokenSpaceGuid.PcdFvBaseAddress diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.in= f b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf index 7ecf6dfbb786..f045e39a4131 100644 --- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf @@ -32,16 +32,16 @@ [LibraryClasses] BaseMemoryLib DebugLib FdtLib - PcdLib MemoryAllocationLib =20 -[Pcd] +[Guids] + gArmVirtSystemMemorySizeGuid + +[FixedPcd] gArmTokenSpaceGuid.PcdFdBaseAddress gArmTokenSpaceGuid.PcdFvBaseAddress gArmTokenSpaceGuid.PcdSystemMemoryBase gArmTokenSpaceGuid.PcdSystemMemorySize - -[FixedPcd] gArmTokenSpaceGuid.PcdFdSize gArmTokenSpaceGuid.PcdFvSize gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibCon= structor.c b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibCon= structor.c index 33d3597d57ab..c47ab8296622 100644 --- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibConstructo= r.c +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibConstructo= r.c @@ -6,9 +6,10 @@ =20 **/ =20 -#include +#include +#include #include -#include +#include #include =20 RETURN_STATUS @@ -17,14 +18,14 @@ QemuVirtMemInfoPeiLibConstructor ( VOID ) { - VOID *DeviceTreeBase; - INT32 Node, Prev; - UINT64 NewBase, CurBase; - UINT64 NewSize, CurSize; - CONST CHAR8 *Type; - INT32 Len; - CONST UINT64 *RegProp; - RETURN_STATUS PcdStatus; + VOID *DeviceTreeBase; + INT32 Node, Prev; + UINT64 NewBase, CurBase; + UINT64 NewSize, CurSize; + CONST CHAR8 *Type; + INT32 Len; + CONST UINT64 *RegProp; + VOID *Hob; =20 NewBase =3D 0; NewSize =3D 0; @@ -86,8 +87,13 @@ QemuVirtMemInfoPeiLibConstructor ( // Make sure the start of DRAM matches our expectation // ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) =3D=3D NewBase); - PcdStatus =3D PcdSet64S (PcdSystemMemorySize, NewSize); - ASSERT_RETURN_ERROR (PcdStatus); + + Hob =3D BuildGuidDataHob ( + &gArmVirtSystemMemorySizeGuid, + &NewSize, + sizeof NewSize + ); + ASSERT (Hob !=3D NULL); =20 // // We need to make sure that the machine we are running on has at least --=20 2.35.1 -=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 (#94339): https://edk2.groups.io/g/devel/message/94339 Mute This Topic: https://groups.io/mt/93922707/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- From nobody Tue May 14 17:51:23 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+94338+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+94338+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180743; cv=none; d=zohomail.com; s=zohoarc; b=LSvzI7DQA+PcIhIWKn98oYPFEPEjHhgLz4lu6UzjTHAJYTL54vTihBKTKGQOLdxCekoZWnJQSIsNUfcNByXRP5dTaDsr25s6PX912727Kszy5OVH5CKUU6AVWSrx6WVb8YsI2wDReRmiy7AIFDiyC7tJx9SblL7cf7xnZuYpguA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180743; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=JFSm/jQvhcV/4F2plGYF7a26cwiJPUBB5X95WlEyc0M=; b=ggC5U1y+Ns3qqcPndCZ7dTAOlCnQ6xDLr/+dhPLgbEsZ1zKACLhZOJ6fclijmh4ZA23cXVnvn7I9DPmpBAkdriTQgUMvoYTn4xknLA0PFmUsA1rocjMwleaAY0rWL78QgECzGWfaLNKdSGQ0AIVCZWbiqTlTVcHgN8uJEzMRX0U= 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+94338+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 1664180743716752.9781882784944; Mon, 26 Sep 2022 01:25:43 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id nAQsYY1788612xVUvrFsEVen; Mon, 26 Sep 2022 01:25:43 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web09.26238.1664180742307786920 for ; Mon, 26 Sep 2022 01:25:42 -0700 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 dfw.source.kernel.org (Postfix) with ESMTPS id 70E2E6190B; Mon, 26 Sep 2022 08:25:41 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7155C43141; Mon, 26 Sep 2022 08:25:39 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 16/16] ArmVirtPkg/ArmVirtQemu: omit PCD PEIM unless TPM support is enabled Date: Mon, 26 Sep 2022 10:25:11 +0200 Message-Id: <20220926082511.2110797-17-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: MPWnHW2T9SF7vKppFU97YYffx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180743; bh=Bz0509mP+/EhhBX/EJxdNGIJZPHCko/y0og2HZF7HoE=; h=Cc:Date:From:Reply-To:Subject:To; b=blwEHomsbWjKP0/mRQE7XauwrypOluMb6dmv3j/ZEa1eDkRF1rs2QxdurZdjKowyk05 UZevRFT+35q3xnQybNMLhSRDonacy1JaFZ+C/aqByDQImBNwnj8cG2BaNS6YpLhphJye7 V4so/q9oT/EabtQtySoDw3PucOdTT82tDWE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180744410100029 Content-Type: text/plain; charset="utf-8" The TPM discovery code relies on a dynamic PCD to communicate the TPM base address to other components. But no other code relies on dynamic PCDs in the PEI phase so let's drop the PCD PEIM when TPM support is not enabled. Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirtQemu.dsc | 22 +++++++++++++++----- ArmVirtPkg/ArmVirtQemu.fdf | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index 43e19f605084..842a298e0435 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -287,10 +287,15 @@ [PcdsDynamicDefault.common] # # TPM2 support # - gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress|0x0 !if $(TPM2_ENABLE) =3D=3D TRUE + gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress|0x0 gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0x00, 0x00, 0x00, 0x00= , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} gEfiSecurityPkgTokenSpaceGuid.PcdTpm2HashMask|0 +!else +[PcdsPatchableInModule] + # make this PCD patchable instead of dynamic when TPM support is not ena= bled + # this permits setting the PCD in unreachable code without pulling in dy= namic PCD support + gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress|0x0 !endif =20 [PcdsDynamicHii] @@ -303,6 +308,13 @@ [PcdsDynamicHii] =20 gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVar= iableGuid|0x0|5 =20 +[LibraryClasses.common.PEI_CORE, LibraryClasses.common.PEIM] +!if $(TPM2_ENABLE) =3D=3D TRUE + PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf +!else + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf +!endif + ##########################################################################= ###### # # Components Section - list of all EDK II Modules needed by this Platform @@ -314,10 +326,6 @@ [Components.common] # ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf MdeModulePkg/Core/Pei/PeiMain.inf - MdeModulePkg/Universal/PCD/Pei/Pcd.inf { - - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - } ArmPlatformPkg/PlatformPei/PlatformPeim.inf ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf { @@ -328,6 +336,10 @@ [Components.common] ArmPkg/Drivers/CpuPei/CpuPei.inf =20 !if $(TPM2_ENABLE) =3D=3D TRUE + MdeModulePkg/Universal/PCD/Pei/Pcd.inf { + + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + } MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf { ResetSystemLib|ArmVirtPkg/Library/ArmVirtPsciResetSystemPeiLib/ArmVi= rtPsciResetSystemPeiLib.inf diff --git a/ArmVirtPkg/ArmVirtQemu.fdf b/ArmVirtPkg/ArmVirtQemu.fdf index c85e36b185d3..764f652afd0e 100644 --- a/ArmVirtPkg/ArmVirtQemu.fdf +++ b/ArmVirtPkg/ArmVirtQemu.fdf @@ -109,10 +109,10 @@ [FV.FVMAIN_COMPACT] INF ArmPlatformPkg/PlatformPei/PlatformPeim.inf INF ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf INF ArmPkg/Drivers/CpuPei/CpuPei.inf - INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf =20 !if $(TPM2_ENABLE) =3D=3D TRUE + INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf INF MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf INF OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf INF SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf --=20 2.35.1 -=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 (#94338): https://edk2.groups.io/g/devel/message/94338 Mute This Topic: https://groups.io/mt/93922705/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-