]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: Update AcpiPlatformDxe to alter MADT table
authorMin Xu <min.m.xu@intel.com>
Wed, 22 Sep 2021 13:02:19 +0000 (21:02 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sat, 2 Apr 2022 08:15:12 +0000 (08:15 +0000)
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429

In TDX the guest firmware is designed to publish a multiprocessor-wakeup
structure to let the guest-bootstrap processor wake up guest-application
processors with a mailbox. The mailbox is memory that the guest firmware
can reserve so each guest virtual processor can have the guest OS send
a message to them. The address of the mailbox is recorded in the MADT
table. See [ACPI].

To maintain the simplicity of the AcpiPlatformDxe, the MADT ACPI table
will be altered in another driver (TdxDxe) by installing a protocol
to notify that the ACPI table provided by Qemu is ready. Then in TdxDxe
a notification functioin will be called to alter the MADT table to recorded
the mailbox address.

The protocol is gQemuAcpiTableNotifyProtocolGuid.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c
OvmfPkg/Include/Protocol/QemuAcpiTableNotify.h [new file with mode: 0644]

index f22bd7cb6da1fbf1a0c84778fcb72d06ef23d3a8..09daf30bcd3d4f75843bce96cb12d12eca113223 100644 (file)
@@ -49,6 +49,7 @@
 [Protocols]\r
   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED\r
   gEfiPciIoProtocolGuid                         # PROTOCOL SOMETIMES_CONSUMED\r
+  gQemuAcpiTableNotifyProtocolGuid              # PROTOCOL PRODUCES\r
 \r
 [Guids]\r
   gRootBridgesConnectedEventGroupGuid\r
index b885965a601e427b5ee76c03b2f37b41f65c38d4..c8dee17c13e63aa208ffe15b955c056b3b758805 100644 (file)
 #include <Library/QemuFwCfgS3Lib.h>           // QemuFwCfgS3Enabled()\r
 #include <Library/UefiBootServicesTableLib.h> // gBS\r
 \r
+#include <Protocol/QemuAcpiTableNotify.h>\r
 #include "AcpiPlatform.h"\r
+EFI_HANDLE                       mQemuAcpiHandle = NULL;\r
+QEMU_ACPI_TABLE_NOTIFY_PROTOCOL  mAcpiNotifyProtocol;\r
 \r
 //\r
 // The user structure for the ordered collection that will track the fw_cfg\r
@@ -1273,7 +1276,16 @@ UninstallAcpiTables:
       AcpiProtocol->UninstallAcpiTable (AcpiProtocol, InstalledKey[Installed]);\r
     }\r
   } else {\r
-    DEBUG ((DEBUG_INFO, "%a: installed %d tables\n", __FUNCTION__, Installed));\r
+    //\r
+    // Install a protocol to notify that the ACPI table provided by Qemu is\r
+    // ready.\r
+    //\r
+    gBS->InstallProtocolInterface (\r
+           &mQemuAcpiHandle,\r
+           &gQemuAcpiTableNotifyProtocolGuid,\r
+           EFI_NATIVE_INTERFACE,\r
+           &mAcpiNotifyProtocol\r
+           );\r
   }\r
 \r
   for (SeenPointerEntry = OrderedCollectionMin (SeenPointers);\r
diff --git a/OvmfPkg/Include/Protocol/QemuAcpiTableNotify.h b/OvmfPkg/Include/Protocol/QemuAcpiTableNotify.h
new file mode 100644 (file)
index 0000000..a3dd2fc
--- /dev/null
@@ -0,0 +1,27 @@
+/** @file\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef QEMU_ACPI_TABLE_NOTIFY_H_\r
+#define QEMU_ACPI_TABLE_NOTIFY_H_\r
+\r
+#define QEMU_ACPI_TABLE_NOTIFY_GUID \\r
+  { 0x928939b2, 0x4235, 0x462f, { 0x95, 0x80, 0xf6, 0xa2, 0xb2, 0xc2, 0x1a, 0x4f } };\r
+\r
+///\r
+/// Forward declaration\r
+///\r
+typedef struct _QEMU_ACPI_TABLE_NOTIFY_PROTOCOL QEMU_ACPI_TABLE_NOTIFY_PROTOCOL;\r
+\r
+///\r
+/// Protocol structure\r
+///\r
+struct _QEMU_ACPI_TABLE_NOTIFY_PROTOCOL {\r
+  UINT8    Notify;\r
+};\r
+\r
+extern EFI_GUID  gQemuAcpiTableNotifyProtocolGuid;\r
+\r
+#endif\r