diff options
-rw-r--r-- | shvvmxhv.c | 4 | ||||
-rw-r--r-- | shvvp.c | 9 |
2 files changed, 8 insertions, 5 deletions
@@ -270,14 +270,16 @@ ShvVmxEntryHandler ( // Did we hit the magic exit sequence, or should we resume back to the VM // context? // - if (guestContext.ExitVm) + if (guestContext.ExitVm != FALSE) { // // Return the VP Data structure in RAX:RBX which is going to be part of // the CPUID response that the caller (ShvVpUninitialize) expects back. + // Return confirmation in RCX that we are loaded // Context->Rax = (uintptr_t)vpData >> 32; Context->Rbx = (uintptr_t)vpData & 0xFFFFFFFF; + Context->Rcx = 0x43434343; // // Perform any OS-specific CPU uninitialization work @@ -172,12 +172,13 @@ ShvVpUnloadCallback ( __cpuidex(cpuInfo, 0x41414141, 0x42424242); // - // If SimpleVisor is disabled for some reason, CPUID won't return anything - // so don't free any memory. It will unfortunately end up leaked. + // If SimpleVisor is disabled for some reason, CPUID will return the values + // of the highest valid CPUID. We use a magic value to make sure we really + // are loaded and returned something valid. // - vpData = (PSHV_VP_DATA)((UINT64)cpuInfo[0] << 32 | (UINT32)cpuInfo[1]); - if (vpData != NULL) + if (cpuInfo[2] == 0x43434343) { + vpData = (PSHV_VP_DATA)((UINT64)cpuInfo[0] << 32 | (UINT32)cpuInfo[1]); ShvOsFreeContiguousAlignedMemory(vpData, sizeof(*vpData)); } } |