From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.3894.1643092565142842596 for ; Mon, 24 Jan 2022 22:36:05 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=RwuqG3Lm; spf=pass (domain: intel.com, ip: 192.55.52.151, 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=1643092565; x=1674628565; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bW83pezdrOCzGZkx+je8cNTmZqB1kI9dQTqAR8tU8G4=; b=RwuqG3LmeLr5rkD82N06Q7/sHg4NYzkbvzEHvLQoUK4YaSneq85L2dmF BiKfp8HK14rh7RrpE+tkhrfvfwlHypT4gJphYCT5Ur4iXYDawSfg3gHB8 LdrLt+7l9L5K0CR0Ed6YW47jc8oX6ysxAtl5v0xBSpLT1Ez4mqBNEnFcx VY2WHT5UGBp9ui78n8HbL4VTVlaMRYd3NMalU+jg+ChGgH1iFZLHXggGh EYfhwXrNR6FuFi0le5iz4u1nmUBCjh74sSpuhlZ18P72ma58uqnLUfCLJ QWcrVkxNUjSxbjaheeQ5K34EyJB4ZEnckLbFEib5Nfn2LvR9OkZbxrYgt g==; X-IronPort-AV: E=McAfee;i="6200,9189,10237"; a="226904951" X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="226904951" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 22:35:55 -0800 X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="534592726" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.238.0.72]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 22:35:52 -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 V2 09/10] OvmfPkg: Update DxeAcpiTimerLib to read HostBridgeDevId in PlatformInfoHob Date: Tue, 25 Jan 2022 14:33:17 +0800 Message-Id: <20220125063318.862-10-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: <20220125063318.862-1-min.m.xu@intel.com> References: <20220125063318.862-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 PEI-less boot 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 | 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