From nobody Mon Feb 9 08:56:43 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+95918+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+95918+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667517621; cv=none; d=zohomail.com; s=zohoarc; b=NypebU1SAYpi6tog3aCaQ3Sw87dbsvcm5YZSwGxm3eYMUnA7XIvgLpRHYIJjsHIy7H6CL7v2ii/mQIBuq6tLHI6avfyMrt/BhhosglDPgetf+BrMajECoeoJlG9GS5pugFC9xx+DPkICDS+Yw1zECZW11Sitc6bnBNWbdWJxbl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667517621; 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=GHlVn2UyapcZc2o2J+eZnVRousIQTmjh4OBHdFbSId0=; b=TiNjn/lOAO/pzHs7tKsz80Rj2rv4VH2DfgTc8tj/8q4kbiqjZ/hmT+kbiFhGLbjICymKCTEmVAWy/E3qwRU16w+ehsSzL8MBA6365nOrM6VMKxPIP6EZNpT9vzw1vtHes83agysdc7CQ9XtkXX6OaRhUiesBxLCOqgLqS/NXbF8= 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+95918+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 1667517621856854.0719605248448; Thu, 3 Nov 2022 16:20:21 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id UGJ8YY1788612xsI0yXVSQVv; Thu, 03 Nov 2022 16:20:21 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web09.5284.1667517610553055782 for ; Thu, 03 Nov 2022 16:20:20 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10520"; a="310947284" X-IronPort-AV: E=Sophos;i="5.96,135,1665471600"; d="scan'208";a="310947284" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2022 16:20:19 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10520"; a="724131945" X-IronPort-AV: E=Sophos;i="5.96,135,1665471600"; d="scan'208";a="724131945" X-Received: from yananliu-mobl.ccr.corp.intel.com (HELO mxu9-mobl1.ccr.corp.intel.com) ([10.255.30.132]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2022 16:20:16 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Eric Dong , Ray Ni , Brijesh Singh , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH V2 4/9] UefiCpuPkg: Use CcExitLib instead of VmgExitLib Date: Fri, 4 Nov 2022 07:19:50 +0800 Message-Id: <20221103231955.1365-5-min.m.xu@intel.com> In-Reply-To: <20221103231955.1365-1-min.m.xu@intel.com> References: <20221103231955.1365-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: QtiXdIXgq6knaj4XYnkSdmxFx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667517621; bh=xjcuVL2vNiQrO8vM9kkev3xJYnExzuWTgxCU4e02CAQ=; h=Cc:Date:From:Reply-To:Subject:To; b=FRQ3JGBzkNSTXwtZ7pDN+o5Q6hY+s4FvOhIFLSQngV5SV8nVV+DX5NbbqRZXaH7qB41 w+Qena7TDTiQoIoRaozGrfXZzXXPKzRYoga12OMFWLa/qn921MYVsh96tdjcxNZqD7qNr 8H4Gm9vUg56+Q9lQE6N8QAEbfYSGh0vYyOU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667517623330100001 Content-Type: text/plain; charset="utf-8" From: Min M Xu BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4123 VmgExitLib once was designed to provide interfaces to support #VC handler and issue VMGEXIT instruction. After TDVF (enable TDX feature in OVMF) is introduced, this library is updated to support #VE as well. Now the name of VmgExitLib cannot reflect what the lib does. So VmgExitLib is replaced by CcExitLib. Cc: Eric Dong Cc: Ray Ni Cc: Brijesh Singh Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu --- .../DxeCpuExceptionHandlerLib.inf | 2 +- .../PeiCpuExceptionHandlerLib.inf | 2 +- .../CpuExceptionHandlerLib/PeiDxeSmmCpuException.c | 6 +++--- .../CpuExceptionHandlerLib/SecPeiCpuException.c | 6 +++--- .../SecPeiCpuExceptionHandlerLib.inf | 2 +- .../SmmCpuExceptionHandlerLib.inf | 2 +- .../Xcode5SecPeiCpuExceptionHandlerLib.inf | 2 +- UefiCpuPkg/Library/MpInitLib/AmdSev.c | 10 +++++----- UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf | 2 +- UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 8 ++++---- UefiCpuPkg/Library/MpInitLib/MpLib.c | 2 +- UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf | 2 +- UefiCpuPkg/Library/MpInitLib/X64/AmdSev.c | 10 +++++----- UefiCpuPkg/UefiCpuPkg.dsc | 2 ++ 14 files changed, 30 insertions(+), 28 deletions(-) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandl= erLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandle= rLib.inf index e7a81bebdb13..d0f82095cf92 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.i= nf +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.i= nf @@ -60,4 +60,4 @@ PeCoffGetEntryPointLib MemoryAllocationLib DebugLib - VmgExitLib + CcExitLib diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandl= erLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandle= rLib.inf index 7c2ec3b2db4c..5339f8e60404 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.i= nf +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.i= nf @@ -52,7 +52,7 @@ HobLib MemoryAllocationLib SynchronizationLib - VmgExitLib + CcExitLib =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard # CONSUMES diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuExceptio= n.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c index a7d0897ef1f9..748cf8d3bfc6 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c @@ -7,7 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 #include -#include +#include #include "CpuExceptionCommon.h" =20 /** @@ -40,7 +40,7 @@ CommonExceptionHandlerWorker ( // On other - ExceptionType contains (possibly new) exception // value // - Status =3D VmgExitHandleVc (&ExceptionType, SystemContext); + Status =3D CcExitHandleVc (&ExceptionType, SystemContext); if (!EFI_ERROR (Status)) { return; } @@ -57,7 +57,7 @@ CommonExceptionHandlerWorker ( // On other - ExceptionType contains (possibly new) exception // value // - Status =3D VmTdExitHandleVe (&ExceptionType, SystemContext); + Status =3D CcExitHandleVe (&ExceptionType, SystemContext); if (!EFI_ERROR (Status)) { return; } diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c index ad5e0e9ed4f1..497cd1649930 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c @@ -7,7 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 #include -#include +#include #include "CpuExceptionCommon.h" =20 CONST UINTN mDoFarReturnFlag =3D 0; @@ -39,7 +39,7 @@ CommonExceptionHandler ( // On other - ExceptionType contains (possibly new) exception // value // - Status =3D VmgExitHandleVc (&ExceptionType, SystemContext); + Status =3D CcExitHandleVc (&ExceptionType, SystemContext); if (!EFI_ERROR (Status)) { return; } @@ -57,7 +57,7 @@ CommonExceptionHandler ( // On other - ExceptionType contains (possibly new) exception // value // - Status =3D VmTdExitHandleVe (&ExceptionType, SystemContext); + Status =3D CcExitHandleVe (&ExceptionType, SystemContext); if (!EFI_ERROR (Status)) { return; } diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHa= ndlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException= HandlerLib.inf index 6a170286c8fc..df44371fe018 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLi= b.inf +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLi= b.inf @@ -48,7 +48,7 @@ PrintLib LocalApicLib PeCoffGetEntryPointLib - VmgExitLib + CcExitLib =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandl= erLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandle= rLib.inf index 9dde07612a04..8f8a5dab7930 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.i= nf +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.i= nf @@ -51,7 +51,7 @@ LocalApicLib PeCoffGetEntryPointLib DebugLib - VmgExitLib + CcExitLib =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExcep= tionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPei= CpuExceptionHandlerLib.inf index 6d2f66504a5b..619b39d7f1de 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHan= dlerLib.inf +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHan= dlerLib.inf @@ -53,7 +53,7 @@ PrintLib LocalApicLib PeCoffGetEntryPointLib - VmgExitLib + CcExitLib =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard diff --git a/UefiCpuPkg/Library/MpInitLib/AmdSev.c b/UefiCpuPkg/Library/MpI= nitLib/AmdSev.c index 4e4c63a52de4..9af108fcb5ff 100644 --- a/UefiCpuPkg/Library/MpInitLib/AmdSev.c +++ b/UefiCpuPkg/Library/MpInitLib/AmdSev.c @@ -8,7 +8,7 @@ **/ =20 #include "MpLib.h" -#include +#include =20 /** Get Protected mode code segment with 16-bit default addressing @@ -209,7 +209,7 @@ SevEsPlaceApHlt ( Msr.GhcbPhysicalAddress =3D AsmReadMsr64 (MSR_SEV_ES_GHCB); Ghcb =3D Msr.Ghcb; =20 - VmgInit (Ghcb, &InterruptState); + CcExitLibVmgInit (Ghcb, &InterruptState); =20 if (DoDecrement) { DoDecrement =3D FALSE; @@ -221,13 +221,13 @@ SevEsPlaceApHlt ( InterlockedDecrement ((UINT32 *)&CpuMpData->MpCpuExchangeInfo->NumAp= sExecuting); } =20 - Status =3D VmgExit (Ghcb, SVM_EXIT_AP_RESET_HOLD, 0, 0); + Status =3D CcExitLibVmgExit (Ghcb, SVM_EXIT_AP_RESET_HOLD, 0, 0); if ((Status =3D=3D 0) && (Ghcb->SaveArea.SwExitInfo2 !=3D 0)) { - VmgDone (Ghcb, InterruptState); + CcExitLibVmgDone (Ghcb, InterruptState); break; } =20 - VmgDone (Ghcb, InterruptState); + CcExitLibVmgDone (Ghcb, InterruptState); } =20 // diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf b/UefiCpuPkg/Lib= rary/MpInitLib/DxeMpInitLib.inf index e1cd0b350008..cd07de3a3c0b 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf @@ -54,7 +54,7 @@ DebugAgentLib SynchronizationLib PcdLib - VmgExitLib + CcExitLib MicrocodeLib =20 [Protocols] diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/M= pInitLib/DxeMpLib.c index 78cc3e2b93fd..8c7a131a0a3f 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include =20 @@ -222,9 +222,9 @@ GetSevEsAPMemory ( Msr.GhcbPhysicalAddress =3D AsmReadMsr64 (MSR_SEV_ES_GHCB); Ghcb =3D Msr.Ghcb; =20 - VmgInit (Ghcb, &InterruptState); - VmgExit (Ghcb, SVM_EXIT_AP_JUMP_TABLE, 0, (UINT64)(UINTN)StartAddress); - VmgDone (Ghcb, InterruptState); + CcExitLibVmgInit (Ghcb, &InterruptState); + CcExitLibVmgExit (Ghcb, SVM_EXIT_AP_JUMP_TABLE, 0, (UINT64)(UINTN)StartA= ddress); + CcExitLibVmgDone (Ghcb, InterruptState); =20 return (UINTN)StartAddress; } diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index 1c053f87a4c6..e5dc852ed95f 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -9,7 +9,7 @@ **/ =20 #include "MpLib.h" -#include +#include #include #include =20 diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf b/UefiCpuPkg/Lib= rary/MpInitLib/PeiMpInitLib.inf index 5facf4db9499..afd551bb0f64 100644 --- a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf +++ b/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf @@ -53,7 +53,7 @@ SynchronizationLib PeiServicesLib PcdLib - VmgExitLib + CcExitLib MicrocodeLib =20 [Pcd] diff --git a/UefiCpuPkg/Library/MpInitLib/X64/AmdSev.c b/UefiCpuPkg/Library= /MpInitLib/X64/AmdSev.c index a3cd377ef600..933f765f3f5e 100644 --- a/UefiCpuPkg/Library/MpInitLib/X64/AmdSev.c +++ b/UefiCpuPkg/Library/MpInitLib/X64/AmdSev.c @@ -9,7 +9,7 @@ **/ =20 #include "MpLib.h" -#include +#include #include #include =20 @@ -150,16 +150,16 @@ SevSnpCreateSaveArea ( Msr.GhcbPhysicalAddress =3D AsmReadMsr64 (MSR_SEV_ES_GHCB); Ghcb =3D Msr.Ghcb; =20 - VmgInit (Ghcb, &InterruptState); + CcExitLibVmgInit (Ghcb, &InterruptState); Ghcb->SaveArea.Rax =3D SaveArea->SevFeatures; - VmgSetOffsetValid (Ghcb, GhcbRax); - VmgExitStatus =3D VmgExit ( + CcExitLibVmgSetOffsetValid (Ghcb, GhcbRax); + VmgExitStatus =3D CcExitLibVmgExit ( Ghcb, SVM_EXIT_SNP_AP_CREATION, ExitInfo1, ExitInfo2 ); - VmgDone (Ghcb, InterruptState); + CcExitLibVmgDone (Ghcb, InterruptState); =20 ASSERT (VmgExitStatus =3D=3D 0); if (VmgExitStatus !=3D 0) { diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc index 0e1a99ddc09f..57c74ba844d2 100644 --- a/UefiCpuPkg/UefiCpuPkg.dsc +++ b/UefiCpuPkg/UefiCpuPkg.dsc @@ -60,6 +60,7 @@ PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeC= offExtraActionLibNull.inf TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurem= entLibNull.inf VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf + CcExitLib|UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf MicrocodeLib|UefiCpuPkg/Library/MicrocodeLib/MicrocodeLib.inf SmmCpuRendezvousLib|UefiCpuPkg/Library/SmmCpuRendezvousLib/SmmCpuRendezv= ousLib.inf CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf @@ -164,6 +165,7 @@ UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf + UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf UefiCpuPkg/SecCore/SecCore.inf --=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 (#95918): https://edk2.groups.io/g/devel/message/95918 Mute This Topic: https://groups.io/mt/94795611/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-