From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.24626.1661437527602551781 for ; Thu, 25 Aug 2022 07:25:27 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=AWt0JNTX; spf=pass (domain: intel.com, ip: 192.55.52.43, 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=1661437527; x=1692973527; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=BdC8dYVnujf3uVU/O+WHoDRzZhFq83u5joO81X/35wU=; b=AWt0JNTXWtaX38Nal5sQPmlCL1+WHFHhDsLhsw/3K5VFxZ5fN+9RA8jK LGafrsNvdDiRPKwxhjkoXPbe/ocza1AHX0sJJVuiECVSq78LKGcmxHEws cMCOoAZdjfTwsUBoob3YBTi20f9X1FQht0rQAYaRmqwZEBNoewOfrdCwI SQoY9Wdec5HH1+RXVCJ0lRnmiL9+1e5fRZl/bWpHcnR/pN6KnEDFsnrzn Dlmo21oGqT3yyTN0+8tn3TP1Jhn0/VQiVk8ot1jTp3+dbC5t/rudsSULe jc6eXUcRdMSWJwX/NSngh+vbpL4yZQzrHG1b6Jd/2H95IN22Xfc4nXG8R g==; X-IronPort-AV: E=McAfee;i="6500,9779,10450"; a="380542339" X-IronPort-AV: E=Sophos;i="5.93,263,1654585200"; d="scan'208";a="380542339" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2022 07:25:27 -0700 X-IronPort-AV: E=Sophos;i="5.93,263,1654585200"; d="scan'208";a="671004741" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.31.22]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2022 07:25:25 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Gerd Hoffmann , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Yuan Yu Subject: [PATCH V3 0/2] Re-design CcProbeLib Date: Thu, 25 Aug 2022 22:24:24 +0800 Message-Id: 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=3974 CcProbeLib once was designed to probe the Confidential Computing guest type by checking the PcdOvmfWorkArea. But this memory is allocated with either EfiACPIMemoryNVS or EfiBootServicesData. It cannot be accessed after ExitBootService. Please see the detailed analysis in BZ#3974. To fix this issue, CcProbeLib is re-designed as 2 implementation: - SecPeiCcProbeLib - DxeCcProbeLib In SecPeiCcProbeLib we check the CC guest type by reading the PcdOvmfWorkArea. Because it is used in SEC / PEI and we don't worry about the issues in BZ#3974. In DxeCcProbeLib we cache the GuestType in Ovmf work area in first-call. After that the Guest type is returned with the cached value. So that we don't need to worry about the access to Ovmf work area after ExitBootService. The reason why we probe CC guest type in 2 different ways is the global varialbe. Global variable cannot be used in SEC/PEI and CcProbe is called very frequently. Code: https://github.com/mxu9/edk2/tree/CcProbeLib.BZ3974.v3 v3 changes: - Re-design CcProbeLib to 2 implementation: SecPeiCcProbeLib and DxeCcProbeLib. The difference between the 2 implementation is the cache of the CcGuestType. v2 changes: - Reserve Ovmf work-area as RT_DATA. See https://edk2.groups.io/g/devel/message/92599 Cc: Gerd Hoffmann Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Yuan Yu Signed-off-by: Min Xu Min M Xu (2): OvmfPkg: Add SecPeiCcProbeLib OvmfPkg: Update CcProbeLib to DxeCcProbeLib OvmfPkg/IntelTdx/IntelTdxX64.dsc | 3 +- OvmfPkg/Library/CcProbeLib/DxeCcProbeLib.c | 38 +++++++++++++++++++ .../{CcProbeLib.inf => DxeCcProbeLib.inf} | 6 +-- .../{CcProbeLib.c => SecPeiCcProbeLib.c} | 0 .../Library/CcProbeLib/SecPeiCcProbeLib.inf | 25 ++++++++++++ OvmfPkg/OvmfPkgX64.dsc | 5 ++- 6 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 OvmfPkg/Library/CcProbeLib/DxeCcProbeLib.c rename OvmfPkg/Library/CcProbeLib/{CcProbeLib.inf => DxeCcProbeLib.inf} (70%) rename OvmfPkg/Library/CcProbeLib/{CcProbeLib.c => SecPeiCcProbeLib.c} (100%) create mode 100644 OvmfPkg/Library/CcProbeLib/SecPeiCcProbeLib.inf -- 2.29.2.windows.2