From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.86]) by mx.groups.io with SMTP id smtpd.web11.5196.1667184678180062300 for ; Sun, 30 Oct 2022 19:51:18 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=HzyU3Izh; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.244.86, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bknr/2JH32HMH4MdsaMtKF5xccp3/s73Xc9B1nSdIjYmINm9dLq9KOwLXBwLIikclUmtCRkJ/BCYpP3fNfOX/CftKuvq8Eg/UL2kxVDkjiHGOs1MNUJRV97nEwYMxbsPalcYXZeDSwRA/nN7znIKDDCvERsns3Z9YKAQk5ZmEdewz7fO0MaYuiDkS1Hm9kNxDYQcvBux4K+6wxoiKGvzlX8v6Iiq7khbrDRf4e4glUnxuW/o3YwFZ35HVJD0aCA+qYh7JUMIurgw44vV1VRjtuVNQwjqfRm/KgtBTxeVvWqUh2kr8ZWfMOshufBB3uUJd4SepFycHtmGyf6TSvSHZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=i8QHFjcyDMy/CsVOVlkNPZ5DDRV6bJcn9DXdJcrORAM=; b=mWblAhUW653NeZh9VkIiHeUkbgigCvOoRRq67jXxqoc8GM8IAq5JnpxCDtJNvMOOhbjHj7wZM/PEIkx1KwUzlNZfp9xJYh7FCnlM679+s1KHzcbspnM4vS5vxE5aX8LzAAn2COBhZQMM1yr49Mjiab1UldRl/Er7Oqj2y7dr61hBhEBpL8l6DNEp5gWG7QPPnCS2ihOEs1TMiVfw+s+o8gf2igZ9ekpB+eygwd7nxve3edJyyLR74/vhL819TZmSitCtIsFWurya8ypx6iZSj918UFobpcpGam5DdoAJX0wX/PogWOwD9Uwrrfy+l8lSwkWx2iguAGxa6s0aUH7WyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i8QHFjcyDMy/CsVOVlkNPZ5DDRV6bJcn9DXdJcrORAM=; b=HzyU3IzhuO1RdzMYk34+kmhKSd7tv/dyJoiZ/EnCNKiuD/+QKzJzNVn3RiSfBGtdip2EElhw0FUBY6oTG8z0PsPn6zVI1sRGfLatAGh51sj6FRwZsvQO2ImX0WCnwAUCZRoyuBbXZXMOJ5oz2OERL3Ik9lkY88QcFDYOd02/LdM= Received: from MW4PR04CA0343.namprd04.prod.outlook.com (2603:10b6:303:8a::18) by SN7PR12MB6789.namprd12.prod.outlook.com (2603:10b6:806:26b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.15; Mon, 31 Oct 2022 02:51:15 +0000 Received: from CO1NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8a:cafe::cc) by MW4PR04CA0343.outlook.office365.com (2603:10b6:303:8a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.18 via Frontend Transport; Mon, 31 Oct 2022 02:51:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT021.mail.protection.outlook.com (10.13.175.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5769.14 via Frontend Transport; Mon, 31 Oct 2022 02:51:14 +0000 Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sun, 30 Oct 2022 21:51:09 -0500 From: "Chang, Abner" To: CC: Abdul Lateef Attar , Garrett Kirkendall , Paul Grimes , Eric Dong , Ray Ni , Rahul Kumar Subject: [PATCH V3 2/3] UefiCpuPkg/SmmCpuFeaturesLib: Abstract arch dependent code Date: Mon, 31 Oct 2022 10:49:11 +0800 Message-ID: <20221031024912.60-2-abner.chang@amd.com> X-Mailer: git-send-email 2.37.1.windows.1 In-Reply-To: <20221031024912.60-1-abner.chang@amd.com> References: <20221031024912.60-1-abner.chang@amd.com> MIME-Version: 1.0 Return-Path: Abner.Chang@amd.com X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT021:EE_|SN7PR12MB6789:EE_ X-MS-Office365-Filtering-Correlation-Id: cc89b21c-f2d1-45e5-ba5f-08dabaeac70e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8n8JllhdGPh6/WofH0P8kYiLuHeAvqXmYTZxDq7N9ucv4ydTBE4WhZWTsvFTv2qZeFlsE6wAVgD3t9ypCYatyUt/lLdLactp5z+JKzA+Vy+ALXXyOVI0TpkPYFXP6fkko64Gs/79jDlCA79RhPwXUccpzEpAzi4oGOnTOBzww9nnkEdWSMp8KjVfUCl6PA5IChpcnc5Vf9/Z57FMgcq/szMjCenbqOZJr4Ur4tdx4jOmVKo6SdcUsOzZB6OMcY0U4IajJQtIr19bqqkDFKpcCUJx6JXFXFy/dOsU+7rIddq+5CbibPX++nbFeWa8VZAlqZmTVZORSTWnB0Bzh+r7WVc1WBr59Y80OqUxL15sfkN0orVNuiFVLfVQlgW2SA437ZlSSfw/Vq8lhg0ydwbye1BVrfRIhkc7/cfrIKcg8HNegurJQT457LhDVV7Ks2p1JV1StukUeFwDmzod9lbwB0eD+oiDvKnT05wAfkBY6cB6XX1Z1kDY665cHCkX4W/SjFPJr5RpgvBr8GBMqiM/wdQrAW/OG4+C7qZKmyzykE3AH8qfDXuS24ItNJ3WeaPrdo4D8MnPxy9Okr1dQ5haXW9cfyV5wwtStmTrUpmf+KbYbbb8A9WsXd7zC9NnGlud/h2TnL7EpJpoBFbylv2Jbxh5EjUrOMy0gKF4tM8oVpbjPMufmOF3mEDxhqwsTmVQnLZgORJd1XzGtcmLCfPkx1MCNmVpeUHwVEt/tUQzzK6HjRQ7eCiHcGei3amLW1PXR7DxWt8JhZT98laTnITQ+kabZ9FL1yGGmtf9cs/4ddU= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(396003)(346002)(376002)(451199015)(36840700001)(46966006)(40470700004)(86362001)(36756003)(82740400003)(356005)(81166007)(47076005)(83380400001)(2906002)(2876002)(40480700001)(336012)(40460700003)(16526019)(478600001)(26005)(2616005)(6666004)(7696005)(36860700001)(426003)(1076003)(186003)(30864003)(70206006)(316002)(19627235002)(54906003)(82310400005)(6916009)(8676002)(4326008)(70586007)(41300700001)(5660300002)(8936002)(45080400002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2022 02:51:14.9528 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc89b21c-f2d1-45e5-ba5f-08dabaeac70e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6789 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Abner Chang BZ# 4093: Abstract SmmCpuFeaturesLib for sharing common code This change stripped away the code that can be shared with other archs or vendors from Intel implementation and put in to the common file, leaves the Intel X86 implementation in the IntelSmmCpuFeatureLib. Also updates the header file and INF file. Signed-off-by: Abner Chang Cc: Abdul Lateef Attar Cc: Garrett Kirkendall Cc: Paul Grimes Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar --- .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 1 + .../SmmCpuFeaturesLibStm.inf | 1 + .../StandaloneMmCpuFeaturesLib.inf | 1 + .../SmmCpuFeaturesLib/CpuFeaturesLib.h | 6 + .../IntelSmmCpuFeaturesLib.c | 206 +---------------- .../SmmCpuFeaturesLibCommon.c | 216 ++++++++++++++++++ 6 files changed, 227 insertions(+), 204 deletions(-) create mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibC= ommon.c diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/U= efiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf index 6254a14698a..9ac7dde78f8 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf @@ -20,6 +20,7 @@ CpuFeaturesLib.h IntelSmmCpuFeaturesLib.c SmmCpuFeaturesLib.c + SmmCpuFeaturesLibCommon.c SmmCpuFeaturesLibNoStm.c TraditionalMmCpuFeaturesLib.c =20 diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf = b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf index d64d8e66b38..86d367e0a09 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf @@ -20,6 +20,7 @@ [Sources] CpuFeaturesLib.h IntelSmmCpuFeaturesLib.c + SmmCpuFeaturesLibCommon.c SmmStm.c SmmStm.h TraditionalMmCpuFeaturesLib.c diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLi= b.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf index 5935b3e1fd6..b1f60a55055 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf @@ -21,6 +21,7 @@ [Sources] CpuFeaturesLib.h IntelSmmCpuFeaturesLib.c + SmmCpuFeaturesLibCommon.c StandaloneMmCpuFeaturesLib.c SmmCpuFeaturesLibNoStm.c =20 diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h b/UefiCp= uPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h index 8a1c2adc5c4..fd3e902547c 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h @@ -9,6 +9,12 @@ #ifndef CPU_FEATURES_LIB_H_ #define CPU_FEATURES_LIB_H_ =20 +#include +#include +#include +#include +#include + /** Performs library initialization. =20 diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c = b/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c index 75a0ec8e948..cb4897b21e3 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c @@ -7,16 +7,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 -#include -#include -#include +#include "CpuFeaturesLib.h" + #include -#include -#include -#include #include #include -#include "CpuFeaturesLib.h" =20 // // Machine Specific Registers (MSRs) @@ -287,64 +282,6 @@ SmmCpuFeaturesInitializeProcessor ( FinishSmmCpuFeaturesInitializeProcessor (); } =20 -/** - This function updates the SMRAM save state on the currently executing CP= U - to resume execution at a specific address after an RSM instruction. Thi= s - function must evaluate the SMRAM save state to determine the execution m= ode - the RSM instruction resumes and update the resume execution address with - either NewInstructionPointer32 or NewInstructionPoint. The auto HALT re= start - flag in the SMRAM save state must always be cleared. This function retu= rns - the value of the instruction pointer from the SMRAM save state that was - replaced. If this function returns 0, then the SMRAM save state was not - modified. - - This function is called during the very first SMI on each CPU after - SmmCpuFeaturesInitializeProcessor() to set a flag in normal execution mo= de - to signal that the SMBASE of each CPU has been updated before the defaul= t - SMBASE address is used for the first SMI to the next CPU. - - @param[in] CpuIndex The index of the CPU to hook. The v= alue - must be between 0 and the NumberOfCp= us - field in the System Management Syste= m Table - (SMST). - @param[in] CpuState Pointer to SMRAM Save State Map for = the - currently executing CPU. - @param[in] NewInstructionPointer32 Instruction pointer to use if resumi= ng to - 32-bit execution mode from 64-bit SM= M. - @param[in] NewInstructionPointer Instruction pointer to use if resumi= ng to - same execution mode as SMM. - - @retval 0 This function did modify the SMRAM save state. - @retval > 0 The original instruction pointer value from the SMRAM save = state - before it was replaced. -**/ -UINT64 -EFIAPI -SmmCpuFeaturesHookReturnFromSmm ( - IN UINTN CpuIndex, - IN SMRAM_SAVE_STATE_MAP *CpuState, - IN UINT64 NewInstructionPointer32, - IN UINT64 NewInstructionPointer - ) -{ - return 0; -} - -/** - Hook point in normal execution mode that allows the one CPU that was ele= cted - as monarch during System Management Mode initialization to perform addit= ional - initialization actions immediately after all of the CPUs have processed = their - first SMI and called SmmCpuFeaturesInitializeProcessor() relocating SMBA= SE - into a buffer in SMRAM and called SmmCpuFeaturesHookReturnFromSmm(). -**/ -VOID -EFIAPI -SmmCpuFeaturesSmmRelocationComplete ( - VOID - ) -{ -} - /** Determines if MTRR registers must be configured to set SMRAM cache-abili= ty when executing in System Management Mode. @@ -414,48 +351,6 @@ SmmCpuFeaturesRendezvousEntry ( } } =20 -/** - Processor specific hook point each time a CPU exits System Management Mo= de. - - @param[in] CpuIndex The index of the CPU that is exiting SMM. The valu= e must - be between 0 and the NumberOfCpus field in the Syst= em - Management System Table (SMST). -**/ -VOID -EFIAPI -SmmCpuFeaturesRendezvousExit ( - IN UINTN CpuIndex - ) -{ -} - -/** - Check to see if an SMM register is supported by a specified CPU. - - @param[in] CpuIndex The index of the CPU to check for SMM register supp= ort. - The value must be between 0 and the NumberOfCpus fi= eld - in the System Management System Table (SMST). - @param[in] RegName Identifies the SMM register to check for support. - - @retval TRUE The SMM register specified by RegName is supported by the= CPU - specified by CpuIndex. - @retval FALSE The SMM register specified by RegName is not supported by= the - CPU specified by CpuIndex. -**/ -BOOLEAN -EFIAPI -SmmCpuFeaturesIsSmmRegisterSupported ( - IN UINTN CpuIndex, - IN SMM_REG_NAME RegName - ) -{ - if (FeaturePcdGet (PcdSmmFeatureControlEnable) && (RegName =3D=3D SmmReg= FeatureControl)) { - return TRUE; - } - - return FALSE; -} - /** Returns the current value of the SMM register for the specified CPU. If the SMM register is not supported, then 0 is returned. @@ -506,100 +401,3 @@ SmmCpuFeaturesSetSmmRegister ( } } =20 -/** - Read an SMM Save State register on the target processor. If this functi= on - returns EFI_UNSUPPORTED, then the caller is responsible for reading the - SMM Save Sate register. - - @param[in] CpuIndex The index of the CPU to read the SMM Save State. = The - value must be between 0 and the NumberOfCpus field= in - the System Management System Table (SMST). - @param[in] Register The SMM Save State register to read. - @param[in] Width The number of bytes to read from the CPU save stat= e. - @param[out] Buffer Upon return, this holds the CPU register value rea= d - from the save state. - - @retval EFI_SUCCESS The register was read from Save State. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED This function does not support reading Reg= ister. - -**/ -EFI_STATUS -EFIAPI -SmmCpuFeaturesReadSaveStateRegister ( - IN UINTN CpuIndex, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN Width, - OUT VOID *Buffer - ) -{ - return EFI_UNSUPPORTED; -} - -/** - Writes an SMM Save State register on the target processor. If this func= tion - returns EFI_UNSUPPORTED, then the caller is responsible for writing the - SMM Save Sate register. - - @param[in] CpuIndex The index of the CPU to write the SMM Save State. = The - value must be between 0 and the NumberOfCpus field = in - the System Management System Table (SMST). - @param[in] Register The SMM Save State register to write. - @param[in] Width The number of bytes to write to the CPU save state. - @param[in] Buffer Upon entry, this holds the new CPU register value. - - @retval EFI_SUCCESS The register was written to Save State. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED This function does not support writing Reg= ister. -**/ -EFI_STATUS -EFIAPI -SmmCpuFeaturesWriteSaveStateRegister ( - IN UINTN CpuIndex, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN Width, - IN CONST VOID *Buffer - ) -{ - return EFI_UNSUPPORTED; -} - -/** - This function is hook point called after the gEfiSmmReadyToLockProtocolG= uid - notification is completely processed. -**/ -VOID -EFIAPI -SmmCpuFeaturesCompleteSmmReadyToLock ( - VOID - ) -{ -} - -/** - This API provides a method for a CPU to allocate a specific region for s= toring page tables. - - This API can be called more once to allocate memory for page tables. - - Allocates the number of 4KB pages of type EfiRuntimeServicesData and ret= urns a pointer to the - allocated buffer. The buffer returned is aligned on a 4KB boundary. If= Pages is 0, then NULL - is returned. If there is not enough memory remaining to satisfy the req= uest, then NULL is - returned. - - This function can also return NULL if there is no preference on where th= e page tables are allocated in SMRAM. - - @param Pages The number of 4 KB pages to allocate. - - @return A pointer to the allocated buffer for page tables. - @retval NULL Fail to allocate a specific region for storing page ta= bles, - Or there is no preference on where the page tables are= allocated in SMRAM. - -**/ -VOID * -EFIAPI -SmmCpuFeaturesAllocatePageTableMemory ( - IN UINTN Pages - ) -{ - return NULL; -} diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c= b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c new file mode 100644 index 00000000000..7777e52740e --- /dev/null +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c @@ -0,0 +1,216 @@ +/** @file +Implementation shared across all library instances. + +Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include + +#include "CpuFeaturesLib.h" + +/** + This function updates the SMRAM save state on the currently executing CP= U + to resume execution at a specific address after an RSM instruction. Thi= s + function must evaluate the SMRAM save state to determine the execution m= ode + the RSM instruction resumes and update the resume execution address with + either NewInstructionPointer32 or NewInstructionPoint. The auto HALT re= start + flag in the SMRAM save state must always be cleared. This function retu= rns + the value of the instruction pointer from the SMRAM save state that was + replaced. If this function returns 0, then the SMRAM save state was not + modified. + + This function is called during the very first SMI on each CPU after + SmmCpuFeaturesInitializeProcessor() to set a flag in normal execution mo= de + to signal that the SMBASE of each CPU has been updated before the defaul= t + SMBASE address is used for the first SMI to the next CPU. + + @param[in] CpuIndex The index of the CPU to hook. The v= alue + must be between 0 and the NumberOfCp= us + field in the System Management Syste= m Table + (SMST). + @param[in] CpuState Pointer to SMRAM Save State Map for = the + currently executing CPU. + @param[in] NewInstructionPointer32 Instruction pointer to use if resumi= ng to + 32-bit execution mode from 64-bit SM= M. + @param[in] NewInstructionPointer Instruction pointer to use if resumi= ng to + same execution mode as SMM. + + @retval 0 This function did modify the SMRAM save state. + @retval > 0 The original instruction pointer value from the SMRAM save = state + before it was replaced. +**/ +UINT64 +EFIAPI +SmmCpuFeaturesHookReturnFromSmm ( + IN UINTN CpuIndex, + IN SMRAM_SAVE_STATE_MAP *CpuState, + IN UINT64 NewInstructionPointer32, + IN UINT64 NewInstructionPointer + ) +{ + return 0; +} + +/** + Hook point in normal execution mode that allows the one CPU that was ele= cted + as monarch during System Management Mode initialization to perform addit= ional + initialization actions immediately after all of the CPUs have processed = their + first SMI and called SmmCpuFeaturesInitializeProcessor() relocating SMBA= SE + into a buffer in SMRAM and called SmmCpuFeaturesHookReturnFromSmm(). +**/ +VOID +EFIAPI +SmmCpuFeaturesSmmRelocationComplete ( + VOID + ) +{ +} + +/** + Processor specific hook point each time a CPU exits System Management Mo= de. + + @param[in] CpuIndex The index of the CPU that is exiting SMM. The valu= e must + be between 0 and the NumberOfCpus field in the Syst= em + Management System Table (SMST). +**/ +VOID +EFIAPI +SmmCpuFeaturesRendezvousExit ( + IN UINTN CpuIndex + ) +{ +} + +/** + Check to see if an SMM register is supported by a specified CPU. + + @param[in] CpuIndex The index of the CPU to check for SMM register supp= ort. + The value must be between 0 and the NumberOfCpus fi= eld + in the System Management System Table (SMST). + @param[in] RegName Identifies the SMM register to check for support. + + @retval TRUE The SMM register specified by RegName is supported by the= CPU + specified by CpuIndex. + @retval FALSE The SMM register specified by RegName is not supported by= the + CPU specified by CpuIndex. +**/ +BOOLEAN +EFIAPI +SmmCpuFeaturesIsSmmRegisterSupported ( + IN UINTN CpuIndex, + IN SMM_REG_NAME RegName + ) +{ + if (FeaturePcdGet (PcdSmmFeatureControlEnable) && (RegName =3D=3D SmmReg= FeatureControl)) { + return TRUE; + } + + return FALSE; +} + +/** + Read an SMM Save State register on the target processor. If this functi= on + returns EFI_UNSUPPORTED, then the caller is responsible for reading the + SMM Save Sate register. + + @param[in] CpuIndex The index of the CPU to read the SMM Save State. = The + value must be between 0 and the NumberOfCpus field= in + the System Management System Table (SMST). + @param[in] Register The SMM Save State register to read. + @param[in] Width The number of bytes to read from the CPU save stat= e. + @param[out] Buffer Upon return, this holds the CPU register value rea= d + from the save state. + + @retval EFI_SUCCESS The register was read from Save State. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED This function does not support reading Reg= ister. + +**/ +EFI_STATUS +EFIAPI +SmmCpuFeaturesReadSaveStateRegister ( + IN UINTN CpuIndex, + IN EFI_SMM_SAVE_STATE_REGISTER Register, + IN UINTN Width, + OUT VOID *Buffer + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Writes an SMM Save State register on the target processor. If this func= tion + returns EFI_UNSUPPORTED, then the caller is responsible for writing the + SMM Save Sate register. + + @param[in] CpuIndex The index of the CPU to write the SMM Save State. = The + value must be between 0 and the NumberOfCpus field = in + the System Management System Table (SMST). + @param[in] Register The SMM Save State register to write. + @param[in] Width The number of bytes to write to the CPU save state. + @param[in] Buffer Upon entry, this holds the new CPU register value. + + @retval EFI_SUCCESS The register was written to Save State. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED This function does not support writing Reg= ister. +**/ +EFI_STATUS +EFIAPI +SmmCpuFeaturesWriteSaveStateRegister ( + IN UINTN CpuIndex, + IN EFI_SMM_SAVE_STATE_REGISTER Register, + IN UINTN Width, + IN CONST VOID *Buffer + ) +{ + return EFI_UNSUPPORTED; +} + +/** + This function is hook point called after the gEfiSmmReadyToLockProtocolG= uid + notification is completely processed. +**/ +VOID +EFIAPI +SmmCpuFeaturesCompleteSmmReadyToLock ( + VOID + ) +{ +} + +/** + This API provides a method for a CPU to allocate a specific region for s= toring page tables. + + This API can be called more once to allocate memory for page tables. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and ret= urns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If= Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the req= uest, then NULL is + returned. + + This function can also return NULL if there is no preference on where th= e page tables are allocated in SMRAM. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer for page tables. + @retval NULL Fail to allocate a specific region for storing page ta= bles, + Or there is no preference on where the page tables are= allocated in SMRAM. + +**/ +VOID * +EFIAPI +SmmCpuFeaturesAllocatePageTableMemory ( + IN UINTN Pages + ) +{ + return NULL; +} --=20 2.37.1.windows.1