From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web08.25742.1639489321528370744 for ; Tue, 14 Dec 2021 05:42:11 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.com header.s=intel header.b=NbV/GKSS; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639489331; x=1671025331; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vyGzYkvgRX4FijCfoTN/SEm2903YaPadfEqqSnqBk6Y=; b=NbV/GKSS7bMg5qD0dCsrZGnKH8TuuvF/ttXVZhsmgK4hZjV+2VkABikJ T+Zzbp/ed1fltfbSjvmdfQ629VPp/KIS4zz0xw3j4JnFcDzMnx4KKCxZq 7w+po631vtO/2USLSaLw9Xs1MBQWg1UBrsfjbsWM3d+ppAgS3mnXfSBGd z0Xm/OqYEoQnhNC7y4AliBG9FeOKi+6QKvk1UVVUFgzm2+2zirQlLS4JG 9y0YuF9NcubAcbPyj8pdDQTbu7IeymA3I9cNUHTsAg1z3ajmKaiW4nwK1 1zuk3OIC6gVw9b3RLW+oZ/2iIxgbCtGF79lmV7h3POkgN+LBq37snDRJ9 w==; X-IronPort-AV: E=McAfee;i="6200,9189,10197"; a="218993709" X-IronPort-AV: E=Sophos;i="5.88,205,1635231600"; d="scan'208";a="218993709" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2021 05:42:11 -0800 X-IronPort-AV: E=Sophos;i="5.88,205,1635231600"; d="scan'208";a="465094293" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.115]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2021 05:42:08 -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 09/10] OvmfPkg: Update DxeAcpiTimerLib to read HostBridgeDevId in PlatformInfoHob Date: Tue, 14 Dec 2021 21:41:25 +0800 Message-Id: <20211214134126.869-10-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: <20211214134126.869-1-min.m.xu@intel.com> References: <20211214134126.869-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. But Tdvf Config-B skips PEI phase so there is no chance to set this DevId. A word-round is that in Tdx guest HostBridgeDevId is set in PlatformInfoHob (in SecPlatformLibQemuTdx). 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 | 23 ++++++++++++++++--- .../Library/AcpiTimerLib/DxeAcpiTimerLib.inf | 4 ++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c index 115846187455..5c7011f2dd3d 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,24 @@ AcpiTimerLibConstructor ( VOID ) { - UINT16 HostBridgeDevId; - UINTN Pmba; + UINT16 HostBridgeDevId; + UINTN Pmba; + EFI_HOB_GUID_TYPE *GuidHob; + EFI_HOB_PLATFORM_INFO *PlatformInfo = 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 (&gUefiOvmfPkgTdxPlatformGuid); + if (GuidHob != NULL) { + PlatformInfo = (EFI_HOB_PLATFORM_INFO *)GET_GUID_HOB_DATA (GuidHob); + HostBridgeDevId = PlatformInfo->HostBridgePciDevId; + } else { + HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId); + } + 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..44a4423a9ddd 100644 --- a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf +++ b/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf @@ -33,3 +33,7 @@ BaseLib PciLib IoLib + HobLib + +[Guids] + gUefiOvmfPkgTdxPlatformGuid ## CONSUMES -- 2.29.2.windows.2