HyperDbg Debugger
Loading...
Searching...
No Matches
CrossVmexits.c File Reference

The functions for passing vm-exits in vmx root. More...

#include "pch.h"

Functions

VOID VmxHandleXsetbv (VIRTUAL_MACHINE_STATE *VCpu)
 Handling XSETBV Instruction vm-exits.
VOID VmxHandleVmxPreemptionTimerVmexit (VIRTUAL_MACHINE_STATE *VCpu)
 Handling VMX Preemption Timer vm-exits.
VOID VmxHandleTripleFaults (VIRTUAL_MACHINE_STATE *VCpu)
 Handling triple fault VM-exits.

Detailed Description

The functions for passing vm-exits in vmx root.

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.1
Date
2020-06-14

Function Documentation

◆ VmxHandleTripleFaults()

VOID VmxHandleTripleFaults ( VIRTUAL_MACHINE_STATE * VCpu)

Handling triple fault VM-exits.

Parameters
VCpuThe virtual processor's state
Returns
VOID
71{
72 LogError("Err, triple fault error occurred!");
73
74 //
75 // This error cannot be recovered, produce debug results
76 //
78
79 //
80 // We won't further continue after this error
81 //
82 DbgBreakPoint();
83}
#define LogError(format,...)
Log in the case of error.
Definition HyperDbgHyperLogIntrinsics.h:113
VOID CommonWriteDebugInformation(VIRTUAL_MACHINE_STATE *VCpu)
Produce debug information from unrecoverable bugs.
Definition Common.c:149

◆ VmxHandleVmxPreemptionTimerVmexit()

VOID VmxHandleVmxPreemptionTimerVmexit ( VIRTUAL_MACHINE_STATE * VCpu)

Handling VMX Preemption Timer vm-exits.

Parameters
VCpuThe virtual processor's state
Returns
VOID
54{
55 LogError("Why vm-exit for VMX preemption timer happened?");
56
57 //
58 // Not increase the RIP by default
59 //
61}
VOID HvSuppressRipIncrement(VIRTUAL_MACHINE_STATE *VCpu)
Suppress the incrementation of RIP.
Definition Hv.c:320

◆ VmxHandleXsetbv()

VOID VmxHandleXsetbv ( VIRTUAL_MACHINE_STATE * VCpu)

Handling XSETBV Instruction vm-exits.

Parameters
VCpu
Returns
VOID
22{
23 CPUID_EAX_01 CpuidInfo;
25 UINT32 XCrIndex = VCpu->Regs->rcx & 0xffffffff;
26 XCR0 XCr0 = {.AsUInt = VCpu->Regs->rdx << 32 | VCpu->Regs->rax};
27 CR4 GuestCr4 = {.AsUInt = GetGuestCr4()};
28
29 if (XCrIndex != 0 || GuestCs.Attributes.DescriptorPrivilegeLevel != 0 || !CommonIsXCr0Valid(XCr0))
30 {
32 return;
33 }
34
35 CommonCpuidInstruction(CPUID_VERSION_INFORMATION, 0, (INT32 *)&CpuidInfo);
36
37 if (CpuidInfo.CpuidFeatureInformationEcx.XsaveXrstorInstruction == 0 || GuestCr4.OsXsave == 0)
38 {
40 return;
41 }
42
43 _xsetbv(XCrIndex, XCr0.AsUInt);
44}
VOID EventInjectUndefinedOpcode(VIRTUAL_MACHINE_STATE *VCpu)
Inject UD to the guest (Invalid Opcode - Undefined Opcode).
Definition Events.c:79
VOID EventInjectGeneralProtection()
Inject GP to the guest (Event Injection).
Definition Events.c:62
signed int INT32
Definition BasicTypes.h:50
unsigned int UINT32
Definition BasicTypes.h:54
struct _VMX_SEGMENT_SELECTOR VMX_SEGMENT_SELECTOR
Segment selector.
IMPORT_EXPORT_VMM UINT64 GetGuestCr4()
Get the Guest Cr4 value.
Definition ManageRegs.c:507
IMPORT_EXPORT_VMM VMX_SEGMENT_SELECTOR GetGuestCs()
Get the Guest Cs Selector.
Definition ManageRegs.c:49
BOOLEAN CommonIsXCr0Valid(XCR0 XCr0)
Check correctness of the XCR0 register value.
Definition Common.c:202
VOID CommonCpuidInstruction(UINT32 Func, UINT32 SubFunc, INT *CpuInfo)
Get cpuid results.
Definition Common.c:85
GUEST_REGS * Regs
Definition State.h:326
VMX_SEGMENT_ACCESS_RIGHTS_TYPE Attributes
Definition DataTypes.h:487
UINT64 rax
Definition BasicTypes.h:141
UINT64 rcx
Definition BasicTypes.h:142
UINT64 rdx
Definition BasicTypes.h:143
UINT32 DescriptorPrivilegeLevel
Definition DataTypes.h:442