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.web08.4939.1667780856864962924 for ; Sun, 06 Nov 2022 16:27:47 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=g8mNFwxa; 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=1667780866; x=1699316866; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DPGYODe4VRwIRhzEEV6b+oibY+2PNwLXXSPwEY51+EQ=; b=g8mNFwxa6BOC7Cj1dUd/XJ5YRSSpa68gXT/ufDNQE5DQDNudKuFKdgou Srbg6/s0ghJqmjyKhv+gUDTOgpD0nju6toYZxnIAbgA+u51/vKw3gIlyy HzumIOkpO9vR+wLnzM0axpjMIVKNgu1PYc3cRKu9ri8C7z+lX4VI2K3Be b8Gpy1rxizyzIvjXhyuxXSNHlgeDQ6GfdDOcZSy5ZZ6KksXeY0Y1781bf Hcp2cTLhfPrtFdxIy1AwH1KNNaPzKnizJAkXMaDsaTcx+W5aMErVy94qi ozusUsKVJHhsvmi/+utpiSDhqupMBzTSTaguR99HBGqpGSeBlQf4duicB A==; X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="396593414" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="396593414" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2022 16:27:46 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="613681467" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="613681467" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.238.0.61]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2022 16:27:43 -0800 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: [PATCH V3 4/9] UefiCpuPkg: Use CcExitLib instead of VmgExitLib Date: Mon, 7 Nov 2022 08:27:12 +0800 Message-Id: <20221107002717.461-5-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: <20221107002717.461-1-min.m.xu@intel.com> References: <20221107002717.461-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=4123 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/DxeCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf index e7a81bebdb13..d0f82095cf92 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf @@ -60,4 +60,4 @@ PeCoffGetEntryPointLib MemoryAllocationLib DebugLib - VmgExitLib + CcExitLib diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf index 7c2ec3b2db4c..5339f8e60404 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf @@ -52,7 +52,7 @@ HobLib MemoryAllocationLib SynchronizationLib - VmgExitLib + CcExitLib [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard # CONSUMES diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c index a7d0897ef1f9..588f0e1809a2 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c @@ -7,7 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include -#include +#include #include "CpuExceptionCommon.h" /** @@ -40,7 +40,7 @@ CommonExceptionHandlerWorker ( // On other - ExceptionType contains (possibly new) exception // value // - Status = VmgExitHandleVc (&ExceptionType, SystemContext); + Status = CcExitLibHandleVc (&ExceptionType, SystemContext); if (!EFI_ERROR (Status)) { return; } @@ -57,7 +57,7 @@ CommonExceptionHandlerWorker ( // On other - ExceptionType contains (possibly new) exception // value // - Status = VmTdExitHandleVe (&ExceptionType, SystemContext); + Status = CcExitLibHandleVe (&ExceptionType, SystemContext); if (!EFI_ERROR (Status)) { return; } diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c index ad5e0e9ed4f1..bb1d173eba6d 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c @@ -7,7 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include -#include +#include #include "CpuExceptionCommon.h" CONST UINTN mDoFarReturnFlag = 0; @@ -39,7 +39,7 @@ CommonExceptionHandler ( // On other - ExceptionType contains (possibly new) exception // value // - Status = VmgExitHandleVc (&ExceptionType, SystemContext); + Status = CcExitLibHandleVc (&ExceptionType, SystemContext); if (!EFI_ERROR (Status)) { return; } @@ -57,7 +57,7 @@ CommonExceptionHandler ( // On other - ExceptionType contains (possibly new) exception // value // - Status = VmTdExitHandleVe (&ExceptionType, SystemContext); + Status = CcExitLibHandleVe (&ExceptionType, SystemContext); if (!EFI_ERROR (Status)) { return; } diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf index 6a170286c8fc..df44371fe018 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf @@ -48,7 +48,7 @@ PrintLib LocalApicLib PeCoffGetEntryPointLib - VmgExitLib + CcExitLib [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf index 9dde07612a04..8f8a5dab7930 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf @@ -51,7 +51,7 @@ LocalApicLib PeCoffGetEntryPointLib DebugLib - VmgExitLib + CcExitLib [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf index 6d2f66504a5b..619b39d7f1de 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf @@ -53,7 +53,7 @@ PrintLib LocalApicLib PeCoffGetEntryPointLib - VmgExitLib + CcExitLib [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard diff --git a/UefiCpuPkg/Library/MpInitLib/AmdSev.c b/UefiCpuPkg/Library/MpInitLib/AmdSev.c index 4e4c63a52de4..9af108fcb5ff 100644 --- a/UefiCpuPkg/Library/MpInitLib/AmdSev.c +++ b/UefiCpuPkg/Library/MpInitLib/AmdSev.c @@ -8,7 +8,7 @@ **/ #include "MpLib.h" -#include +#include /** Get Protected mode code segment with 16-bit default addressing @@ -209,7 +209,7 @@ SevEsPlaceApHlt ( Msr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB); Ghcb = Msr.Ghcb; - VmgInit (Ghcb, &InterruptState); + CcExitLibVmgInit (Ghcb, &InterruptState); if (DoDecrement) { DoDecrement = FALSE; @@ -221,13 +221,13 @@ SevEsPlaceApHlt ( InterlockedDecrement ((UINT32 *)&CpuMpData->MpCpuExchangeInfo->NumApsExecuting); } - Status = VmgExit (Ghcb, SVM_EXIT_AP_RESET_HOLD, 0, 0); + Status = CcExitLibVmgExit (Ghcb, SVM_EXIT_AP_RESET_HOLD, 0, 0); if ((Status == 0) && (Ghcb->SaveArea.SwExitInfo2 != 0)) { - VmgDone (Ghcb, InterruptState); + CcExitLibVmgDone (Ghcb, InterruptState); break; } - VmgDone (Ghcb, InterruptState); + CcExitLibVmgDone (Ghcb, InterruptState); } // diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf b/UefiCpuPkg/Library/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 [Protocols] diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/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 @@ -222,9 +222,9 @@ GetSevEsAPMemory ( Msr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB); Ghcb = Msr.Ghcb; - 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)StartAddress); + CcExitLibVmgDone (Ghcb, InterruptState); return (UINTN)StartAddress; } diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index 1c053f87a4c6..e5dc852ed95f 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -9,7 +9,7 @@ **/ #include "MpLib.h" -#include +#include #include #include diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf b/UefiCpuPkg/Library/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 [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 @@ **/ #include "MpLib.h" -#include +#include #include #include @@ -150,16 +150,16 @@ SevSnpCreateSaveArea ( Msr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB); Ghcb = Msr.Ghcb; - VmgInit (Ghcb, &InterruptState); + CcExitLibVmgInit (Ghcb, &InterruptState); Ghcb->SaveArea.Rax = SaveArea->SevFeatures; - VmgSetOffsetValid (Ghcb, GhcbRax); - VmgExitStatus = VmgExit ( + CcExitLibVmgSetOffsetValid (Ghcb, GhcbRax); + VmgExitStatus = CcExitLibVmgExit ( Ghcb, SVM_EXIT_SNP_AP_CREATION, ExitInfo1, ExitInfo2 ); - VmgDone (Ghcb, InterruptState); + CcExitLibVmgDone (Ghcb, InterruptState); ASSERT (VmgExitStatus == 0); if (VmgExitStatus != 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/BasePeCoffExtraActionLibNull.inf TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf + CcExitLib|UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf MicrocodeLib|UefiCpuPkg/Library/MicrocodeLib/MicrocodeLib.inf SmmCpuRendezvousLib|UefiCpuPkg/Library/SmmCpuRendezvousLib/SmmCpuRendezvousLib.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 -- 2.29.2.windows.2