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