public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/5] OvmfPkg/Bhyve: install Acpi tables by FwCfg
@ 2023-06-14  7:55 Corvin Köhne
  2023-06-14  7:55 ` [PATCH 1/5] OvmfPkg: avoid including AcpiPlatformLib twice Corvin Köhne
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Corvin Köhne @ 2023-06-14  7:55 UTC (permalink / raw)
  To: devel

Hi,

latest Bhyve exposes it's Acpi tables by FwCfg. This patch series reuses
the Acpi Install method of Qemu for Bhyve.

CI: https://github.com/tianocore/edk2/pull/4545


Kind regards,
Corvin

Corvin Köhne (5):
  OvmfPkg: avoid including AcpiPlatformLib twice
  OvmfPkg: move PciEncoding into AcpiPlatformLib
  OvmfPkg: move BootScript into AcpiPlatformLib
  OvmfPkg: move QemuFwCfgAcpi into AcpiPlatformLib
  OvmfPkg/Bhyve: install Acpi tables provided by FwCfg

 ArmVirtPkg/ArmVirtQemu.dsc                    |   1 +
 ArmVirtPkg/ArmVirtQemuKernel.dsc              |   1 +
 OvmfPkg/AmdSev/AmdSevX64.dsc                  |   1 +
 OvmfPkg/CloudHv/CloudHvX64.dsc                |   1 +
 OvmfPkg/IntelTdx/IntelTdxX64.dsc              |   1 +
 OvmfPkg/Microvm/MicrovmX64.dsc                |   1 +
 OvmfPkg/OvmfPkgIa32.dsc                       |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc                    |   1 +
 OvmfPkg/OvmfPkgX64.dsc                        |   1 +
 OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc           |   1 +
 OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf   |  10 +-
 .../Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf |   1 -
 .../AcpiPlatformLib/DxeAcpiPlatformLib.inf    |  14 ++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h        |  51 ----
 OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.h  |  17 --
 OvmfPkg/Include/Library/AcpiPlatformLib.h     |  56 +++++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c        |   3 +
 OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c  |   5 +
 OvmfPkg/Bhyve/AcpiPlatformDxe/PciDecoding.c   | 232 ------------------
 .../AcpiPlatformLib}/BootScript.c             |   3 +-
 .../AcpiPlatformLib}/PciDecoding.c            |   3 +-
 .../AcpiPlatformLib}/QemuFwCfgAcpi.c          |   3 +-
 22 files changed, 92 insertions(+), 316 deletions(-)
 delete mode 100644 OvmfPkg/Bhyve/AcpiPlatformDxe/PciDecoding.c
 rename OvmfPkg/{AcpiPlatformDxe => Library/AcpiPlatformLib}/BootScript.c (96%)
 rename OvmfPkg/{AcpiPlatformDxe => Library/AcpiPlatformLib}/PciDecoding.c (96%)
 rename OvmfPkg/{AcpiPlatformDxe => Library/AcpiPlatformLib}/QemuFwCfgAcpi.c (96%)

-- 
2.41.0


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

* [PATCH 1/5] OvmfPkg: avoid including AcpiPlatformLib twice
  2023-06-14  7:55 [PATCH 0/5] OvmfPkg/Bhyve: install Acpi tables by FwCfg Corvin Köhne
@ 2023-06-14  7:55 ` Corvin Köhne
  2023-06-19 10:41   ` Gerd Hoffmann
  2023-06-14  7:55 ` [PATCH 2/5] OvmfPkg: move PciEncoding into AcpiPlatformLib Corvin Köhne
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Corvin Köhne @ 2023-06-14  7:55 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Gerd Hoffmann, Jiewen Yao, Jordan Justen,
	Leif Lindholm, Peter Grehan, Rebecca Cran, Sami Mujawar

Signed-off-by: Corvin Köhne <corvink@FreeBSD.org>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
---
 OvmfPkg/Include/Library/AcpiPlatformLib.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/OvmfPkg/Include/Library/AcpiPlatformLib.h b/OvmfPkg/Include/Library/AcpiPlatformLib.h
