From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web08.5056.1639128953049854399 for ; Fri, 10 Dec 2021 01:35:53 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.com header.s=intel header.b=l3iDXHZQ; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: sebastien.boeuf@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639128953; x=1670664953; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qJbC2FDcSn8ih9olfIJvDSbfyCE1XyjAie0CWjHO0xw=; b=l3iDXHZQpfxhjAfHGaYNbBG7RD0Eyle8ulJAbKk7VxTN9tygee+5WyFB oW/fMiGQLmcXb1Du27XQ3PsmQlCkk7I8kwJzkvOQX27yVo1y4KRKB/KMF 3A4cDuf2//M5XiiV3jYz6Kc0niULwCfn6wCv0pMvswIAhbJquBql/LlIr Szxmu11F0Nw+FUv85/BDPozmNBeeTY043sZe2U1g05F18m0i5gkYFUhzL FxmhvVZ1wsBITILbgl70BLhD/JhuH8e/9Ornz/Rj68X3I4lMC1ef4P+Uu 1lIck9RZ3VDrBBeE74OrnWBx4LkreXdr3hVHW+cr9PD1q6kpPFYit6BE3 A==; X-IronPort-AV: E=McAfee;i="6200,9189,10193"; a="299104134" X-IronPort-AV: E=Sophos;i="5.88,195,1635231600"; d="scan'208";a="299104134" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 01:35:51 -0800 X-IronPort-AV: E=Sophos;i="5.88,195,1635231600"; d="scan'208";a="503862782" Received: from gmarti2-mobl1.amr.corp.intel.com (HELO sboeuf-mobl.home) ([10.252.20.4]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 01:35:49 -0800 From: sebastien.boeuf@intel.com To: devel@edk2.groups.io Cc: jiewen.yao@intel.com, jordan.l.justen@intel.com, kraxel@redhat.com, sebastien.boeuf@intel.com Subject: [PATCH v6 3/5] OvmfPkg: Retrieve SMBIOS from Cloud Hypervisor Date: Fri, 10 Dec 2021 10:35:11 +0100 Message-Id: <69527effb741b9a1f2dafd764ab1fd06abe386c6.1639128828.git.sebastien.boeuf@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable From: Sebastien Boeuf Add a fallback on the SMBIOS code to find the SMBIOS table for Cloud Hypervisor if it couldn't be found for Qemu through fw_cfg. Reviewed-by: Gerd Hoffmann Reviewed-by: Jiewen Yao Signed-off-by: Rob Bradford Signed-off-by: Sebastien Boeuf --- OvmfPkg/Include/IndustryStandard/CloudHv.h | 5 +++ OvmfPkg/SmbiosPlatformDxe/CloudHv.c | 32 +++++++++++++++++++ OvmfPkg/SmbiosPlatformDxe/EntryPoint.c | 20 +++++++++--- OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h | 11 +++++++ .../SmbiosPlatformDxe/SmbiosPlatformDxe.inf | 2 ++ 5 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 OvmfPkg/SmbiosPlatformDxe/CloudHv.c diff --git a/OvmfPkg/Include/IndustryStandard/CloudHv.h b/OvmfPkg/Include/I= ndustryStandard/CloudHv.h index 6ab18ad50d..ad0e170795 100644 --- a/OvmfPkg/Include/IndustryStandard/CloudHv.h +++ b/OvmfPkg/Include/IndustryStandard/CloudHv.h @@ -32,4 +32,9 @@ // #define CLOUDHV_MMIO_HOLE_SIZE 0x38000000 = +// +// SMBIOS address +// +#define CLOUDHV_SMBIOS_ADDRESS 0xf0000 + #endif // __CLOUDHV_H__ diff --git a/OvmfPkg/SmbiosPlatformDxe/CloudHv.c b/OvmfPkg/SmbiosPlatformDx= e/CloudHv.c new file mode 100644 index 0000000000..e9ce00b6eb --- /dev/null +++ b/OvmfPkg/SmbiosPlatformDxe/CloudHv.c @@ -0,0 +1,32 @@ +/** @file + Find Cloud Hypervisor SMBIOS data. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include // CLOUDHV_SMBIOS_ADDRESS +#include // SMBIOS_TABLE_3_0_ENTRY_POINT + +/** + Locates and extracts Cloud Hypervisor SMBIOS data + + @return Address of extracted Cloud Hypervisor SMBIOS data + +**/ +UINT8 * +GetCloudHvSmbiosTables ( + VOID + ) +{ + SMBIOS_TABLE_3_0_ENTRY_POINT *CloudHvTables =3D (VOID *)CLOUDHV_SMBIOS_A= DDRESS; + + if (CloudHvTables->AnchorString[0] =3D=3D '_' && + CloudHvTables->AnchorString[1] =3D=3D 'S' && + CloudHvTables->AnchorString[2] =3D=3D 'M' && + CloudHvTables->AnchorString[3] =3D=3D '3' && + CloudHvTables->AnchorString[4] =3D=3D '_') { + return (UINT8*)(UINTN)CloudHvTables->TableAddress; + } + + return NULL; +} diff --git a/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c b/OvmfPkg/SmbiosPlatfor= mDxe/EntryPoint.c index c72ba1d14b..992ae5e2ab 100644 --- a/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c +++ b/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c @@ -5,6 +5,7 @@ **/ = #include // FreePool() +#include // CLOUDHV_DEVICE_ID = #include "SmbiosPlatformDxe.h" = @@ -27,15 +28,24 @@ SmbiosTablePublishEntry ( { EFI_STATUS Status; UINT8 *SmbiosTables; + UINT16 HostBridgeDevId; = Status =3D EFI_NOT_FOUND; // - // Add QEMU SMBIOS data if found + // Add SMBIOS data if found // - SmbiosTables =3D GetQemuSmbiosTables (); - if (SmbiosTables !=3D NULL) { - Status =3D InstallAllStructures (SmbiosTables); - FreePool (SmbiosTables); + HostBridgeDevId =3D PcdGet16 (PcdOvmfHostBridgePciDevId); + if (HostBridgeDevId =3D=3D CLOUDHV_DEVICE_ID) { + SmbiosTables =3D GetCloudHvSmbiosTables (); + if (SmbiosTables !=3D NULL) { + Status =3D InstallAllStructures (SmbiosTables); + } + } else { + SmbiosTables =3D GetQemuSmbiosTables (); + if (SmbiosTables !=3D NULL) { + Status =3D InstallAllStructures (SmbiosTables); + FreePool (SmbiosTables); + } } = return Status; diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h b/OvmfPkg/Smbios= PlatformDxe/SmbiosPlatformDxe.h index b7bf004be9..709e096e7b 100644 --- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h +++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h @@ -33,4 +33,15 @@ GetQemuSmbiosTables ( VOID ); = +/** + Locates and extracts Cloud Hypervisor SMBIOS data + + @return Address of extracted Cloud Hypervisor SMBIOS data + +**/ +UINT8 * +GetCloudHvSmbiosTables ( + VOID + ); + #endif diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/OvmfPkg/Smbi= osPlatformDxe/SmbiosPlatformDxe.inf index e239a631f2..0066bbc922 100644 --- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf +++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf @@ -24,6 +24,7 @@ # = [Sources] + CloudHv.c EntryPoint.c Qemu.c SmbiosPlatformDxe.c @@ -42,6 +43,7 @@ UefiDriverEntryPoint = [Pcd] + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated = [Protocols] -- = 2.30.2 --------------------------------------------------------------------- Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, = 92196 Meudon Cedex, France Registration Number: 302 456 199 R.C.S. NANTERRE Capital: 4,572,000 Euros This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.