MCPcopy Create free account
hub / github.com/HoShiMin/Kernel-Bridge / DevirtualizeProcessor

Function DevirtualizeProcessor

Kernel-Bridge/API/Hypervisor.cpp:205–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203 }
204
205 static bool DevirtualizeProcessor(__out void*& PrivateVmData)
206 {
207 PrivateVmData = NULL;
208
209 // Trigger the #VMEXIT with the predefined arguments:
210 CPUID_REGS Regs = {};
211 __cpuid(Regs.Raw, CPUID_VMM_SHUTDOWN);
212 if (Regs.Regs.Ecx != CPUID_VMM_SHUTDOWN) return false; // Processor not virtualized!
213
214 // Processor is devirtualized now:
215 // Info.Eax -> PRIVATE_VM_DATA* Private LOW
216 // Info.Ebx -> Vmexit RIP
217 // Info.Ecx -> VMEXIT_SIGNATURE
218 // Info.Edx -> PRIVATE_VM_DATA* Private HIGH
219
220 PrivateVmData = reinterpret_cast<void*>(
221 (static_cast<UINT64>(Regs.Regs.Edx) << 32u) |
222 (static_cast<UINT64>(Regs.Regs.Eax))
223 );
224
225 return true;
226 }
227
228 static bool DevirtualizeAllProcessors()
229 {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected