2 Protected Processor Inventory Number(PPIN) feature.
4 Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "CpuCommonFeatures.h"
12 Prepares for the data used by CPU feature detection and initialization.
14 @param[in] NumberOfProcessors The number of CPUs in the platform.
16 @return Pointer to a buffer of CPU related configuration data.
18 @note This service could be called by BSP only.
23 IN UINTN NumberOfProcessors
28 ConfigData
= AllocateZeroPool (sizeof (MSR_IVY_BRIDGE_PPIN_CTL_REGISTER
) * NumberOfProcessors
);
29 ASSERT (ConfigData
!= NULL
);
34 Detects if Protected Processor Inventory Number feature supported on current
37 @param[in] ProcessorNumber The index of the CPU executing this function.
38 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
39 structure for the CPU executing this function.
40 @param[in] ConfigData A pointer to the configuration buffer returned
41 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
42 CPU_FEATURE_GET_CONFIG_DATA was not provided in
45 @retval TRUE Protected Processor Inventory Number feature is supported.
46 @retval FALSE Protected Processor Inventory Number feature is not supported.
48 @note This service could be called by BSP/APs.
53 IN UINTN ProcessorNumber
,
54 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
55 IN VOID
*ConfigData OPTIONAL
58 MSR_IVY_BRIDGE_PLATFORM_INFO_1_REGISTER PlatformInfo
;
59 MSR_IVY_BRIDGE_PPIN_CTL_REGISTER
*MsrPpinCtrl
;
61 if ((CpuInfo
->DisplayFamily
== 0x06) &&
62 ((CpuInfo
->DisplayModel
== 0x3E) || // Xeon E5 V2
63 (CpuInfo
->DisplayModel
== 0x56) || // Xeon Processor D Product
64 (CpuInfo
->DisplayModel
== 0x4F) || // Xeon E5 v4, E7 v4
65 (CpuInfo
->DisplayModel
== 0x55) || // Xeon Processor Scalable
66 (CpuInfo
->DisplayModel
== 0x57) || // Xeon Phi processor 3200, 5200, 7200 series.
67 (CpuInfo
->DisplayModel
== 0x85) // Future Xeon phi processor
70 // Check whether platform support this feature.
72 PlatformInfo
.Uint64
= AsmReadMsr64 (MSR_IVY_BRIDGE_PLATFORM_INFO_1
);
73 if (PlatformInfo
.Bits
.PPIN_CAP
!= 0) {
74 MsrPpinCtrl
= (MSR_IVY_BRIDGE_PPIN_CTL_REGISTER
*) ConfigData
;
75 ASSERT (MsrPpinCtrl
!= NULL
);
76 MsrPpinCtrl
[ProcessorNumber
].Uint64
= AsmReadMsr64 (MSR_IVY_BRIDGE_PPIN_CTL
);
85 Initializes Protected Processor Inventory Number feature to specific state.
87 @param[in] ProcessorNumber The index of the CPU executing this function.
88 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
89 structure for the CPU executing this function.
90 @param[in] ConfigData A pointer to the configuration buffer returned
91 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
92 CPU_FEATURE_GET_CONFIG_DATA was not provided in
94 @param[in] State If TRUE, then the Protected Processor Inventory
95 Number feature must be enabled.
96 If FALSE, then the Protected Processor Inventory
97 Number feature must be disabled.
99 @retval RETURN_SUCCESS Protected Processor Inventory Number feature is
101 @retval RETURN_DEVICE_ERROR Device can't change state because it has been
104 @note This service could be called by BSP only.
109 IN UINTN ProcessorNumber
,
110 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
111 IN VOID
*ConfigData
, OPTIONAL
115 MSR_IVY_BRIDGE_PPIN_CTL_REGISTER
*MsrPpinCtrl
;
117 MsrPpinCtrl
= (MSR_IVY_BRIDGE_PPIN_CTL_REGISTER
*) ConfigData
;
118 ASSERT (MsrPpinCtrl
!= NULL
);
121 // Check whether processor already lock this register.
122 // If already locked, just based on the request state and
123 // the current state to return the status.
125 if (MsrPpinCtrl
[ProcessorNumber
].Bits
.LockOut
!= 0) {
126 return MsrPpinCtrl
[ProcessorNumber
].Bits
.Enable_PPIN
== State
? RETURN_SUCCESS
: RETURN_DEVICE_ERROR
;
130 // Support function already check the processor which support PPIN feature, so this function not need
131 // to check the processor again.
133 // The scope of the MSR_IVY_BRIDGE_PPIN_CTL is package level, only program MSR_IVY_BRIDGE_PPIN_CTL for
134 // thread 0 core 0 in each package.
136 if ((CpuInfo
->ProcessorInfo
.Location
.Thread
!= 0) || (CpuInfo
->ProcessorInfo
.Location
.Core
!= 0)) {
137 return RETURN_SUCCESS
;
142 // Enable and Unlock.
143 // According to SDM, once Enable_PPIN is set, attempt to write 1 to LockOut will cause #GP.
145 MsrPpinCtrl
[ProcessorNumber
].Bits
.Enable_PPIN
= 1;
146 MsrPpinCtrl
[ProcessorNumber
].Bits
.LockOut
= 0;
150 // According to SDM, writing 1 to LockOut is permitted only if Enable_PPIN is clear.
152 MsrPpinCtrl
[ProcessorNumber
].Bits
.Enable_PPIN
= 0;
153 MsrPpinCtrl
[ProcessorNumber
].Bits
.LockOut
= 1;
156 CPU_REGISTER_TABLE_WRITE64 (
159 MSR_IVY_BRIDGE_PPIN_CTL
,
160 MsrPpinCtrl
[ProcessorNumber
].Uint64
163 return RETURN_SUCCESS
;