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.64]) by mx.groups.io with SMTP id smtpd.web12.8066.1667134934764432046 for ; Sun, 30 Oct 2022 06:02:14 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=j+lU6qhb; 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.64, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jLCar0Wz/EeEkPfbEdv3LVC/41ytYj9GY/VQ5IVJWCvPZxG/QEAwMw18jEybcE76G4SREVIRYpfN8hf9gTag4coq+MtR/YWhKsTwvCKArWMEVHg4uAHI5jSoh3g3BVr19vwvH1qQnibN4Buc0zd7/HwDZ0B2dhcW1h0HZtfFvbCim3V2vGD9sXJqd8GimtI4fwPfv0te0dbVfvK97bye6NeWmUEBNckwkd17Ax2JNM83ez5JPGPkrUWrFi9B55J02gtT0VaDxjh3Xdj2y1Y3t+i9ygSXnRABEbWqHsUHW/Ka2gnB79tqRW/sb/Nrusf+N6JoXJ6iu2iR8hpXWT8SVw== 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=bI9q+EjEdkTU67T269SKv4plvbUThcatomSkPb8Y+J4=; b=V0zmGnPdRb+/YVaPZsBKus/qKcl54FXFJMlKgVqhOI1RQfoF3p4dhdEsyXJe3vX5DsiF2KXLrrfIlDItGEdN3FIFAIjxBbpnWxI4DD2VKtp1Jqrj4AIL5zy4UT0XcKv8syXCKi7Mr82WPhJtkgPKrw0e2ZAtlHp3FgEkQORI4QKDRLVw2rrcgQq6Pkzm9Yvs9+FTGl7AW8SrUCMia602i9msAV/EXiijf5uT2St3xfOfg5YC0ahci/IzQ8Wen97Mjxv5De0BZnj23q03EXRGU43XlZo7vHyEbPYgtfstR++Z6WqFxuo553i3vLV6P24kBUshL+e8XtgqbZA2AMPmBQ== 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=bI9q+EjEdkTU67T269SKv4plvbUThcatomSkPb8Y+J4=; b=j+lU6qhbW5wvAERnhuOL47bK3wVrG3N6TcQNclNFiM5OeLlEl3O64Ps0rOhNkOJPjARHeyiOB4KBooAzq2ypS9gSe/Q2iLJ+B+LBBpLoshe8sN1Iq9oBbs6//O/SIvSpu5hbjB2DEptY1QAipNefysfgZ2iqggsozxh/b61h5Lw= Received: from DS7PR03CA0110.namprd03.prod.outlook.com (2603:10b6:5:3b7::25) by DM6PR12MB4498.namprd12.prod.outlook.com (2603:10b6:5:2a2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.19; Sun, 30 Oct 2022 13:02:10 +0000 Received: from DM6NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b7:cafe::9f) by DS7PR03CA0110.outlook.office365.com (2603:10b6:5:3b7::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.18 via Frontend Transport; Sun, 30 Oct 2022 13:02:10 +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 DM6NAM11FT021.mail.protection.outlook.com (10.13.173.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5769.14 via Frontend Transport; Sun, 30 Oct 2022 13:02:10 +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 08:02:07 -0500 From: "Chang, Abner" To: CC: Abdul Lateef Attar , Garrett Kirkendall , Paul Grimes , Eric Dong , Ray Ni , Rahul Kumar Subject: [PATCH V2 2/3] UefiCpuPkg/SmmCpuFeaturesLib: Abstract arch dependent code Date: Sun, 30 Oct 2022 21:01:46 +0800 Message-ID: <20221030130147.1143-2-abner.chang@amd.com> X-Mailer: git-send-email 2.37.1.windows.1 In-Reply-To: <20221030130147.1143-1-abner.chang@amd.com> References: <20221030130147.1143-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: DM6NAM11FT021:EE_|DM6PR12MB4498:EE_ X-MS-Office365-Filtering-Correlation-Id: c501771d-d158-44a6-d5fc-08daba76f4e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: whaA00QWOiDbggGUbyX0ZOn9O0LNdNHS59u68UoZcLm/OgiwLEZHybmgSI2kDZSwrpTnGXq+IVmt83rm2pTq6+D/y5bUrPaDrexCiryMLG/i3SESf4z+NnFQWWMN9A/DvJx3H0ixHLvkgNNAkyywh0G+6J+OmHhiB3BqSOZavTW/iozMPLvm6QG1U6FsTEsVtYUuEZZH+IkcnV91oBRyARC4qRy9lr7qcQjeoVRV7IG9wu706Sbz9rWP228KRIwZDaais/JgXP9WqtyFt3ztVTZelobxUaXBFbJH9hZuLNDDQgThE+zfLHn7NIo8eMl8XT/trh/C70lv2gCYhfLeqIB7KdqW/Wn8Y11LUCa1129MKxR4WpMZk4sHYnm9x5I9R72hwPKgvieMDczcsCfyHFqVi1PYLLQEIpbJzZzQl9uB8b0KTxNk1oUQJkV+VNGQgbGD0AAHGU2/QtvHwTi/SguW2xK5GL0bqGaKLRlS5xhdWXPIAqLtcOFdCsdJuKb1f//3UCykVZzQyi/5mOO6/2ltaVGHp6+2vhZIHjUn86vPlM6J+dTKsGst0OC4DBvZK8QxQTMyzOjVJ4tNSvwtEfacM87xNaayhuJJNKioxxtU0y/jbVR8Thcp9x/lBIiNixVLJpId/DmYJPA01b9q0M8UVp/0yn1k/0FzZmjNbHp6jaisHEFGYaHXqNdMk3FEcLrpafIlVBsVE6hy7z5iVKGrQmUKt+llmdXzUi+31MokkmPV//mNRiGm4QAuKCF4gmVogVq7Tc+EGI58CG6CPnzqoyPqVxhZRKrB7lVtPmw= 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)(346002)(396003)(376002)(451199015)(36840700001)(46966006)(40470700004)(356005)(81166007)(36756003)(82740400003)(40480700001)(86362001)(40460700003)(2876002)(2906002)(30864003)(6666004)(478600001)(19627235002)(316002)(4326008)(70586007)(70206006)(8676002)(8936002)(45080400002)(5660300002)(6916009)(54906003)(41300700001)(7696005)(82310400005)(36860700001)(186003)(2616005)(16526019)(1076003)(26005)(83380400001)(47076005)(336012)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2022 13:02:10.3266 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c501771d-d158-44a6-d5fc-08daba76f4e4 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: DM6NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4498 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 7b5cef97008..9ac7dde78f8 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf @@ -18,6 +18,7 @@ =20 [Sources] CpuFeaturesLib.h + IntelSmmCpuFeaturesLib.c SmmCpuFeaturesLib.c SmmCpuFeaturesLibCommon.c SmmCpuFeaturesLibNoStm.c diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf = b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf index 85214ee31cd..86d367e0a09 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf @@ -19,6 +19,7 @@ =20 [Sources] CpuFeaturesLib.h + IntelSmmCpuFeaturesLib.c SmmCpuFeaturesLibCommon.c SmmStm.c SmmStm.h diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLi= b.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf index 3eacab48db3..61890205e18 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf @@ -20,6 +20,7 @@ =20 [Sources] CpuFeaturesLib.h + IntelSmmCpuFeaturesLib.c StandaloneMmCpuFeaturesLib.c SmmCpuFeaturesLibCommon.c SmmCpuFeaturesLibNoStm.c 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