Handles in the cases when RDMSR causes a vm-exit.
22{
25
26
27
28
29
30
31
32
33
34
35
36 TargetMsr = GuestRegs->
rcx & 0xffffffff;
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 if ((TargetMsr <= 0x00001FFF) || ((0xC0000000 <= TargetMsr) && (TargetMsr <= 0xC0001FFF)) ||
56 {
57
58
59
60 switch (TargetMsr)
61 {
62 case IA32_SYSENTER_CS:
64 break;
65
66 case IA32_SYSENTER_ESP:
68 break;
69
70 case IA32_SYSENTER_EIP:
72 break;
73
74 case IA32_GS_BASE:
76 break;
77
78 case IA32_FS_BASE:
80 break;
81
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104 break;
105
106 default:
107
108
109
110
112 {
113
114
115
117 return;
118 }
119
120
121
122
123 Msr.
Flags = __readmsr(TargetMsr);
124
125
126
127
128 if (GuestRegs->
rcx == IA32_EFER)
129 {
130 IA32_EFER_REGISTER MsrEFER;
131 MsrEFER.AsUInt = Msr.
Flags;
132 MsrEFER.SyscallEnable =
TRUE;
133 Msr.
Flags = MsrEFER.AsUInt;
134 }
135
136 break;
137 }
138
141
144 }
145 else
146 {
147
148
149
151 return;
152 }
153}
#define NULL64_ZERO
Definition BasicTypes.h:52
unsigned int UINT32
Definition BasicTypes.h:48
int TestBit(int BitNumber, unsigned long *addr)
Check whether the bit is set or not.
Definition Bitwise.c:22
VOID EventInjectGeneralProtection()
Inject #GP to the guest (Event Injection)
Definition Events.c:62
UINT64 * g_MsrBitmapInvalidMsrs
Bitmap of MSRs that cause #GP.
Definition GlobalVariables.h:107
#define HV_X64_MSR_GUEST_IDLE
Definition HypervTlfs.h:232
UCHAR VmxVmread64P(size_t Field, UINT64 *FieldValue)
VMX VMREAD instruction (64-bit)
Definition Vmx.c:72
UINT64 rax
Definition BasicTypes.h:75
UINT64 rcx
Definition BasicTypes.h:76
UINT64 rdx
Definition BasicTypes.h:77
General MSR Structure.
Definition Msr.h:23
UINT64 Flags
Definition Msr.h:30
ULONG Low
Definition Msr.h:26
ULONG High
Definition Msr.h:27