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:31 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=JfhkhrSM; 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=1674778291; x=1706314291; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qaXdw4nU8UGFLa7x/upSXlA0bvixsoMjJE2I5CAuuvE=; b=JfhkhrSMUJTQOjdUSglElBCLO8GBvvYA94/2mrAd2D1HVvdYfm9yDwMS ezp59bkccSst596H2eairiHVabZcLR6vS1rJg/zcYgH30pbKeWLJ7Wibd gwVXBg4ZB9ND5JhOmKqzaVZiYnALOeioK88L00fpKyaGNjo19wunpMKoa XUOT5ukf7Z3WKvhvCHLeMnt2Al/Nt4VUuW9k+uQ9huvZyirmLGhU+jFI9 tkmvjKnCwiA+YqHGj03R6Fqwpvfmrr/nbofvd75WXCCxeUAFfQ9joTVUR /wj1cdYumhumJ3xWhIQ9T8Wqn70GVieIHBg8ORAXr3xv8eRHriy+3FHgk g==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="314942306" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="314942306" 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:31 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="695335662" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="695335662" 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:28 -0800 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Erdem Aktas , James Bottomley , Jiewen Yao , Gerd Hoffmann , Tom Lendacky , Michael Roth Subject: [PATCH V4 04/12] OvmfPkg/IntelTdx: Update tdx measurement in SEC phase Date: Fri, 27 Jan 2023 08:10:58 +0800 Message-Id: <20230127001106.2038-5-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: <20230127001106.2038-1-min.m.xu@intel.com> References: <20230127001106.2038-1-min.m.xu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Min M Xu BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4243 After TdxHelperLib is instroduced, the SecMain.c in IntelTdx is updated with the new functions provided by TdxHelperLib. Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Tom Lendacky Cc: Michael Roth Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- OvmfPkg/IntelTdx/IntelTdxX64.dsc | 1 + OvmfPkg/IntelTdx/Sec/SecMain.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc index 0f1e970fbbb3..920f1c6080d4 100644 --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc @@ -549,6 +549,7 @@ NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf TpmMeasurementLib|SecurityPkg/Library/SecTpmMeasurementLib/SecTpmMeasurementLibTdx.inf + NULL|OvmfPkg/IntelTdx/TdxHelperLib/SecTdxHelperLib.inf BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf HashLib|SecurityPkg/Library/HashLibTdx/HashLibTdx.inf NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf diff --git a/OvmfPkg/IntelTdx/Sec/SecMain.c b/OvmfPkg/IntelTdx/Sec/SecMain.c index ab01ec9ab19c..ccb217b709a0 100644 --- a/OvmfPkg/IntelTdx/Sec/SecMain.c +++ b/OvmfPkg/IntelTdx/Sec/SecMain.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include @@ -62,12 +62,25 @@ SecCoreStartupWithStack ( volatile UINT8 *Table; if (CcProbe () == CcGuestTypeIntelTdx) { + // + // From the security perspective all the external input should be measured before + // it is consumed. TdHob and Configuration FV (Cfv) image are passed from VMM + // and should be measured here. + // + if (EFI_ERROR (TdxHelperMeasureTdHob ())) { + CpuDeadLoop (); + } + + if (EFI_ERROR (TdxHelperMeasureCfvImage ())) { + CpuDeadLoop (); + } + // // For Td guests, the memory map info is in TdHobLib. It should be processed // first so that the memory is accepted. Otherwise access to the unaccepted // memory will trigger tripple fault. // - if (ProcessTdxHobList () != EFI_SUCCESS) { + if (TdxHelperProcessTdHob () != EFI_SUCCESS) { CpuDeadLoop (); } } -- 2.29.2.windows.2