index 78d5010e91d5..617265000315 100644
--- a/OvmfPkg/Include/Library/AcpiPlatformLib.h
+++ b/OvmfPkg/Include/Library/AcpiPlatformLib.h
@@ -4,6 +4,9 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
+#ifndef ACPI_PLATFORM_LIB_H_
+#define ACPI_PLATFORM_LIB_H_
+
 #include <Protocol/AcpiTable.h>
 
 /**
@@ -47,3 +50,5 @@ InstallAcpiTablesFromRsdp (
   IN EFI_ACPI_TABLE_PROTOCOL                       *AcpiProtocol,
   IN EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp
   );
+
+#endif
-- 
2.41.0


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

* [PATCH 2/5] OvmfPkg: move PciEncoding into AcpiPlatformLib
  2023-06-14  7:55 [PATCH 0/5] OvmfPkg/Bhyve: install Acpi tables by FwCfg Corvin Köhne
  2023-06-14  7:55 ` [PATCH 1/5] OvmfPkg: avoid including AcpiPlatformLib twice Corvin Köhne
@ 2023-06-14  7:55 ` Corvin Köhne
  2023-06-14  7:55 ` [PATCH 3/5] OvmfPkg: move BootScript " Corvin Köhne
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Corvin Köhne @ 2023-06-14  7:55 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Gerd Hoffmann, Jiewen Yao, Jordan Justen,
	Leif Lindholm, Peter Grehan, Rebecca Cran, Sami Mujawar

Bhyve supports providing ACPI tables by FwCfg. Therefore,
InstallQemuFwCfgTables should be moved to AcpiPlatformLib to reuse the
code. As first step, move PciEncoding into AcpiPlatformLib.

Signed-off-by: Corvin Köhne <corvink@FreeBSD.org>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
---
 ArmVirtPkg/ArmVirtQemu.dsc                    |   1 +
 ArmVirtPkg/ArmVirtQemuKernel.dsc              |   1 +
 OvmfPkg/AmdSev/AmdSevX64.dsc                  |   1 +
 OvmfPkg/CloudHv/CloudHvX64.dsc                |   1 +
 OvmfPkg/IntelTdx/IntelTdxX64.dsc              |   1 +
 OvmfPkg/Microvm/MicrovmX64.dsc                |   1 +
 OvmfPkg/OvmfPkgIa32.dsc                       |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc                    |   1 +
 OvmfPkg/OvmfPkgX64.dsc                        |   1 +
 OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc           |   1 +
 OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf   |   5 +-
 .../Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf |   1 -
 .../AcpiPlatformLib/DxeAcpiPlatformLib.inf    |   7 +
 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h        |  18 --
 OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.h  |  17 --
 OvmfPkg/Include/Library/AcpiPlatformLib.h     |  18 ++
 OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c       |   1 +
 OvmfPkg/Bhyve/AcpiPlatformDxe/PciDecoding.c   | 232 ------------------
 .../AcpiPlatformLib}/PciDecoding.c            |   3 +-
 19 files changed, 38 insertions(+), 274 deletions(-)
 delete mode 100644 OvmfPkg/Bhyve/AcpiPlatformDxe/PciDecoding.c
 rename OvmfPkg/{AcpiPlatformDxe => Library/AcpiPlatformLib}/PciDecoding.c (96%)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index d998f816b2b3..1e0225951aef 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -111,6 +111,7 @@ [LibraryClasses.AARCH64.PEIM]
   ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
 
 [LibraryClasses.common.DXE_DRIVER]
+  AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
   ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
 
 !if $(TPM2_ENABLE) == TRUE
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index c9d2b18392b9..8ef5927b53ff 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -83,6 +83,7 @@ [LibraryClasses.common]
   TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLibNull/PeiDxeTpmPlatformHierarchyLib.inf
 
 [LibraryClasses.common.DXE_DRIVER]
+  AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
   ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
 
 [LibraryClasses.common.UEFI_DRIVER]
diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index d24909e847b4..2c6ed7c9745f 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -329,6 +329,7 @@ [LibraryClasses.common.UEFI_DRIVER]
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
 
 [LibraryClasses.common.DXE_DRIVER]
+  AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
   ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
index dd9aa403d6a0..e000deed9e4d 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -366,6 +366,7 @@ [LibraryClasses.common.UEFI_DRIVER]
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
 
 [LibraryClasses.common.DXE_DRIVER]
+  AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
   ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
index db4953a82ec6..193657ff2d61 100644
--- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
+++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
@@ -289,6 +289,7 @@ [LibraryClasses.common.UEFI_DRIVER]
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
 
 [LibraryClasses.common.DXE_DRIVER]
+  AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
   ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index 82da3a7e7cce..2f7585639374 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -368,6 +368,7 @@ [LibraryClasses.common.UEFI_DRIVER]
   PciExpressLib|OvmfPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf
 
 [LibraryClasses.common.DXE_DRIVER]
+  AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLibMicrovm.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 08b04e65cab7..8d1ef4e833b2 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -373,6 +373,7 @@ [LibraryClasses.common.UEFI_DRIVER]
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
 
 [LibraryClasses.common.DXE_DRIVER]
+  AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
   ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index d456896a45fb..afee349910a2 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -378,6 +378,7 @@ [LibraryClasses.common.UEFI_DRIVER]
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
 
 [LibraryClasses.common.DXE_DRIVER]
+  AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
   ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index e1c0a6fe9ff7..24ac834e0631 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -399,6 +399,7 @@ [LibraryClasses.common.UEFI_DRIVER]
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
 
 [LibraryClasses.common.DXE_DRIVER]
+  AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
   ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
diff --git a/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc b/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc
index 414d186179fb..06c300c4e850 100644
--- a/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc
+++ b/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc
@@ -113,6 +113,7 @@ [LibraryClasses.common]
 !endif
 
 [LibraryClasses.common.DXE_DRIVER]
+  AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
   ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
   PciExpressLib|OvmfPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf
 
diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
index 3fd0483b50eb..b22aad95e081 100644
--- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
+++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
@@ -26,7 +26,6 @@ [Sources]
   BootScript.c
   CloudHvAcpi.c
   EntryPoint.c
-  PciDecoding.c
   QemuFwCfgAcpi.c
 
 [Packages]
@@ -35,15 +34,13 @@ [Packages]
   OvmfPkg/OvmfPkg.dec
 
 [LibraryClasses]
+  AcpiPlatformLib
   BaseLib
   BaseMemoryLib
-  DebugLib
   MemoryAllocationLib
   OrderedCollectionLib
-  PcdLib
   QemuFwCfgLib
   QemuFwCfgS3Lib
-  UefiBootServicesTableLib
   UefiDriverEntryPoint
   HobLib
   TpmMeasurementLib
diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
index 75ed8e4a7deb..2e228d815b87 100644
--- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
+++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
@@ -26,7 +26,6 @@ [Sources]
   AcpiPlatform.h
   Bhyve.c
   EntryPoint.c
-  PciDecoding.c
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
index dfe0e5623d32..4be501bb2c58 100644
--- a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
+++ b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
@@ -16,11 +16,18 @@ [Defines]
 
 [Sources]
   DxeAcpiPlatformLib.c
+  PciDecoding.c
 
 [Packages]
+  MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
   OvmfPkg/OvmfPkg.dec
 
 [LibraryClasses]
   BaseLib
   DebugLib
+  PcdLib
+  UefiBootServicesTableLib
+
+[Pcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h
index 3ec509865863..1328f6d1cba6 100644
--- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h
+++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h
@@ -10,12 +10,6 @@
 #define ACPI_PLATFORM_H_
 
 #include <Protocol/AcpiTable.h> // EFI_ACPI_TABLE_PROTOCOL
-#include <Protocol/PciIo.h>     // EFI_PCI_IO_PROTOCOL
-
-typedef struct {
-  EFI_PCI_IO_PROTOCOL    *PciIo;
-  UINT64                 PciAttributes;
-} ORIGINAL_ATTRIBUTES;
 
 typedef struct S3_CONTEXT S3_CONTEXT;
 
@@ -43,18 +37,6 @@ InstallAcpiTables (
   IN   EFI_ACPI_TABLE_PROTOCOL  *AcpiTable
   );
 
-VOID
-EnablePciDecoding (
-  OUT ORIGINAL_ATTRIBUTES  **OriginalAttributes,
-  OUT UINTN                *Count
-  );
-
-VOID
-RestorePciDecoding (
-  IN ORIGINAL_ATTRIBUTES  *OriginalAttributes,
-  IN UINTN                Count
-  );
-
 EFI_STATUS
 AllocateS3Context (
   OUT S3_CONTEXT  **S3Context,
diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.h b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.h
index 54d1af073eab..b75292b73546 100644
--- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.h
+++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.h
@@ -21,11 +21,6 @@
 #include <Library/XenPlatformLib.h>
 #include <IndustryStandard/Acpi.h>
 
-typedef struct {
-  EFI_PCI_IO_PROTOCOL    *PciIo;
-  UINT64                 PciAttributes;
-} ORIGINAL_ATTRIBUTES;
-
 typedef struct S3_CONTEXT S3_CONTEXT;
 
 EFI_STATUS
@@ -58,16 +53,4 @@ InstallAcpiTables (
   IN   EFI_ACPI_TABLE_PROTOCOL  *AcpiTable
   );
 
-VOID
-EnablePciDecoding (
-  OUT ORIGINAL_ATTRIBUTES  **OriginalAttributes,
-  OUT UINTN                *Count
-  );
-
-VOID
-RestorePciDecoding (
-  IN ORIGINAL_ATTRIBUTES  *OriginalAttributes,
-  IN UINTN                Count
-  );
-
 #endif /* _ACPI_PLATFORM_H_INCLUDED_ */
