]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c
OvfmPkg/VmgExitLib: Properly decode MMIO MOVZX and MOVSX opcodes
[mirror_edk2.git] / OvmfPkg / Library / VmgExitLib / VmgExitVcHandler.c
index 24259060fd652460103698fbbe92205f03420a49..b716541ad170380c2d0869f23a1b990d471196fa 100644 (file)
@@ -643,6 +643,9 @@ ValidateMmioMemory (
   //\r
   // Any state other than unencrypted is an error, issue a #GP.\r
   //\r
+  DEBUG ((DEBUG_ERROR,\r
+    "MMIO using encrypted memory: %lx\n",\r
+    (UINT64) MemoryAddress));\r
   GpEvent.Uint64 = 0;\r
   GpEvent.Elements.Vector = GP_EXCEPTION;\r
   GpEvent.Elements.Type   = GHCB_EVENT_INJECTION_TYPE_EXCEPTION;\r
@@ -817,6 +820,7 @@ MmioExit (
     // fall through\r
     //\r
   case 0xB7:\r
+    DecodeModRm (Regs, InstructionData);\r
     Bytes = (Bytes != 0) ? Bytes : 2;\r
 \r
     Status = ValidateMmioMemory (Ghcb, InstructionData->Ext.RmData, Bytes);\r
@@ -835,7 +839,7 @@ MmioExit (
     }\r
 \r
     Register = GetRegisterPointer (Regs, InstructionData->Ext.ModRm.Reg);\r
-    SetMem (Register, InstructionData->DataSize, 0);\r
+    SetMem (Register, (UINTN) (1 << InstructionData->DataSize), 0);\r
     CopyMem (Register, Ghcb->SharedBuffer, Bytes);\r
     break;\r
 \r
@@ -848,6 +852,7 @@ MmioExit (
     // fall through\r
     //\r
   case 0xBF:\r
+    DecodeModRm (Regs, InstructionData);\r
     Bytes = (Bytes != 0) ? Bytes : 2;\r
 \r
     Status = ValidateMmioMemory (Ghcb, InstructionData->Ext.RmData, Bytes);\r
@@ -878,7 +883,7 @@ MmioExit (
     }\r
 \r
     Register = GetRegisterPointer (Regs, InstructionData->Ext.ModRm.Reg);\r
-    SetMem (Register, InstructionData->DataSize, SignByte);\r
+    SetMem (Register, (UINTN) (1 << InstructionData->DataSize), SignByte);\r
     CopyMem (Register, Ghcb->SharedBuffer, Bytes);\r
     break;\r
 \r