public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH 1/2] CloudHv: Add CloudHv support to PlatformScanE820 utility function.
@ 2024-01-10 22:21 Thomas Barrett
  2024-01-10 22:21 ` [edk2-devel] [PATCH 2/2] CloudHv: Update PlatformAddressWidthInitialization logic Thomas Barrett
  2024-01-11  9:39 ` [edk2-devel] [PATCH 1/2] CloudHv: Add CloudHv support to PlatformScanE820 utility function Laszlo Ersek
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Barrett @ 2024-01-10 22:21 UTC (permalink / raw)
  To: devel; +Cc: Thomas Barrett

[-- Attachment #1: Type: text/plain, Size: 5149 bytes --]

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

Disclaimer

The information contained in this communication from the sender is confidential. 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 any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.

This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast, a leader in email security and cyber resilience. Mimecast integrates email defenses with brand protection, security awareness training, web security, compliance and other essential capabilities. Mimecast helps protect large and small organizations from malicious activity, human error and technology failure; and to lead the movement toward building a more resilient world. To find out more, visit our website.


-=-=-=-=-=-=-=-=-=-=-=-
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]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 6326 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [edk2-devel] [PATCH 2/2] CloudHv: Update PlatformAddressWidthInitialization logic
  2024-01-10 22:21 [edk2-devel] [PATCH 1/2] CloudHv: Add CloudHv support to PlatformScanE820 utility function Thomas Barrett
@ 2024-01-10 22:21 ` Thomas Barrett
  2024-01-11  9:39 ` [edk2-devel] [PATCH 1/2] CloudHv: Add CloudHv support to PlatformScanE820 utility function Laszlo Ersek
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Barrett @ 2024-01-10 22:21 UTC (permalink / raw)
  To: devel; +Cc: Thomas Barrett

[-- Attachment #1: Type: text/plain, Size: 3546 bytes --]

When booting CloudHv guests with greater than 1TiB of high
memory, the PlatformAddressWidthInitialization function
incorrect calculates the address width using the overflowed
24-bit CMOS register rather than the E820 entries.

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.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, 0x31 }

 

+  gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable|TRUE

+

 ################################################################################

 #

 # Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform

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 == 0xffff /* microvm */) {

     PlatformAddressWidthFromCpuid (PlatformInfoHob, FALSE);

+    return;

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

+    PlatformInfoHob->FirstNonAddress = BASE_4GB;

+    Status                           = PlatformScanE820 (PlatformGetFirstNonAddressCB, PlatformInfoHob);

+    if (EFI_ERROR (Status)) {

+      PlatformInfoHob->FirstNonAddress = BASE_4GB + PlatformGetSystemMemorySizeAbove4gb ();

+    }

+

+    PlatformInfoHob->PcdPciMmio64Base = PlatformInfoHob->FirstNonAddress;

+    PlatformAddressWidthFromCpuid (PlatformInfoHob, FALSE);

+    PlatformInfoHob->PcdPciMmio64Size = PlatformInfoHob->FirstNonAddress - PlatformInfoHob->PcdPciMmio64Base;

+

     return;

   }

 

-- 
2.34.1

Disclaimer

The information contained in this communication from the sender is confidential. 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 any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.

