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.web12.12068.1651761816591790482 for ; Thu, 05 May 2022 07:43:40 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=iWs6K9PQ; 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=1651761819; x=1683297819; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mGxQj6UbHItS4edlyQjC3JurZGJtkURtf1IbL2qYdW4=; b=iWs6K9PQB6LOqu+0deNOu8jETaoONq/+NJE+Nn/vXY8gHrx41G10u3+W 3aNzLhWhrtR4NwExnsWpliXhQ+VpmDXxL2SOf5TBPPEMQj84wA1KJKfEI 5NITX7hsYyp0hQqORXgXAY+coM9B9msyESroST1WTNx71MtTrsKY+rP/U iXq8LbjvrnhRsjz0QHk0odS/2bB6patj9UADepqnIkfXu+Mx9N9vi8wwV YScpq3bhLWNjWy2K1fSDOLwXz7pnGuymss/7vCi4b/tcxE7OpijxkkUp3 eR3iGszXCdeqcjSMWiIgdG2y4sgPDRFVgAlntX4ZKCIp2tbBKP/FNJX1M g==; X-IronPort-AV: E=McAfee;i="6400,9594,10338"; a="255604309" X-IronPort-AV: E=Sophos;i="5.91,201,1647327600"; d="scan'208";a="255604309" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2022 07:43:39 -0700 X-IronPort-AV: E=Sophos;i="5.91,201,1647327600"; d="scan'208";a="563268831" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.175.139]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2022 07:43:36 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Eric Dong , Ray Ni , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Gerd Hoffmann Subject: [PATCH 1/6] UefiCpuPkg: Revert "UefiCpuPkg: Enable Tdx support in MpInitLib" Date: Thu, 5 May 2022 22:43:14 +0800 Message-Id: X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Min M Xu BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3918 This reverts commit 88da06ca763eb6514565c1867a801a427c1f3447. This commit triggers the ASSERT in Non-Td guest. Cc: Eric Dong Cc: Ray Ni Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Gerd Hoffmann Signed-off-by: Min Xu --- UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf | 3 - UefiCpuPkg/Library/MpInitLib/MpIntelTdx.h | 69 ------------ UefiCpuPkg/Library/MpInitLib/MpLib.c | 63 +---------- UefiCpuPkg/Library/MpInitLib/MpLibTdx.c | 106 ------------------ UefiCpuPkg/Library/MpInitLib/MpLibTdxNull.c | 69 ------------ UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf | 3 - 6 files changed, 5 insertions(+), 308 deletions(-) delete mode 100644 UefiCpuPkg/Library/MpInitLib/MpIntelTdx.h delete mode 100644 UefiCpuPkg/Library/MpInitLib/MpLibTdx.c delete mode 100644 UefiCpuPkg/Library/MpInitLib/MpLibTdxNull.c diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf index 159b4d16ed0e..e1cd0b350008 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf @@ -24,12 +24,10 @@ [Sources.IA32] Ia32/AmdSev.c Ia32/MpFuncs.nasm - MpLibTdxNull.c [Sources.X64] X64/AmdSev.c X64/MpFuncs.nasm - MpLibTdx.c [Sources.common] AmdSev.c @@ -38,7 +36,6 @@ MpLib.c MpLib.h Microcode.c - MpIntelTdx.h [Packages] MdePkg/MdePkg.dec diff --git a/UefiCpuPkg/Library/MpInitLib/MpIntelTdx.h b/UefiCpuPkg/Library/MpInitLib/MpIntelTdx.h deleted file mode 100644 index 8a26f6c19fc4..000000000000 --- a/UefiCpuPkg/Library/MpInitLib/MpIntelTdx.h +++ /dev/null @@ -1,69 +0,0 @@ -/** @file - CPU MP Initialize Library header file for Td guest. - - Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
- - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#ifndef MP_INTEL_TDX_H_ -#define MP_INTEL_TDX_H_ - -#include -#include -#include -#include -#include - -/** - Gets detailed MP-related information on the requested processor at the - instant this call is made. This service may only be called from the BSP. - - @param[in] ProcessorNumber The handle number of processor. - @param[out] ProcessorInfoBuffer A pointer to the buffer where information for - the requested processor is deposited. - @param[out] HealthData Return processor health data. - - @retval EFI_SUCCESS Processor information was returned. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist in the platform. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -TdxMpInitLibGetProcessorInfo ( - IN UINTN ProcessorNumber, - OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer, - OUT EFI_HEALTH_FLAGS *HealthData OPTIONAL - ); - -/** - Retrieves the number of logical processor in the platform and the number of - those logical processors that are enabled on this boot. This service may only - be called from the BSP. - - @param[out] NumberOfProcessors Pointer to the total number of logical - processors in the system, including the BSP - and disabled APs. - @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical - processors that exist in system, including - the BSP. - - @retval EFI_SUCCESS The number of logical processors and enabled - logical processors was retrieved. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL and NumberOfEnabledProcessors - is NULL. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -TdxMpInitLibGetNumberOfProcessors ( - OUT UINTN *NumberOfProcessors, OPTIONAL - OUT UINTN *NumberOfEnabledProcessors OPTIONAL - ); - -#endif diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index 91c7afaeb2ad..4a73787ee43a 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -9,11 +9,9 @@ **/ #include "MpLib.h" -#include "MpIntelTdx.h" #include #include #include -#include EFI_GUID mCpuInitMpLibHobGuid = CPU_INIT_MP_LIB_HOB_GUID; @@ -1805,10 +1803,6 @@ MpInitLibInitialize ( UINTN BackupBufferAddr; UINTN ApIdtBase; - if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) { - return EFI_SUCCESS; - } - OldCpuMpData = GetCpuMpDataFromGuidedHob (); if (OldCpuMpData == NULL) { MaxLogicalProcessorNumber = PcdGet32 (PcdCpuMaxLogicalProcessorNumber); @@ -2079,10 +2073,6 @@ MpInitLibGetProcessorInfo ( CPU_INFO_IN_HOB *CpuInfoInHob; UINTN OriginalProcessorNumber; - if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) { - return TdxMpInitLibGetProcessorInfo (ProcessorNumber, ProcessorInfoBuffer, HealthData); - } - CpuMpData = GetCpuMpData (); CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob; @@ -2177,10 +2167,6 @@ SwitchBSPWorker ( BOOLEAN OldInterruptState; BOOLEAN OldTimerInterruptState; - if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) { - return EFI_UNSUPPORTED; - } - // // Save and Disable Local APIC timer interrupt // @@ -2321,10 +2307,6 @@ EnableDisableApWorker ( CPU_MP_DATA *CpuMpData; UINTN CallerNumber; - if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) { - return EFI_UNSUPPORTED; - } - CpuMpData = GetCpuMpData (); // @@ -2385,11 +2367,6 @@ MpInitLibWhoAmI ( return EFI_INVALID_PARAMETER; } - if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) { - *ProcessorNumber = 0; - return EFI_SUCCESS; - } - CpuMpData = GetCpuMpData (); return GetProcessorNumber (CpuMpData, ProcessorNumber); @@ -2428,16 +2405,12 @@ MpInitLibGetNumberOfProcessors ( UINTN EnabledProcessorNumber; UINTN Index; + CpuMpData = GetCpuMpData (); + if ((NumberOfProcessors == NULL) && (NumberOfEnabledProcessors == NULL)) { return EFI_INVALID_PARAMETER; } - if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) { - return TdxMpInitLibGetNumberOfProcessors (NumberOfProcessors, NumberOfEnabledProcessors); - } - - CpuMpData = GetCpuMpData (); - // // Check whether caller processor is BSP // @@ -2517,16 +2490,13 @@ StartupAllCPUsWorker ( BOOLEAN HasEnabledAp; CPU_STATE ApState; + CpuMpData = GetCpuMpData (); + if (FailedCpuList != NULL) { *FailedCpuList = NULL; } - Status = MpInitLibGetNumberOfProcessors (&ProcessorCount, NULL); - if (EFI_ERROR (Status)) { - return Status; - } - - if ((ProcessorCount == 1) && ExcludeBsp) { + if ((CpuMpData->CpuCount == 1) && ExcludeBsp) { return EFI_NOT_STARTED; } @@ -2534,22 +2504,6 @@ StartupAllCPUsWorker ( return EFI_INVALID_PARAMETER; } - if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) { - // - // For Td guest ExcludeBsp must be FALSE. Otherwise it will return in above checks. - // - ASSERT (!ExcludeBsp); - - // - // Start BSP. - // - Procedure (ProcedureArgument); - - return EFI_SUCCESS; - } - - CpuMpData = GetCpuMpData (); - // // Check whether caller processor is BSP // @@ -2689,13 +2643,6 @@ StartupThisAPWorker ( CPU_AP_DATA *CpuData; UINTN CallerNumber; - // - // In Td guest, startup of AP is not supported in current stage. - // - if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) { - return EFI_UNSUPPORTED; - } - CpuMpData = GetCpuMpData (); if (Finished != NULL) { diff --git a/UefiCpuPkg/Library/MpInitLib/MpLibTdx.c b/UefiCpuPkg/Library/MpInitLib/MpLibTdx.c deleted file mode 100644 index fdb58fba9323..000000000000 --- a/UefiCpuPkg/Library/MpInitLib/MpLibTdx.c +++ /dev/null @@ -1,106 +0,0 @@ -/** @file - CPU MP Initialize Library common functions for Td guest. - - Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
- - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "MpLib.h" -#include "MpIntelTdx.h" - -/** - Gets detailed MP-related information on the requested processor at the - instant this call is made. This service may only be called from the BSP. - - In current stage only the BSP is workable. So ProcessorNumber should be 0. - - @param[in] ProcessorNumber The handle number of processor. - @param[out] ProcessorInfoBuffer A pointer to the buffer where information for - the requested processor is deposited. - @param[out] HealthData Return processor health data. - - @retval EFI_SUCCESS Processor information was returned. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL or ProcessorNumber is not 0. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist in the platform. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -TdxMpInitLibGetProcessorInfo ( - IN UINTN ProcessorNumber, - OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer, - OUT EFI_HEALTH_FLAGS *HealthData OPTIONAL - ) -{ - UINTN OriginalProcessorNumber; - - // - // Lower 24 bits contains the actual processor number. - // - OriginalProcessorNumber = ProcessorNumber; - ProcessorNumber &= BIT24 - 1; - - if ((ProcessorInfoBuffer == NULL) || (ProcessorNumber != 0)) { - return EFI_INVALID_PARAMETER; - } - - ProcessorInfoBuffer->ProcessorId = 0; - ProcessorInfoBuffer->StatusFlag = PROCESSOR_AS_BSP_BIT | PROCESSOR_ENABLED_BIT; - ZeroMem (&ProcessorInfoBuffer->Location, sizeof (EFI_CPU_PHYSICAL_LOCATION)); - - if ((OriginalProcessorNumber & CPU_V2_EXTENDED_TOPOLOGY) != 0) { - ZeroMem (&ProcessorInfoBuffer->ExtendedInformation.Location2, sizeof (EFI_CPU_PHYSICAL_LOCATION2)); - } - - if (HealthData != NULL) { - HealthData->Uint32 = 0; - } - - return EFI_SUCCESS; -} - -/** - Retrieves the number of logical processor in the platform and the number of - those logical processors that are enabled on this boot. This service may only - be called from the BSP. - - @param[out] NumberOfProcessors Pointer to the total number of logical - processors in the system, including the BSP - and disabled APs. - @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical - processors that exist in system, including - the BSP. - - @retval EFI_SUCCESS The number of logical processors and enabled - logical processors was retrieved. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL and NumberOfEnabledProcessors - is NULL. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -TdxMpInitLibGetNumberOfProcessors ( - OUT UINTN *NumberOfProcessors, OPTIONAL - OUT UINTN *NumberOfEnabledProcessors OPTIONAL - ) -{ - ASSERT (NumberOfProcessors != NULL || NumberOfEnabledProcessors != NULL); - // - // In current stage only the BSP is workable. So NumberOfProcessors - // & NumberOfEnableddProcessors are both 1. - // - if (NumberOfProcessors != NULL) { - *NumberOfProcessors = 1; - } - - if (NumberOfEnabledProcessors != NULL) { - *NumberOfEnabledProcessors = 1; - } - - return EFI_SUCCESS; -} diff --git a/UefiCpuPkg/Library/MpInitLib/MpLibTdxNull.c b/UefiCpuPkg/Library/MpInitLib/MpLibTdxNull.c deleted file mode 100644 index b5aaf6df283f..000000000000 --- a/UefiCpuPkg/Library/MpInitLib/MpLibTdxNull.c +++ /dev/null @@ -1,69 +0,0 @@ -/** @file - CPU MP Initialize Library common functions (NULL instance) for Td guest. - - Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
- - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "MpLib.h" -#include "MpIntelTdx.h" - -/** - Gets detailed MP-related information on the requested processor at the - instant this call is made. This service may only be called from the BSP. - - @param[in] ProcessorNumber The handle number of processor. - @param[out] ProcessorInfoBuffer A pointer to the buffer where information for - the requested processor is deposited. - @param[out] HealthData Return processor health data. - - @retval EFI_SUCCESS Processor information was returned. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist in the platform. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -TdxMpInitLibGetProcessorInfo ( - IN UINTN ProcessorNumber, - OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer, - OUT EFI_HEALTH_FLAGS *HealthData OPTIONAL - ) -{ - ASSERT (FALSE); - return EFI_UNSUPPORTED; -} - -/** - Retrieves the number of logical processor in the platform and the number of - those logical processors that are enabled on this boot. This service may only - be called from the BSP. - - @param[out] NumberOfProcessors Pointer to the total number of logical - processors in the system, including the BSP - and disabled APs. - @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical - processors that exist in system, including - the BSP. - - @retval EFI_SUCCESS The number of logical processors and enabled - logical processors was retrieved. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL and NumberOfEnabledProcessors - is NULL. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -TdxMpInitLibGetNumberOfProcessors ( - OUT UINTN *NumberOfProcessors, OPTIONAL - OUT UINTN *NumberOfEnabledProcessors OPTIONAL - ) -{ - ASSERT (FALSE); - return EFI_UNSUPPORTED; -} diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf b/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf index 894be0f8daab..5facf4db9499 100644 --- a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf +++ b/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf @@ -24,12 +24,10 @@ [Sources.IA32] Ia32/AmdSev.c Ia32/MpFuncs.nasm - MpLibTdxNull.c [Sources.X64] X64/AmdSev.c X64/MpFuncs.nasm - MpLibTdx.c [Sources.common] AmdSev.c @@ -38,7 +36,6 @@ MpLib.c MpLib.h Microcode.c - MpIntelTdx.h [Packages] MdePkg/MdePkg.dec -- 2.29.2.windows.2