Fix multiple bugs, refactor InitializeMsrBitmaps

This commit is contained in:
Satoshi Tanda
2020-03-08 20:12:24 -07:00
parent d19ea35db2
commit b49a595b0a
6 changed files with 139 additions and 18 deletions

View File

@@ -996,6 +996,7 @@ SetupVmcs (
// Finally, place necessary data for hypervisor into the hypervisor stack.
//
ProcessorContext->HypervisorStack.u.Layout.Context.ProcessorNumber = GetCurrentProcessorNumber();
ProcessorContext->HypervisorStack.u.Layout.Context.SharedMsrBitmaps = &SharedProcessorContext->MsrBitmaps;
ProcessorContext->HypervisorStack.u.Layout.Context.SharedProcessorContext = SharedProcessorContext;
ProcessorContext->HypervisorStack.u.Layout.Context.EptContext = &ProcessorContext->EptContext;
ProcessorContext->HypervisorStack.u.Layout.Context.MemoryAccessContext = &ProcessorContext->MemoryAccessContext;
@@ -1178,14 +1179,28 @@ InitializeMsrBitmaps (
_Out_ MSR_BITMAPS* Bitmaps
)
{
static CONST UINT64 biosSignatureByteOffset = (IA32_BIOS_SIGN_ID / CHAR_BIT);
static CONST UINT64 biosSignatureBitMask = (1ull << (IA32_BIOS_SIGN_ID % CHAR_BIT));
typedef struct _INTERCEPT_MSR_REGISTRATION
{
IA32_MSR_ADDRESS Msr;
OPERATION_TYPE InterceptType;
} INTERCEPT_MSR_REGISTRATION;
static CONST INTERCEPT_MSR_REGISTRATION registrations[] =
{
{ IA32_BIOS_SIGN_ID, OperationRead, },
};
PAGED_CODE();
RtlZeroMemory(Bitmaps, sizeof(*Bitmaps));
Bitmaps->ReadBitmapLow[biosSignatureByteOffset] |= biosSignatureBitMask;
for (int i = 0; i < RTL_NUMBER_OF(registrations); ++i)
{
UpdateMsrBitmaps(Bitmaps,
registrations[i].Msr,
registrations[i].InterceptType,
TRUE);
}
}
/*!