diff --git a/OvmfPkg/Include/Library/AcpiPlatformLib.h b/OvmfPkg/Include/Library/AcpiPlatformLib.h
index 617265000315..167d6c49d6e2 100644
--- a/OvmfPkg/Include/Library/AcpiPlatformLib.h
+++ b/OvmfPkg/Include/Library/AcpiPlatformLib.h
@@ -8,6 +8,12 @@
 #define ACPI_PLATFORM_LIB_H_
 
 #include <Protocol/AcpiTable.h>
+#include <Protocol/PciIo.h>
+
+typedef struct {
+  EFI_PCI_IO_PROTOCOL    *PciIo;
+  UINT64                 PciAttributes;
+} ORIGINAL_ATTRIBUTES;
 
 /**
   Searches and returns the address of the ACPI Root System Description Pointer (RSDP) in system memory.
@@ -51,4 +57,16 @@ InstallAcpiTablesFromRsdp (
   IN EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp
   );
 
+VOID
+EnablePciDecoding (
+  OUT ORIGINAL_ATTRIBUTES  **OriginalAttributes,
+  OUT UINTN                *Count
+  );
+
+VOID
+RestorePciDecoding (
+  IN ORIGINAL_ATTRIBUTES  *OriginalAttributes,
+  IN UINTN                Count
+  );
+
 #endif
diff --git a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c
index a073b292b743..3de039d57414 100644
--- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c
+++ b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c
@@ -11,6 +11,7 @@
 #include <IndustryStandard/Acpi.h>            // EFI_ACPI_DESCRIPTION_HEADER
 #include <IndustryStandard/QemuLoader.h>      // QEMU_LOADER_FNAME_SIZE
 #include <IndustryStandard/UefiTcgPlatform.h>
+#include <Library/AcpiPlatformLib.h>
 #include <Library/BaseLib.h>                  // AsciiStrCmp()
 #include <Library/BaseMemoryLib.h>            // CopyMem()
 #include <Library/DebugLib.h>                 // DEBUG()
diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/PciDecoding.c b/OvmfPkg/Bhyve/AcpiPlatformDxe/PciDecoding.c
deleted file mode 100644
index 0dcf3517f1e7..000000000000
--- a/OvmfPkg/Bhyve/AcpiPlatformDxe/PciDecoding.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/** @file
-  Temporarily enable IO and MMIO decoding for all PCI devices while QEMU
-  regenerates the ACPI tables.
-
-  Copyright (C) 2016, Red Hat, Inc.
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#include <Library/MemoryAllocationLib.h>
-
-#include "AcpiPlatform.h"
-
-/**
-  Collect all PciIo protocol instances in the system. Save their original
-  attributes, and enable IO and MMIO decoding for each.
-
-  This is a best effort function; it doesn't return status codes. Its
-  caller is supposed to proceed even if this function fails.
-
-  @param[out] OriginalAttributes  On output, a dynamically allocated array of
-                                  ORIGINAL_ATTRIBUTES elements. The array lists
-                                  the PciIo protocol instances found in the
-                                  system at the time of the call, plus the
-                                  original PCI attributes for each.
-
-                                  Before returning, the function enables IO and
-                                  MMIO decoding for each PciIo instance it
-                                  finds.
-
-                                  On error, or when no such instances are
-                                  found, OriginalAttributes is set to NULL.
-
-  @param[out] Count               On output, the number of elements in
-                                  OriginalAttributes. On error it is set to
-                                  zero.
-**/
-VOID
-EnablePciDecoding (
-  OUT ORIGINAL_ATTRIBUTES  **OriginalAttributes,
-  OUT UINTN                *Count
-  )
-{
-  EFI_STATUS           Status;
-  UINTN                NoHandles;
-  EFI_HANDLE           *Handles;
-  ORIGINAL_ATTRIBUTES  *OrigAttrs;
-  UINTN                Idx;
-
-  *OriginalAttributes = NULL;
-  *Count              = 0;
-
-  if (PcdGetBool (PcdPciDisableBusEnumeration)) {
-    //
-    // The platform downloads ACPI tables from QEMU in general, but there are
-    // no root bridges in this execution. We're done.
-    //
-    return;
-  }
-
-  Status = gBS->LocateHandleBuffer (
-                  ByProtocol,
-                  &gEfiPciIoProtocolGuid,
-                  NULL /* SearchKey */,
-                  &NoHandles,
-                  &Handles
-                  );
-  if (Status == EFI_NOT_FOUND) {
-    //
-    // No PCI devices were found on either of the root bridges. We're done.
-    //
-    return;
-  }
-
-  if (EFI_ERROR (Status)) {
-    DEBUG ((
-      DEBUG_WARN,
-      "%a: LocateHandleBuffer(): %r\n",
-      __func__,
-      Status
-      ));
-    return;
-  }
-
-  OrigAttrs = AllocatePool (NoHandles * sizeof *OrigAttrs);
-  if (OrigAttrs == NULL) {
-    DEBUG ((
-      DEBUG_WARN,
-      "%a: AllocatePool(): out of resources\n",
-      __func__
-      ));
-    goto FreeHandles;
-  }
-
-  for (Idx = 0; Idx < NoHandles; ++Idx) {
-    EFI_PCI_IO_PROTOCOL  *PciIo;
-    UINT64               Attributes;
-
-    //
-    // Look up PciIo on the handle and stash it
-    //
-    Status = gBS->HandleProtocol (
-                    Handles[Idx],
-                    &gEfiPciIoProtocolGuid,
-                    (VOID **)&PciIo
-                    );
-    ASSERT_EFI_ERROR (Status);
-    OrigAttrs[Idx].PciIo = PciIo;
-
-    //
-    // Stash the current attributes
-    //
-    Status = PciIo->Attributes (
-                      PciIo,
-                      EfiPciIoAttributeOperationGet,
-                      0,
-                      &OrigAttrs[Idx].PciAttributes
-                      );
-    if (EFI_ERROR (Status)) {
-      DEBUG ((
-        DEBUG_WARN,
-        "%a: EfiPciIoAttributeOperationGet: %r\n",
-        __func__,
-        Status
-        ));
-      goto RestoreAttributes;
-    }
-
-    //
-    // Retrieve supported attributes
-    //
-    Status = PciIo->Attributes (
-                      PciIo,
-                      EfiPciIoAttributeOperationSupported,
-                      0,
-                      &Attributes
-                      );
-    if (EFI_ERROR (Status)) {
-      DEBUG ((
-        DEBUG_WARN,
-        "%a: EfiPciIoAttributeOperationSupported: %r\n",
-        __func__,
-        Status
-        ));
-      goto RestoreAttributes;
-    }
-
-    //
-    // Enable IO and MMIO decoding
-    //
-    Attributes &= EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY;
-    Status      = PciIo->Attributes (
-                           PciIo,
-                           EfiPciIoAttributeOperationEnable,
-                           Attributes,
-                           NULL
-                           );
-    if (EFI_ERROR (Status)) {
-      DEBUG ((
-        DEBUG_WARN,
-        "%a: EfiPciIoAttributeOperationEnable: %r\n",
-        __func__,
-        Status
-        ));
-      goto RestoreAttributes;
-    }
-  }
-
-  //
-  // Success
-  //
-  FreePool (Handles);
-  *OriginalAttributes = OrigAttrs;
-  *Count              = NoHandles;
-  return;
-
-RestoreAttributes:
-  while (Idx > 0) {
-    --Idx;
-    OrigAttrs[Idx].PciIo->Attributes (
-                            OrigAttrs[Idx].PciIo,
-                            EfiPciIoAttributeOperationSet,
-                            OrigAttrs[Idx].PciAttributes,
-                            NULL
-                            );
-  }
-
-  FreePool (OrigAttrs);
-
-FreeHandles:
-  FreePool (Handles);
-}
-
-/**
-  Restore the original PCI attributes saved with EnablePciDecoding().
-
-  @param[in] OriginalAttributes  The array allocated and populated by
-                                 EnablePciDecoding(). This parameter may be
-                                 NULL. If OriginalAttributes is NULL, then the
-                                 function is a no-op; otherwise the PciIo
-                                 attributes will be restored, and the
-                                 OriginalAttributes array will be freed.
-
-  @param[in] Count               The Count value stored by EnablePciDecoding(),
-                                 the number of elements in OriginalAttributes.
-                                 Count may be zero if and only if
-                                 OriginalAttributes is NULL.
-**/
-VOID
-RestorePciDecoding (
-  IN ORIGINAL_ATTRIBUTES  *OriginalAttributes,
-  IN UINTN                Count
-  )
-{
-  UINTN  Idx;
-
-  ASSERT ((OriginalAttributes == NULL) == (Count == 0));
-  if (OriginalAttributes == NULL) {
-    return;
-  }
-
-  for (Idx = 0; Idx < Count; ++Idx) {
-    OriginalAttributes[Idx].PciIo->Attributes (
-                                     OriginalAttributes[Idx].PciIo,
-                                     EfiPciIoAttributeOperationSet,
-                                     OriginalAttributes[Idx].PciAttributes,
-                                     NULL
-                                     );
-  }
-
-  FreePool (OriginalAttributes);
-}
diff --git a/OvmfPkg/AcpiPlatformDxe/PciDecoding.c b/OvmfPkg/Library/AcpiPlatformLib/PciDecoding.c
similarity index 96%
rename from OvmfPkg/AcpiPlatformDxe/PciDecoding.c
rename to OvmfPkg/Library/AcpiPlatformLib/PciDecoding.c
index c7dbfb1baaea..58fbfeefda36 100644
--- a/OvmfPkg/AcpiPlatformDxe/PciDecoding.c
+++ b/OvmfPkg/Library/AcpiPlatformLib/PciDecoding.c
@@ -7,12 +7,11 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
+#include <Library/AcpiPlatformLib.h>
 #include <Library/DebugLib.h>                  // DEBUG()
 #include <Library/MemoryAllocationLib.h>       // AllocatePool()
 #include <Library/UefiBootServicesTableLib.h>  // gBS
 
