From nobody Fri May 17 06:54:12 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+113630+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+113630+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=crusoeenergy.com ARC-Seal: i=1; a=rsa-sha256; t=1705000271; cv=none; d=zohomail.com; s=zohoarc; b=WuURaY2sl+vOntyG+9sPcXTkSMZMFHrEsQNtPT7VP5JSm/YLpIVMQ1XmHlFC7x2f1q27dzIB3/paDtYWg9uAnxw0QCTNsOM9Z0cPJG+Hq6TfQ5JVT7MoF06SUF0x0p13gDmp1baJr7A3jDyw0XTJJ+h8mTtucA60LRHWab0YEvE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705000271; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=FiLrq4zBWiICTw1Ywr6hISGCtqj52Iv4a0+YHtunUuI=; b=eg+dftV4/xuklhlt0DB3YTNHAwToqHoW4ugPnCOpmC3FyLu41pTHM1ZIUcYu3GD6vGNRdOjwoCAb9svdrQF11TvkpQt0OBk7JS1f99IdXa6665nbf/QEH2G/4cv7vBzfSLgDjS4CcfeGwfaIuxNnm/HG2sqPSNltV/l6FNXTeXc= 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+113630+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 1705000271682702.4406616048399; Thu, 11 Jan 2024 11:11:11 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=hsGA3S68spwhLC46ddmWADq+w623TJ/Wn7uM8y9BawA=; 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=1705000271; v=1; b=oWOUOlylbh1GOmk9SP2qxu8+UOymhn8eDIV6xnpjPk5Wi08GybWvCvOQKN0Zc2iqk66ze6hU shDmzZokzMvos6hzdljshNW2WXcYtyZGFau8+iOGBzKe5pVHl0YJlx+xvqCgjcAEEOHXR5tZZ+n anE2tViJs2+m8Rnak0sfXFnk= X-Received: by 127.0.0.2 with SMTP id e5OHYY1788612xgSAZ7aK7zj; Thu, 11 Jan 2024 11:11:11 -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.1193.1705000270470509341 for ; Thu, 11 Jan 2024 11:11:10 -0800 X-Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-516-VXvLruHjPJWXczwZai01lg-1; Thu, 11 Jan 2024 14:11:03 -0500 X-MC-Unique: VXvLruHjPJWXczwZai01lg-1 X-Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-3bb91e121e6so5207094b6e.1 for ; Thu, 11 Jan 2024 11:11:03 -0800 (PST) X-Gm-Message-State: v4juw1FaV8fWK6wsLEq0SvHnx1787277AA= X-Received: by 2002:a05:6808:14c4:b0:3bd:3fd3:50e3 with SMTP id f4-20020a05680814c400b003bd3fd350e3mr598051oiw.20.1705000262203; Thu, 11 Jan 2024 11:11:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJKfQlKcmeeGY6aDTUWsmYeZ4W9e9N1KV1dFK3ruVAOJyPNi5jHS5HZs6nzE1KPDYP+2y0Ag== X-Received: by 2002:a17:902:ec86:b0:1d5:a005:4212 with SMTP id x6-20020a170902ec8600b001d5a0054212mr479932plg.0.1704999777681; Thu, 11 Jan 2024 11:02:57 -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.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 11:02:57 -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 1/2] OvmfPkg: Add CloudHv support to PlatformScanE820 utility function. Date: Thu, 11 Jan 2024 19:02:14 +0000 Message-Id: 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=_12401111411040631" X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1705000273675100003 --MCBoundary=_12401111411040631 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The PlatformScanE820 utility function is not currently compatible with CloudHv since it relies on the prescence of the "etc/e820" QemuFwCfg file. Update the PlatformScanE820 to iterate through the PVH e820 entries when running on a CloudHv guest. 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/Library/PlatformInitLib/MemDetect.c | 95 +++++++++++++------- 1 file changed, 65 insertions(+), 30 deletions(-) diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/= PlatformInitLib/MemDetect.c index 662e7e85bb..76a9dc9211 100644 --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c @@ -248,6 +248,67 @@ PlatformReservationConflictCB ( PlatformInfoHob->PcdPciMmio64Base =3D NewBase; } =20 +/** + Returns PVH memmap + @param Entries Pointer to PVH memmap + @param Count Number of entries + @return EFI_STATUS +**/ +EFI_STATUS +GetPvhMemmapEntries ( + struct hvm_memmap_table_entry **Entries, + UINT32 *Count + ) +{ + UINT32 *PVHResetVectorData; + struct hvm_start_info *pvh_start_info; + + PVHResetVectorData =3D (VOID *)(UINTN)PcdGet32 (PcdXenPvhStartOfDayStruc= tPtr); + if (PVHResetVectorData =3D=3D 0) { + return EFI_NOT_FOUND; + } + + pvh_start_info =3D (struct hvm_start_info *)(UINTN)PVHResetVectorData[0]; + + *Entries =3D (struct hvm_memmap_table_entry *)(UINTN)pvh_start_info->mem= map_paddr; + *Count =3D pvh_start_info->memmap_entries; + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +PlatformScanE820Pvh ( + IN E820_SCAN_CALLBACK Callback, + IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob + ) +{ + struct hvm_memmap_table_entry *Memmap; + UINT32 MemmapEntriesCount; + struct hvm_memmap_table_entry *Entry; + EFI_E820_ENTRY64 E820Entry; + EFI_STATUS Status; + UINT32 Loop; + + Status =3D GetPvhMemmapEntries (&Memmap, &MemmapEntriesCount); + if (EFI_ERROR (Status)) { + return Status; + } + + for (Loop =3D 0; Loop < MemmapEntriesCount; Loop++) { + Entry =3D Memmap + Loop; + + if (Entry->type =3D=3D XEN_HVM_MEMMAP_TYPE_RAM) { + E820Entry.BaseAddr =3D Entry->addr; + E820Entry.Length =3D Entry->size; + E820Entry.Type =3D Entry->type; + Callback (&E820Entry, PlatformInfoHob); + } + } + + return EFI_SUCCESS; +} + /** Iterate over the entries in QEMU's fw_cfg E820 RAM map, call the passed callback for each entry. @@ -279,6 +340,10 @@ PlatformScanE820 ( EFI_E820_ENTRY64 E820Entry; UINTN Processed; =20 + if (PlatformInfoHob->HostBridgeDevId =3D=3D CLOUDHV_DEVICE_ID) { + return PlatformScanE820Pvh (Callback, PlatformInfoHob); + } + Status =3D QemuFwCfgFindFile ("etc/e820", &FwCfgItem, &FwCfgSize); if (EFI_ERROR (Status)) { return Status; @@ -297,36 +362,6 @@ PlatformScanE820 ( return EFI_SUCCESS; } =20 -/** - Returns PVH memmap - - @param Entries Pointer to PVH memmap - @param Count Number of entries - - @return EFI_STATUS -**/ -EFI_STATUS -GetPvhMemmapEntries ( - struct hvm_memmap_table_entry **Entries, - UINT32 *Count - ) -{ - UINT32 *PVHResetVectorData; - struct hvm_start_info *pvh_start_info; - - PVHResetVectorData =3D (VOID *)(UINTN)PcdGet32 (PcdXenPvhStartOfDayStruc= tPtr); - if (PVHResetVectorData =3D=3D 0) { - return EFI_NOT_FOUND; - } - - pvh_start_info =3D (struct hvm_start_info *)(UINTN)PVHResetVectorData[0]; - - *Entries =3D (struct hvm_memmap_table_entry *)(UINTN)pvh_start_info->mem= map_paddr; - *Count =3D pvh_start_info->memmap_entries; - - return EFI_SUCCESS; -} - STATIC UINT64 GetHighestSystemMemoryAddressFromPvhMemmap ( --=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 (#113630): https://edk2.groups.io/g/devel/message/113630 Mute This Topic: https://groups.io/mt/103668748/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- --MCBoundary=_12401111411040631 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=UTF-8 The PlatformScanE820 utility function is not curren= tly compatible
with CloudHv since it relies on the prescence of the "etc/e820" QemuFwCfg file. Update the PlatformScanE820 to iterate through the
PVH e820 entries when running on a CloudHv guest.

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/Library/PlatformInitLib/MemDetect.c | 95 +++++++++++++-------
1 file changed, 65 insertions(+), 30 deletions(-)

diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/= PlatformInitLib/MemDetect.c
index 662e7e85bb..76a9dc9211 100644
--- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c
+++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
@@ -248,6 +248,67 @@ PlatformReservationConflictCB (
PlatformInfoHob->PcdPciMmio64Base =3D NewBase;

}



+/**

+ Returns PVH memmap

+ @param Entries Pointer to PVH memmap

+ @param Count Number of entries

+ @return EFI_STATUS

+**/

+EFI_STATUS

+GetPvhMemmapEntries (

+ struct hvm_memmap_table_entry **Entries,

+ UINT32 *Count

+ )

+{

+ UINT32 *PVHResetVectorData;

+ struct hvm_start_info *pvh_start_info;

+

+ PVHResetVectorData =3D (VOID *)(UINTN)PcdGet32 (PcdXenPvhStartOfDayStruc= tPtr);

+ if (PVHResetVectorData =3D=3D 0) {

+ return EFI_NOT_FOUND;

+ }

+

+ pvh_start_info =3D (struct hvm_start_info *)(UINTN)PVHResetVectorData[0]= ;

+

+ *Entries =3D (struct hvm_memmap_table_entry *)(UINTN)pvh_start_info->= memmap_paddr;

+ *Count =3D pvh_start_info->memmap_entries;

+

+ return EFI_SUCCESS;

+}

+

+STATIC

+EFI_STATUS

+PlatformScanE820Pvh (

+ IN E820_SCAN_CALLBACK Callback,

+ IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob

+ )

