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 C9882AC0F28 for ; Thu, 11 Jan 2024 06:54:08 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=LNpIlucaSK5OxzeAHDEV7PbfcEpvrMH30n6MZpS0P54=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id: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=1704956047; v=1; b=h5cA3XEXSrosQC9JF2ijJbRAJcoNNrgY6N949gHoXGY8nPYnXt/qPiN5Lkv/mQIdy57OJnpW Bhk26RJsIdqTVD2PCzac9HJR6HgN5IWqKqgxwoEXYdAtdXbrrNb0PWK32aUTv0FyQv0qujUAmxT JyvAYhbqPURdPd5PLcdEKpWQ= X-Received: by 127.0.0.2 with SMTP id N3lUYY7687511xj4VVKtH31m; Wed, 10 Jan 2024 22:54:07 -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.web10.7239.1704925365253267415 for ; Wed, 10 Jan 2024 14:22:45 -0800 X-Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-Nb--pqkzMZGGc2uzdHs_Ug-1; Wed, 10 Jan 2024 17:22:29 -0500 X-MC-Unique: Nb--pqkzMZGGc2uzdHs_Ug-1 X-Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-28c2033b552so4942295a91.2 for ; Wed, 10 Jan 2024 14:22:29 -0800 (PST) X-Gm-Message-State: 5zXxrveRtq2CMl9F9pAH8XAKx7686176AA= X-Received: by 2002:a17:90b:11cf:b0:28d:15a:4c05 with SMTP id gv15-20020a17090b11cf00b0028d015a4c05mr181626pjb.94.1704925347379; Wed, 10 Jan 2024 14:22:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IH6SgD94h0XogG5Ik1kkreh5SCsC030FXKjMWAbkCqBjneGtv0yF6etFqrGz+cFPKJWaiqsfg== X-Received: by 2002:a17:90b:11cf:b0:28d:15a:4c05 with SMTP id gv15-20020a17090b11cf00b0028d015a4c05mr181613pjb.94.1704925347023; Wed, 10 Jan 2024 14:22:27 -0800 (PST) X-Received: from dev-hypervisor-01.hsd1.ca.comcast.net ([2601:645:8001:5750::6d3b]) by smtp.googlemail.com with ESMTPSA id m1-20020a17090b068100b0028b6759d8c1sm2099092pjz.29.2024.01.10.14.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:22:26 -0800 (PST) From: "Thomas Barrett" To: devel@edk2.groups.io Cc: Thomas Barrett Subject: [edk2-devel] [PATCH 1/2] CloudHv: Add CloudHv support to PlatformScanE820 utility function. Date: Wed, 10 Jan 2024 22:21:36 +0000 Message-Id: <283db24a1d906fd115f85636bd1c2f9ddcde150c.1704921917.git.tbarrett@crusoeenergy.com> 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=_12401101722311991" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=h5cA3XEX; 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=_12401101722311991 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 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 (#113585): https://edk2.groups.io/g/devel/message/113585 Mute This Topic: https://groups.io/mt/103657892/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=_12401101722311991 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=UTF-8 Signed-off-by: Thomas Barrett <tbarrett@crusoeen= ergy.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 (#113585) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--MCBoundary=_12401101722311991--