From nobody Mon Feb 9 23:38:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+87096+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87096+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646036246; cv=none; d=zohomail.com; s=zohoarc; b=k9nMYZpxigkQfA4I4aYKRC++Vtr5bPE6TmodcJynq54D13lqRzLQjGK7oO+vx4yzBEarMNZkJrxyxHrRwOJa/osBBALJWkEFxjDBuDJliY7UOzCedVHLFWDjPtBuREvK4dzlmZo97p4BzG8GQe8w/CG852PMzEYrdzXRWSZi80I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646036246; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=PgDKDS0FG3O7lUIMV5tlmitd2rKs3tF0Fc3UUPbIsno=; b=HnmpyYLgwLw0aTUfKodNnE0AtCXFuC4nQTI5inhwaQ4BwnAp01spq1HmJQqPa/g5vC5ym1X//a2Mhf94gOvoH05KXKmwcuNBrppRD7aH645fRvZHn9IYVhjOLg9oe0Gtv7fHkCeKGeQ+ZEUnRP69jcKoLGDLHFCH3EunZ+pq/4k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87096+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1646036246965407.14989550731275; Mon, 28 Feb 2022 00:17:26 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id rPSsYY1788612xiA8ACnWCFd; Mon, 28 Feb 2022 00:17:26 -0800 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web11.17836.1646036244358797905 for ; Mon, 28 Feb 2022 00:17:24 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10271"; a="339268980" X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="339268980" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2022 00:17:22 -0800 X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="550140153" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.238.2.184]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2022 00:17:16 -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: [edk2-devel] [PATCH V4 06/10] OvmfPkg: Update TdxDxe to set TDX PCDs Date: Mon, 28 Feb 2022 16:16:27 +0800 Message-Id: <20220228081631.681-7-min.m.xu@intel.com> In-Reply-To: <20220228081631.681-1-min.m.xu@intel.com> References: <20220228081631.681-1-min.m.xu@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,min.m.xu@intel.com X-Gm-Message-State: iSDPyZd1yKAIYoABJF0ugxsnx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646036246; bh=Kc87HwtBdzJnNjneQw4WsYTRiaw47GqpBM55LA9DON4=; h=Cc:Date:From:Reply-To:Subject:To; b=DufXT4t3ZQkW8JYTY7JEAzFMdTGi8yPj/+eVwoftcNgykL3CdkbKSnjChJiFNPdwTCk JryilE6ONo1mwPxEwPXOLq7UlIr5Q2x/jcrOmxYx4hgGhYEmFFsPz9YLJacRzyU4LCwsU 27QwIOAKKvr5tMiDu2RRJoysFuWl8dKIkCo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646036248515100012 Content-Type: text/plain; charset="utf-8" RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3429 TDX_PEI_LESS_BOOT indicates the boot without PEI phase. In this case settings in EFI_HOB_PLATFORM_INFO should be set to its according PCDs. TdxDxe driver is workable for both Legacy guest and Tdx guest. It is because for Legacy guest (in PEI-less boot) there should be a place to set the PCDs based on EFI_HOB_PLATFORM_INFO hob. TdxDxe driver is the right place to do this work. Cc: Michael D Kinney 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/TdxDxe/TdxDxe.c | 69 ++++++++++++++++++++++++++++++++++++++- OvmfPkg/TdxDxe/TdxDxe.inf | 5 +++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/TdxDxe/TdxDxe.c b/OvmfPkg/TdxDxe/TdxDxe.c index da392a492c63..6c93fac4558a 100644 --- a/OvmfPkg/TdxDxe/TdxDxe.c +++ b/OvmfPkg/TdxDxe/TdxDxe.c @@ -24,12 +24,68 @@ #include #include #include +#include #include #include #include #include #include =20 +VOID +SetPcdSettings ( + EFI_HOB_PLATFORM_INFO *PlatformInfoHob + ) +{ + RETURN_STATUS PcdStatus; + + PcdStatus =3D PcdSet64S (PcdConfidentialComputingGuestAttr, PlatformInfo= Hob->PcdConfidentialComputingGuestAttr); + ASSERT_RETURN_ERROR (PcdStatus); + PcdStatus =3D PcdSetBoolS (PcdSetNxForStack, PlatformInfoHob->PcdSetNxFo= rStack); + ASSERT_RETURN_ERROR (PcdStatus); + PcdStatus =3D PcdSetBoolS (PcdIa32EferChangeAllowed, PlatformInfoHob->Pc= dIa32EferChangeAllowed); + ASSERT_RETURN_ERROR (PcdStatus); + + DEBUG (( + DEBUG_INFO, + "HostBridgeDevId=3D0x%x, CCAttr=3D0x%x, SetNxForStack=3D%x, Ia32EferCh= angeAllowed=3D%x\n", + PlatformInfoHob->HostBridgePciDevId, + PlatformInfoHob->PcdConfidentialComputingGuestAttr, + PlatformInfoHob->PcdSetNxForStack, + PlatformInfoHob->PcdIa32EferChangeAllowed + )); + + PcdStatus =3D PcdSet32S (PcdCpuBootLogicalProcessorNumber, PlatformInfoH= ob->PcdCpuBootLogicalProcessorNumber); + ASSERT_RETURN_ERROR (PcdStatus); + PcdStatus =3D PcdSet32S (PcdCpuMaxLogicalProcessorNumber, PlatformInfoHo= b->PcdCpuMaxLogicalProcessorNumber); + + ASSERT_RETURN_ERROR (PcdStatus); + DEBUG (( + DEBUG_INFO, + "MaxCpuCount=3D0x%x, BootCpuCount=3D0x%x\n", + PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber, + PlatformInfoHob->PcdCpuBootLogicalProcessorNumber + )); + + if (TdIsEnabled ()) { + PcdStatus =3D PcdSet64S (PcdTdxSharedBitMask, TdSharedPageMask ()); + ASSERT_RETURN_ERROR (PcdStatus); + DEBUG ((DEBUG_INFO, "TdxSharedBitMask=3D0x%llx\n", PcdGet64 (PcdTdxSha= redBitMask))); + } else { + PcdStatus =3D PcdSet64S (PcdPciMmio64Base, PlatformInfoHob->PcdPciMmio= 64Base); + ASSERT_RETURN_ERROR (PcdStatus); + PcdStatus =3D PcdSet64S (PcdPciMmio64Size, PlatformInfoHob->PcdPciMmio= 64Size); + ASSERT_RETURN_ERROR (PcdStatus); + PcdStatus =3D PcdSet64S (PcdPciMmio32Base, PlatformInfoHob->PcdPciMmio= 32Base); + ASSERT_RETURN_ERROR (PcdStatus); + PcdStatus =3D PcdSet64S (PcdPciMmio32Size, PlatformInfoHob->PcdPciMmio= 32Size); + ASSERT_RETURN_ERROR (PcdStatus); + PcdStatus =3D PcdSet64S (PcdPciIoBase, PlatformInfoHob->PcdPciIoBase); + ASSERT_RETURN_ERROR (PcdStatus); + PcdStatus =3D PcdSet64S (PcdPciIoSize, PlatformInfoHob->PcdPciIoSize); + ASSERT_RETURN_ERROR (PcdStatus); + } +} + /** Location of resource hob matching type and starting address =20 @@ -187,8 +243,19 @@ TdxDxeEntryPoint ( PcdStatus =3D PcdSet16S (PcdOvmfHostBridgePciDevId, PlatformInfo->HostBr= idgePciDevId); ASSERT_RETURN_ERROR (PcdStatus); =20 + #ifdef TDX_PEI_LESS_BOOT + // + // For Pei-less boot, PlatformInfo contains more information and + // need to set PCDs based on these information. + // + SetPcdSettings (PlatformInfo); + #endif + if (!TdIsEnabled ()) { - return EFI_UNSUPPORTED; + // + // If it is Non-Td guest, we're done. + // + return EFI_SUCCESS; } =20 SetMmioSharedBit (); diff --git a/OvmfPkg/TdxDxe/TdxDxe.inf b/OvmfPkg/TdxDxe/TdxDxe.inf index b5976ab3ceba..4d169ae61129 100644 --- a/OvmfPkg/TdxDxe/TdxDxe.inf +++ b/OvmfPkg/TdxDxe/TdxDxe.inf @@ -60,5 +60,10 @@ gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber + gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress + gEfiMdeModulePkgTokenSpaceGuid.PcdIa32EferChangeAllowed + gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr + gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask + gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack --=20 2.29.2.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87096): https://edk2.groups.io/g/devel/message/87096 Mute This Topic: https://groups.io/mt/89446697/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-