From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web11.91010.1674778280571183584 for ; Thu, 26 Jan 2023 16:11:20 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=nIzUnjq6; spf=pass (domain: intel.com, ip: 134.134.136.20, 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=1674778280; x=1706314280; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=47UXJT7oK3QcbEhUCggjQPY8ER5veFOottMGPxjFXSU=; b=nIzUnjq6LkK6EkFl6R/aqXPqw4mFmtnQA1TJ4wl3w+G/V2EabhWTxHfQ KPDJJ/RQmEGuQKYtYrpOgF83EXIZQqpUecm158JKIRMmgcYWApc3LI1o/ iTcqH4CtutLq08OODkuoJXONGQjUafmJ1U1svhIdkeisaptcfwaBtoR8G EgQIrtTRkrne7b2xNaTTnYXC5+bxaLHpIMVk5bb35ggqnv6prRPpaROXM mhbvgtl0KBwiC1D7Ql/YkQrEpFUmlWTb42OTwLPBNFTG8trYgfn0Xxc1D S4B3naAJ2nosEp9ubPCMg2biw7KJSd9Dzp4QRFJl2fL6eRP+/pGqjte5Z Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="314942192" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="314942192" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 16:11:20 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="695335561" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="695335561" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.254.209.180]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 16:11:17 -0800 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Erdem Aktas , James Bottomley , Jiewen Yao , Gerd Hoffmann , Tom Lendacky , Michael Roth Subject: [PATCH V4 00/12] Enable Tdx measurement in OvmfPkgX64 Date: Fri, 27 Jan 2023 08:10:54 +0800 Message-Id: <20230127001106.2038-1-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4243 Tdx measurement (RTMR based measurement) is enabled in OvmfPkg/IntelTdx. This patch-set enables the feature in OvmfPkgX64 as well. Patch #1: Introduce TDX_MEASUREMETNS_DATA in SEC_TDX_WORK_AREA. That is because the RTMR measurement of TdHob and Configuration FV (CFV) are executed in very early stage of boot process. At that time the memory service is not ready and the measurement values have to be stored in OvmfWorkArea. Patch #2: Introduce TdxHelperLibNull which is the NULL instance of TdxHelperLib. Patch #3: Introduce SecTdxHelperLib which is the instance of TdxHelperLib for SEC Phase. In this patch TdxHelperBuildGuidHobForTdxMeasurement and TdxHelperProcessTdHob are not implemented. Their implementation are in patch #9 and patch #5. This is for the patch to be reviewed more friendly. Patch #4: SecMain.c in IntelTdx is updated with the new functions provided by TdxHelperLib. Patch #5-8: To make the code reviewable, the implementation of TdxHelperBuildGuidHobForTdxMeasurement is split into 4 patches (5-8). Patch #10: This patch introduce PeiTdxHelperLib which is for PEI phase. Patch #9/11: These 2 patches are the changes for OvmfPkg/OvmfPkgX64 to enable Tdx measurement. Patch #12: This patch implements TdxHelperProcessTdHob which is moved from PlatformInitLib/IntelTdx.c. Its counterpart in PlatformInitLib is ProcessTdxHobList and the duplicated codes are deleted in this patch. Code: https://github.com/mxu9/edk2/tree/TdxMeasurementInOvmfX64.v4 v4 changes: - To make the code reviewable, the implementation of TdxHelperBuildGuidHobForTdxMeasurement is split into 4 patches (5-8). - Call Sha384HashAll instead of the 3 Sha384XXX functions so that we need to allocate memory in SEC phase. v3 changes: - Use the definition of PLATFORM_FIRMWARE_BLOB2_STRUCT in Library/TcgEventLogRecordLib.h. - Rename TDX_ENABLE as TDX_MEASUREMENT_ENABLE because this flag is introduced for Tdx-measurement. - Split the patch of SecTdxHelperLib into 2 separate patches (#3/#9). Patch#3 implements TdxHelperMeasureTdHob and TdxHelperMeasureCfvImage. Patch#9 implements TdxHelperProcessTdHob. This is to make the patches more reviewable. The duplicated codes of TdxHelperProcessTdHob are deleted in Patch#9 as well. - The implementation of TdxHelperBuildGuidHobForTdxMeasurement and update of PeilessStartupLib are in one patch (#5). Because the implmentation of TdxHelperBuildGuidHobForTdxMeasurement was once in PeilessStartupLib. v2 changes: - Split the patch of TdxHelperLib into 4 separate patches. So that it is more reviewable. - Add commit message in Patch#1 to emphasize that the tdx-measurement in OvmfPkgX64 is supported in SEC phase. Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Tom Lendacky Cc: Michael Roth Signed-off-by: Min Xu Min M Xu (12): OvmfPkg: Add Tdx measurement data structure in WorkArea OvmfPkg/IntelTdx: Add TdxHelperLibNull OvmfPkg/IntelTdx: Add SecTdxHelperLib OvmfPkg/IntelTdx: Update tdx measurement in SEC phase OvmfPkg/PeilessStartupLib: Update the define of FV_HANDOFF_TABLE_POINTERS2 OvmfPkg/PeilessStartupLib: Build GuidHob for Tdx measurement OvmfPkg/PeilessStartupLib: Call TdxHelperBuildGuidHobForTdxMeasurement OvmfPkg/TdxHelperLib: Implement TdxHelperBuildGuidHobForTdxMeasurement OvmfPkg: Enable Tdx measurement in OvmfPkgX64 OvmfPkg/IntelTdx: Add PeiTdxHelperLib OvmfPkg/PlatformPei: Build GuidHob for Tdx measurement OvmfPkg/TdxHelperLib: Implement TdxHelperProcessTdHob OvmfPkg/AmdSev/AmdSevX64.dsc | 5 +- OvmfPkg/CloudHv/CloudHvX64.dsc | 5 +- OvmfPkg/Include/Dsc/OvmfTpmLibs.dsc.inc | 10 +- .../Include/Dsc/OvmfTpmSecurityStub.dsc.inc | 8 + OvmfPkg/Include/Library/PlatformInitLib.h | 17 - OvmfPkg/Include/Library/TdxHelperLib.h | 70 ++ OvmfPkg/Include/WorkArea.h | 25 +- OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 +- OvmfPkg/IntelTdx/Sec/SecMain.c | 17 +- OvmfPkg/IntelTdx/TdxHelperLib/PeiTdxHelper.c | 91 +++ .../IntelTdx/TdxHelperLib/PeiTdxHelperLib.inf | 48 ++ .../TdxHelperLib/SecTdxHelper.c} | 303 +++---- .../IntelTdx/TdxHelperLib/SecTdxHelperLib.inf | 53 ++ .../TdxHelperLib/TdxHelperLibNull.inf | 32 + OvmfPkg/IntelTdx/TdxHelperLib/TdxHelperNull.c | 79 ++ .../IntelTdx/TdxHelperLib/TdxMeasurementHob.c | 259 ++++++ OvmfPkg/Library/PeilessStartupLib/IntelTdx.c | 196 ----- .../PeilessStartupLib/PeilessStartup.c | 16 +- .../PeilessStartupInternal.h | 36 - .../PeilessStartupLib/PeilessStartupLib.inf | 6 - OvmfPkg/Library/PlatformInitLib/IntelTdx.c | 768 ------------------ .../Library/PlatformInitLib/IntelTdxNull.c | 20 - .../PlatformInitLib/PlatformInitLib.inf | 1 - OvmfPkg/Microvm/MicrovmX64.dsc | 5 +- OvmfPkg/OvmfPkg.dec | 4 + OvmfPkg/OvmfPkgX64.dsc | 20 +- OvmfPkg/OvmfPkgX64.fdf | 7 + OvmfPkg/PlatformPei/IntelTdx.c | 3 + OvmfPkg/Sec/SecMain.c | 17 +- 29 files changed, 915 insertions(+), 1210 deletions(-) create mode 100644 OvmfPkg/Include/Library/TdxHelperLib.h create mode 100644 OvmfPkg/IntelTdx/TdxHelperLib/PeiTdxHelper.c create mode 100644 OvmfPkg/IntelTdx/TdxHelperLib/PeiTdxHelperLib.inf copy OvmfPkg/{Library/PlatformInitLib/IntelTdx.c => IntelTdx/TdxHelperLib/SecTdxHelper.c} (80%) create mode 100644 OvmfPkg/IntelTdx/TdxHelperLib/SecTdxHelperLib.inf create mode 100644 OvmfPkg/IntelTdx/TdxHelperLib/TdxHelperLibNull.inf create mode 100644 OvmfPkg/IntelTdx/TdxHelperLib/TdxHelperNull.c create mode 100644 OvmfPkg/IntelTdx/TdxHelperLib/TdxMeasurementHob.c delete mode 100644 OvmfPkg/Library/PeilessStartupLib/IntelTdx.c -- 2.29.2.windows.2