In my driver for Windows 7 64 bits, I tried to use KeSaveExtendedProcessorState/KeRestoreExtendedProcessorState to save and restore extended processor states.
I used RtlGetEnabledExtendedFeatures((ULONG64)(-1)) to get the enabled extended features (the returned value is 0x3 in one of my target system with Intel i7 dual core CPU, and use it as the first parameter for KeSaveExtendedProcessorState, and I used MmAllocateContiguousMemory(sizeof(XSTATE_SAVE), highAddress) with highAddress = 0xbfffffff to allocate the nonpaged memory used to save the extended states, and raised IRQL to DISPATCH_LEVEL before KeSaveExtendedProcessorState. I got BSOD with following message:
0: kd> !analyze -v
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************
INVALID_EXTENDED_PROCESSOR_STATE (131)
Invalid combination of parameters was detected while saving or restoring
extended processor state.
Arguments:
Arg1: 0000000000000000, Invalid feature mask was passed or extended processor state is
not enabled.
Arg2: 0000000000800000, Nonzero if extended state is enabled.
Arg3: 0000000000000003, The low 32 bits of the feature mask.
Arg4: 0000000000000000, The high 32 bits of the feature mask.
Did I miss anything?
Also, I noticed that (sizeof(XSTATE_SAVE)) is 0x38 bytes, it is apparently far too small to save the enabled exteand features, should I intitialize any components of the XSTATE_SAVE structures to pass additional memory space to save the enabled extended features? Is there any sample code or documentation to demo how to properly use KeSaveExtendedProcessorState ? In my driver, I alreay specify this code to run on thread 2 only.
Thanks.
Regards,
David
Link Copied
For more complete information about compiler optimizations, see our Optimization Notice.