} SEV_ES_PER_CPU_DATA;\r
\r
\r
-/**\r
- Checks the GHCB to determine if the specified register has been marked valid.\r
-\r
- The ValidBitmap area represents the areas of the GHCB that have been marked\r
- valid. Return an indication of whether the area of the GHCB that holds the\r
- specified register has been marked valid.\r
-\r
- @param[in] Ghcb Pointer to the Guest-Hypervisor Communication Block\r
- @param[in] Reg Offset in the GHCB of the register to check\r
-\r
- @retval TRUE Register has been marked vald in the GHCB\r
- @retval FALSE Register has not been marked valid in the GHCB\r
-\r
-**/\r
-STATIC\r
-BOOLEAN\r
-GhcbIsRegValid (\r
- IN GHCB *Ghcb,\r
- IN GHCB_REGISTER Reg\r
- )\r
-{\r
- UINT32 RegIndex;\r
- UINT32 RegBit;\r
-\r
- RegIndex = Reg / 8;\r
- RegBit = Reg & 0x07;\r
-\r
- return ((Ghcb->SaveArea.ValidBitmap[RegIndex] & (1 << RegBit)) != 0);\r
-}\r
-\r
-/**\r
- Marks a register as valid in the GHCB.\r
-\r
- The ValidBitmap area represents the areas of the GHCB that have been marked\r
- valid. Set the area of the GHCB that holds the specified register as valid.\r
-\r
- @param[in, out] Ghcb Pointer to the Guest-Hypervisor Communication Block\r
- @param[in] Reg Offset in the GHCB of the register to mark valid\r
-\r
-**/\r
-STATIC\r
-VOID\r
-GhcbSetRegValid (\r
- IN OUT GHCB *Ghcb,\r
- IN GHCB_REGISTER Reg\r
- )\r
-{\r
- UINT32 RegIndex;\r
- UINT32 RegBit;\r
-\r
- RegIndex = Reg / 8;\r
- RegBit = Reg & 0x07;\r
-\r
- Ghcb->SaveArea.ValidBitmap[RegIndex] |= (1 << RegBit);\r
-}\r
-\r
/**\r
Return a pointer to the contents of the specified register.\r
\r
DecodeModRm (Regs, InstructionData);\r
\r
Ghcb->SaveArea.Rax = Regs->Rax;\r
- GhcbSetRegValid (Ghcb, GhcbRax);\r
+ VmgSetOffsetValid (Ghcb, GhcbRax);\r
Ghcb->SaveArea.Rcx = Regs->Rcx;\r
- GhcbSetRegValid (Ghcb, GhcbRcx);\r
+ VmgSetOffsetValid (Ghcb, GhcbRcx);\r
\r
return VmgExit (Ghcb, SVM_EXIT_MWAIT, 0, 0);\r
}\r
DecodeModRm (Regs, InstructionData);\r
\r
Ghcb->SaveArea.Rax = Regs->Rax; // Identity mapped, so VA = PA\r
- GhcbSetRegValid (Ghcb, GhcbRax);\r
+ VmgSetOffsetValid (Ghcb, GhcbRax);\r
Ghcb->SaveArea.Rcx = Regs->Rcx;\r
- GhcbSetRegValid (Ghcb, GhcbRcx);\r
+ VmgSetOffsetValid (Ghcb, GhcbRcx);\r
Ghcb->SaveArea.Rdx = Regs->Rdx;\r
- GhcbSetRegValid (Ghcb, GhcbRdx);\r
+ VmgSetOffsetValid (Ghcb, GhcbRdx);\r
\r
return VmgExit (Ghcb, SVM_EXIT_MONITOR, 0, 0);\r
}\r
return Status;\r
}\r
\r
- if (!GhcbIsRegValid (Ghcb, GhcbRax) ||\r
- !GhcbIsRegValid (Ghcb, GhcbRcx) ||\r
- !GhcbIsRegValid (Ghcb, GhcbRdx)) {\r
+ if (!VmgIsOffsetValid (Ghcb, GhcbRax) ||\r
+ !VmgIsOffsetValid (Ghcb, GhcbRcx) ||\r
+ !VmgIsOffsetValid (Ghcb, GhcbRdx)) {\r
return UnsupportedExit (Ghcb, Regs, InstructionData);\r
}\r
Regs->Rax = Ghcb->SaveArea.Rax;\r
DecodeModRm (Regs, InstructionData);\r
\r
Ghcb->SaveArea.Rax = Regs->Rax;\r
- GhcbSetRegValid (Ghcb, GhcbRax);\r
+ VmgSetOffsetValid (Ghcb, GhcbRax);\r
Ghcb->SaveArea.Cpl = (UINT8) (Regs->Cs & 0x3);\r
- GhcbSetRegValid (Ghcb, GhcbCpl);\r
+ VmgSetOffsetValid (Ghcb, GhcbCpl);\r
\r
Status = VmgExit (Ghcb, SVM_EXIT_VMMCALL, 0, 0);\r
if (Status != 0) {\r
return Status;\r
}\r
\r
- if (!GhcbIsRegValid (Ghcb, GhcbRax)) {\r
+ if (!VmgIsOffsetValid (Ghcb, GhcbRax)) {\r
return UnsupportedExit (Ghcb, Regs, InstructionData);\r
}\r
Regs->Rax = Ghcb->SaveArea.Rax;\r
case 0x30: // WRMSR\r
ExitInfo1 = 1;\r
Ghcb->SaveArea.Rax = Regs->Rax;\r
- GhcbSetRegValid (Ghcb, GhcbRax);\r
+ VmgSetOffsetValid (Ghcb, GhcbRax);\r
Ghcb->SaveArea.Rdx = Regs->Rdx;\r
- GhcbSetRegValid (Ghcb, GhcbRdx);\r
+ VmgSetOffsetValid (Ghcb, GhcbRdx);\r
//\r
// fall through\r
//\r
case 0x32: // RDMSR\r
Ghcb->SaveArea.Rcx = Regs->Rcx;\r
- GhcbSetRegValid (Ghcb, GhcbRcx);\r
+ VmgSetOffsetValid (Ghcb, GhcbRcx);\r
break;\r
default:\r
return UnsupportedExit (Ghcb, Regs, InstructionData);\r
}\r
\r
if (ExitInfo1 == 0) {\r
- if (!GhcbIsRegValid (Ghcb, GhcbRax) ||\r
- !GhcbIsRegValid (Ghcb, GhcbRdx)) {\r
+ if (!VmgIsOffsetValid (Ghcb, GhcbRax) ||\r
+ !VmgIsOffsetValid (Ghcb, GhcbRdx)) {\r
return UnsupportedExit (Ghcb, Regs, InstructionData);\r
}\r
Regs->Rax = Ghcb->SaveArea.Rax;\r
} else {\r
CopyMem (&Ghcb->SaveArea.Rax, &Regs->Rax, IOIO_DATA_BYTES (ExitInfo1));\r
}\r
- GhcbSetRegValid (Ghcb, GhcbRax);\r
+ VmgSetOffsetValid (Ghcb, GhcbRax);\r
\r
Status = VmgExit (Ghcb, SVM_EXIT_IOIO_PROT, ExitInfo1, 0);\r
if (Status != 0) {\r
}\r
\r
if ((ExitInfo1 & IOIO_TYPE_IN) != 0) {\r
- if (!GhcbIsRegValid (Ghcb, GhcbRax)) {\r
+ if (!VmgIsOffsetValid (Ghcb, GhcbRax)) {\r
return UnsupportedExit (Ghcb, Regs, InstructionData);\r
}\r
CopyMem (&Regs->Rax, &Ghcb->SaveArea.Rax, IOIO_DATA_BYTES (ExitInfo1));\r
UINT64 Status;\r
\r
Ghcb->SaveArea.Rax = Regs->Rax;\r
- GhcbSetRegValid (Ghcb, GhcbRax);\r
+ VmgSetOffsetValid (Ghcb, GhcbRax);\r
Ghcb->SaveArea.Rcx = Regs->Rcx;\r
- GhcbSetRegValid (Ghcb, GhcbRcx);\r
+ VmgSetOffsetValid (Ghcb, GhcbRcx);\r
if (Regs->Rax == CPUID_EXTENDED_STATE) {\r
IA32_CR4 Cr4;\r
\r
Cr4.UintN = AsmReadCr4 ();\r
Ghcb->SaveArea.XCr0 = (Cr4.Bits.OSXSAVE == 1) ? AsmXGetBv (0) : 1;\r
- GhcbSetRegValid (Ghcb, GhcbXCr0);\r
+ VmgSetOffsetValid (Ghcb, GhcbXCr0);\r
}\r
\r
Status = VmgExit (Ghcb, SVM_EXIT_CPUID, 0, 0);\r
return Status;\r
}\r
\r
- if (!GhcbIsRegValid (Ghcb, GhcbRax) ||\r
- !GhcbIsRegValid (Ghcb, GhcbRbx) ||\r
- !GhcbIsRegValid (Ghcb, GhcbRcx) ||\r
- !GhcbIsRegValid (Ghcb, GhcbRdx)) {\r
+ if (!VmgIsOffsetValid (Ghcb, GhcbRax) ||\r
+ !VmgIsOffsetValid (Ghcb, GhcbRbx) ||\r
+ !VmgIsOffsetValid (Ghcb, GhcbRcx) ||\r
+ !VmgIsOffsetValid (Ghcb, GhcbRdx)) {\r
return UnsupportedExit (Ghcb, Regs, InstructionData);\r
}\r
Regs->Rax = Ghcb->SaveArea.Rax;\r
UINT64 Status;\r
\r
Ghcb->SaveArea.Rcx = Regs->Rcx;\r
- GhcbSetRegValid (Ghcb, GhcbRcx);\r
+ VmgSetOffsetValid (Ghcb, GhcbRcx);\r
\r
Status = VmgExit (Ghcb, SVM_EXIT_RDPMC, 0, 0);\r
if (Status != 0) {\r
return Status;\r
}\r
\r
- if (!GhcbIsRegValid (Ghcb, GhcbRax) ||\r
- !GhcbIsRegValid (Ghcb, GhcbRdx)) {\r
+ if (!VmgIsOffsetValid (Ghcb, GhcbRax) ||\r
+ !VmgIsOffsetValid (Ghcb, GhcbRdx)) {\r
return UnsupportedExit (Ghcb, Regs, InstructionData);\r
}\r
Regs->Rax = Ghcb->SaveArea.Rax;\r
return Status;\r
}\r
\r
- if (!GhcbIsRegValid (Ghcb, GhcbRax) ||\r
- !GhcbIsRegValid (Ghcb, GhcbRdx)) {\r
+ if (!VmgIsOffsetValid (Ghcb, GhcbRax) ||\r
+ !VmgIsOffsetValid (Ghcb, GhcbRdx)) {\r
return UnsupportedExit (Ghcb, Regs, InstructionData);\r
}\r
Regs->Rax = Ghcb->SaveArea.Rax;\r
// Using a value of 0 for ExitInfo1 means RAX holds the value\r
//\r
Ghcb->SaveArea.Rax = *Register;\r
- GhcbSetRegValid (Ghcb, GhcbRax);\r
+ VmgSetOffsetValid (Ghcb, GhcbRax);\r
\r
Status = VmgExit (Ghcb, SVM_EXIT_DR7_WRITE, 0, 0);\r
if (Status != 0) {\r