From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.37667.1674098921938942214 for ; Wed, 18 Jan 2023 19:28:59 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=QI9Jej0O; spf=pass (domain: intel.com, ip: 134.134.136.31, 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=1674098939; x=1705634939; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sULh3pQU/Lvtc6Mf4E/wDwU/0buRMbu6Y+eB4dCgR70=; b=QI9Jej0OJqn5XdOfdznQFDa/gRFpHWdrgtEoSvwLcbhR9pIPK5CkV+kj RfMGl1bxDUOqS5cggKcDouo1caEm1HwIKCS6p+vFZudZTRTz3i4dL7ZUo R0vFORtjnFfWKuL1KaQ7fUBWjuSFWJn0hdmC90J/QDH0SE/iuv7DPZvZC 4TutFQ7ub7i9lnQdd6Mfsz2wn9mnT5J/DtdUVKj22xVkj3nlbmMHN6+TJ olJKSABLtmk8OZO0F+497YyS6fXVBGtOyPkNP81KXjctb42yFGBD8/6+X TOjTrhwvwkMFNdU6bPKx8uSL79GZw83ks8thTQESKMiM9vYnNXQ4ipB/A Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="387531257" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="387531257" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2023 19:28:58 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="692264441" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="692264441" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.254.211.169]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2023 19:28:56 -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 V2 07/10] OvmfPkg/IntelTdx: Update tdx measurement in SEC phase Date: Thu, 19 Jan 2023 11:28:19 +0800 Message-Id: <20230119032822.1406-8-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: <20230119032822.1406-1-min.m.xu@intel.com> References: <20230119032822.1406-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 Signed-off-by: Min Xu --- OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 +--- OvmfPkg/IntelTdx/Sec/SecMain.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc index 81511e3556a6..d8232f27dae9 100644 --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc @@ -541,10 +541,8 @@ OvmfPkg/IntelTdx/Sec/SecMain.inf { 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