From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 1CBA8AC1A1E for ; Thu, 11 Jan 2024 19:10:38 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=gtK4zVOzSFwyK3H/zrTb4iU8ebd7WWWdw0icSIPLgRM=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20140610; t=1705000237; v=1; b=UmPyHrhNFkO/j/+KsCngI6XQGmL4kAG2q0YLT4M8RP//ZMKh6pUyCBJzOvZMBg4x/BiXwcnv U3dngcgWrSxVCkQzQBDBT/gXPGiRVPwyo1jAmZ4eSr2AqSZ9GuNvC5nR7dWlcQPnCUQSHngIotj 2WBtDWxaCXb+d43qrO+B6gbQ= X-Received: by 127.0.0.2 with SMTP id VckPYY7687511xrE1UFzarpj; Thu, 11 Jan 2024 11:10:37 -0800 X-Received: from us-smtp-delivery-137.mimecast.com (us-smtp-delivery-137.mimecast.com [170.10.133.137]) by mx.groups.io with SMTP id smtpd.web11.1181.1705000236851253217 for ; Thu, 11 Jan 2024 11:10:37 -0800 X-Received: from mail-oa1-f72.google.com (mail-oa1-f72.google.com [209.85.160.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-68-908Sqpn2NFmq2X7A4tf34g-1; Thu, 11 Jan 2024 14:10:24 -0500 X-MC-Unique: 908Sqpn2NFmq2X7A4tf34g-1 X-Received: by mail-oa1-f72.google.com with SMTP id 586e51a60fabf-203ff4c8936so7024485fac.2 for ; Thu, 11 Jan 2024 11:10:24 -0800 (PST) X-Gm-Message-State: od2tBFaMgD3fBGbVA6pWqb58x7686176AA= X-Received: by 2002:a05:6871:4488:b0:204:5427:4270 with SMTP id ne8-20020a056871448800b0020454274270mr238021oab.18.1705000223489; Thu, 11 Jan 2024 11:10:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IFLqglB7gr7EU7nczLTVhD49l9b4RCE3L8+W6qNw8or68pHp9ZkevS/v2CSPqyESewg6/+Miw== X-Received: by 2002:a17:902:9f8f:b0:1d5:4b18:17d1 with SMTP id g15-20020a1709029f8f00b001d54b1817d1mr170745plq.106.1704999781891; Thu, 11 Jan 2024 11:03:01 -0800 (PST) X-Received: from dev-hypervisor-01.hsd1.ca.comcast.net ([2601:645:8001:5750::6d3b]) by smtp.googlemail.com with ESMTPSA id o17-20020a170902e29100b001d05bb77b43sm1491661plc.19.2024.01.11.11.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 11:03:01 -0800 (PST) From: "Thomas Barrett" To: devel@edk2.groups.io Cc: Thomas Barrett , Anatol Belski , Ard Biesheuvel , Gerd Hoffmann , Jianyong Wu , Jiewen Yao , Laszlo Ersek , Rob Bradford Subject: [edk2-devel] [PATCH v2 2/2] OvmfPkg: Update PlatformAddressWidthInitialization for CloudHv Date: Thu, 11 Jan 2024 19:02:15 +0000 Message-Id: <02d4a4fa4b0fcc9d0b356ea740d1abd82caba9a4.1704998169.git.tbarrett@crusoeenergy.com> In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: crusoeenergy.com Precedence: Bulk 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,tbarrett@crusoeenergy.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: multipart/alternative; boundary="MCBoundary=_12401111410302941" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=UmPyHrhN; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=crusoeenergy.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io --MCBoundary=_12401111410302941 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 In addition to initializing the PhysMemAddressWidth and FirstNonAddress fields in PlatformInfoHob, the PlatformAddressWidthInitialization function is responsible for initializing the PcdPciMmio64Base and PcdPciMmio64Size fields. Currently, for CloudHv guests, the PcdPciMmio64Base is placed immediately after either the 4G boundary or the last RAM region, whichever is greater. We do not change this behavior. Previously, when booting CloudHv guests with greater than 1TiB of high memory, the PlatformAddressWidthInitialization function incorrect calculates the amount of RAM using the overflowed 24-bit CMOS register. Now, we update the PlatformAddressWidthInitialization behavior on CloudHv to scan the E820 entries to detect the amount of RAM. This allows CloudHv guests to boot with greater than 1TiB of RAM Cc: Anatol Belski Cc: Ard Biesheuvel Cc: Gerd Hoffmann Cc: Jianyong Wu Cc: Jiewen Yao Cc: Laszlo Ersek Cc: Rob Bradford Signed-off-by: Thomas Barrett --- OvmfPkg/CloudHv/CloudHvX64.dsc | 2 ++ OvmfPkg/Library/PlatformInitLib/MemDetect.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.ds= c index af594959a9..b522fa1059 100644 --- a/OvmfPkg/CloudHv/CloudHvX64.dsc +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc @@ -566,6 +566,8 @@ # Point to the MdeModulePkg/Application/UiApp/UiApp.inf gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c= , 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0= x31 } =20 + gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable|TRUE + ##########################################################################= ###### # # Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Pla= tform diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/= PlatformInitLib/MemDetect.c index 76a9dc9211..f042517bb6 100644 --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c @@ -873,6 +873,18 @@ PlatformAddressWidthInitialization ( =20 if (PlatformInfoHob->HostBridgeDevId =3D=3D 0xffff /* microvm */) { PlatformAddressWidthFromCpuid (PlatformInfoHob, FALSE); + return; + } else if (PlatformInfoHob->HostBridgeDevId =3D=3D CLOUDHV_DEVICE_ID) { + PlatformInfoHob->FirstNonAddress =3D BASE_4GB; + Status =3D PlatformScanE820 (PlatformGetFirs= tNonAddressCB, PlatformInfoHob); + if (EFI_ERROR (Status)) { + PlatformInfoHob->FirstNonAddress =3D BASE_4GB + PlatformGetSystemMem= orySizeAbove4gb (); + } + + PlatformInfoHob->PcdPciMmio64Base =3D PlatformInfoHob->FirstNonAddress= ; + PlatformAddressWidthFromCpuid (PlatformInfoHob, FALSE); + PlatformInfoHob->PcdPciMmio64Size =3D PlatformInfoHob->FirstNonAddress= - PlatformInfoHob->PcdPciMmio64Base; + return; } =20 --=20 2.34.1 Disclaimer The information contained in this communication from the sender is confiden= tial. It is intended solely for use by the recipient and others authorized = to receive it. If you are not the recipient, you are hereby notified that a= ny disclosure, copying, distribution or taking action in relation of the co= ntents of this information is strictly prohibited and may be unlawful. This email has been scanned for viruses and malware, and may have been auto= matically archived by Mimecast, a leader in email security and cyber resili= ence. Mimecast integrates email defenses with brand protection, security aw= areness training, web security, compliance and other essential capabilities= . Mimecast helps protect large and small organizations from malicious activ= ity, human error and technology failure; and to lead the movement toward bu= ilding a more resilient world. To find out more, visit our website. -=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 (#113629): https://edk2.groups.io/g/devel/message/113629 Mute This Topic: https://groups.io/mt/103668740/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --MCBoundary=_12401111410302941 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=UTF-8 In addition to initializing the PhysMemAddressWidth= and
FirstNonAddress fields in PlatformInfoHob, the
PlatformAddressWidthInitialization function is responsible
for initializing the PcdPciMmio64Base and PcdPciMmio64Size
fields.

