diff options
author | Thomas Barrett <tbarrett@crusoeenergy.com> | 2024-01-12 18:31:42 +0000 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-01-15 15:57:42 +0000 |
commit | bfad87ceec39eae9f836a5e2c9597948fc1a7395 (patch) | |
tree | fb513e5b8f362d8965818202585860f3789d13d7 /OvmfPkg/Library/PlatformInitLib | |
parent | 195e59bd0c60523caa415f429517e46ff7065600 (diff) | |
download | edk2-bfad87ceec39eae9f836a5e2c9597948fc1a7395.zip edk2-bfad87ceec39eae9f836a5e2c9597948fc1a7395.tar.gz edk2-bfad87ceec39eae9f836a5e2c9597948fc1a7395.tar.bz2 |
OvmfPkg: Add CloudHv support to PlatformScanE820 utility function.
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.
Signed-off-by: Thomas Barrett <tbarrett@crusoeenergy.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'OvmfPkg/Library/PlatformInitLib')
-rw-r--r-- | OvmfPkg/Library/PlatformInitLib/MemDetect.c | 95 |
1 files changed, 65 insertions, 30 deletions
diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c index 662e7e8..76a9dc9 100644 --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c @@ -249,6 +249,67 @@ PlatformReservationConflictCB ( }
/**
+ 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 (
|