ionescu007/SimpleVisor

General Protection Fault in ShvVmxLaunchOnVp

jtsylve opened this issue · 1 comments

I'm getting a general protection fault when starting the service.

1: kd> k
 # Child-SP          RetAddr           Call Site
00 ffffd001`1399b658 fffff803`71bd1afe nt!KeBugCheckEx
01 ffffd001`1399b660 fffff803`71b5a80d nt!KiFatalExceptionHandler+0x22
02 ffffd001`1399b6a0 fffff803`71a17139 nt!RtlpExecuteHandlerForException+0xd
03 ffffd001`1399b6d0 fffff803`71a155a8 nt!RtlDispatchException+0x429
04 ffffd001`1399bdd0 fffff803`71b5f3c2 nt!KiDispatchException+0x144
05 ffffd001`1399c4b0 fffff803`71b5d87d nt!KiExceptionDispatch+0xc2
06 ffffd001`1399c690 fffff801`046508e5 nt!KiGeneralProtectionFault+0xfd
07 ffffd001`1399c820 fffff801`04650c4e SimpleVisor!ShvVmxLaunchOnVp+0x21 [c:\users\joe\source\repos\simplevisor\shvvmx.c @ 379]
08 ffffd001`1399c850 fffff801`04650ca3 SimpleVisor!ShvVpInitialize+0xb2 [c:\users\joe\source\repos\simplevisor\shvvp.c @ 101]
09 ffffd001`1399c880 fffff803`71a806a0 SimpleVisor!ShvVpCallbackDpc+0x47 [c:\users\joe\source\repos\simplevisor\shvvp.c @ 161]
0a ffffd001`1399c8c0 fffff803`71a7fdb9 nt!KiExecuteAllDpcs+0x270
0b ffffd001`1399ca10 fffff803`71b5751a nt!KiRetireDpcList+0xe9
0c ffffd001`1399cc60 00000000`00000000 nt!KiIdleLoop+0x5a
1: kd> .frame 0n7;dv /t /v
07 ffffd001`1399c820 fffff801`04650c4e SimpleVisor!ShvVmxLaunchOnVp+0x21 [c:\users\joe\source\repos\simplevisor\shvvmx.c @ 379]
@rdi              struct _SHV_VP_DATA * VpData = 0xffffe000`1760a000
@r8d              unsigned long i = 0x11

The offending line of code seems to be the __readmsr below

    //
    // Initialize all the VMX-related MSRs by reading their value
    //
    for (i = 0; i < RTL_NUMBER_OF(VpData->MsrData); i++)
    {
        VpData->MsrData[i].QuadPart = __readmsr(MSR_IA32_VMX_BASIC + i);
    }

The issue here is that my processor is an Intel-Core-i7-2860QM and processors before Haswell don't have VMFUNC, so reading from MSR 0x491 causes the fault.