-#include "AcpiPlatform.h"
-
 /**
   Collect all PciIo protocol instances in the system. Save their original
   attributes, and enable IO and MMIO decoding for each.
-- 
2.41.0


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

* [PATCH 3/5] OvmfPkg: move BootScript into AcpiPlatformLib
  2023-06-14  7:55 [PATCH 0/5] OvmfPkg/Bhyve: install Acpi tables by FwCfg Corvin Köhne
  2023-06-14  7:55 ` [PATCH 1/5] OvmfPkg: avoid including AcpiPlatformLib twice Corvin Köhne
  2023-06-14  7:55 ` [PATCH 2/5] OvmfPkg: move PciEncoding into AcpiPlatformLib Corvin Köhne
@ 2023-06-14  7:55 ` Corvin Köhne
  2023-06-14  7:55 ` [PATCH 4/5] OvmfPkg: move QemuFwCfgAcpi " Corvin Köhne
  2023-06-14  7:55 ` [PATCH 5/5] OvmfPkg/Bhyve: install Acpi tables provided by FwCfg Corvin Köhne
  4 siblings, 0 replies; 10+ messages in thread
From: Corvin Köhne @ 2023-06-14  7:55 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Gerd Hoffmann, Jiewen Yao, Jordan Justen,
	Leif Lindholm, Peter Grehan, Rebecca Cran, Sami Mujawar

This is required to move InstallQemuFwCfgTables into AcpiPlatformLib.

Signed-off-by: Corvin Köhne <corvink@FreeBSD.org>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
---
 OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf   |  2 --
 .../AcpiPlatformLib/DxeAcpiPlatformLib.inf    |  2 ++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h        | 27 -------------------
 OvmfPkg/Include/Library/AcpiPlatformLib.h     | 27 +++++++++++++++++++
 .../AcpiPlatformLib}/BootScript.c             |  3 +--
 5 files changed, 30 insertions(+), 31 deletions(-)
 rename OvmfPkg/{AcpiPlatformDxe => Library/AcpiPlatformLib}/BootScript.c (96%)

diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
index b22aad95e081..6001b9626970 100644
--- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
+++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
@@ -23,7 +23,6 @@ [Defines]
 [Sources]
   AcpiPlatform.c
   AcpiPlatform.h
-  BootScript.c
   CloudHvAcpi.c
   EntryPoint.c
   QemuFwCfgAcpi.c
@@ -40,7 +39,6 @@ [LibraryClasses]
   MemoryAllocationLib
   OrderedCollectionLib
   QemuFwCfgLib
-  QemuFwCfgS3Lib
   UefiDriverEntryPoint
   HobLib
   TpmMeasurementLib
diff --git a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
index 4be501bb2c58..b6e55b618cbb 100644
--- a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
+++ b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
@@ -15,6 +15,7 @@ [Defines]
   LIBRARY_CLASS  = AcpiPlatformLib
 
 [Sources]
+  BootScript.c
   DxeAcpiPlatformLib.c
   PciDecoding.c
 
@@ -27,6 +28,7 @@ [LibraryClasses]
   BaseLib
   DebugLib
   PcdLib
+  QemuFwCfgS3Lib
   UefiBootServicesTableLib
 
 [Pcd]
diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h
index 1328f6d1cba6..c9f2755014a1 100644
--- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h
+++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h
@@ -11,8 +11,6 @@
 
 #include <Protocol/AcpiTable.h> // EFI_ACPI_TABLE_PROTOCOL
 
-typedef struct S3_CONTEXT S3_CONTEXT;
-
 EFI_STATUS
 EFIAPI
 InstallCloudHvTablesTdx (
@@ -37,29 +35,4 @@ InstallAcpiTables (
   IN   EFI_ACPI_TABLE_PROTOCOL  *AcpiTable
   );
 
-EFI_STATUS
-AllocateS3Context (
-  OUT S3_CONTEXT  **S3Context,
-  IN  UINTN       WritePointerCount
-  );
-
-VOID
-ReleaseS3Context (
-  IN S3_CONTEXT  *S3Context
-  );
-
-EFI_STATUS
-SaveCondensedWritePointerToS3Context (
-  IN OUT S3_CONTEXT  *S3Context,
-  IN     UINT16      PointerItem,
-  IN     UINT8       PointerSize,
-  IN     UINT32      PointerOffset,
-  IN     UINT64      PointerValue
-  );
-
-EFI_STATUS
-TransferS3ContextToBootScript (
-  IN S3_CONTEXT  *S3Context
-  );
-
 #endif
diff --git a/OvmfPkg/Include/Library/AcpiPlatformLib.h b/OvmfPkg/Include/Library/AcpiPlatformLib.h
index 167d6c49d6e2..70c974dce05e 100644
--- a/OvmfPkg/Include/Library/AcpiPlatformLib.h
+++ b/OvmfPkg/Include/Library/AcpiPlatformLib.h
@@ -15,6 +15,8 @@ typedef struct {
   UINT64                 PciAttributes;
 } ORIGINAL_ATTRIBUTES;
 
+typedef struct S3_CONTEXT S3_CONTEXT;
+
 /**
   Searches and returns the address of the ACPI Root System Description Pointer (RSDP) in system memory.
 
@@ -69,4 +71,29 @@ RestorePciDecoding (
   IN UINTN                Count
   );
 
+EFI_STATUS
+AllocateS3Context (
+  OUT S3_CONTEXT  **S3Context,
+  IN  UINTN       WritePointerCount
+  );
+
+VOID
+ReleaseS3Context (
+  IN S3_CONTEXT  *S3Context
+  );
+
+EFI_STATUS
+SaveCondensedWritePointerToS3Context (
+  IN OUT S3_CONTEXT  *S3Context,
+  IN     UINT16      PointerItem,
+  IN     UINT8       PointerSize,
+  IN     UINT32      PointerOffset,
+  IN     UINT64      PointerValue
+  );
+
+EFI_STATUS
+TransferS3ContextToBootScript (
+  IN S3_CONTEXT  *S3Context
+  );
+
 #endif
diff --git a/OvmfPkg/AcpiPlatformDxe/BootScript.c b/OvmfPkg/Library/AcpiPlatformLib/BootScript.c
similarity index 96%
rename from OvmfPkg/AcpiPlatformDxe/BootScript.c
rename to OvmfPkg/Library/AcpiPlatformLib/BootScript.c
index ff1491de0d2d..1b1658d703b0 100644
--- a/OvmfPkg/AcpiPlatformDxe/BootScript.c
+++ b/OvmfPkg/Library/AcpiPlatformLib/BootScript.c
@@ -7,13 +7,12 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
+#include <Library/AcpiPlatformLib.h>
 #include <Library/BaseLib.h>             // CpuDeadLoop()
 #include <Library/DebugLib.h>            // DEBUG()
 #include <Library/MemoryAllocationLib.h> // AllocatePool()
 #include <Library/QemuFwCfgS3Lib.h>      // QemuFwCfgS3ScriptSkipBytes()
 
-#include "AcpiPlatform.h"
-
 //
 // Condensed structure for capturing the fw_cfg operations -- select, skip,
 // write -- inherent in executing a QEMU_LOADER_WRITE_POINTER command.
-- 
2.41.0


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

* [PATCH 4/5] OvmfPkg: move QemuFwCfgAcpi into AcpiPlatformLib
  2023-06-14  7:55 [PATCH 0/5] OvmfPkg/Bhyve: install Acpi tables by FwCfg Corvin Köhne
                   ` (2 preceding siblings ...)
  2023-06-14  7:55 ` [PATCH 3/5] OvmfPkg: move BootScript " Corvin Köhne
@ 2023-06-14  7:55 ` Corvin Köhne
  2023-06-14  7:55 ` [PATCH 5/5] OvmfPkg/Bhyve: install Acpi tables provided by FwCfg Corvin Köhne
  4 siblings, 0 replies; 10+ messages in thread
From: Corvin Köhne @ 2023-06-14  7:55 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Gerd Hoffmann, Jiewen Yao, Jordan Justen,
	Leif Lindholm, Peter Grehan, Rebecca Cran, Sami Mujawar

This makes the InstallQemuFwcfgTables function reusable by bhyve.

Signed-off-by: Corvin Köhne <corvink@FreeBSD.org>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
---
 OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf                 | 3 ---
 OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf      | 5 +++++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h                      | 6 ------
 OvmfPkg/Include/Library/AcpiPlatformLib.h                   | 6 ++++++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c                      | 3 +++
 .../AcpiPlatformLib}/QemuFwCfgAcpi.c                        | 2 --
 6 files changed, 14 insertions(+), 11 deletions(-)
 rename OvmfPkg/{AcpiPlatformDxe => Library/AcpiPlatformLib}/QemuFwCfgAcpi.c (96%)

diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
index 6001b9626970..622589e607e9 100644
--- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
+++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
@@ -25,7 +25,6 @@ [Sources]
   AcpiPlatform.h
   CloudHvAcpi.c
   EntryPoint.c
-  QemuFwCfgAcpi.c
 
 [Packages]
   MdeModulePkg/MdeModulePkg.dec
@@ -41,12 +40,10 @@ [LibraryClasses]
   QemuFwCfgLib
   UefiDriverEntryPoint
   HobLib
-  TpmMeasurementLib
 
 [Protocols]
   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED
   gEfiPciIoProtocolGuid                         # PROTOCOL SOMETIMES_CONSUMED
-  gQemuAcpiTableNotifyProtocolGuid              # PROTOCOL PRODUCES
 
 [Guids]
   gRootBridgesConnectedEventGroupGuid
diff --git a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
index b6e55b618cbb..59fcb957d059 100644
--- a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
+++ b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
@@ -18,6 +18,7 @@ [Sources]
   BootScript.c
   DxeAcpiPlatformLib.c
   PciDecoding.c
+  QemuFwCfgAcpi.c
 
 [Packages]
   MdeModulePkg/MdeModulePkg.dec
@@ -30,6 +31,10 @@ [LibraryClasses]
   PcdLib
   QemuFwCfgS3Lib
   UefiBootServicesTableLib
+  TpmMeasurementLib
+
+[Protocols]
+  gQemuAcpiTableNotifyProtocolGuid              # PROTOCOL PRODUCES
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h
index c9f2755014a1..f4ae84b5a194 100644
--- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h
+++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h
@@ -23,12 +23,6 @@ InstallCloudHvTables (
   IN   EFI_ACPI_TABLE_PROTOCOL  *AcpiProtocol
   );
 
-EFI_STATUS
-EFIAPI
-InstallQemuFwCfgTables (
-  IN   EFI_ACPI_TABLE_PROTOCOL  *AcpiProtocol
-  );
-
 EFI_STATUS
 EFIAPI
 InstallAcpiTables (
diff --git a/OvmfPkg/Include/Library/AcpiPlatformLib.h b/OvmfPkg/Include/Library/AcpiPlatformLib.h
index 70c974dce05e..277be93a50bc 100644
--- a/OvmfPkg/Include/Library/AcpiPlatformLib.h
+++ b/OvmfPkg/Include/Library/AcpiPlatformLib.h
@@ -59,6 +59,12 @@ InstallAcpiTablesFromRsdp (
   IN EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp
   );
 
+EFI_STATUS
+EFIAPI
+InstallQemuFwCfgTables (
+  IN   EFI_ACPI_TABLE_PROTOCOL  *AcpiProtocol
+  );
+
 VOID
 EnablePciDecoding (
   OUT ORIGINAL_ATTRIBUTES  **OriginalAttributes,
diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c
index b446bb487234..20c98bb67fa3 100644
--- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c
+++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c
@@ -9,6 +9,9 @@
 
 #include <OvmfPlatforms.h> // CLOUDHV_DEVICE_ID
 #include <ConfidentialComputingGuestAttr.h>
+
+#include <Library/AcpiPlatformLib.h>
+
 #include "AcpiPlatform.h"
 
 /**
diff --git a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c b/OvmfPkg/Library/AcpiPlatformLib/QemuFwCfgAcpi.c
similarity index 96%
rename from OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c
rename to OvmfPkg/Library/AcpiPlatformLib/QemuFwCfgAcpi.c
index 3de039d57414..d9d0163ffd9f 100644
--- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c
+++ b/OvmfPkg/Library/AcpiPlatformLib/QemuFwCfgAcpi.c
@@ -22,8 +22,6 @@
 #include <Library/UefiBootServicesTableLib.h> // gBS
 #include <Library/TpmMeasurementLib.h>
 
-#include "AcpiPlatform.h"
-
 //
 // The user structure for the ordered collection that will track the fw_cfg
 // blobs under processing.
-- 
2.41.0


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

* [PATCH 5/5] OvmfPkg/Bhyve: install Acpi tables provided by FwCfg
  2023-06-14  7:55 [PATCH 0/5] OvmfPkg/Bhyve: install Acpi tables by FwCfg Corvin Köhne
                   ` (3 preceding siblings ...)
  2023-06-14  7:55 ` [PATCH 4/5] OvmfPkg: move QemuFwCfgAcpi " Corvin Köhne
@ 2023-06-14  7:55 ` Corvin Köhne
  4 siblings, 0 replies; 10+ messages in thread
From: Corvin Köhne @ 2023-06-14  7:55 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Gerd Hoffmann, Jiewen Yao, Jordan Justen,
	Leif Lindholm, Peter Grehan, Rebecca Cran, Sami Mujawar

Signed-off-by: Corvin Köhne <corvink@FreeBSD.org>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
---
 OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c
index 1e1c90614ea1..fb926a8bd803 100644
--- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c
+++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c
@@ -249,6 +249,11 @@ InstallAcpiTables (
   EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp;
   EFI_STATUS                                    Status;
 
+  Status = InstallQemuFwCfgTables (AcpiTable);
+  if (!EFI_ERROR (Status)) {
+    return EFI_SUCCESS;
+  }
+
   Status = GetAcpiRsdpFromMemory (
              BHYVE_ACPI_PHYSICAL_ADDRESS,
              BHYVE_BIOS_PHYSICAL_END,
-- 
2.41.0


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

* Re: [PATCH 1/5] OvmfPkg: avoid including AcpiPlatformLib twice
  2023-06-14  7:55 ` [PATCH 1/5] OvmfPkg: avoid including AcpiPlatformLib twice Corvin Köhne
@ 2023-06-19 10:41   ` Gerd Hoffmann
  2023-06-19 11:52     ` Corvin Köhne
  0 siblings, 1 reply; 10+ messages in thread
From: Gerd Hoffmann @ 2023-06-19 10:41 UTC (permalink / raw)
  To: Corvin Köhne
  Cc: devel, Ard Biesheuvel, Jiewen Yao, Jordan Justen, Leif Lindholm,
	Peter Grehan, Rebecca Cran, Sami Mujawar

On Wed, Jun 14, 2023 at 09:55:43AM +0200, Corvin Köhne wrote:
> Signed-off-by: Corvin Köhne <corvink@FreeBSD.org>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Leif Lindholm <quic_llindhol@quicinc.com>
> Cc: Peter Grehan <grehan@freebsd.org>
> Cc: Rebecca Cran <rebecca@bsdio.com>
> Cc: Sami Mujawar <sami.mujawar@arm.com>

Series breaks OvmfPkg/OvmfPkgIa32.dsc build.

take care,
  Gerd


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

* Re: [PATCH 1/5] OvmfPkg: avoid including AcpiPlatformLib twice
  2023-06-19 10:41   ` Gerd Hoffmann
@ 2023-06-19 11:52     ` Corvin Köhne
  2023-06-19 13:04       ` Gerd Hoffmann
  0 siblings, 1 reply; 10+ messages in thread
From: Corvin Köhne @ 2023-06-19 11:52 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: devel, Ard Biesheuvel, Jiewen Yao, Jordan Justen, Leif Lindholm,
	Peter Grehan, Rebecca Cran, Sami Mujawar

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

On Mon, 2023-06-19 at 12:41 +0200, Gerd Hoffmann wrote:
> On Wed, Jun 14, 2023 at 09:55:43AM +0200, Corvin Köhne wrote:
> > Signed-off-by: Corvin Köhne <corvink@FreeBSD.org>
> > Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > Cc: Jordan Justen <jordan.l.justen@intel.com>
> > Cc: Leif Lindholm <quic_llindhol@quicinc.com>
> > Cc: Peter Grehan <grehan@freebsd.org>
> > Cc: Rebecca Cran <rebecca@bsdio.com>
> > Cc: Sami Mujawar <sami.mujawar@arm.com>
> 
> Series breaks OvmfPkg/OvmfPkgIa32.dsc build.
> 
> take care,
>   Gerd
> 

Hi Gerd,

CI was successful for OvmfPkg/OvmfPkgIa32.dsc:
https://github.com/tianocore/edk2/pull/4545
https://dev.azure.com/tianocore/edk2-ci/_build/results?buildId=95435&view=results


-- 
Kind regards,
Corvin

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 1/5] OvmfPkg: avoid including AcpiPlatformLib twice
  2023-06-19 11:52     ` Corvin Köhne
@ 2023-06-19 13:04       ` Gerd Hoffmann
  2023-06-19 13:11         ` Corvin Köhne
  0 siblings, 1 reply; 10+ messages in thread
From: Gerd Hoffmann @ 2023-06-19 13:04 UTC (permalink / raw)
  To: Corvin Köhne
  Cc: devel, Ard Biesheuvel, Jiewen Yao, Jordan Justen, Leif Lindholm,
	Peter Grehan, Rebecca Cran, Sami Mujawar

On Mon, Jun 19, 2023 at 01:52:19PM +0200, Corvin Köhne wrote:
> On Mon, 2023-06-19 at 12:41 +0200, Gerd Hoffmann wrote:
> > On Wed, Jun 14, 2023 at 09:55:43AM +0200, Corvin Köhne wrote:
> > > Signed-off-by: Corvin Köhne <corvink@FreeBSD.org>
> > > Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> > > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > > Cc: Jordan Justen <jordan.l.justen@intel.com>
> > > Cc: Leif Lindholm <quic_llindhol@quicinc.com>
> > > Cc: Peter Grehan <grehan@freebsd.org>
> > > Cc: Rebecca Cran <rebecca@bsdio.com>
> > > Cc: Sami Mujawar <sami.mujawar@arm.com>
> > 
> > Series breaks OvmfPkg/OvmfPkgIa32.dsc build.
> > 
> > take care,
> >   Gerd
> > 
> 
> Hi Gerd,
> 
> CI was successful for OvmfPkg/OvmfPkgIa32.dsc:
> https://github.com/tianocore/edk2/pull/4545
> https://dev.azure.com/tianocore/edk2-ci/_build/results?buildId=95435&view=results

/home/kraxel/projects/edk2/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c:18:1: error: conflicting types for ‘GetAcpiRsdpFromMemory’; have ‘EFI_STATUS(UINTN,  UINTN,  EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER **)’ {aka ‘unsigned int(unsigned int,  unsigned int,  EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER **)’}
   18 | GetAcpiRsdpFromMemory (
      | ^~~~~~~~~~~~~~~~~~~~~
In file included from /home/kraxel/projects/edk2/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c:12:
/home/kraxel/projects/edk2/OvmfPkg/Include/Library/AcpiPlatformLib.h:33:1: note: previous declaration of ‘GetAcpiRsdpFromMemory’ with type ‘EFI_STATUS(UINT64,  UINT64,  EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER **)’ {aka ‘unsigned int(long long unsigned int,  long long unsigned int,  EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER **)’}
   33 | GetAcpiRsdpFromMemory (
      | ^~~~~~~~~~~~~~~~~~~~~
make: *** [GNUmakefile:311: /home/kraxel/projects/edk2/Build/OvmfIa32/DEBUG_GCC5/IA32/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib/OUTPUT/DxeAcpiPlatformLib.obj] Error 1

Looks like UINTN vs. UINT64

take care,
  Gerd


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

* Re: [PATCH 1/5] OvmfPkg: avoid including AcpiPlatformLib twice
  2023-06-19 13:04       ` Gerd Hoffmann
@ 2023-06-19 13:11         ` Corvin Köhne
  0 siblings, 0 replies; 10+ messages in thread
From: Corvin Köhne @ 2023-06-19 13:11 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: devel, Ard Biesheuvel, Jiewen Yao, Jordan Justen, Leif Lindholm,
	Peter Grehan, Rebecca Cran, Sami Mujawar

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

On Mon, 2023-06-19 at 15:04 +0200, Gerd Hoffmann wrote:
> On Mon, Jun 19, 2023 at 01:52:19PM +0200, Corvin Köhne wrote:
> > On Mon, 2023-06-19 at 12:41 +0200, Gerd Hoffmann wrote:
> > > On Wed, Jun 14, 2023 at 09:55:43AM +0200, Corvin Köhne wrote:
> > > > Signed-off-by: Corvin Köhne <corvink@FreeBSD.org>
> > > > Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> > > > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > > > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > > > Cc: Jordan Justen <jordan.l.justen@intel.com>
> > > > Cc: Leif Lindholm <quic_llindhol@quicinc.com>
> > > > Cc: Peter Grehan <grehan@freebsd.org>
> > > > Cc: Rebecca Cran <rebecca@bsdio.com>
> > > > Cc: Sami Mujawar <sami.mujawar@arm.com>
> > > 
> > > Series breaks OvmfPkg/OvmfPkgIa32.dsc build.
> > > 
> > > take care,
> > >   Gerd
> > > 
> > 
> > Hi Gerd,
> > 
> > CI was successful for OvmfPkg/OvmfPkgIa32.dsc:
> > https://github.com/tianocore/edk2/pull/4545
> > https://dev.azure.com/tianocore/edk2-ci/_build/results?buildId=95435&view=results
> 
> /home/kraxel/projects/edk2/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPla
> tformLib.c:18:1: error: conflicting types for
> ‘GetAcpiRsdpFromMemory’; have ‘EFI_STATUS(UINTN,  UINTN, 
> EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER **)’ {aka ‘unsigned
> int(unsigned int,  unsigned int, 
> EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER **)’}
>    18 | GetAcpiRsdpFromMemory (
>       | ^~~~~~~~~~~~~~~~~~~~~
> In file included from
> /home/kraxel/projects/edk2/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPla
> tformLib.c:12:
> /home/kraxel/projects/edk2/OvmfPkg/Include/Library/AcpiPlatformLib.h:
> 33:1: note: previous declaration of ‘GetAcpiRsdpFromMemory’ with type
> ‘EFI_STATUS(UINT64,  UINT64, 
> EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER **)’ {aka ‘unsigned
> int(long long unsigned int,  long long unsigned int, 
> EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER **)’}
>    33 | GetAcpiRsdpFromMemory (
>       | ^~~~~~~~~~~~~~~~~~~~~
> make: *** [GNUmakefile:311:
> /home/kraxel/projects/edk2/Build/OvmfIa32/DEBUG_GCC5/IA32/OvmfPkg/Lib
> rary/AcpiPlatformLib/DxeAcpiPlatformLib/OUTPUT/DxeAcpiPlatformLib.obj
> ] Error 1
> 
> Looks like UINTN vs. UINT64
> 
> take care,
>   Gerd
> 

Sry, forgot to send an update of my series. Already fixed it in my PR:
https://github.com/tianocore/edk2/pull/4545/commits/3b7b1e09051228ee0cfb5ef0765a707e4c83bbfc


-- 
Kind regards,
Corvin

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2023-06-19 13:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-14  7:55 [PATCH 0/5] OvmfPkg/Bhyve: install Acpi tables by FwCfg Corvin Köhne
2023-06-14  7:55 ` [PATCH 1/5] OvmfPkg: avoid including AcpiPlatformLib twice Corvin Köhne
2023-06-19 10:41   ` Gerd Hoffmann
2023-06-19 11:52     ` Corvin Köhne
2023-06-19 13:04       ` Gerd Hoffmann
2023-06-19 13:11         ` Corvin Köhne
2023-06-14  7:55 ` [PATCH 2/5] OvmfPkg: move PciEncoding into AcpiPlatformLib Corvin Köhne
2023-06-14  7:55 ` [PATCH 3/5] OvmfPkg: move BootScript " Corvin Köhne
2023-06-14  7:55 ` [PATCH 4/5] OvmfPkg: move QemuFwCfgAcpi " Corvin Köhne
2023-06-14  7:55 ` [PATCH 5/5] OvmfPkg/Bhyve: install Acpi tables provided by FwCfg Corvin Köhne

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