+{

+ struct hvm_memmap_table_entry *Memmap;

+ UINT32 MemmapEntriesCount;

+ struct hvm_memmap_table_entry *Entry;

+ EFI_E820_ENTRY64 E820Entry;

+ EFI_STATUS Status;

+ UINT32 Loop;

+

+ Status =3D GetPvhMemmapEntries (&Memmap, &MemmapEntriesCount);
+ if (EFI_ERROR (Status)) {

+ return Status;

+ }

+

+ for (Loop =3D 0; Loop < MemmapEntriesCount; Loop++) {

+ Entry =3D Memmap + Loop;

+

+ if (Entry->type =3D=3D XEN_HVM_MEMMAP_TYPE_RAM) {

+ E820Entry.BaseAddr =3D Entry->addr;

+ E820Entry.Length =3D Entry->size;

+ E820Entry.Type =3D Entry->type;

+ Callback (&E820Entry, PlatformInfoHob);

+ }

+ }

+

+ return EFI_SUCCESS;

+}

+

/**

Iterate over the entries in QEMU's fw_cfg E820 RAM map, call the

passed callback for each entry.

@@ -279,6 +340,10 @@ PlatformScanE820 (
EFI_E820_ENTRY64 E820Entry;

UINTN Processed;



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

+ return PlatformScanE820Pvh (Callback, PlatformInfoHob);

+ }

+

Status =3D QemuFwCfgFindFile ("etc/e820", &FwCfgItem, &= ;FwCfgSize);

if (EFI_ERROR (Status)) {

return Status;

@@ -297,36 +362,6 @@ PlatformScanE820 (
return EFI_SUCCESS;

}



-/**

- Returns PVH memmap

-

- @param Entries Pointer to PVH memmap

- @param Count Number of entries

-

- @return EFI_STATUS

-**/

-EFI_STATUS

-GetPvhMemmapEntries (

- struct hvm_memmap_table_entry **Entries,

- UINT32 *Count

- )

-{

- UINT32 *PVHResetVectorData;

- struct hvm_start_info *pvh_start_info;

-

- PVHResetVectorData =3D (VOID *)(UINTN)PcdGet32 (PcdXenPvhStartOfDayStruc= tPtr);

- if (PVHResetVectorData =3D=3D 0) {

- return EFI_NOT_FOUND;

- }

-

- pvh_start_info =3D (struct hvm_start_info *)(UINTN)PVHResetVectorData[0]= ;

-

- *Entries =3D (struct hvm_memmap_table_entry *)(UINTN)pvh_start_info->= memmap_paddr;

- *Count =3D pvh_start_info->memmap_entries;

-

- return EFI_SUCCESS;

-}

-

STATIC

UINT64

GetHighestSystemMemoryAddressFromPvhMemmap (

--
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 (#113630) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [importer@patchew.org]

_._,_._,_
--MCBoundary=_12401111411040631-- From nobody Fri May 17 06:54:12 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+113629+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+113629+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=crusoeenergy.com ARC-Seal: i=1; a=rsa-sha256; t=1705000238; cv=none; d=zohomail.com; s=zohoarc; b=GgZWOoqwpkebdJk/M7z71fECyPlxcZ6LVZLsY5Jk1z0T7waSK1Ja33THIdt8/l4S42hIQMavkkNZchLEM6iZEKcx22pSYMQqIt7VxaojEPhITDPw6LQweJPclsB+xWNF6CSD2VzOC36gW/DonCIuwbixBhR5WiiNL76SKI6SFqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705000238; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=X9TfkG12zY/hA4427osOH8ZJlsTbZS9wQUYnruQyh2o=; b=ffQBd/l9Hdz1bKDd2AJx4givBYrJgt9J/PEbh5/AK2eTei5GdSvqPAynIrooJM0Pa+M53J4uXNm+LKQP6qHn/PQxOJHWEI55fGFJARftaCNTo1phhrKKI/+Mj3Utx7Sg0yozw0PT8qwGkQz8PbGxMKjmfTj9A1pnFoAzxgeibtw= 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+113629+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 1705000238159818.2375008088395; Thu, 11 Jan 2024 11:10:38 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=nis8G61KakxOj8TxQubesmi3Y4sZUgwuBenfV2BfUyQ=; 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=R/1ejWMQ5Mzy4ec/vjC9V6YOOrSAAFod1faGufcB5WpLFdFTLBYgFvArhqC37Tte42Zpjuig De1RSJ3tgRVyidVYK7RCAhZPE7WCcKVmxdQpEr2NU8hVZyWZBjpQC+sV7LqI/ZwnwgNemvj4SmZ IQ9SnKgS+bxsDG3rYyxxG2K0= X-Received: by 127.0.0.2 with SMTP id dI7YYY1788612xkHwDOWT6LS; 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: Rb6lBmqJQcVKqxUqftqjsnD8x1787277AA= 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-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1705000239363100002 --MCBoundary=_12401111410302941 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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.dsc 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/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- --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 [importer@patchew.org]

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