From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web11.903.1647050145463002246 for ; Fri, 11 Mar 2022 17:56:28 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=gpqJfFd0; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647050188; x=1678586188; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VM0P7Co48kIZsHThLH5mc/POebZZB6RzBWLij04HKUg=; b=gpqJfFd0Sf3UpTtCXDj2oilQPRx3P9oT2I5ScCylItXi38iooOVLSlvh F1zk1/VPP2UGUmfTmg5no/IOTEQpDNqgKhnNgJol7s9AeFU6ldZhc2Kvg tNBDX8goyUyHRdLnSu7uKq2O/BkpEscKqtkLWlLOw93dWskrKWtYvyoX2 +SYlp5LcK99vOhWoUx8+HerymMz0kTQSzsT3khxb6NnGfqH9ad3fCUana BTOyVXU9yO6vAXjoYCN0De91b6E6ynA2j5eEhHoxuIxC8zl6W0PDcYevi UMmO7jwCuc0EDX6Yl9FsqqHcm87OU5z75wIV3rhWnA1UcKek1xjvHxz+r w==; X-IronPort-AV: E=McAfee;i="6200,9189,10283"; a="255895279" X-IronPort-AV: E=Sophos;i="5.90,175,1643702400"; d="scan'208";a="255895279" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2022 17:56:27 -0800 X-IronPort-AV: E=Sophos;i="5.90,175,1643702400"; d="scan'208";a="555565350" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.254]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2022 17:56:25 -0800 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Ard Biesheuvel , Jordan Justen , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Gerd Hoffmann Subject: [PATCH V8 40/47] OvmfPkg: Update AcpiPlatformDxe to alter MADT table Date: Sat, 12 Mar 2022 09:54:05 +0800 Message-Id: <0411ee4a238a8dbaae434215408a4b8c7d014077.1647047482.git.min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Jordan Justen Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Gerd Hoffmann Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf | 1 + OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c | 14 +++++++++- .../Include/Protocol/QemuAcpiTableNotify.h | 27 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 OvmfPkg/Include/Protocol/QemuAcpiTableNotify.h diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf index f22bd7cb6da1..09daf30bcd3d 100644 --- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf +++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf @@ -49,6 +49,7 @@ [Protocols] gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiPciIoProtocolGuid # PROTOCOL SOMETIMES_CONSUMED + gQemuAcpiTableNotifyProtocolGuid # PROTOCOL PRODUCES [Guids] gRootBridgesConnectedEventGroupGuid diff --git a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c index b885965a601e..c8dee17c13e6 100644 --- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c +++ b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c @@ -19,7 +19,10 @@ #include // QemuFwCfgS3Enabled() #include // gBS +#include #include "AcpiPlatform.h" +EFI_HANDLE mQemuAcpiHandle = NULL; +QEMU_ACPI_TABLE_NOTIFY_PROTOCOL mAcpiNotifyProtocol; // // The user structure for the ordered collection that will track the fw_cfg @@ -1273,7 +1276,16 @@ UninstallAcpiTables: AcpiProtocol->UninstallAcpiTable (AcpiProtocol, InstalledKey[Installed]); } } else { - DEBUG ((DEBUG_INFO, "%a: installed %d tables\n", __FUNCTION__, Installed)); + // + // Install a protocol to notify that the ACPI table provided by Qemu is + // ready. + // + gBS->InstallProtocolInterface ( + &mQemuAcpiHandle, + &gQemuAcpiTableNotifyProtocolGuid, + EFI_NATIVE_INTERFACE, + &mAcpiNotifyProtocol + ); } for (SeenPointerEntry = OrderedCollectionMin (SeenPointers); diff --git a/OvmfPkg/Include/Protocol/QemuAcpiTableNotify.h b/OvmfPkg/Include/Protocol/QemuAcpiTableNotify.h new file mode 100644 index 000000000000..a3dd2fc1dc91 --- /dev/null +++ b/OvmfPkg/Include/Protocol/QemuAcpiTableNotify.h @@ -0,0 +1,27 @@ +/** @file + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef QEMU_ACPI_TABLE_NOTIFY_H_ +#define QEMU_ACPI_TABLE_NOTIFY_H_ + +#define QEMU_ACPI_TABLE_NOTIFY_GUID \ + { 0x928939b2, 0x4235, 0x462f, { 0x95, 0x80, 0xf6, 0xa2, 0xb2, 0xc2, 0x1a, 0x4f } }; + +/// +/// Forward declaration +/// +typedef struct _QEMU_ACPI_TABLE_NOTIFY_PROTOCOL QEMU_ACPI_TABLE_NOTIFY_PROTOCOL; + +/// +/// Protocol structure +/// +struct _QEMU_ACPI_TABLE_NOTIFY_PROTOCOL { + UINT8 Notify; +}; + +extern EFI_GUID gQemuAcpiTableNotifyProtocolGuid; + +#endif -- 2.29.2.windows.2