]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Library/CpuCommonFeaturesLib/LimitCpuIdMaxval.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / UefiCpuPkg / Library / CpuCommonFeaturesLib / LimitCpuIdMaxval.c
CommitLineData
80c4b236
JF
1/** @file\r
2 LimitCpuidMaxval Feature.\r
3\r
60cb4d1b 4 Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>\r
0acd8697 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
80c4b236
JF
6\r
7**/\r
8\r
9#include "CpuCommonFeatures.h"\r
10\r
11/**\r
12 Detects if LimitCpuidMaxval feature supported on current processor.\r
13\r
14 @param[in] ProcessorNumber The index of the CPU executing this function.\r
15 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
16 structure for the CPU executing this function.\r
17 @param[in] ConfigData A pointer to the configuration buffer returned\r
18 by CPU_FEATURE_GET_CONFIG_DATA. NULL if\r
19 CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
20 RegisterCpuFeature().\r
21\r
22 @retval TRUE LimitCpuidMaxval feature is supported.\r
23 @retval FALSE LimitCpuidMaxval feature is not supported.\r
24\r
25 @note This service could be called by BSP/APs.\r
26**/\r
27BOOLEAN\r
28EFIAPI\r
29LimitCpuidMaxvalSupport (\r
30 IN UINTN ProcessorNumber,\r
31 IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,\r
32 IN VOID *ConfigData OPTIONAL\r
33 )\r
34{\r
35 UINT32 Eax;\r
36\r
37 AsmCpuid (CPUID_SIGNATURE, &Eax, NULL, NULL, NULL);\r
60cb4d1b 38 return (Eax > 2);\r
80c4b236
JF
39}\r
40\r
41/**\r
42 Initializes LimitCpuidMaxval feature to specific state.\r
43\r
44 @param[in] ProcessorNumber The index of the CPU executing this function.\r
45 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
46 structure for the CPU executing this function.\r
47 @param[in] ConfigData A pointer to the configuration buffer returned\r
48 by CPU_FEATURE_GET_CONFIG_DATA. NULL if\r
49 CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
50 RegisterCpuFeature().\r
51 @param[in] State If TRUE, then the LimitCpuidMaxval feature must be enabled.\r
52 If FALSE, then the LimitCpuidMaxval feature must be disabled.\r
53\r
54 @retval RETURN_SUCCESS LimitCpuidMaxval feature is initialized.\r
55\r
56 @note This service could be called by BSP only.\r
57**/\r
58RETURN_STATUS\r
59EFIAPI\r
60LimitCpuidMaxvalInitialize (\r
61 IN UINTN ProcessorNumber,\r
62 IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,\r
4ec586b9 63 IN VOID *ConfigData OPTIONAL,\r
80c4b236
JF
64 IN BOOLEAN State\r
65 )\r
66{\r
d28daadd
ED
67 //\r
68 // The scope of LimitCpuidMaxval bit in the MSR_IA32_MISC_ENABLE is core for below\r
69 // processor type, only program MSR_IA32_MISC_ENABLE for thread 0 in each core.\r
70 //\r
e2aaec4b 71 if (IS_PENTIUM_4_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
d28daadd
ED
72 IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
73 IS_GOLDMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
74 IS_CORE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
053e878b
MK
75 IS_CORE2_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel))\r
76 {\r
d28daadd
ED
77 if (CpuInfo->ProcessorInfo.Location.Thread != 0) {\r
78 return RETURN_SUCCESS;\r
79 }\r
80 }\r
81\r
80c4b236
JF
82 CPU_REGISTER_TABLE_WRITE_FIELD (\r
83 ProcessorNumber,\r
84 Msr,\r
85 MSR_IA32_MISC_ENABLE,\r
86 MSR_IA32_MISC_ENABLE_REGISTER,\r
87 Bits.LimitCpuidMaxval,\r
88 (State) ? 1 : 0\r
89 );\r
90 return RETURN_SUCCESS;\r
91}\r