From: "Thomas Barrett" <tbarrett1200@gmail.com>
To: devel@edk2.groups.io
Cc: Thomas Barrett <tbarrett@crusoeenergy.com>,
Anatol Belski <anbelski@linux.microsoft.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>,
Gerd Hoffmann <kraxel@redhat.com>,
Jianyong Wu <jianyong.wu@arm.com>,
Jiewen Yao <jiewen.yao@intel.com>,
Laszlo Ersek <lersek@redhat.com>,
Rob Bradford <rbradford@rivosinc.com>
Subject: [edk2-devel] [PATCH v3 1/3] OvmfPkg: Add CloudHv support to PlatformScanE820 utility function.
Date: Fri, 12 Jan 2024 18:31:42 +0000 [thread overview]
Message-ID: <b659cdf2231e6c0fb81ad93c3faa0f73e2e6c110.1705084003.git.tbarrett1200@gmail.com> (raw)
In-Reply-To: <cover.1705084003.git.tbarrett1200@gmail.com>
From: Thomas Barrett <tbarrett@crusoeenergy.com>
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 <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 = 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 = (VOID *)(UINTN)PcdGet32 (PcdXenPvhStartOfDayStructPtr);
+ if (PVHResetVectorData == 0) {
+ return EFI_NOT_FOUND;
+ }
+
+ pvh_start_info = (struct hvm_start_info *)(UINTN)PVHResetVectorData[0];
+
+ *Entries = (struct hvm_memmap_table_entry *)(UINTN)pvh_start_info->memmap_paddr;
+ *Count = 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 = GetPvhMemmapEntries (&Memmap, &MemmapEntriesCount);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ for (Loop = 0; Loop < MemmapEntriesCount; Loop++) {
+ Entry = Memmap + Loop;
+
+ if (Entry->type == XEN_HVM_MEMMAP_TYPE_RAM) {
+ E820Entry.BaseAddr = Entry->addr;
+ E820Entry.Length = Entry->size;
+ E820Entry.Type = 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 == CLOUDHV_DEVICE_ID) {
+ return PlatformScanE820Pvh (Callback, PlatformInfoHob);
+ }
+
Status = 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 = (VOID *)(UINTN)PcdGet32 (PcdXenPvhStartOfDayStructPtr);
- if (PVHResetVectorData == 0) {
- return EFI_NOT_FOUND;
- }
-
- pvh_start_info = (struct hvm_start_info *)(UINTN)PVHResetVectorData[0];
-
- *Entries = (struct hvm_memmap_table_entry *)(UINTN)pvh_start_info->memmap_paddr;
- *Count = pvh_start_info->memmap_entries;
-
- return EFI_SUCCESS;
-}
-
STATIC
UINT64
GetHighestSystemMemoryAddressFromPvhMemmap (
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113772): https://edk2.groups.io/g/devel/message/113772
Mute This Topic: https://groups.io/mt/103689731/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-01-12 19:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-12 18:31 [edk2-devel] [PATCH v3 0/3] Support CloudHv guests with >1TB of RAM Thomas Barrett
2024-01-12 18:31 ` Thomas Barrett [this message]
2024-01-12 18:31 ` [edk2-devel] [PATCH v3 2/3] OvmfPkg: Update PlatformAddressWidthInitialization for CloudHv Thomas Barrett
2024-01-12 18:31 ` [edk2-devel] [PATCH v3 3/3] OvmfPkg: CloudHv: Enable PcdUse1GPageTable Thomas Barrett
2024-01-15 15:27 ` [edk2-devel] [PATCH v3 0/3] Support CloudHv guests with >1TB of RAM Gerd Hoffmann
2024-01-15 15:32 ` Ard Biesheuvel
2024-01-15 16:13 ` Ard Biesheuvel
2024-01-15 19:10 ` Laszlo Ersek
2024-01-15 17:39 ` Laszlo Ersek
2024-01-15 17:52 ` Ard Biesheuvel
2024-01-15 18:26 ` Thomas Barrett
2024-01-15 22:07 ` Anatol Belski
2024-01-16 6:40 ` Anatol Belski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b659cdf2231e6c0fb81ad93c3faa0f73e2e6c110.1705084003.git.tbarrett1200@gmail.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox