From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web12.10908.1647132088165160377 for ; Sat, 12 Mar 2022 16:41:45 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=ZPgLEoH3; spf=pass (domain: intel.com, ip: 134.134.136.100, 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=1647132104; x=1678668104; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=g/32KdiCLE7E87R2c5l2v6pHzjOhYnA3l08LhNfGOcg=; b=ZPgLEoH3rn7OuTZ2cvvtP4IZku9D1amxyBPylk+XkcR+jma5dnBQC/eH lRkygYcYcvLhBU4F/kGmTCBj+rgInCTqqKqcf1Kh4ZNgMZBEq60quZtS1 ktLXbaoRFrrj6SbmSl0vTuxPPwihnGorMjhNapdNbmmhaYncaeHAHzHcx snjpYQ7N7bsKltmS+wVUWEyu0GiQdL0zXpdSQ4deIih0vmgNlNhw0qhvn +vgiQb0dBGvel3SIpQCLnFZJqqS/HWdGZuhaJDYUF1F3B1xWVbgAmtXxv azSE/SRCHKfddwaB7c11mcZz8kJHOPu82JffAX/hMj60xLwo5HjcCFdlt Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10284"; a="319056911" X-IronPort-AV: E=Sophos;i="5.90,177,1643702400"; d="scan'208";a="319056911" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2022 16:41:44 -0800 X-IronPort-AV: E=Sophos;i="5.90,177,1643702400"; d="scan'208";a="539479337" Received: from xshi3x-mobl.ccr.corp.intel.com (HELO mxu9-mobl1.ccr.corp.intel.com) ([10.249.171.182]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2022 16:41:42 -0800 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Michael D Kinney , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Gerd Hoffmann Subject: [PATCH V5 06/10] OvmfPkg: Update DxeAcpiTimerLib to read HostBridgeDevId in PlatformInfoHob Date: Sun, 13 Mar 2022 08:41:07 +0800 Message-Id: <20220313004111.388-7-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: <20220313004111.388-1-min.m.xu@intel.com> References: <20220313004111.388-1-min.m.xu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 The entrypoint of DxeAcpiTimerLib checks HostBridgeDevId by reading PcdOvmfHostBridgePciDevId. If the DevId is not set, ASSERT is triggered. Normally this DevId is set in PlatformPei which is executed in PEI phase. This patch-set is introducing PEI-less boot which means PEI phase is skipped. So there is no chance to set this DevId. Instead HostBridgeDevId is set in PlatformInfoHob. So we can check if PlatformInfoHob exists and if HostBridgeDevId is set in this Hob. Cc: Michael D Kinney Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Gerd Hoffmann Signed-off-by: Min Xu --- .../Library/AcpiTimerLib/DxeAcpiTimerLib.c | 25 ++++++++++++++++--- .../Library/AcpiTimerLib/DxeAcpiTimerLib.inf | 7 +++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c index 115846187455..01a41a6a4515 100644 --- a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c +++ b/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c @@ -6,10 +6,16 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ +#include +#include +#include +#include +#include #include #include #include #include +#include #include // @@ -36,13 +42,26 @@ AcpiTimerLibConstructor ( VOID ) { - UINT16 HostBridgeDevId; - UINTN Pmba; + UINT16 HostBridgeDevId; + UINTN Pmba; + EFI_HOB_GUID_TYPE *GuidHob; + EFI_HOB_PLATFORM_INFO *PlatformInfoHob = NULL; // // Query Host Bridge DID to determine platform type + // Tdx guest stores the HostBridgePciDevId in a GuidHob. + // So we first check if this HOB exists // - HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId); + GuidHob = GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid); + if (GuidHob != NULL) { + PlatformInfoHob = (EFI_HOB_PLATFORM_INFO *)GET_GUID_HOB_DATA (GuidHob); + HostBridgeDevId = PlatformInfoHob->HostBridgeDevId; + } else { + DEBUG ((DEBUG_ERROR, "PlatformInfoHob is not found.\n")); + ASSERT (FALSE); + return RETURN_UNSUPPORTED; + } + switch (HostBridgeDevId) { case INTEL_82441_DEVICE_ID: Pmba = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMBA); diff --git a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf b/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf index e29872add3c7..9c364be886bd 100644 --- a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf +++ b/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf @@ -26,10 +26,11 @@ MdePkg/MdePkg.dec OvmfPkg/OvmfPkg.dec -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId - [LibraryClasses] BaseLib PciLib IoLib + HobLib + +[Guids] + gUefiOvmfPkgPlatformInfoGuid ## CONSUMES -- 2.29.2.windows.2