This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast, a leader in email security and cyber resilience. Mimecast integrates email defenses with brand protection, security awareness training, web security, compliance and other essential capabilities. Mimecast helps protect large and small organizations from malicious activity, human error and technology failure; and to lead the movement toward building a more resilient world. To find out more, visit our website.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113586): https://edk2.groups.io/g/devel/message/113586
Mute This Topic: https://groups.io/mt/103657893/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 4027 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [PATCH 1/2] CloudHv: Add CloudHv support to PlatformScanE820 utility function.
  2024-01-10 22:21 [edk2-devel] [PATCH 1/2] CloudHv: Add CloudHv support to PlatformScanE820 utility function Thomas Barrett
  2024-01-10 22:21 ` [edk2-devel] [PATCH 2/2] CloudHv: Update PlatformAddressWidthInitialization logic Thomas Barrett
@ 2024-01-11  9:39 ` Laszlo Ersek
  2024-01-11 16:37   ` Thomas Barrett
  1 sibling, 1 reply; 4+ messages in thread
From: Laszlo Ersek @ 2024-01-11  9:39 UTC (permalink / raw)
  To: devel, tbarrett; +Cc: Jianyong Wu, Anatol Belski, Gerd Hoffmann

Hello Thomas,

(+ Jianyong, Anatol, Gerd)

On 1/10/24 23:21, Thomas Barrett wrote:
> Signed-off-by: Thomas Barrett <tbarrett@crusoeenergy.com>
> ---
> OvmfPkg/Library/PlatformInitLib/MemDetect.c | 95 ++++++++++++++-------
> 1 file changed, 65 insertions(+), 30 deletions(-)

please don't paste patches in email bodies; they are hard to read
(review) and effectively impossible to apply that way.

Here's the official dev guide:

https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Development-Process

A few more personal ideas:

https://github.com/tianocore/tianocore.github.io/wiki/Laszlo%27s-unkempt-git-guide-for-edk2-contributors-and-maintainers

Please don't forget to run the GetMaintainer.py script either, for
composing the Cc: tags in the commit message body.

Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113611): https://edk2.groups.io/g/devel/message/113611
Mute This Topic: https://groups.io/mt/103657892/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [PATCH 1/2] CloudHv: Add CloudHv support to PlatformScanE820 utility function.
  2024-01-11  9:39 ` [edk2-devel] [PATCH 1/2] CloudHv: Add CloudHv support to PlatformScanE820 utility function Laszlo Ersek
@ 2024-01-11 16:37   ` Thomas Barrett
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Barrett @ 2024-01-11 16:37 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: Anatol Belski, Gerd Hoffmann, Jianyong Wu, devel

[-- Attachment #1: Type: text/plain, Size: 2644 bytes --]

Hey Laslo,

Thank you for the link to your git workflow and your patience. I will send
out a ‘PATCH v2’ series that hopefully has all the necessary components by
following the steps in the guide.

Thomas

On Thu, Jan 11, 2024 at 1:39 AM Laszlo Ersek <lersek@redhat.com> wrote:

> Hello Thomas,
>
> (+ Jianyong, Anatol, Gerd)
>
> On 1/10/24 23:21, Thomas Barrett wrote:
> > Signed-off-by: Thomas Barrett <tbarrett@crusoeenergy.com>
> > ---
> > OvmfPkg/Library/PlatformInitLib/MemDetect.c | 95 ++++++++++++++-------
> > 1 file changed, 65 insertions(+), 30 deletions(-)
>
> please don't paste patches in email bodies; they are hard to read
> (review) and effectively impossible to apply that way.
>
> Here's the official dev guide:
>
>
> https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Development-Process
> <https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Development-Process>
>
> A few more personal ideas:
>
>
> https://github.com/tianocore/tianocore.github.io/wiki/Laszlo%27s-unkempt-git-guide-for-edk2-contributors-and-maintainers
> <https://github.com/tianocore/tianocore.github.io/wiki/Laszlo%27s-unkempt-git-guide-for-edk2-contributors-and-maintainers>
>
> Please don't forget to run the GetMaintainer.py script either, for
> composing the Cc: tags in the commit message body.
>
>
> Laszlo
>

Disclaimer

The information contained in this communication from the sender is confidential. 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 any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.

This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast, a leader in email security and cyber resilience. Mimecast integrates email defenses with brand protection, security awareness training, web security, compliance and other essential capabilities. Mimecast helps protect large and small organizations from malicious activity, human error and technology failure; and to lead the movement toward building a more resilient world. To find out more, visit our website.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113626): https://edk2.groups.io/g/devel/message/113626
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]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 3559 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-11 16:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-10 22:21 [edk2-devel] [PATCH 1/2] CloudHv: Add CloudHv support to PlatformScanE820 utility function Thomas Barrett
2024-01-10 22:21 ` [edk2-devel] [PATCH 2/2] CloudHv: Update PlatformAddressWidthInitialization logic Thomas Barrett
2024-01-11  9:39 ` [edk2-devel] [PATCH 1/2] CloudHv: Add CloudHv support to PlatformScanE820 utility function Laszlo Ersek
2024-01-11 16:37   ` Thomas Barrett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox