]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/Ia32/WriteMsr64.c
MdePkg/Baseib: Filter/trace MSR access for IA32/X64
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / WriteMsr64.c
index badf1d8e5830b3103845e10db949ec4e7a715f38..ba0cf3f74c308229c2809ed29b55f52509344e97 100644 (file)
@@ -1,13 +1,13 @@
 /** @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
@@ -33,11 +33,19 @@ AsmWriteMsr64 (
   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