DebugLib\r
BaseMemoryLib\r
\r
+[LibraryClasses.X64, LibraryClasses.IA32]\r
+ RegisterFilterLib\r
+\r
[Pcd]\r
gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength ## SOMETIMES_CONSUMES\r
gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength ## SOMETIMES_CONSUMES\r
GCC inline implementation of BaseLib processor specific functions that use\r
privlidged instructions.\r
\r
- Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>\r
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
\r
\r
#include "BaseLibInternals.h"\r
+#include <Library/RegisterFilterLib.h>\r
\r
/**\r
Enables CPU interrupts.\r
)\r
{\r
UINT64 Data;\r
-\r
- __asm__ __volatile__ (\r
- "rdmsr"\r
- : "=A" (Data) // %0\r
- : "c" (Index) // %1\r
- );\r
+ BOOLEAN Flag;\r
+\r
+ Flag = FilterBeforeMsrRead (Index, &Data);\r
+ if (Flag) {\r
+ __asm__ __volatile__ (\r
+ "rdmsr"\r
+ : "=A" (Data) // %0\r
+ : "c" (Index) // %1\r
+ );\r
+ }\r
+ FilterAfterMsrRead (Index, &Data);\r
\r
return Data;\r
}\r
IN UINT64 Value\r
)\r
{\r
- __asm__ __volatile__ (\r
- "wrmsr"\r
- :\r
- : "c" (Index),\r
- "A" (Value)\r
- );\r
+ BOOLEAN Flag;\r
+\r
+ Flag = FilterBeforeMsrWrite (Index, &Value);\r
+ if (Flag) {\r
+ __asm__ __volatile__ (\r
+ "wrmsr"\r
+ :\r
+ : "c" (Index),\r
+ "A" (Value)\r
+ );\r
+ }\r
+ FilterAfterMsrWrite (Index, &Value);\r
\r
return Value;\r
}\r
/** @file\r
AsmReadMsr64 function\r
\r
- Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
\r
-\r
+#include <Library/RegisterFilterLib.h>\r
\r
/**\r
Returns a 64-bit Machine Specific Register(MSR).\r
\r
**/\r
UINT64\r
-EFIAPI\r
-AsmReadMsr64 (\r
+AsmReadMsr64Internal (\r
IN UINT32 Index\r
)\r
{\r
}\r
}\r
\r
+/**\r
+ Returns a 64-bit Machine Specific Register(MSR).\r
+\r
+ Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r
+ performed on Index, and some Index values may cause CPU exceptions. The\r
+ caller must either guarantee that Index is valid, or the caller must set up\r
+ exception handlers to catch the exceptions. This function is only available\r
+ on IA-32 and x64.\r
+\r
+ @param Index The 32-bit MSR index to read.\r
+\r
+ @return The value of the MSR identified by Index.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadMsr64 (\r
+ IN UINT32 Index\r
+ )\r
+{\r
+ UINT64 Value;\r
+ BOOLEAN Flag;\r
+\r
+ Flag = FilterBeforeMsrRead (Index, &Value);\r
+ if (Flag) {\r
+ Value = AsmReadMsr64Internal (Index);\r
+ }\r
+ FilterAfterMsrRead (Index, &Value);\r
+\r
+ return Value;\r
+}\r
/** @file\r
AsmWriteMsr64 function\r
\r
- Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
\r
-\r
+#include <Library/RegisterFilterLib.h>\r
\r
/**\r
Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r
IN UINT64 Value\r
)\r
{\r
- _asm {\r
- mov edx, dword ptr [Value + 4]\r
- mov eax, dword ptr [Value + 0]\r
- mov ecx, Index\r
- wrmsr\r
+ BOOLEAN Flag;\r
+\r
+ Flag = FilterBeforeMsrWrite (Index, &Value);\r
+ if (Flag) {\r
+ _asm {\r
+ mov edx, dword ptr [Value + 4]\r
+ mov eax, dword ptr [Value + 0]\r
+ mov ecx, Index\r
+ wrmsr\r
+ }\r
}\r
+ FilterAfterMsrWrite (Index, &Value);\r
+\r
+ return Value;\r
}\r
\r
GCC inline implementation of BaseLib processor specific functions that use\r
privlidged instructions.\r
\r
- Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>\r
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
\r
\r
#include "BaseLibInternals.h"\r
+#include <Library/RegisterFilterLib.h>\r
\r
/**\r
Enables CPU interrupts.\r
{\r
UINT32 LowData;\r
UINT32 HighData;\r
-\r
- __asm__ __volatile__ (\r
- "rdmsr"\r
- : "=a" (LowData), // %0\r
- "=d" (HighData) // %1\r
- : "c" (Index) // %2\r
- );\r
+ UINT64 Value;\r
+ BOOLEAN Flag;\r
+\r
+ Flag = FilterBeforeMsrRead (Index, &Value);\r
+ if (Flag) {\r
+ __asm__ __volatile__ (\r
+ "rdmsr"\r
+ : "=a" (LowData), // %0\r
+ "=d" (HighData) // %1\r
+ : "c" (Index) // %2\r
+ );\r
+ Value = (((UINT64)HighData) << 32) | LowData;\r
+ }\r
+ FilterAfterMsrRead (Index, &Value);\r
\r
return (((UINT64)HighData) << 32) | LowData;\r
}\r
{\r
UINT32 LowData;\r
UINT32 HighData;\r
+ BOOLEAN Flag;\r
\r
LowData = (UINT32)(Value);\r
HighData = (UINT32)(Value >> 32);\r
\r
- __asm__ __volatile__ (\r
- "wrmsr"\r
- :\r
- : "c" (Index),\r
- "a" (LowData),\r
- "d" (HighData)\r
- );\r
+ Flag = FilterBeforeMsrWrite (Index, &Value);\r
+ if (Flag) {\r
+ __asm__ __volatile__ (\r
+ "wrmsr"\r
+ :\r
+ : "c" (Index),\r
+ "a" (LowData),\r
+ "d" (HighData)\r
+ );\r
+ }\r
+ FilterAfterMsrWrite (Index, &Value);\r
\r
return Value;\r
}\r
/** @file\r
CpuBreakpoint function.\r
\r
- Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.\r
**/\r
\r
+#include <Library/RegisterFilterLib.h>\r
+\r
unsigned __int64 __readmsr (int register);\r
\r
#pragma intrinsic(__readmsr)\r
IN UINT32 Index\r
)\r
{\r
- return __readmsr (Index);\r
+ UINT64 Value;\r
+ BOOLEAN Flag;\r
+\r
+ Flag = FilterBeforeMsrRead (Index, &Value);\r
+ if (Flag) {\r
+ Value = __readmsr (Index);\r
+ }\r
+ FilterAfterMsrRead (Index, &Value);\r
+\r
+ return Value;\r
}\r
\r
/** @file\r
CpuBreakpoint function.\r
\r
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.\r
**/\r
\r
+#include <Library/RegisterFilterLib.h>\r
+\r
void __writemsr (unsigned long Register, unsigned __int64 Value);\r
\r
#pragma intrinsic(__writemsr)\r
IN UINT64 Value\r
)\r
{\r
- __writemsr (Index, Value);\r
+ BOOLEAN Flag;\r
+\r
+ Flag = FilterBeforeMsrWrite (Index, &Value);\r
+ if (Flag) {\r
+ __writemsr (Index, Value);\r
+ }\r
+ FilterAfterMsrWrite (Index, &Value);\r
+\r
return Value;\r
}\r
\r