Currently, for CloudHv guests, the PcdPciMmio64Base is
placed immediately after either the 4G boundary or the
last RAM region, whichever is greater. We do not change
this behavior.

Previously, when booting CloudHv guests with greater than
1TiB of high memory, the PlatformAddressWidthInitialization
function incorrect calculates the amount of RAM using the
overflowed 24-bit CMOS register.

Now, we update the PlatformAddressWidthInitialization
behavior on CloudHv to scan the E820 entries to detect
the amount of RAM. This allows CloudHv guests to boot with
greater than 1TiB of RAM

Cc: Anatol Belski <anbelski@linux.microsoft.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jianyong Wu <jianyong.wu@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rob Bradford <rbradford@rivosinc.com>
Signed-off-by: Thomas Barrett <tbarrett@crusoeenergy.com>
---
OvmfPkg/CloudHv/CloudHvX64.dsc | 2 ++
OvmfPkg/Library/PlatformInitLib/MemDetect.c | 12 ++++++++++++
2 files changed, 14 insertions(+)

diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.ds= c
index af594959a9..b522fa1059 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -566,6 +566,8 @@
# Point to the MdeModulePkg/Application/UiApp/UiApp.inf

gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c= , 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0= x31 }



+ gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable|TRUE

+

##########################################################################= ######

#

# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Pla= tform

diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/= PlatformInitLib/MemDetect.c
index 76a9dc9211..f042517bb6 100644
--- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c
+++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
@@ -873,6 +873,18 @@ PlatformAddressWidthInitialization (


if (PlatformInfoHob->HostBridgeDevId =3D=3D 0xffff /* microvm */) {
PlatformAddressWidthFromCpuid (PlatformInfoHob, FALSE);

+ return;

+ } else if (PlatformInfoHob->HostBridgeDevId =3D=3D CLOUDHV_DEVICE_ID)= {

+ PlatformInfoHob->FirstNonAddress =3D BASE_4GB;

+ Status =3D PlatformScanE820 (PlatformGetFirs= tNonAddressCB, PlatformInfoHob);

+ if (EFI_ERROR (Status)) {

+ PlatformInfoHob->FirstNonAddress =3D BASE_4GB + PlatformGetSystem= MemorySizeAbove4gb ();

+ }

+

+ PlatformInfoHob->PcdPciMmio64Base =3D PlatformInfoHob->FirstNonA= ddress;

+ PlatformAddressWidthFromCpuid (PlatformInfoHob, FALSE);

+ PlatformInfoHob->PcdPciMmio64Size =3D PlatformInfoHob->FirstNonA= ddress - PlatformInfoHob->PcdPciMmio64Base;

+

return;

}



--
2.34.1


<= b>Disclaimer

The information contained in this communication from the sender i= s confidential. It is intended solely for use by the recipient and others a= uthorized to receive it. If you are not the recipient, you are hereby notif= ied that any disclosure, copying, distribution or taking action in relation= of the contents of this information is strictly prohibited and may be unla= wful.

_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#113629) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--MCBoundary=_12401111410302941--