public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Corvin Köhne" <corvink@FreeBSD.org>
To: devel@edk2.groups.io
Cc: "Corvin Köhne" <corvink@FreeBSD.org>,
	"Ard Biesheuvel" <ardb+tianocore@kernel.org>,
	"Jiewen Yao" <jiewen.yao@intel.com>,
	"Jordan Justen" <jordan.l.justen@intel.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Rebecca Cran" <rebecca@bsdio.com>,
	"Peter Grehan" <grehan@freebsd.org>
Subject: [PATCH v3 3/3] OvmfPkg/Bhyve: install ACPI tables from memory
Date: Wed,  3 May 2023 09:32:05 +0200	[thread overview]
Message-ID: <20230503073205.306090-3-corvink@FreeBSD.org> (raw)
In-Reply-To: <20230503073205.306090-1-corvink@FreeBSD.org>

It's much easier to create configuration dependend ACPI tables for bhyve
than for OVMF. For this reason, don't use the statically created ACPI
tables provided by OVMF. Instead prefer the dynamically created ACPI
tables of bhyve. If bhyve provides no ACPI tables or we are unable to
detect those, fall back to OVMF tables.

Ideally, we use the qemu fwcfg interface to pass the ACPI tables from
bhyve to OVMF. bhyve will support this in the future. However, current
bhyve executables don't support passing ACPI tables by the qemu fwcfg
interface. They just copy the ACPI into main memory. For that reason,
pick up the ACPI tables from main memory.

Signed-off-by: Corvin Köhne <corvink@FreeBSD.org>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Peter Grehan <grehan@freebsd.org>
---
 OvmfPkg/Bhyve/BhyveX64.dsc                    |  1 +
 .../Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf |  1 +
 OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c  | 26 +++++++++++++++++++
 3 files changed, 28 insertions(+)

diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index d0d2712c5662..465b81ffcd51 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -341,6 +341,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
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
index 94c65f32dcab..75ed8e4a7deb 100644
--- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
+++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
@@ -35,6 +35,7 @@ [Packages]
   UefiCpuPkg/UefiCpuPkg.dec
 
 [LibraryClasses]
+  AcpiPlatformLib
   BaseLib
   BaseMemoryLib
   BhyveFwCtlLib
diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c
index 999e9f151ebb..a4498080cf7a 100644
--- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c
+++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c
@@ -10,6 +10,11 @@
 
 #include "AcpiPlatform.h"
 
+#include <Library/AcpiPlatformLib.h> // InstallAcpiTablesFromMemory()
+
+#define BHYVE_ACPI_PHYSICAL_ADDRESS  ((UINTN)0x000F2400)
+#define BHYVE_BIOS_PHYSICAL_END      ((UINTN)0x00100000)
+
 EFI_STATUS
 EFIAPI
 InstallAcpiTable (
@@ -243,6 +248,27 @@ InstallAcpiTables (
 {
   EFI_STATUS  Status;
 
+  Status = InstallAcpiTablesFromMemory (
+             AcpiTable,
+             BHYVE_ACPI_PHYSICAL_ADDRESS,
+             BHYVE_BIOS_PHYSICAL_END
+             );
+  if (!EFI_ERROR (Status)) {
+    return EFI_SUCCESS;
+  }
+
+  if (Status != EFI_NOT_FOUND) {
+    DEBUG (
+      (
+       DEBUG_WARN,
+       "%a: unable to install bhyve's ACPI tables (%r)\n",
+       __func__,
+       Status
+      )
+      );
+    return Status;
+  }
+
   Status = InstallOvmfFvTables (AcpiTable);
 
   return Status;
-- 
2.40.1


  parent reply	other threads:[~2023-05-03  7:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-03  7:32 [PATCH v3 1/3] OvmfPkg/Xen: export search of RSDP into a library function Corvin Köhne
2023-05-03  7:32 ` [PATCH v3 2/3] OvmfPkg/Xen: export AcpiTable installation into AcpiPlatformLib Corvin Köhne
2023-05-03  7:32 ` Corvin Köhne [this message]
2023-05-05 14:43   ` [PATCH v3 3/3] OvmfPkg/Bhyve: install ACPI tables from memory Rebecca Cran
2023-05-08  6:04     ` Corvin Köhne
2023-05-04 10:05 ` [PATCH v3 1/3] OvmfPkg/Xen: export search of RSDP into a library function Gerd Hoffmann

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=20230503073205.306090-3-corvink@FreeBSD.org \
    --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