UefiCpuPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the UefiCpuPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
91415a36ae
commit
053e878bfb
File diff suppressed because it is too large
Load Diff
@@ -38,15 +38,15 @@ EFI_SMM_CPU_SERVICE_PROTOCOL mSmmCpuService = {
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmGetProcessorInfo (
|
||||
IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber,
|
||||
OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
|
||||
IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber,
|
||||
OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Check parameter
|
||||
//
|
||||
if (ProcessorNumber >= mMaxNumberOfCpus || ProcessorInfoBuffer == NULL) {
|
||||
if ((ProcessorNumber >= mMaxNumberOfCpus) || (ProcessorInfoBuffer == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ SmmGetProcessorInfo (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmSwitchBsp (
|
||||
IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber
|
||||
IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -90,8 +90,9 @@ SmmSwitchBsp (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (gSmmCpuPrivate->Operation[ProcessorNumber] != SmmCpuNone ||
|
||||
gSmst->CurrentlyExecutingCpu == ProcessorNumber) {
|
||||
if ((gSmmCpuPrivate->Operation[ProcessorNumber] != SmmCpuNone) ||
|
||||
(gSmst->CurrentlyExecutingCpu == ProcessorNumber))
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -132,7 +133,7 @@ SmmAddProcessor (
|
||||
//
|
||||
// Check parameter
|
||||
//
|
||||
if (ProcessorNumber == NULL || ProcessorId == INVALID_APIC_ID) {
|
||||
if ((ProcessorNumber == NULL) || (ProcessorId == INVALID_APIC_ID)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -151,10 +152,11 @@ SmmAddProcessor (
|
||||
// of the APIC ID to SMBASE.
|
||||
//
|
||||
for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
|
||||
if (mCpuHotPlugData.ApicId[Index] == ProcessorId &&
|
||||
gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId == INVALID_APIC_ID) {
|
||||
if ((mCpuHotPlugData.ApicId[Index] == ProcessorId) &&
|
||||
(gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId == INVALID_APIC_ID))
|
||||
{
|
||||
gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId = ProcessorId;
|
||||
gSmmCpuPrivate->ProcessorInfo[Index].StatusFlag = 0;
|
||||
gSmmCpuPrivate->ProcessorInfo[Index].StatusFlag = 0;
|
||||
GetProcessorLocationByApicId (
|
||||
(UINT32)ProcessorId,
|
||||
&gSmmCpuPrivate->ProcessorInfo[Index].Location.Package,
|
||||
@@ -162,7 +164,7 @@ SmmAddProcessor (
|
||||
&gSmmCpuPrivate->ProcessorInfo[Index].Location.Thread
|
||||
);
|
||||
|
||||
*ProcessorNumber = Index;
|
||||
*ProcessorNumber = Index;
|
||||
gSmmCpuPrivate->Operation[Index] = SmmCpuAdd;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -197,8 +199,9 @@ SmmRemoveProcessor (
|
||||
//
|
||||
// Check parameter
|
||||
//
|
||||
if (ProcessorNumber >= mMaxNumberOfCpus ||
|
||||
gSmmCpuPrivate->ProcessorInfo[ProcessorNumber].ProcessorId == INVALID_APIC_ID) {
|
||||
if ((ProcessorNumber >= mMaxNumberOfCpus) ||
|
||||
(gSmmCpuPrivate->ProcessorInfo[ProcessorNumber].ProcessorId == INVALID_APIC_ID))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -214,7 +217,7 @@ SmmRemoveProcessor (
|
||||
}
|
||||
|
||||
gSmmCpuPrivate->ProcessorInfo[ProcessorNumber].ProcessorId = INVALID_APIC_ID;
|
||||
mCpuHotPlugData.ApicId[ProcessorNumber] = INVALID_APIC_ID;
|
||||
mCpuHotPlugData.ApicId[ProcessorNumber] = INVALID_APIC_ID;
|
||||
|
||||
//
|
||||
// Removal of the processor from the CPU list is pending until all SMI handlers are finished
|
||||
@@ -237,12 +240,12 @@ SmmRemoveProcessor (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmWhoAmI (
|
||||
IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
|
||||
OUT UINTN *ProcessorNumber
|
||||
IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
|
||||
OUT UINTN *ProcessorNumber
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINT64 ApicId;
|
||||
UINTN Index;
|
||||
UINT64 ApicId;
|
||||
|
||||
//
|
||||
// Check parameter
|
||||
@@ -259,6 +262,7 @@ SmmWhoAmI (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// This should not happen
|
||||
//
|
||||
@@ -276,15 +280,15 @@ SmmCpuUpdate (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Handle pending BSP switch operations
|
||||
//
|
||||
for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
|
||||
if (gSmmCpuPrivate->Operation[Index] == SmmCpuSwitchBsp) {
|
||||
gSmmCpuPrivate->Operation[Index] = SmmCpuNone;
|
||||
mSmmMpSyncData->SwitchBsp = TRUE;
|
||||
gSmmCpuPrivate->Operation[Index] = SmmCpuNone;
|
||||
mSmmMpSyncData->SwitchBsp = TRUE;
|
||||
mSmmMpSyncData->CandidateBsp[Index] = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -330,10 +334,10 @@ SmmCpuUpdate (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmRegisterExceptionHandler (
|
||||
IN EFI_SMM_CPU_SERVICE_PROTOCOL *This,
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
|
||||
)
|
||||
IN EFI_SMM_CPU_SERVICE_PROTOCOL *This,
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
|
||||
)
|
||||
{
|
||||
return RegisterCpuInterruptHandler (ExceptionType, InterruptHandler);
|
||||
}
|
||||
@@ -352,7 +356,7 @@ InitializeSmmCpuServices (
|
||||
IN EFI_HANDLE Handle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gSmst->SmmInstallProtocolInterface (
|
||||
&Handle,
|
||||
@@ -363,4 +367,3 @@ InitializeSmmCpuServices (
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@@ -38,9 +38,9 @@ typedef enum {
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmGetProcessorInfo (
|
||||
IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber,
|
||||
OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
|
||||
IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber,
|
||||
OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -57,8 +57,8 @@ SmmGetProcessorInfo (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmSwitchBsp (
|
||||
IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber
|
||||
IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -115,8 +115,8 @@ SmmRemoveProcessor (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmWhoAmI (
|
||||
IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
|
||||
OUT UINTN *ProcessorNumber
|
||||
IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
|
||||
OUT UINTN *ProcessorNumber
|
||||
);
|
||||
|
||||
/**
|
||||
|
@@ -36,13 +36,13 @@ EnableCet (
|
||||
**/
|
||||
VOID
|
||||
GetPageTable (
|
||||
OUT UINTN *Base,
|
||||
OUT BOOLEAN *FiveLevels OPTIONAL
|
||||
OUT UINTN *Base,
|
||||
OUT BOOLEAN *FiveLevels OPTIONAL
|
||||
)
|
||||
{
|
||||
*Base = ((mInternalCr3 == 0) ?
|
||||
(AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64) :
|
||||
mInternalCr3);
|
||||
(AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64) :
|
||||
mInternalCr3);
|
||||
if (FiveLevels != NULL) {
|
||||
*FiveLevels = FALSE;
|
||||
}
|
||||
@@ -59,9 +59,9 @@ SmmInitPageTable (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN PageFaultHandlerHookAddress;
|
||||
IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
|
||||
EFI_STATUS Status;
|
||||
UINTN PageFaultHandlerHookAddress;
|
||||
IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Initialize spin lock
|
||||
@@ -72,18 +72,19 @@ SmmInitPageTable (
|
||||
|
||||
if (FeaturePcdGet (PcdCpuSmmProfileEnable) ||
|
||||
HEAP_GUARD_NONSTOP_MODE ||
|
||||
NULL_DETECTION_NONSTOP_MODE) {
|
||||
NULL_DETECTION_NONSTOP_MODE)
|
||||
{
|
||||
//
|
||||
// Set own Page Fault entry instead of the default one, because SMM Profile
|
||||
// feature depends on IRET instruction to do Single Step
|
||||
//
|
||||
PageFaultHandlerHookAddress = (UINTN)PageFaultIdtHandlerSmmProfile;
|
||||
IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *) gcSmiIdtr.Base;
|
||||
IdtEntry += EXCEPT_IA32_PAGE_FAULT;
|
||||
IdtEntry->Bits.OffsetLow = (UINT16)PageFaultHandlerHookAddress;
|
||||
IdtEntry->Bits.Reserved_0 = 0;
|
||||
IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32;
|
||||
IdtEntry->Bits.OffsetHigh = (UINT16)(PageFaultHandlerHookAddress >> 16);
|
||||
IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *)gcSmiIdtr.Base;
|
||||
IdtEntry += EXCEPT_IA32_PAGE_FAULT;
|
||||
IdtEntry->Bits.OffsetLow = (UINT16)PageFaultHandlerHookAddress;
|
||||
IdtEntry->Bits.Reserved_0 = 0;
|
||||
IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32;
|
||||
IdtEntry->Bits.OffsetHigh = (UINT16)(PageFaultHandlerHookAddress >> 16);
|
||||
} else {
|
||||
//
|
||||
// Register SMM Page Fault Handler
|
||||
@@ -98,6 +99,7 @@ SmmInitPageTable (
|
||||
if (FeaturePcdGet (PcdCpuSmmStackGuard)) {
|
||||
InitializeIDTSmmStackGuard ();
|
||||
}
|
||||
|
||||
return Gen4GPageTable (TRUE);
|
||||
}
|
||||
|
||||
@@ -124,13 +126,13 @@ SmiDefaultPFHandler (
|
||||
VOID
|
||||
EFIAPI
|
||||
SmiPFHandler (
|
||||
IN EFI_EXCEPTION_TYPE InterruptType,
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||
IN EFI_EXCEPTION_TYPE InterruptType,
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
{
|
||||
UINTN PFAddress;
|
||||
UINTN GuardPageAddress;
|
||||
UINTN CpuIndex;
|
||||
UINTN PFAddress;
|
||||
UINTN GuardPageAddress;
|
||||
UINTN CpuIndex;
|
||||
|
||||
ASSERT (InterruptType == EXCEPT_IA32_PAGE_FAULT);
|
||||
|
||||
@@ -143,25 +145,27 @@ SmiPFHandler (
|
||||
// or SMM page protection violation.
|
||||
//
|
||||
if ((PFAddress >= mCpuHotPlugData.SmrrBase) &&
|
||||
(PFAddress < (mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize))) {
|
||||
(PFAddress < (mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize)))
|
||||
{
|
||||
DumpCpuContext (InterruptType, SystemContext);
|
||||
CpuIndex = GetCpuIndex ();
|
||||
CpuIndex = GetCpuIndex ();
|
||||
GuardPageAddress = (mSmmStackArrayBase + EFI_PAGE_SIZE + CpuIndex * mSmmStackSize);
|
||||
if ((FeaturePcdGet (PcdCpuSmmStackGuard)) &&
|
||||
(PFAddress >= GuardPageAddress) &&
|
||||
(PFAddress < (GuardPageAddress + EFI_PAGE_SIZE))) {
|
||||
(PFAddress < (GuardPageAddress + EFI_PAGE_SIZE)))
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, "SMM stack overflow!\n"));
|
||||
} else {
|
||||
if ((SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_ID) != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "SMM exception at execution (0x%x)\n", PFAddress));
|
||||
DEBUG_CODE (
|
||||
DumpModuleInfoByIp (*(UINTN *)(UINTN)SystemContext.SystemContextIa32->Esp);
|
||||
);
|
||||
);
|
||||
} else {
|
||||
DEBUG ((DEBUG_ERROR, "SMM exception at access (0x%x)\n", PFAddress));
|
||||
DEBUG_CODE (
|
||||
DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextIa32->Eip);
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
if (HEAP_GUARD_NONSTOP_MODE) {
|
||||
@@ -169,6 +173,7 @@ SmiPFHandler (
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
|
||||
CpuDeadLoop ();
|
||||
goto Exit;
|
||||
}
|
||||
@@ -177,13 +182,14 @@ SmiPFHandler (
|
||||
// If a page fault occurs in non-SMRAM range.
|
||||
//
|
||||
if ((PFAddress < mCpuHotPlugData.SmrrBase) ||
|
||||
(PFAddress >= mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize)) {
|
||||
(PFAddress >= mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize))
|
||||
{
|
||||
if ((SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_ID) != 0) {
|
||||
DumpCpuContext (InterruptType, SystemContext);
|
||||
DEBUG ((DEBUG_ERROR, "Code executed on IP(0x%x) out of SMM range after SMM is locked!\n", PFAddress));
|
||||
DEBUG_CODE (
|
||||
DumpModuleInfoByIp (*(UINTN *)(UINTN)SystemContext.SystemContextIa32->Esp);
|
||||
);
|
||||
);
|
||||
CpuDeadLoop ();
|
||||
goto Exit;
|
||||
}
|
||||
@@ -191,13 +197,14 @@ SmiPFHandler (
|
||||
//
|
||||
// If NULL pointer was just accessed
|
||||
//
|
||||
if ((PcdGet8 (PcdNullPointerDetectionPropertyMask) & BIT1) != 0 &&
|
||||
(PFAddress < EFI_PAGE_SIZE)) {
|
||||
if (((PcdGet8 (PcdNullPointerDetectionPropertyMask) & BIT1) != 0) &&
|
||||
(PFAddress < EFI_PAGE_SIZE))
|
||||
{
|
||||
DumpCpuContext (InterruptType, SystemContext);
|
||||
DEBUG ((DEBUG_ERROR, "!!! NULL pointer access !!!\n"));
|
||||
DEBUG_CODE (
|
||||
DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextIa32->Eip);
|
||||
);
|
||||
);
|
||||
|
||||
if (NULL_DETECTION_NONSTOP_MODE) {
|
||||
GuardPagePFHandler (SystemContext.SystemContextIa32->ExceptionData);
|
||||
@@ -213,7 +220,7 @@ SmiPFHandler (
|
||||
DEBUG ((DEBUG_ERROR, "Access SMM communication forbidden address (0x%x)!\n", PFAddress));
|
||||
DEBUG_CODE (
|
||||
DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextIa32->Eip);
|
||||
);
|
||||
);
|
||||
CpuDeadLoop ();
|
||||
goto Exit;
|
||||
}
|
||||
@@ -241,15 +248,15 @@ SetPageTableAttributes (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN Index2;
|
||||
UINTN Index3;
|
||||
UINT64 *L1PageTable;
|
||||
UINT64 *L2PageTable;
|
||||
UINT64 *L3PageTable;
|
||||
UINTN PageTableBase;
|
||||
BOOLEAN IsSplitted;
|
||||
BOOLEAN PageTableSplitted;
|
||||
BOOLEAN CetEnabled;
|
||||
UINTN Index2;
|
||||
UINTN Index3;
|
||||
UINT64 *L1PageTable;
|
||||
UINT64 *L2PageTable;
|
||||
UINT64 *L3PageTable;
|
||||
UINTN PageTableBase;
|
||||
BOOLEAN IsSplitted;
|
||||
BOOLEAN PageTableSplitted;
|
||||
BOOLEAN CetEnabled;
|
||||
|
||||
//
|
||||
// Don't mark page table to read-only if heap guard is enabled.
|
||||
@@ -259,7 +266,7 @@ SetPageTableAttributes (
|
||||
//
|
||||
if ((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0) {
|
||||
DEBUG ((DEBUG_INFO, "Don't mark page table to read-only as heap guard is enabled\n"));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -267,7 +274,7 @@ SetPageTableAttributes (
|
||||
//
|
||||
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
|
||||
DEBUG ((DEBUG_INFO, "Don't mark page table to read-only as SMM profile is enabled\n"));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "SetPageTableAttributes\n"));
|
||||
@@ -276,14 +283,15 @@ SetPageTableAttributes (
|
||||
// Disable write protection, because we need mark page table to be write protected.
|
||||
// We need *write* page table memory, to mark itself to be *read only*.
|
||||
//
|
||||
CetEnabled = ((AsmReadCr4() & CR4_CET_ENABLE) != 0) ? TRUE : FALSE;
|
||||
CetEnabled = ((AsmReadCr4 () & CR4_CET_ENABLE) != 0) ? TRUE : FALSE;
|
||||
if (CetEnabled) {
|
||||
//
|
||||
// CET must be disabled if WP is disabled.
|
||||
//
|
||||
DisableCet();
|
||||
DisableCet ();
|
||||
}
|
||||
AsmWriteCr0 (AsmReadCr0() & ~CR0_WP);
|
||||
|
||||
AsmWriteCr0 (AsmReadCr0 () & ~CR0_WP);
|
||||
|
||||
do {
|
||||
DEBUG ((DEBUG_INFO, "Start...\n"));
|
||||
@@ -304,15 +312,17 @@ SetPageTableAttributes (
|
||||
SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L2PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted);
|
||||
PageTableSplitted = (PageTableSplitted || IsSplitted);
|
||||
|
||||
for (Index2 = 0; Index2 < SIZE_4KB/sizeof(UINT64); Index2++) {
|
||||
for (Index2 = 0; Index2 < SIZE_4KB/sizeof (UINT64); Index2++) {
|
||||
if ((L2PageTable[Index2] & IA32_PG_PS) != 0) {
|
||||
// 2M
|
||||
continue;
|
||||
}
|
||||
|
||||
L1PageTable = (UINT64 *)(UINTN)(L2PageTable[Index2] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64);
|
||||
if (L1PageTable == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L1PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted);
|
||||
PageTableSplitted = (PageTableSplitted || IsSplitted);
|
||||
}
|
||||
@@ -322,15 +332,15 @@ SetPageTableAttributes (
|
||||
//
|
||||
// Enable write protection, after page table updated.
|
||||
//
|
||||
AsmWriteCr0 (AsmReadCr0() | CR0_WP);
|
||||
AsmWriteCr0 (AsmReadCr0 () | CR0_WP);
|
||||
if (CetEnabled) {
|
||||
//
|
||||
// re-enable CET.
|
||||
//
|
||||
EnableCet();
|
||||
EnableCet ();
|
||||
}
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -343,7 +353,7 @@ SaveCr2 (
|
||||
OUT UINTN *Cr2
|
||||
)
|
||||
{
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,7 +366,7 @@ RestoreCr2 (
|
||||
IN UINTN Cr2
|
||||
)
|
||||
{
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -32,7 +32,7 @@ SemaphoreHook (
|
||||
|
||||
mRebasedFlag = RebasedFlag;
|
||||
|
||||
CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);
|
||||
CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);
|
||||
mSmmRelocationOriginalAddress = (UINTN)HookReturnFromSmm (
|
||||
CpuIndex,
|
||||
CpuState,
|
||||
|
@@ -8,18 +8,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "PiSmmCpuDxeSmm.h"
|
||||
|
||||
extern UINT64 gTaskGateDescriptor;
|
||||
extern UINT64 gTaskGateDescriptor;
|
||||
|
||||
EFI_PHYSICAL_ADDRESS mGdtBuffer;
|
||||
UINTN mGdtBufferSize;
|
||||
EFI_PHYSICAL_ADDRESS mGdtBuffer;
|
||||
UINTN mGdtBufferSize;
|
||||
|
||||
extern BOOLEAN mCetSupported;
|
||||
extern UINTN mSmmShadowStackSize;
|
||||
extern BOOLEAN mCetSupported;
|
||||
extern UINTN mSmmShadowStackSize;
|
||||
|
||||
X86_ASSEMBLY_PATCH_LABEL mPatchCetPl0Ssp;
|
||||
X86_ASSEMBLY_PATCH_LABEL mPatchCetInterruptSsp;
|
||||
UINT32 mCetPl0Ssp;
|
||||
UINT32 mCetInterruptSsp;
|
||||
X86_ASSEMBLY_PATCH_LABEL mPatchCetPl0Ssp;
|
||||
X86_ASSEMBLY_PATCH_LABEL mPatchCetInterruptSsp;
|
||||
UINT32 mCetPl0Ssp;
|
||||
UINT32 mCetInterruptSsp;
|
||||
|
||||
/**
|
||||
Initialize IDT for SMM Stack Guard.
|
||||
@@ -38,8 +38,8 @@ InitializeIDTSmmStackGuard (
|
||||
// is a Task Gate Descriptor so that when a Page Fault Exception occurs,
|
||||
// the processors can use a known good stack in case stack is ran out.
|
||||
//
|
||||
IdtGate = (IA32_IDT_GATE_DESCRIPTOR *)gcSmiIdtr.Base;
|
||||
IdtGate += EXCEPT_IA32_PAGE_FAULT;
|
||||
IdtGate = (IA32_IDT_GATE_DESCRIPTOR *)gcSmiIdtr.Base;
|
||||
IdtGate += EXCEPT_IA32_PAGE_FAULT;
|
||||
IdtGate->Uint64 = gTaskGateDescriptor;
|
||||
}
|
||||
|
||||
@@ -58,13 +58,13 @@ InitGdt (
|
||||
OUT UINTN *GdtStepSize
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
IA32_SEGMENT_DESCRIPTOR *GdtDescriptor;
|
||||
UINTN TssBase;
|
||||
UINTN GdtTssTableSize;
|
||||
UINT8 *GdtTssTables;
|
||||
UINTN GdtTableStepSize;
|
||||
UINTN InterruptShadowStack;
|
||||
UINTN Index;
|
||||
IA32_SEGMENT_DESCRIPTOR *GdtDescriptor;
|
||||
UINTN TssBase;
|
||||
UINTN GdtTssTableSize;
|
||||
UINT8 *GdtTssTables;
|
||||
UINTN GdtTableStepSize;
|
||||
UINTN InterruptShadowStack;
|
||||
|
||||
if (FeaturePcdGet (PcdCpuSmmStackGuard)) {
|
||||
//
|
||||
@@ -79,46 +79,46 @@ InitGdt (
|
||||
gcSmiGdtr.Limit += (UINT16)(2 * sizeof (IA32_SEGMENT_DESCRIPTOR));
|
||||
|
||||
GdtTssTableSize = (gcSmiGdtr.Limit + 1 + TSS_SIZE + EXCEPTION_TSS_SIZE + 7) & ~7; // 8 bytes aligned
|
||||
mGdtBufferSize = GdtTssTableSize * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus;
|
||||
mGdtBufferSize = GdtTssTableSize * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus;
|
||||
//
|
||||
// IA32 Stack Guard need use task switch to switch stack that need
|
||||
// write GDT and TSS, so AllocateCodePages() could not be used here
|
||||
// as code pages will be set to RO.
|
||||
//
|
||||
GdtTssTables = (UINT8*)AllocatePages (EFI_SIZE_TO_PAGES (mGdtBufferSize));
|
||||
GdtTssTables = (UINT8 *)AllocatePages (EFI_SIZE_TO_PAGES (mGdtBufferSize));
|
||||
ASSERT (GdtTssTables != NULL);
|
||||
mGdtBuffer = (UINTN)GdtTssTables;
|
||||
mGdtBuffer = (UINTN)GdtTssTables;
|
||||
GdtTableStepSize = GdtTssTableSize;
|
||||
|
||||
for (Index = 0; Index < gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; Index++) {
|
||||
CopyMem (GdtTssTables + GdtTableStepSize * Index, (VOID*)(UINTN)gcSmiGdtr.Base, gcSmiGdtr.Limit + 1 + TSS_SIZE + EXCEPTION_TSS_SIZE);
|
||||
CopyMem (GdtTssTables + GdtTableStepSize * Index, (VOID *)(UINTN)gcSmiGdtr.Base, gcSmiGdtr.Limit + 1 + TSS_SIZE + EXCEPTION_TSS_SIZE);
|
||||
//
|
||||
// Fixup TSS descriptors
|
||||
//
|
||||
TssBase = (UINTN)(GdtTssTables + GdtTableStepSize * Index + gcSmiGdtr.Limit + 1);
|
||||
GdtDescriptor = (IA32_SEGMENT_DESCRIPTOR *)(TssBase) - 2;
|
||||
GdtDescriptor->Bits.BaseLow = (UINT16)TssBase;
|
||||
GdtDescriptor->Bits.BaseMid = (UINT8)(TssBase >> 16);
|
||||
TssBase = (UINTN)(GdtTssTables + GdtTableStepSize * Index + gcSmiGdtr.Limit + 1);
|
||||
GdtDescriptor = (IA32_SEGMENT_DESCRIPTOR *)(TssBase) - 2;
|
||||
GdtDescriptor->Bits.BaseLow = (UINT16)TssBase;
|
||||
GdtDescriptor->Bits.BaseMid = (UINT8)(TssBase >> 16);
|
||||
GdtDescriptor->Bits.BaseHigh = (UINT8)(TssBase >> 24);
|
||||
|
||||
TssBase += TSS_SIZE;
|
||||
GdtDescriptor++;
|
||||
GdtDescriptor->Bits.BaseLow = (UINT16)TssBase;
|
||||
GdtDescriptor->Bits.BaseMid = (UINT8)(TssBase >> 16);
|
||||
GdtDescriptor->Bits.BaseLow = (UINT16)TssBase;
|
||||
GdtDescriptor->Bits.BaseMid = (UINT8)(TssBase >> 16);
|
||||
GdtDescriptor->Bits.BaseHigh = (UINT8)(TssBase >> 24);
|
||||
//
|
||||
// Fixup TSS segments
|
||||
//
|
||||
// ESP as known good stack
|
||||
//
|
||||
*(UINTN *)(TssBase + TSS_IA32_ESP_OFFSET) = mSmmStackArrayBase + EFI_PAGE_SIZE + Index * mSmmStackSize;
|
||||
*(UINTN *)(TssBase + TSS_IA32_ESP_OFFSET) = mSmmStackArrayBase + EFI_PAGE_SIZE + Index * mSmmStackSize;
|
||||
*(UINT32 *)(TssBase + TSS_IA32_CR3_OFFSET) = Cr3;
|
||||
|
||||
//
|
||||
// Setup ShadowStack for stack switch
|
||||
//
|
||||
if ((PcdGet32 (PcdControlFlowEnforcementPropertyMask) != 0) && mCetSupported) {
|
||||
InterruptShadowStack = (UINTN)(mSmmStackArrayBase + mSmmStackSize + EFI_PAGES_TO_SIZE (1) - sizeof(UINT64) + (mSmmStackSize + mSmmShadowStackSize) * Index);
|
||||
InterruptShadowStack = (UINTN)(mSmmStackArrayBase + mSmmStackSize + EFI_PAGES_TO_SIZE (1) - sizeof (UINT64) + (mSmmStackSize + mSmmShadowStackSize) * Index);
|
||||
*(UINT32 *)(TssBase + TSS_IA32_SSP_OFFSET) = (UINT32)InterruptShadowStack;
|
||||
}
|
||||
}
|
||||
@@ -127,14 +127,14 @@ InitGdt (
|
||||
// Just use original table, AllocatePage and copy them here to make sure GDTs are covered in page memory.
|
||||
//
|
||||
GdtTssTableSize = gcSmiGdtr.Limit + 1;
|
||||
mGdtBufferSize = GdtTssTableSize * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus;
|
||||
GdtTssTables = (UINT8*)AllocateCodePages (EFI_SIZE_TO_PAGES (mGdtBufferSize));
|
||||
mGdtBufferSize = GdtTssTableSize * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus;
|
||||
GdtTssTables = (UINT8 *)AllocateCodePages (EFI_SIZE_TO_PAGES (mGdtBufferSize));
|
||||
ASSERT (GdtTssTables != NULL);
|
||||
mGdtBuffer = (UINTN)GdtTssTables;
|
||||
mGdtBuffer = (UINTN)GdtTssTables;
|
||||
GdtTableStepSize = GdtTssTableSize;
|
||||
|
||||
for (Index = 0; Index < gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; Index++) {
|
||||
CopyMem (GdtTssTables + GdtTableStepSize * Index, (VOID*)(UINTN)gcSmiGdtr.Base, gcSmiGdtr.Limit + 1);
|
||||
CopyMem (GdtTssTables + GdtTableStepSize * Index, (VOID *)(UINTN)gcSmiGdtr.Base, gcSmiGdtr.Limit + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,24 +181,24 @@ InitShadowStack (
|
||||
IN VOID *ShadowStack
|
||||
)
|
||||
{
|
||||
UINTN SmmShadowStackSize;
|
||||
UINTN SmmShadowStackSize;
|
||||
|
||||
if ((PcdGet32 (PcdControlFlowEnforcementPropertyMask) != 0) && mCetSupported) {
|
||||
SmmShadowStackSize = EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (PcdGet32 (PcdCpuSmmShadowStackSize)));
|
||||
if (FeaturePcdGet (PcdCpuSmmStackGuard)) {
|
||||
SmmShadowStackSize += EFI_PAGES_TO_SIZE (2);
|
||||
}
|
||||
mCetPl0Ssp = (UINT32)((UINTN)ShadowStack + SmmShadowStackSize - sizeof(UINT64));
|
||||
|
||||
mCetPl0Ssp = (UINT32)((UINTN)ShadowStack + SmmShadowStackSize - sizeof (UINT64));
|
||||
PatchInstructionX86 (mPatchCetPl0Ssp, mCetPl0Ssp, 4);
|
||||
DEBUG ((DEBUG_INFO, "mCetPl0Ssp - 0x%x\n", mCetPl0Ssp));
|
||||
DEBUG ((DEBUG_INFO, "ShadowStack - 0x%x\n", ShadowStack));
|
||||
DEBUG ((DEBUG_INFO, " SmmShadowStackSize - 0x%x\n", SmmShadowStackSize));
|
||||
|
||||
if (FeaturePcdGet (PcdCpuSmmStackGuard)) {
|
||||
mCetInterruptSsp = (UINT32)((UINTN)ShadowStack + EFI_PAGES_TO_SIZE(1) - sizeof(UINT64));
|
||||
mCetInterruptSsp = (UINT32)((UINTN)ShadowStack + EFI_PAGES_TO_SIZE (1) - sizeof (UINT64));
|
||||
PatchInstructionX86 (mPatchCetInterruptSsp, mCetInterruptSsp, 4);
|
||||
DEBUG ((DEBUG_INFO, "mCetInterruptSsp - 0x%x\n", mCetInterruptSsp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,7 @@ InitSmmS3Cr3 (
|
||||
{
|
||||
mSmmS3ResumeState->SmmS3Cr3 = Gen4GPageTable (TRUE);
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,11 +49,11 @@ InitPagesForPFHandler (
|
||||
**/
|
||||
VOID
|
||||
RestorePageTableAbove4G (
|
||||
UINT64 *PageTable,
|
||||
UINT64 PFAddress,
|
||||
UINTN CpuIndex,
|
||||
UINTN ErrorCode,
|
||||
BOOLEAN *IsValidPFAddress
|
||||
UINT64 *PageTable,
|
||||
UINT64 PFAddress,
|
||||
UINTN CpuIndex,
|
||||
UINTN ErrorCode,
|
||||
BOOLEAN *IsValidPFAddress
|
||||
)
|
||||
{
|
||||
}
|
||||
@@ -67,7 +67,7 @@ RestorePageTableAbove4G (
|
||||
**/
|
||||
VOID
|
||||
ClearTrapFlag (
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
{
|
||||
SystemContext.SystemContextIa32->Eflags &= (UINTN) ~BIT8;
|
||||
|
@@ -12,42 +12,42 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#pragma pack (1)
|
||||
|
||||
typedef struct _MSR_DS_AREA_STRUCT {
|
||||
UINT32 BTSBufferBase;
|
||||
UINT32 BTSIndex;
|
||||
UINT32 BTSAbsoluteMaximum;
|
||||
UINT32 BTSInterruptThreshold;
|
||||
UINT32 PEBSBufferBase;
|
||||
UINT32 PEBSIndex;
|
||||
UINT32 PEBSAbsoluteMaximum;
|
||||
UINT32 PEBSInterruptThreshold;
|
||||
UINT32 PEBSCounterReset[4];
|
||||
UINT32 Reserved;
|
||||
UINT32 BTSBufferBase;
|
||||
UINT32 BTSIndex;
|
||||
UINT32 BTSAbsoluteMaximum;
|
||||
UINT32 BTSInterruptThreshold;
|
||||
UINT32 PEBSBufferBase;
|
||||
UINT32 PEBSIndex;
|
||||
UINT32 PEBSAbsoluteMaximum;
|
||||
UINT32 PEBSInterruptThreshold;
|
||||
UINT32 PEBSCounterReset[4];
|
||||
UINT32 Reserved;
|
||||
} MSR_DS_AREA_STRUCT;
|
||||
|
||||
typedef struct _BRANCH_TRACE_RECORD {
|
||||
UINT32 LastBranchFrom;
|
||||
UINT32 LastBranchTo;
|
||||
UINT32 Rsvd0 : 4;
|
||||
UINT32 BranchPredicted : 1;
|
||||
UINT32 Rsvd1 : 27;
|
||||
UINT32 LastBranchFrom;
|
||||
UINT32 LastBranchTo;
|
||||
UINT32 Rsvd0 : 4;
|
||||
UINT32 BranchPredicted : 1;
|
||||
UINT32 Rsvd1 : 27;
|
||||
} BRANCH_TRACE_RECORD;
|
||||
|
||||
typedef struct _PEBS_RECORD {
|
||||
UINT32 Eflags;
|
||||
UINT32 LinearIP;
|
||||
UINT32 Eax;
|
||||
UINT32 Ebx;
|
||||
UINT32 Ecx;
|
||||
UINT32 Edx;
|
||||
UINT32 Esi;
|
||||
UINT32 Edi;
|
||||
UINT32 Ebp;
|
||||
UINT32 Esp;
|
||||
UINT32 Eflags;
|
||||
UINT32 LinearIP;
|
||||
UINT32 Eax;
|
||||
UINT32 Ebx;
|
||||
UINT32 Ecx;
|
||||
UINT32 Edx;
|
||||
UINT32 Esi;
|
||||
UINT32 Edi;
|
||||
UINT32 Ebp;
|
||||
UINT32 Esp;
|
||||
} PEBS_RECORD;
|
||||
|
||||
#pragma pack ()
|
||||
|
||||
#define PHYSICAL_ADDRESS_MASK ((1ull << 32) - SIZE_4KB)
|
||||
#define PHYSICAL_ADDRESS_MASK ((1ull << 32) - SIZE_4KB)
|
||||
|
||||
/**
|
||||
Update page table to map the memory correctly in order to make the instruction
|
||||
@@ -63,11 +63,11 @@ typedef struct _PEBS_RECORD {
|
||||
**/
|
||||
VOID
|
||||
RestorePageTableAbove4G (
|
||||
UINT64 *PageTable,
|
||||
UINT64 PFAddress,
|
||||
UINTN CpuIndex,
|
||||
UINTN ErrorCode,
|
||||
BOOLEAN *IsValidPFAddress
|
||||
UINT64 *PageTable,
|
||||
UINT64 PFAddress,
|
||||
UINTN CpuIndex,
|
||||
UINTN ErrorCode,
|
||||
BOOLEAN *IsValidPFAddress
|
||||
);
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,9 @@ SMM_CPU_PRIVATE_DATA mSmmCpuPrivateData = {
|
||||
NULL, // Pointer to Operation array
|
||||
NULL, // Pointer to CpuSaveStateSize array
|
||||
NULL, // Pointer to CpuSaveState array
|
||||
{ {0} }, // SmmReservedSmramRegion
|
||||
{
|
||||
{ 0 }
|
||||
}, // SmmReservedSmramRegion
|
||||
{
|
||||
SmmStartupThisAp, // SmmCoreEntryContext.SmmStartupThisAp
|
||||
0, // SmmCoreEntryContext.CurrentlyExecutingCpu
|
||||
@@ -35,10 +37,10 @@ SMM_CPU_PRIVATE_DATA mSmmCpuPrivateData = {
|
||||
RegisterSmmEntry // SmmConfiguration.RegisterSmmEntry
|
||||
},
|
||||
NULL, // pointer to Ap Wrapper Func array
|
||||
{NULL, NULL}, // List_Entry for Tokens.
|
||||
{ NULL, NULL }, // List_Entry for Tokens.
|
||||
};
|
||||
|
||||
CPU_HOT_PLUG_DATA mCpuHotPlugData = {
|
||||
CPU_HOT_PLUG_DATA mCpuHotPlugData = {
|
||||
CPU_HOT_PLUG_DATA_REVISION_1, // Revision
|
||||
0, // Array Length of SmBase and APIC ID
|
||||
NULL, // Pointer to APIC ID array
|
||||
@@ -67,7 +69,7 @@ EFI_HANDLE mSmmCpuHandle = NULL;
|
||||
///
|
||||
/// SMM CPU Protocol instance
|
||||
///
|
||||
EFI_SMM_CPU_PROTOCOL mSmmCpu = {
|
||||
EFI_SMM_CPU_PROTOCOL mSmmCpu = {
|
||||
SmmReadSaveState,
|
||||
SmmWriteSaveState
|
||||
};
|
||||
@@ -75,60 +77,60 @@ EFI_SMM_CPU_PROTOCOL mSmmCpu = {
|
||||
///
|
||||
/// SMM Memory Attribute Protocol instance
|
||||
///
|
||||
EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL mSmmMemoryAttribute = {
|
||||
EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL mSmmMemoryAttribute = {
|
||||
EdkiiSmmGetMemoryAttributes,
|
||||
EdkiiSmmSetMemoryAttributes,
|
||||
EdkiiSmmClearMemoryAttributes
|
||||
};
|
||||
|
||||
EFI_CPU_INTERRUPT_HANDLER mExternalVectorTable[EXCEPTION_VECTOR_NUMBER];
|
||||
EFI_CPU_INTERRUPT_HANDLER mExternalVectorTable[EXCEPTION_VECTOR_NUMBER];
|
||||
|
||||
//
|
||||
// SMM stack information
|
||||
//
|
||||
UINTN mSmmStackArrayBase;
|
||||
UINTN mSmmStackArrayEnd;
|
||||
UINTN mSmmStackSize;
|
||||
UINTN mSmmStackArrayBase;
|
||||
UINTN mSmmStackArrayEnd;
|
||||
UINTN mSmmStackSize;
|
||||
|
||||
UINTN mSmmShadowStackSize;
|
||||
BOOLEAN mCetSupported = TRUE;
|
||||
UINTN mSmmShadowStackSize;
|
||||
BOOLEAN mCetSupported = TRUE;
|
||||
|
||||
UINTN mMaxNumberOfCpus = 1;
|
||||
UINTN mNumberOfCpus = 1;
|
||||
UINTN mMaxNumberOfCpus = 1;
|
||||
UINTN mNumberOfCpus = 1;
|
||||
|
||||
//
|
||||
// SMM ready to lock flag
|
||||
//
|
||||
BOOLEAN mSmmReadyToLock = FALSE;
|
||||
BOOLEAN mSmmReadyToLock = FALSE;
|
||||
|
||||
//
|
||||
// Global used to cache PCD for SMM Code Access Check enable
|
||||
//
|
||||
BOOLEAN mSmmCodeAccessCheckEnable = FALSE;
|
||||
BOOLEAN mSmmCodeAccessCheckEnable = FALSE;
|
||||
|
||||
//
|
||||
// Global copy of the PcdPteMemoryEncryptionAddressOrMask
|
||||
//
|
||||
UINT64 mAddressEncMask = 0;
|
||||
UINT64 mAddressEncMask = 0;
|
||||
|
||||
//
|
||||
// Spin lock used to serialize setting of SMM Code Access Check feature
|
||||
//
|
||||
SPIN_LOCK *mConfigSmmCodeAccessCheckLock = NULL;
|
||||
SPIN_LOCK *mConfigSmmCodeAccessCheckLock = NULL;
|
||||
|
||||
//
|
||||
// Saved SMM ranges information
|
||||
//
|
||||
EFI_SMRAM_DESCRIPTOR *mSmmCpuSmramRanges;
|
||||
UINTN mSmmCpuSmramRangeCount;
|
||||
EFI_SMRAM_DESCRIPTOR *mSmmCpuSmramRanges;
|
||||
UINTN mSmmCpuSmramRangeCount;
|
||||
|
||||
UINT8 mPhysicalAddressBits;
|
||||
UINT8 mPhysicalAddressBits;
|
||||
|
||||
//
|
||||
// Control register contents saved for SMM S3 resume state initialization.
|
||||
//
|
||||
UINT32 mSmmCr0;
|
||||
UINT32 mSmmCr4;
|
||||
UINT32 mSmmCr0;
|
||||
UINT32 mSmmCr4;
|
||||
|
||||
/**
|
||||
Initialize IDT to setup exception handlers for SMM.
|
||||
@@ -139,19 +141,19 @@ InitializeSmmIdt (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN InterruptState;
|
||||
IA32_DESCRIPTOR DxeIdtr;
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN InterruptState;
|
||||
IA32_DESCRIPTOR DxeIdtr;
|
||||
|
||||
//
|
||||
// There are 32 (not 255) entries in it since only processor
|
||||
// generated exceptions will be handled.
|
||||
//
|
||||
gcSmiIdtr.Limit = (sizeof(IA32_IDT_GATE_DESCRIPTOR) * 32) - 1;
|
||||
gcSmiIdtr.Limit = (sizeof (IA32_IDT_GATE_DESCRIPTOR) * 32) - 1;
|
||||
//
|
||||
// Allocate page aligned IDT, because it might be set as read only.
|
||||
//
|
||||
gcSmiIdtr.Base = (UINTN)AllocateCodePages (EFI_SIZE_TO_PAGES(gcSmiIdtr.Limit + 1));
|
||||
gcSmiIdtr.Base = (UINTN)AllocateCodePages (EFI_SIZE_TO_PAGES (gcSmiIdtr.Limit + 1));
|
||||
ASSERT (gcSmiIdtr.Base != 0);
|
||||
ZeroMem ((VOID *)gcSmiIdtr.Base, gcSmiIdtr.Limit + 1);
|
||||
|
||||
@@ -173,7 +175,7 @@ InitializeSmmIdt (
|
||||
//
|
||||
// Restore DXE IDT table and CPU interrupt
|
||||
//
|
||||
AsmWriteIdtr ((IA32_DESCRIPTOR *) &DxeIdtr);
|
||||
AsmWriteIdtr ((IA32_DESCRIPTOR *)&DxeIdtr);
|
||||
SetInterruptState (InterruptState);
|
||||
}
|
||||
|
||||
@@ -185,19 +187,19 @@ InitializeSmmIdt (
|
||||
**/
|
||||
VOID
|
||||
DumpModuleInfoByIp (
|
||||
IN UINTN CallerIpAddress
|
||||
IN UINTN CallerIpAddress
|
||||
)
|
||||
{
|
||||
UINTN Pe32Data;
|
||||
VOID *PdbPointer;
|
||||
UINTN Pe32Data;
|
||||
VOID *PdbPointer;
|
||||
|
||||
//
|
||||
// Find Image Base
|
||||
//
|
||||
Pe32Data = PeCoffSearchImageBase (CallerIpAddress);
|
||||
if (Pe32Data != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "It is invoked from the instruction before IP(0x%p)", (VOID *) CallerIpAddress));
|
||||
PdbPointer = PeCoffLoaderGetPdbPointer ((VOID *) Pe32Data);
|
||||
DEBUG ((DEBUG_ERROR, "It is invoked from the instruction before IP(0x%p)", (VOID *)CallerIpAddress));
|
||||
PdbPointer = PeCoffLoaderGetPdbPointer ((VOID *)Pe32Data);
|
||||
if (PdbPointer != NULL) {
|
||||
DEBUG ((DEBUG_ERROR, " in module (%a)\n", PdbPointer));
|
||||
}
|
||||
@@ -221,11 +223,11 @@ DumpModuleInfoByIp (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmReadSaveState (
|
||||
IN CONST EFI_SMM_CPU_PROTOCOL *This,
|
||||
IN UINTN Width,
|
||||
IN EFI_SMM_SAVE_STATE_REGISTER Register,
|
||||
IN UINTN CpuIndex,
|
||||
OUT VOID *Buffer
|
||||
IN CONST EFI_SMM_CPU_PROTOCOL *This,
|
||||
IN UINTN Width,
|
||||
IN EFI_SMM_SAVE_STATE_REGISTER Register,
|
||||
IN UINTN CpuIndex,
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -236,6 +238,7 @@ SmmReadSaveState (
|
||||
if ((CpuIndex >= gSmst->NumberOfCpus) || (Buffer == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// The SpeculationBarrier() call here is to ensure the above check for the
|
||||
// CpuIndex has been completed before the execution of subsequent codes.
|
||||
@@ -252,6 +255,7 @@ SmmReadSaveState (
|
||||
if (Width != sizeof (UINT64)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// If the processor is in SMM at the time the SMI occurred,
|
||||
// the pseudo register value for EFI_SMM_SAVE_STATE_REGISTER_PROCESSOR_ID is returned in Buffer.
|
||||
@@ -273,6 +277,7 @@ SmmReadSaveState (
|
||||
if (Status == EFI_UNSUPPORTED) {
|
||||
Status = ReadSaveStateRegister (CpuIndex, Register, Width, Buffer);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -293,11 +298,11 @@ SmmReadSaveState (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmWriteSaveState (
|
||||
IN CONST EFI_SMM_CPU_PROTOCOL *This,
|
||||
IN UINTN Width,
|
||||
IN EFI_SMM_SAVE_STATE_REGISTER Register,
|
||||
IN UINTN CpuIndex,
|
||||
IN CONST VOID *Buffer
|
||||
IN CONST EFI_SMM_CPU_PROTOCOL *This,
|
||||
IN UINTN Width,
|
||||
IN EFI_SMM_SAVE_STATE_REGISTER Register,
|
||||
IN UINTN CpuIndex,
|
||||
IN CONST VOID *Buffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -324,10 +329,10 @@ SmmWriteSaveState (
|
||||
if (Status == EFI_UNSUPPORTED) {
|
||||
Status = WriteSaveStateRegister (CpuIndex, Register, Width, Buffer);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
C function for SMI handler. To change all processor's SMMBase Register.
|
||||
|
||||
@@ -338,8 +343,8 @@ SmmInitHandler (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINT32 ApicId;
|
||||
UINTN Index;
|
||||
UINT32 ApicId;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Update SMM IDT entries' code segment and load IDT
|
||||
@@ -384,6 +389,7 @@ SmmInitHandler (
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
@@ -427,7 +433,7 @@ SmmRelocateBases (
|
||||
gcSmiInitGdtr.Base = gcSmiGdtr.Base;
|
||||
gcSmiInitGdtr.Limit = gcSmiGdtr.Limit;
|
||||
|
||||
U8Ptr = (UINT8*)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET);
|
||||
U8Ptr = (UINT8 *)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET);
|
||||
CpuStatePtr = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);
|
||||
|
||||
//
|
||||
@@ -459,7 +465,8 @@ SmmRelocateBases (
|
||||
//
|
||||
// Wait for this AP to finish its 1st SMI
|
||||
//
|
||||
while (!mRebased[Index]);
|
||||
while (!mRebased[Index]) {
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// BSP will be Relocated later
|
||||
@@ -477,7 +484,8 @@ SmmRelocateBases (
|
||||
//
|
||||
// Wait for the BSP to finish its 1st SMI
|
||||
//
|
||||
while (!mRebased[BspIndex]);
|
||||
while (!mRebased[BspIndex]) {
|
||||
}
|
||||
|
||||
//
|
||||
// Restore contents at address 0x38000
|
||||
@@ -537,24 +545,24 @@ PiCpuSmmEntry (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_MP_SERVICES_PROTOCOL *MpServices;
|
||||
UINTN NumberOfEnabledProcessors;
|
||||
UINTN Index;
|
||||
VOID *Buffer;
|
||||
UINTN BufferPages;
|
||||
UINTN TileCodeSize;
|
||||
UINTN TileDataSize;
|
||||
UINTN TileSize;
|
||||
UINT8 *Stacks;
|
||||
VOID *Registration;
|
||||
UINT32 RegEax;
|
||||
UINT32 RegEbx;
|
||||
UINT32 RegEcx;
|
||||
UINT32 RegEdx;
|
||||
UINTN FamilyId;
|
||||
UINTN ModelId;
|
||||
UINT32 Cr3;
|
||||
EFI_STATUS Status;
|
||||
EFI_MP_SERVICES_PROTOCOL *MpServices;
|
||||
UINTN NumberOfEnabledProcessors;
|
||||
UINTN Index;
|
||||
VOID *Buffer;
|
||||
UINTN BufferPages;
|
||||
UINTN TileCodeSize;
|
||||
UINTN TileDataSize;
|
||||
UINTN TileSize;
|
||||
UINT8 *Stacks;
|
||||
VOID *Registration;
|
||||
UINT32 RegEax;
|
||||
UINT32 RegEbx;
|
||||
UINT32 RegEcx;
|
||||
UINT32 RegEdx;
|
||||
UINTN FamilyId;
|
||||
UINTN ModelId;
|
||||
UINT32 Cr3;
|
||||
|
||||
//
|
||||
// Initialize address fixup
|
||||
@@ -598,10 +606,10 @@ PiCpuSmmEntry (
|
||||
// A constant BSP index makes no sense because it may be hot removed.
|
||||
//
|
||||
DEBUG_CODE_BEGIN ();
|
||||
if (FeaturePcdGet (PcdCpuHotPlugSupport)) {
|
||||
if (FeaturePcdGet (PcdCpuHotPlugSupport)) {
|
||||
ASSERT (FeaturePcdGet (PcdCpuSmmEnableBspElection));
|
||||
}
|
||||
|
||||
ASSERT (FeaturePcdGet (PcdCpuSmmEnableBspElection));
|
||||
}
|
||||
DEBUG_CODE_END ();
|
||||
|
||||
//
|
||||
@@ -625,6 +633,7 @@ PiCpuSmmEntry (
|
||||
} else {
|
||||
mMaxNumberOfCpus = mNumberOfCpus;
|
||||
}
|
||||
|
||||
gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus = mMaxNumberOfCpus;
|
||||
|
||||
//
|
||||
@@ -702,8 +711,8 @@ PiCpuSmmEntry (
|
||||
//
|
||||
AsmCpuid (CPUID_VERSION_INFO, &RegEax, NULL, NULL, NULL);
|
||||
FamilyId = (RegEax >> 8) & 0xf;
|
||||
ModelId = (RegEax >> 4) & 0xf;
|
||||
if (FamilyId == 0x06 || FamilyId == 0x0f) {
|
||||
ModelId = (RegEax >> 4) & 0xf;
|
||||
if ((FamilyId == 0x06) || (FamilyId == 0x0f)) {
|
||||
ModelId = ModelId | ((RegEax >> 12) & 0xf0);
|
||||
}
|
||||
|
||||
@@ -712,6 +721,7 @@ PiCpuSmmEntry (
|
||||
if (RegEax >= CPUID_EXTENDED_CPU_SIG) {
|
||||
AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &RegEdx);
|
||||
}
|
||||
|
||||
//
|
||||
// Determine the mode of the CPU at the time an SMI occurs
|
||||
// Intel(R) 64 and IA-32 Architectures Software Developer's Manual
|
||||
@@ -721,8 +731,9 @@ PiCpuSmmEntry (
|
||||
if ((RegEdx & BIT29) != 0) {
|
||||
mSmmSaveStateRegisterLma = EFI_SMM_SAVE_STATE_REGISTER_LMA_64BIT;
|
||||
}
|
||||
|
||||
if (FamilyId == 0x06) {
|
||||
if (ModelId == 0x17 || ModelId == 0x0f || ModelId == 0x1c) {
|
||||
if ((ModelId == 0x17) || (ModelId == 0x0f) || (ModelId == 0x1c)) {
|
||||
mSmmSaveStateRegisterLma = EFI_SMM_SAVE_STATE_REGISTER_LMA_64BIT;
|
||||
}
|
||||
}
|
||||
@@ -739,17 +750,18 @@ PiCpuSmmEntry (
|
||||
mCetSupported = FALSE;
|
||||
PatchInstructionX86 (mPatchCetSupported, mCetSupported, 1);
|
||||
}
|
||||
|
||||
if (mCetSupported) {
|
||||
AsmCpuidEx (CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_SUB_LEAF, NULL, &RegEbx, &RegEcx, NULL);
|
||||
DEBUG ((DEBUG_INFO, "CPUID[D/1] EBX - 0x%08x, ECX - 0x%08x\n", RegEbx, RegEcx));
|
||||
AsmCpuidEx (CPUID_EXTENDED_STATE, 11, &RegEax, NULL, &RegEcx, NULL);
|
||||
DEBUG ((DEBUG_INFO, "CPUID[D/11] EAX - 0x%08x, ECX - 0x%08x\n", RegEax, RegEcx));
|
||||
AsmCpuidEx(CPUID_EXTENDED_STATE, 12, &RegEax, NULL, &RegEcx, NULL);
|
||||
AsmCpuidEx (CPUID_EXTENDED_STATE, 12, &RegEax, NULL, &RegEcx, NULL);
|
||||
DEBUG ((DEBUG_INFO, "CPUID[D/12] EAX - 0x%08x, ECX - 0x%08x\n", RegEax, RegEcx));
|
||||
}
|
||||
} else {
|
||||
mCetSupported = FALSE;
|
||||
PatchInstructionX86(mPatchCetSupported, mCetSupported, 1);
|
||||
PatchInstructionX86 (mPatchCetSupported, mCetSupported, 1);
|
||||
}
|
||||
} else {
|
||||
mCetSupported = FALSE;
|
||||
@@ -762,11 +774,11 @@ PiCpuSmmEntry (
|
||||
// This size is rounded up to nearest power of 2.
|
||||
//
|
||||
TileCodeSize = GetSmiHandlerSize ();
|
||||
TileCodeSize = ALIGN_VALUE(TileCodeSize, SIZE_4KB);
|
||||
TileCodeSize = ALIGN_VALUE (TileCodeSize, SIZE_4KB);
|
||||
TileDataSize = (SMRAM_SAVE_STATE_MAP_OFFSET - SMM_PSD_OFFSET) + sizeof (SMRAM_SAVE_STATE_MAP);
|
||||
TileDataSize = ALIGN_VALUE(TileDataSize, SIZE_4KB);
|
||||
TileSize = TileDataSize + TileCodeSize - 1;
|
||||
TileSize = 2 * GetPowerOfTwo32 ((UINT32)TileSize);
|
||||
TileDataSize = ALIGN_VALUE (TileDataSize, SIZE_4KB);
|
||||
TileSize = TileDataSize + TileCodeSize - 1;
|
||||
TileSize = 2 * GetPowerOfTwo32 ((UINT32)TileSize);
|
||||
DEBUG ((DEBUG_INFO, "SMRAM TileSize = 0x%08x (0x%08x, 0x%08x)\n", TileSize, TileCodeSize, TileDataSize));
|
||||
|
||||
//
|
||||
@@ -796,8 +808,9 @@ PiCpuSmmEntry (
|
||||
} else {
|
||||
Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB);
|
||||
}
|
||||
|
||||
ASSERT (Buffer != NULL);
|
||||
DEBUG ((DEBUG_INFO, "SMRAM SaveState Buffer (0x%08x, 0x%08x)\n", Buffer, EFI_PAGES_TO_SIZE(BufferPages)));
|
||||
DEBUG ((DEBUG_INFO, "SMRAM SaveState Buffer (0x%08x, 0x%08x)\n", Buffer, EFI_PAGES_TO_SIZE (BufferPages)));
|
||||
|
||||
//
|
||||
// Allocate buffer for pointers to array in SMM_CPU_PRIVATE_DATA.
|
||||
@@ -832,17 +845,19 @@ PiCpuSmmEntry (
|
||||
// size for each CPU in the platform
|
||||
//
|
||||
for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
|
||||
mCpuHotPlugData.SmBase[Index] = (UINTN)Buffer + Index * TileSize - SMM_HANDLER_OFFSET;
|
||||
gSmmCpuPrivate->CpuSaveStateSize[Index] = sizeof(SMRAM_SAVE_STATE_MAP);
|
||||
mCpuHotPlugData.SmBase[Index] = (UINTN)Buffer + Index * TileSize - SMM_HANDLER_OFFSET;
|
||||
gSmmCpuPrivate->CpuSaveStateSize[Index] = sizeof (SMRAM_SAVE_STATE_MAP);
|
||||
gSmmCpuPrivate->CpuSaveState[Index] = (VOID *)(mCpuHotPlugData.SmBase[Index] + SMRAM_SAVE_STATE_MAP_OFFSET);
|
||||
gSmmCpuPrivate->Operation[Index] = SmmCpuNone;
|
||||
gSmmCpuPrivate->Operation[Index] = SmmCpuNone;
|
||||
|
||||
if (Index < mNumberOfCpus) {
|
||||
Status = MpServices->GetProcessorInfo (MpServices, Index, &gSmmCpuPrivate->ProcessorInfo[Index]);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
mCpuHotPlugData.ApicId[Index] = gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId;
|
||||
|
||||
DEBUG ((DEBUG_INFO, "CPU[%03x] APIC ID=%04x SMBASE=%08x SaveState=%08x Size=%08x\n",
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"CPU[%03x] APIC ID=%04x SMBASE=%08x SaveState=%08x Size=%08x\n",
|
||||
Index,
|
||||
(UINT32)gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId,
|
||||
mCpuHotPlugData.SmBase[Index],
|
||||
@@ -851,7 +866,7 @@ PiCpuSmmEntry (
|
||||
));
|
||||
} else {
|
||||
gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId = INVALID_APIC_ID;
|
||||
mCpuHotPlugData.ApicId[Index] = INVALID_APIC_ID;
|
||||
mCpuHotPlugData.ApicId[Index] = INVALID_APIC_ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -916,10 +931,10 @@ PiCpuSmmEntry (
|
||||
}
|
||||
}
|
||||
|
||||
Stacks = (UINT8 *) AllocatePages (gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus * (EFI_SIZE_TO_PAGES (mSmmStackSize + mSmmShadowStackSize)));
|
||||
Stacks = (UINT8 *)AllocatePages (gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus * (EFI_SIZE_TO_PAGES (mSmmStackSize + mSmmShadowStackSize)));
|
||||
ASSERT (Stacks != NULL);
|
||||
mSmmStackArrayBase = (UINTN)Stacks;
|
||||
mSmmStackArrayEnd = mSmmStackArrayBase + gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus * (mSmmStackSize + mSmmShadowStackSize) - 1;
|
||||
mSmmStackArrayEnd = mSmmStackArrayBase + gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus * (mSmmStackSize + mSmmShadowStackSize) - 1;
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Stacks - 0x%x\n", Stacks));
|
||||
DEBUG ((DEBUG_INFO, "mSmmStackSize - 0x%x\n", mSmmStackSize));
|
||||
@@ -933,7 +948,7 @@ PiCpuSmmEntry (
|
||||
//
|
||||
PatchInstructionX86 (
|
||||
gPatchSmmInitStack,
|
||||
(UINTN) (Stacks + mSmmStackSize - sizeof (UINTN)),
|
||||
(UINTN)(Stacks + mSmmStackSize - sizeof (UINTN)),
|
||||
sizeof (UINTN)
|
||||
);
|
||||
|
||||
@@ -977,8 +992,8 @@ PiCpuSmmEntry (
|
||||
if (FeaturePcdGet (PcdCpuSmmStackGuard)) {
|
||||
SetNotPresentPage (
|
||||
Cr3,
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)Stacks + mSmmStackSize + EFI_PAGES_TO_SIZE(1) + (mSmmStackSize + mSmmShadowStackSize) * Index,
|
||||
EFI_PAGES_TO_SIZE(1)
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)Stacks + mSmmStackSize + EFI_PAGES_TO_SIZE (1) + (mSmmStackSize + mSmmShadowStackSize) * Index,
|
||||
EFI_PAGES_TO_SIZE (1)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -997,7 +1012,8 @@ PiCpuSmmEntry (
|
||||
//
|
||||
Status = SystemTable->BootServices->InstallMultipleProtocolInterfaces (
|
||||
&gSmmCpuPrivate->SmmCpuHandle,
|
||||
&gEfiSmmConfigurationProtocolGuid, &gSmmCpuPrivate->SmmConfiguration,
|
||||
&gEfiSmmConfigurationProtocolGuid,
|
||||
&gSmmCpuPrivate->SmmConfiguration,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
@@ -1087,17 +1103,17 @@ PiCpuSmmEntry (
|
||||
**/
|
||||
VOID
|
||||
FindSmramInfo (
|
||||
OUT UINT32 *SmrrBase,
|
||||
OUT UINT32 *SmrrSize
|
||||
OUT UINT32 *SmrrBase,
|
||||
OUT UINT32 *SmrrSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Size;
|
||||
EFI_SMM_ACCESS2_PROTOCOL *SmmAccess;
|
||||
EFI_SMRAM_DESCRIPTOR *CurrentSmramRange;
|
||||
UINTN Index;
|
||||
UINT64 MaxSize;
|
||||
BOOLEAN Found;
|
||||
EFI_STATUS Status;
|
||||
UINTN Size;
|
||||
EFI_SMM_ACCESS2_PROTOCOL *SmmAccess;
|
||||
EFI_SMRAM_DESCRIPTOR *CurrentSmramRange;
|
||||
UINTN Index;
|
||||
UINT64 MaxSize;
|
||||
BOOLEAN Found;
|
||||
|
||||
//
|
||||
// Get SMM Access Protocol
|
||||
@@ -1108,7 +1124,7 @@ FindSmramInfo (
|
||||
//
|
||||
// Get SMRAM information
|
||||
//
|
||||
Size = 0;
|
||||
Size = 0;
|
||||
Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL);
|
||||
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
|
||||
|
||||
@@ -1135,7 +1151,7 @@ FindSmramInfo (
|
||||
if (mSmmCpuSmramRanges[Index].CpuStart >= BASE_1MB) {
|
||||
if ((mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize) <= SMRR_MAX_ADDRESS) {
|
||||
if (mSmmCpuSmramRanges[Index].PhysicalSize >= MaxSize) {
|
||||
MaxSize = mSmmCpuSmramRanges[Index].PhysicalSize;
|
||||
MaxSize = mSmmCpuSmramRanges[Index].PhysicalSize;
|
||||
CurrentSmramRange = &mSmmCpuSmramRanges[Index];
|
||||
}
|
||||
}
|
||||
@@ -1150,14 +1166,15 @@ FindSmramInfo (
|
||||
do {
|
||||
Found = FALSE;
|
||||
for (Index = 0; Index < mSmmCpuSmramRangeCount; Index++) {
|
||||
if (mSmmCpuSmramRanges[Index].CpuStart < *SmrrBase &&
|
||||
*SmrrBase == (mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize)) {
|
||||
if ((mSmmCpuSmramRanges[Index].CpuStart < *SmrrBase) &&
|
||||
(*SmrrBase == (mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize)))
|
||||
{
|
||||
*SmrrBase = (UINT32)mSmmCpuSmramRanges[Index].CpuStart;
|
||||
*SmrrSize = (UINT32)(*SmrrSize + mSmmCpuSmramRanges[Index].PhysicalSize);
|
||||
Found = TRUE;
|
||||
} else if ((*SmrrBase + *SmrrSize) == mSmmCpuSmramRanges[Index].CpuStart && mSmmCpuSmramRanges[Index].PhysicalSize > 0) {
|
||||
Found = TRUE;
|
||||
} else if (((*SmrrBase + *SmrrSize) == mSmmCpuSmramRanges[Index].CpuStart) && (mSmmCpuSmramRanges[Index].PhysicalSize > 0)) {
|
||||
*SmrrSize = (UINT32)(*SmrrSize + mSmmCpuSmramRanges[Index].PhysicalSize);
|
||||
Found = TRUE;
|
||||
Found = TRUE;
|
||||
}
|
||||
}
|
||||
} while (Found);
|
||||
@@ -1272,6 +1289,7 @@ ConfigSmmCodeAccessCheck (
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Acquire Config SMM Code Access Check spin lock. The AP will release the
|
||||
// spin lock when it is done executing ConfigSmmCodeAccessCheckOnCurrentProcessor().
|
||||
@@ -1316,7 +1334,7 @@ ConfigSmmCodeAccessCheck (
|
||||
**/
|
||||
VOID *
|
||||
AllocatePageTableMemory (
|
||||
IN UINTN Pages
|
||||
IN UINTN Pages
|
||||
)
|
||||
{
|
||||
VOID *Buffer;
|
||||
@@ -1325,6 +1343,7 @@ AllocatePageTableMemory (
|
||||
if (Buffer != NULL) {
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
return AllocatePages (Pages);
|
||||
}
|
||||
|
||||
@@ -1337,7 +1356,7 @@ AllocatePageTableMemory (
|
||||
**/
|
||||
VOID *
|
||||
AllocateCodePages (
|
||||
IN UINTN Pages
|
||||
IN UINTN Pages
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -1351,7 +1370,8 @@ AllocateCodePages (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
return (VOID *) (UINTN) Memory;
|
||||
|
||||
return (VOID *)(UINTN)Memory;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1366,8 +1386,8 @@ AllocateCodePages (
|
||||
**/
|
||||
VOID *
|
||||
AllocateAlignedCodePages (
|
||||
IN UINTN Pages,
|
||||
IN UINTN Alignment
|
||||
IN UINTN Pages,
|
||||
IN UINTN Alignment
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -1385,23 +1405,25 @@ AllocateAlignedCodePages (
|
||||
if (Pages == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (Alignment > EFI_PAGE_SIZE) {
|
||||
//
|
||||
// Calculate the total number of pages since alignment is larger than page size.
|
||||
//
|
||||
AlignmentMask = Alignment - 1;
|
||||
RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
|
||||
AlignmentMask = Alignment - 1;
|
||||
RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
|
||||
//
|
||||
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
|
||||
//
|
||||
ASSERT (RealPages > Pages);
|
||||
|
||||
Status = gSmst->SmmAllocatePages (AllocateAnyPages, EfiRuntimeServicesCode, RealPages, &Memory);
|
||||
Status = gSmst->SmmAllocatePages (AllocateAnyPages, EfiRuntimeServicesCode, RealPages, &Memory);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
|
||||
UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);
|
||||
|
||||
AlignedMemory = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask;
|
||||
UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN)Memory);
|
||||
if (UnalignedPages > 0) {
|
||||
//
|
||||
// Free first unaligned page(s).
|
||||
@@ -1409,6 +1431,7 @@ AllocateAlignedCodePages (
|
||||
Status = gSmst->SmmFreePages (Memory, UnalignedPages);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);
|
||||
UnalignedPages = RealPages - Pages - UnalignedPages;
|
||||
if (UnalignedPages > 0) {
|
||||
@@ -1426,9 +1449,11 @@ AllocateAlignedCodePages (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
AlignedMemory = (UINTN) Memory;
|
||||
|
||||
AlignedMemory = (UINTN)Memory;
|
||||
}
|
||||
return (VOID *) AlignedMemory;
|
||||
|
||||
return (VOID *)AlignedMemory;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1447,6 +1472,7 @@ PerformRemainingTasks (
|
||||
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
|
||||
SmmProfileStart ();
|
||||
}
|
||||
|
||||
//
|
||||
// Create a mix of 2MB and 4KB page table. Update some memory ranges absent and execute-disable.
|
||||
//
|
||||
|
@@ -74,69 +74,69 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
typedef union {
|
||||
struct {
|
||||
// enable shadow stacks
|
||||
UINT32 SH_STK_ENP:1;
|
||||
UINT32 SH_STK_ENP : 1;
|
||||
// enable the WRSS{D,Q}W instructions.
|
||||
UINT32 WR_SHSTK_EN:1;
|
||||
UINT32 WR_SHSTK_EN : 1;
|
||||
// enable tracking of indirect call/jmp targets to be ENDBRANCH instruction.
|
||||
UINT32 ENDBR_EN:1;
|
||||
UINT32 ENDBR_EN : 1;
|
||||
// enable legacy compatibility treatment for indirect call/jmp tracking.
|
||||
UINT32 LEG_IW_EN:1;
|
||||
UINT32 LEG_IW_EN : 1;
|
||||
// enable use of no-track prefix on indirect call/jmp.
|
||||
UINT32 NO_TRACK_EN:1;
|
||||
UINT32 NO_TRACK_EN : 1;
|
||||
// disable suppression of CET indirect branch tracking on legacy compatibility.
|
||||
UINT32 SUPPRESS_DIS:1;
|
||||
UINT32 RSVD:4;
|
||||
UINT32 SUPPRESS_DIS : 1;
|
||||
UINT32 RSVD : 4;
|
||||
// indirect branch tracking is suppressed.
|
||||
// This bit can be written to 1 only if TRACKER is written as IDLE.
|
||||
UINT32 SUPPRESS:1;
|
||||
UINT32 SUPPRESS : 1;
|
||||
// Value of the endbranch state machine
|
||||
// Values: IDLE (0), WAIT_FOR_ENDBRANCH(1).
|
||||
UINT32 TRACKER:1;
|
||||
UINT32 TRACKER : 1;
|
||||
// linear address of a bitmap in memory indicating valid
|
||||
// pages as target of CALL/JMP_indirect that do not land on ENDBRANCH when CET is enabled
|
||||
// and not suppressed. Valid when ENDBR_EN is 1. Must be machine canonical when written on
|
||||
// parts that support 64 bit mode. On parts that do not support 64 bit mode, the bits 63:32 are
|
||||
// reserved and must be 0. This value is extended by 12 bits at the low end to form the base address
|
||||
// (this automatically aligns the address on a 4-Kbyte boundary).
|
||||
UINT32 EB_LEG_BITMAP_BASE_low:12;
|
||||
UINT32 EB_LEG_BITMAP_BASE_high:32;
|
||||
UINT32 EB_LEG_BITMAP_BASE_low : 12;
|
||||
UINT32 EB_LEG_BITMAP_BASE_high : 32;
|
||||
} Bits;
|
||||
UINT64 Uint64;
|
||||
UINT64 Uint64;
|
||||
} MSR_IA32_CET;
|
||||
|
||||
//
|
||||
// MSRs required for configuration of SMM Code Access Check
|
||||
//
|
||||
#define EFI_MSR_SMM_MCA_CAP 0x17D
|
||||
#define SMM_CODE_ACCESS_CHK_BIT BIT58
|
||||
#define EFI_MSR_SMM_MCA_CAP 0x17D
|
||||
#define SMM_CODE_ACCESS_CHK_BIT BIT58
|
||||
|
||||
#define SMM_FEATURE_CONTROL_LOCK_BIT BIT0
|
||||
#define SMM_CODE_CHK_EN_BIT BIT2
|
||||
#define SMM_FEATURE_CONTROL_LOCK_BIT BIT0
|
||||
#define SMM_CODE_CHK_EN_BIT BIT2
|
||||
|
||||
///
|
||||
/// Page Table Entry
|
||||
///
|
||||
#define IA32_PG_P BIT0
|
||||
#define IA32_PG_RW BIT1
|
||||
#define IA32_PG_U BIT2
|
||||
#define IA32_PG_WT BIT3
|
||||
#define IA32_PG_CD BIT4
|
||||
#define IA32_PG_A BIT5
|
||||
#define IA32_PG_D BIT6
|
||||
#define IA32_PG_PS BIT7
|
||||
#define IA32_PG_PAT_2M BIT12
|
||||
#define IA32_PG_PAT_4K IA32_PG_PS
|
||||
#define IA32_PG_PMNT BIT62
|
||||
#define IA32_PG_NX BIT63
|
||||
#define IA32_PG_P BIT0
|
||||
#define IA32_PG_RW BIT1
|
||||
#define IA32_PG_U BIT2
|
||||
#define IA32_PG_WT BIT3
|
||||
#define IA32_PG_CD BIT4
|
||||
#define IA32_PG_A BIT5
|
||||
#define IA32_PG_D BIT6
|
||||
#define IA32_PG_PS BIT7
|
||||
#define IA32_PG_PAT_2M BIT12
|
||||
#define IA32_PG_PAT_4K IA32_PG_PS
|
||||
#define IA32_PG_PMNT BIT62
|
||||
#define IA32_PG_NX BIT63
|
||||
|
||||
#define PAGE_ATTRIBUTE_BITS (IA32_PG_D | IA32_PG_A | IA32_PG_U | IA32_PG_RW | IA32_PG_P)
|
||||
#define PAGE_ATTRIBUTE_BITS (IA32_PG_D | IA32_PG_A | IA32_PG_U | IA32_PG_RW | IA32_PG_P)
|
||||
//
|
||||
// Bits 1, 2, 5, 6 are reserved in the IA32 PAE PDPTE
|
||||
// X64 PAE PDPTE does not have such restriction
|
||||
//
|
||||
#define IA32_PAE_PDPTE_ATTRIBUTE_BITS (IA32_PG_P)
|
||||
#define IA32_PAE_PDPTE_ATTRIBUTE_BITS (IA32_PG_P)
|
||||
|
||||
#define PAGE_PROGATE_BITS (IA32_PG_NX | PAGE_ATTRIBUTE_BITS)
|
||||
#define PAGE_PROGATE_BITS (IA32_PG_NX | PAGE_ATTRIBUTE_BITS)
|
||||
|
||||
#define PAGING_4K_MASK 0xFFF
|
||||
#define PAGING_2M_MASK 0x1FFFFF
|
||||
@@ -144,11 +144,11 @@ typedef union {
|
||||
|
||||
#define PAGING_PAE_INDEX_MASK 0x1FF
|
||||
|
||||
#define PAGING_4K_ADDRESS_MASK_64 0x000FFFFFFFFFF000ull
|
||||
#define PAGING_2M_ADDRESS_MASK_64 0x000FFFFFFFE00000ull
|
||||
#define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull
|
||||
#define PAGING_4K_ADDRESS_MASK_64 0x000FFFFFFFFFF000ull
|
||||
#define PAGING_2M_ADDRESS_MASK_64 0x000FFFFFFFE00000ull
|
||||
#define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull
|
||||
|
||||
#define SMRR_MAX_ADDRESS BASE_4GB
|
||||
#define SMRR_MAX_ADDRESS BASE_4GB
|
||||
|
||||
typedef enum {
|
||||
PageNone,
|
||||
@@ -158,28 +158,28 @@ typedef enum {
|
||||
} PAGE_ATTRIBUTE;
|
||||
|
||||
typedef struct {
|
||||
PAGE_ATTRIBUTE Attribute;
|
||||
UINT64 Length;
|
||||
UINT64 AddressMask;
|
||||
PAGE_ATTRIBUTE Attribute;
|
||||
UINT64 Length;
|
||||
UINT64 AddressMask;
|
||||
} PAGE_ATTRIBUTE_TABLE;
|
||||
|
||||
//
|
||||
// Size of Task-State Segment defined in IA32 Manual
|
||||
//
|
||||
#define TSS_SIZE 104
|
||||
#define EXCEPTION_TSS_SIZE (TSS_SIZE + 4) // Add 4 bytes SSP
|
||||
#define TSS_X64_IST1_OFFSET 36
|
||||
#define TSS_IA32_CR3_OFFSET 28
|
||||
#define TSS_IA32_ESP_OFFSET 56
|
||||
#define TSS_IA32_SSP_OFFSET 104
|
||||
#define TSS_SIZE 104
|
||||
#define EXCEPTION_TSS_SIZE (TSS_SIZE + 4) // Add 4 bytes SSP
|
||||
#define TSS_X64_IST1_OFFSET 36
|
||||
#define TSS_IA32_CR3_OFFSET 28
|
||||
#define TSS_IA32_ESP_OFFSET 56
|
||||
#define TSS_IA32_SSP_OFFSET 104
|
||||
|
||||
#define CR0_WP BIT16
|
||||
#define CR0_WP BIT16
|
||||
|
||||
//
|
||||
// Code select value
|
||||
//
|
||||
#define PROTECT_MODE_CODE_SEGMENT 0x08
|
||||
#define LONG_MODE_CODE_SEGMENT 0x38
|
||||
#define PROTECT_MODE_CODE_SEGMENT 0x08
|
||||
#define LONG_MODE_CODE_SEGMENT 0x38
|
||||
|
||||
//
|
||||
// The size 0x20 must be bigger than
|
||||
@@ -189,31 +189,31 @@ typedef struct {
|
||||
//
|
||||
#define BACK_BUF_SIZE 0x20
|
||||
|
||||
#define EXCEPTION_VECTOR_NUMBER 0x20
|
||||
#define EXCEPTION_VECTOR_NUMBER 0x20
|
||||
|
||||
#define INVALID_APIC_ID 0xFFFFFFFFFFFFFFFFULL
|
||||
#define INVALID_APIC_ID 0xFFFFFFFFFFFFFFFFULL
|
||||
|
||||
typedef UINT32 SMM_CPU_ARRIVAL_EXCEPTIONS;
|
||||
#define ARRIVAL_EXCEPTION_BLOCKED 0x1
|
||||
#define ARRIVAL_EXCEPTION_DELAYED 0x2
|
||||
#define ARRIVAL_EXCEPTION_SMI_DISABLED 0x4
|
||||
typedef UINT32 SMM_CPU_ARRIVAL_EXCEPTIONS;
|
||||
#define ARRIVAL_EXCEPTION_BLOCKED 0x1
|
||||
#define ARRIVAL_EXCEPTION_DELAYED 0x2
|
||||
#define ARRIVAL_EXCEPTION_SMI_DISABLED 0x4
|
||||
|
||||
//
|
||||
// Wrapper used to convert EFI_AP_PROCEDURE2 and EFI_AP_PROCEDURE.
|
||||
//
|
||||
typedef struct {
|
||||
EFI_AP_PROCEDURE Procedure;
|
||||
VOID *ProcedureArgument;
|
||||
EFI_AP_PROCEDURE Procedure;
|
||||
VOID *ProcedureArgument;
|
||||
} PROCEDURE_WRAPPER;
|
||||
|
||||
#define PROCEDURE_TOKEN_SIGNATURE SIGNATURE_32 ('P', 'R', 'T', 'S')
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link;
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link;
|
||||
|
||||
SPIN_LOCK *SpinLock;
|
||||
volatile UINT32 RunningApCount;
|
||||
SPIN_LOCK *SpinLock;
|
||||
volatile UINT32 RunningApCount;
|
||||
} PROCEDURE_TOKEN;
|
||||
|
||||
#define PROCEDURE_TOKEN_FROM_LINK(a) CR (a, PROCEDURE_TOKEN, Link, PROCEDURE_TOKEN_SIGNATURE)
|
||||
@@ -221,10 +221,10 @@ typedef struct {
|
||||
#define TOKEN_BUFFER_SIGNATURE SIGNATURE_32 ('T', 'K', 'B', 'S')
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link;
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link;
|
||||
|
||||
UINT8 *Buffer;
|
||||
UINT8 *Buffer;
|
||||
} TOKEN_BUFFER;
|
||||
|
||||
#define TOKEN_BUFFER_FROM_LINK(a) CR (a, TOKEN_BUFFER, Link, TOKEN_BUFFER_SIGNATURE)
|
||||
@@ -237,33 +237,33 @@ typedef struct {
|
||||
#define SMM_CPU_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('s', 'c', 'p', 'u')
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
UINTN Signature;
|
||||
|
||||
EFI_HANDLE SmmCpuHandle;
|
||||
EFI_HANDLE SmmCpuHandle;
|
||||
|
||||
EFI_PROCESSOR_INFORMATION *ProcessorInfo;
|
||||
SMM_CPU_OPERATION *Operation;
|
||||
UINTN *CpuSaveStateSize;
|
||||
VOID **CpuSaveState;
|
||||
EFI_PROCESSOR_INFORMATION *ProcessorInfo;
|
||||
SMM_CPU_OPERATION *Operation;
|
||||
UINTN *CpuSaveStateSize;
|
||||
VOID **CpuSaveState;
|
||||
|
||||
EFI_SMM_RESERVED_SMRAM_REGION SmmReservedSmramRegion[1];
|
||||
EFI_SMM_ENTRY_CONTEXT SmmCoreEntryContext;
|
||||
EFI_SMM_ENTRY_POINT SmmCoreEntry;
|
||||
EFI_SMM_RESERVED_SMRAM_REGION SmmReservedSmramRegion[1];
|
||||
EFI_SMM_ENTRY_CONTEXT SmmCoreEntryContext;
|
||||
EFI_SMM_ENTRY_POINT SmmCoreEntry;
|
||||
|
||||
EFI_SMM_CONFIGURATION_PROTOCOL SmmConfiguration;
|
||||
EFI_SMM_CONFIGURATION_PROTOCOL SmmConfiguration;
|
||||
|
||||
PROCEDURE_WRAPPER *ApWrapperFunc;
|
||||
LIST_ENTRY TokenList;
|
||||
LIST_ENTRY *FirstFreeToken;
|
||||
PROCEDURE_WRAPPER *ApWrapperFunc;
|
||||
LIST_ENTRY TokenList;
|
||||
LIST_ENTRY *FirstFreeToken;
|
||||
} SMM_CPU_PRIVATE_DATA;
|
||||
|
||||
extern SMM_CPU_PRIVATE_DATA *gSmmCpuPrivate;
|
||||
extern CPU_HOT_PLUG_DATA mCpuHotPlugData;
|
||||
extern UINTN mMaxNumberOfCpus;
|
||||
extern UINTN mNumberOfCpus;
|
||||
extern EFI_SMM_CPU_PROTOCOL mSmmCpu;
|
||||
extern EFI_MM_MP_PROTOCOL mSmmMp;
|
||||
extern UINTN mInternalCr3;
|
||||
extern CPU_HOT_PLUG_DATA mCpuHotPlugData;
|
||||
extern UINTN mMaxNumberOfCpus;
|
||||
extern UINTN mNumberOfCpus;
|
||||
extern EFI_SMM_CPU_PROTOCOL mSmmCpu;
|
||||
extern EFI_MM_MP_PROTOCOL mSmmMp;
|
||||
extern UINTN mInternalCr3;
|
||||
|
||||
///
|
||||
/// The mode of the CPU at the time an SMI occurs
|
||||
@@ -291,11 +291,11 @@ extern UINT8 mSmmSaveStateRegisterLma;
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmReadSaveState (
|
||||
IN CONST EFI_SMM_CPU_PROTOCOL *This,
|
||||
IN UINTN Width,
|
||||
IN EFI_SMM_SAVE_STATE_REGISTER Register,
|
||||
IN UINTN CpuIndex,
|
||||
OUT VOID *Buffer
|
||||
IN CONST EFI_SMM_CPU_PROTOCOL *This,
|
||||
IN UINTN Width,
|
||||
IN EFI_SMM_SAVE_STATE_REGISTER Register,
|
||||
IN UINTN CpuIndex,
|
||||
OUT VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -315,11 +315,11 @@ SmmReadSaveState (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmWriteSaveState (
|
||||
IN CONST EFI_SMM_CPU_PROTOCOL *This,
|
||||
IN UINTN Width,
|
||||
IN EFI_SMM_SAVE_STATE_REGISTER Register,
|
||||
IN UINTN CpuIndex,
|
||||
IN CONST VOID *Buffer
|
||||
IN CONST EFI_SMM_CPU_PROTOCOL *This,
|
||||
IN UINTN Width,
|
||||
IN EFI_SMM_SAVE_STATE_REGISTER Register,
|
||||
IN UINTN CpuIndex,
|
||||
IN CONST VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -376,16 +376,16 @@ WriteSaveStateRegister (
|
||||
IN CONST VOID *Buffer
|
||||
);
|
||||
|
||||
extern CONST UINT8 gcSmmInitTemplate[];
|
||||
extern CONST UINT16 gcSmmInitSize;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmmCr0;
|
||||
extern UINT32 mSmmCr0;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmmCr3;
|
||||
extern UINT32 mSmmCr4;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmmCr4;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmmInitStack;
|
||||
X86_ASSEMBLY_PATCH_LABEL mPatchCetSupported;
|
||||
extern BOOLEAN mCetSupported;
|
||||
extern CONST UINT8 gcSmmInitTemplate[];
|
||||
extern CONST UINT16 gcSmmInitSize;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmmCr0;
|
||||
extern UINT32 mSmmCr0;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmmCr3;
|
||||
extern UINT32 mSmmCr4;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmmCr4;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmmInitStack;
|
||||
X86_ASSEMBLY_PATCH_LABEL mPatchCetSupported;
|
||||
extern BOOLEAN mCetSupported;
|
||||
|
||||
/**
|
||||
Semaphore operation for all processor relocate SMMBase.
|
||||
@@ -400,13 +400,13 @@ SmmRelocationSemaphoreComplete (
|
||||
/// The type of SMM CPU Information
|
||||
///
|
||||
typedef struct {
|
||||
SPIN_LOCK *Busy;
|
||||
volatile EFI_AP_PROCEDURE2 Procedure;
|
||||
volatile VOID *Parameter;
|
||||
volatile UINT32 *Run;
|
||||
volatile BOOLEAN *Present;
|
||||
PROCEDURE_TOKEN *Token;
|
||||
EFI_STATUS *Status;
|
||||
SPIN_LOCK *Busy;
|
||||
volatile EFI_AP_PROCEDURE2 Procedure;
|
||||
volatile VOID *Parameter;
|
||||
volatile UINT32 *Run;
|
||||
volatile BOOLEAN *Present;
|
||||
PROCEDURE_TOKEN *Token;
|
||||
EFI_STATUS *Status;
|
||||
} SMM_CPU_DATA_BLOCK;
|
||||
|
||||
typedef enum {
|
||||
@@ -432,56 +432,56 @@ typedef struct {
|
||||
VOID *StartupProcArgs;
|
||||
} SMM_DISPATCHER_MP_SYNC_DATA;
|
||||
|
||||
#define SMM_PSD_OFFSET 0xfb00
|
||||
#define SMM_PSD_OFFSET 0xfb00
|
||||
|
||||
///
|
||||
/// All global semaphores' pointer
|
||||
///
|
||||
typedef struct {
|
||||
volatile UINT32 *Counter;
|
||||
volatile BOOLEAN *InsideSmm;
|
||||
volatile BOOLEAN *AllCpusInSync;
|
||||
SPIN_LOCK *PFLock;
|
||||
SPIN_LOCK *CodeAccessCheckLock;
|
||||
volatile UINT32 *Counter;
|
||||
volatile BOOLEAN *InsideSmm;
|
||||
volatile BOOLEAN *AllCpusInSync;
|
||||
SPIN_LOCK *PFLock;
|
||||
SPIN_LOCK *CodeAccessCheckLock;
|
||||
} SMM_CPU_SEMAPHORE_GLOBAL;
|
||||
|
||||
///
|
||||
/// All semaphores for each processor
|
||||
///
|
||||
typedef struct {
|
||||
SPIN_LOCK *Busy;
|
||||
volatile UINT32 *Run;
|
||||
volatile BOOLEAN *Present;
|
||||
SPIN_LOCK *Token;
|
||||
SPIN_LOCK *Busy;
|
||||
volatile UINT32 *Run;
|
||||
volatile BOOLEAN *Present;
|
||||
SPIN_LOCK *Token;
|
||||
} SMM_CPU_SEMAPHORE_CPU;
|
||||
|
||||
///
|
||||
/// All semaphores' information
|
||||
///
|
||||
typedef struct {
|
||||
SMM_CPU_SEMAPHORE_GLOBAL SemaphoreGlobal;
|
||||
SMM_CPU_SEMAPHORE_CPU SemaphoreCpu;
|
||||
SMM_CPU_SEMAPHORE_GLOBAL SemaphoreGlobal;
|
||||
SMM_CPU_SEMAPHORE_CPU SemaphoreCpu;
|
||||
} SMM_CPU_SEMAPHORES;
|
||||
|
||||
extern IA32_DESCRIPTOR gcSmiGdtr;
|
||||
extern EFI_PHYSICAL_ADDRESS mGdtBuffer;
|
||||
extern UINTN mGdtBufferSize;
|
||||
extern IA32_DESCRIPTOR gcSmiIdtr;
|
||||
extern VOID *gcSmiIdtrPtr;
|
||||
extern UINT64 gPhyMask;
|
||||
extern SMM_DISPATCHER_MP_SYNC_DATA *mSmmMpSyncData;
|
||||
extern UINTN mSmmStackArrayBase;
|
||||
extern UINTN mSmmStackArrayEnd;
|
||||
extern UINTN mSmmStackSize;
|
||||
extern EFI_SMM_CPU_SERVICE_PROTOCOL mSmmCpuService;
|
||||
extern IA32_DESCRIPTOR gcSmiInitGdtr;
|
||||
extern SMM_CPU_SEMAPHORES mSmmCpuSemaphores;
|
||||
extern UINTN mSemaphoreSize;
|
||||
extern SPIN_LOCK *mPFLock;
|
||||
extern SPIN_LOCK *mConfigSmmCodeAccessCheckLock;
|
||||
extern EFI_SMRAM_DESCRIPTOR *mSmmCpuSmramRanges;
|
||||
extern UINTN mSmmCpuSmramRangeCount;
|
||||
extern UINT8 mPhysicalAddressBits;
|
||||
extern IA32_DESCRIPTOR gcSmiGdtr;
|
||||
extern EFI_PHYSICAL_ADDRESS mGdtBuffer;
|
||||
extern UINTN mGdtBufferSize;
|
||||
extern IA32_DESCRIPTOR gcSmiIdtr;
|
||||
extern VOID *gcSmiIdtrPtr;
|
||||
extern UINT64 gPhyMask;
|
||||
extern SMM_DISPATCHER_MP_SYNC_DATA *mSmmMpSyncData;
|
||||
extern UINTN mSmmStackArrayBase;
|
||||
extern UINTN mSmmStackArrayEnd;
|
||||
extern UINTN mSmmStackSize;
|
||||
extern EFI_SMM_CPU_SERVICE_PROTOCOL mSmmCpuService;
|
||||
extern IA32_DESCRIPTOR gcSmiInitGdtr;
|
||||
extern SMM_CPU_SEMAPHORES mSmmCpuSemaphores;
|
||||
extern UINTN mSemaphoreSize;
|
||||
extern SPIN_LOCK *mPFLock;
|
||||
extern SPIN_LOCK *mConfigSmmCodeAccessCheckLock;
|
||||
extern EFI_SMRAM_DESCRIPTOR *mSmmCpuSmramRanges;
|
||||
extern UINTN mSmmCpuSmramRangeCount;
|
||||
extern UINT8 mPhysicalAddressBits;
|
||||
|
||||
//
|
||||
// Copy of the PcdPteMemoryEncryptionAddressOrMask
|
||||
@@ -497,10 +497,9 @@ extern UINT64 mAddressEncMask;
|
||||
**/
|
||||
UINT32
|
||||
Gen4GPageTable (
|
||||
IN BOOLEAN Is32BitPageTable
|
||||
IN BOOLEAN Is32BitPageTable
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Initialize global data for MP synchronization.
|
||||
|
||||
@@ -511,9 +510,9 @@ Gen4GPageTable (
|
||||
**/
|
||||
UINT32
|
||||
InitializeMpServiceData (
|
||||
IN VOID *Stacks,
|
||||
IN UINTN StackSize,
|
||||
IN UINTN ShadowStackSize
|
||||
IN VOID *Stacks,
|
||||
IN UINTN StackSize,
|
||||
IN UINTN ShadowStackSize
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -544,7 +543,7 @@ StartSyncTimer (
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsSyncTimerTimeout (
|
||||
IN UINT64 Timer
|
||||
IN UINT64 Timer
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -567,8 +566,8 @@ InitializeIDTSmmStackGuard (
|
||||
VOID
|
||||
EFIAPI
|
||||
InitializeIdtIst (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN UINT8 Ist
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN UINT8 Ist
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -631,9 +630,9 @@ SmmInitPageTable (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmStartupThisAp (
|
||||
IN EFI_AP_PROCEDURE Procedure,
|
||||
IN UINTN CpuIndex,
|
||||
IN OUT VOID *ProcArguments OPTIONAL
|
||||
IN EFI_AP_PROCEDURE Procedure,
|
||||
IN UINTN CpuIndex,
|
||||
IN OUT VOID *ProcArguments OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -653,9 +652,9 @@ SmmStartupThisAp (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmBlockingStartupThisAp (
|
||||
IN EFI_AP_PROCEDURE Procedure,
|
||||
IN UINTN CpuIndex,
|
||||
IN OUT VOID *ProcArguments OPTIONAL
|
||||
IN EFI_AP_PROCEDURE Procedure,
|
||||
IN UINTN CpuIndex,
|
||||
IN OUT VOID *ProcArguments OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -683,9 +682,9 @@ SmmBlockingStartupThisAp (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmSetMemoryAttributes (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -713,9 +712,9 @@ SmmSetMemoryAttributes (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmClearMemoryAttributes (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -738,8 +737,8 @@ InitializeMpSyncData (
|
||||
**/
|
||||
VOID
|
||||
FindSmramInfo (
|
||||
OUT UINT32 *SmrrBase,
|
||||
OUT UINT32 *SmrrSize
|
||||
OUT UINT32 *SmrrBase,
|
||||
OUT UINT32 *SmrrSize
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -765,8 +764,8 @@ SmmRelocateBases (
|
||||
VOID
|
||||
EFIAPI
|
||||
SmiPFHandler (
|
||||
IN EFI_EXCEPTION_TYPE InterruptType,
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||
IN EFI_EXCEPTION_TYPE InterruptType,
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -795,7 +794,7 @@ PerformPreTasks (
|
||||
**/
|
||||
VOID
|
||||
InitMsrSpinLockByIndex (
|
||||
IN UINT32 MsrIndex
|
||||
IN UINT32 MsrIndex
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -908,7 +907,7 @@ InstallSmiHandler (
|
||||
**/
|
||||
VOID
|
||||
DumpModuleInfoByIp (
|
||||
IN UINTN CallerIpAddress
|
||||
IN UINTN CallerIpAddress
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -964,8 +963,8 @@ SetPageTableAttributes (
|
||||
**/
|
||||
VOID
|
||||
GetPageTable (
|
||||
OUT UINTN *Base,
|
||||
OUT BOOLEAN *FiveLevels OPTIONAL
|
||||
OUT UINTN *Base,
|
||||
OUT BOOLEAN *FiveLevels OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -994,10 +993,10 @@ GetPageTable (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmSetMemoryAttributesEx (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes,
|
||||
OUT BOOLEAN *IsSplitted OPTIONAL
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes,
|
||||
OUT BOOLEAN *IsSplitted OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1026,10 +1025,10 @@ SmmSetMemoryAttributesEx (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmClearMemoryAttributesEx (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes,
|
||||
OUT BOOLEAN *IsSplitted OPTIONAL
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes,
|
||||
OUT BOOLEAN *IsSplitted OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1049,7 +1048,7 @@ SmmClearMemoryAttributesEx (
|
||||
**/
|
||||
VOID *
|
||||
AllocatePageTableMemory (
|
||||
IN UINTN Pages
|
||||
IN UINTN Pages
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1061,7 +1060,7 @@ AllocatePageTableMemory (
|
||||
**/
|
||||
VOID *
|
||||
AllocateCodePages (
|
||||
IN UINTN Pages
|
||||
IN UINTN Pages
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1076,16 +1075,15 @@ AllocateCodePages (
|
||||
**/
|
||||
VOID *
|
||||
AllocateAlignedCodePages (
|
||||
IN UINTN Pages,
|
||||
IN UINTN Alignment
|
||||
IN UINTN Pages,
|
||||
IN UINTN Alignment
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// S3 related global variable and function prototype.
|
||||
//
|
||||
|
||||
extern BOOLEAN mSmmS3Flag;
|
||||
extern BOOLEAN mSmmS3Flag;
|
||||
|
||||
/**
|
||||
Initialize SMM S3 resume state structure used during S3 Resume.
|
||||
@@ -1151,9 +1149,9 @@ TransferApToSafeState (
|
||||
**/
|
||||
EFI_STATUS
|
||||
SetShadowStack (
|
||||
IN UINTN Cr3,
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
IN UINTN Cr3,
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1167,9 +1165,9 @@ SetShadowStack (
|
||||
**/
|
||||
EFI_STATUS
|
||||
SetNotPresentPage (
|
||||
IN UINTN Cr3,
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
IN UINTN Cr3,
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1210,10 +1208,10 @@ InitShadowStack (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EdkiiSmmSetMemoryAttributes (
|
||||
IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes
|
||||
IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1242,10 +1240,10 @@ EdkiiSmmSetMemoryAttributes (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EdkiiSmmClearMemoryAttributes (
|
||||
IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes
|
||||
IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1272,10 +1270,10 @@ EdkiiSmmClearMemoryAttributes (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EdkiiSmmGetMemoryAttributes (
|
||||
IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 *Attributes
|
||||
IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 *Attributes
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1285,7 +1283,7 @@ EdkiiSmmGetMemoryAttributes (
|
||||
VOID
|
||||
EFIAPI
|
||||
PiSmmCpuSmmInitFixupAddress (
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
This function fixes up the address of the global variable or function
|
||||
@@ -1294,7 +1292,7 @@ PiSmmCpuSmmInitFixupAddress (
|
||||
VOID
|
||||
EFIAPI
|
||||
PiSmmCpuSmiEntryFixupAddress (
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
This function reads CR2 register when on-demand paging is enabled
|
||||
@@ -1355,12 +1353,12 @@ RestoreCr2 (
|
||||
**/
|
||||
EFI_STATUS
|
||||
InternalSmmStartupThisAp (
|
||||
IN EFI_AP_PROCEDURE2 Procedure,
|
||||
IN UINTN CpuIndex,
|
||||
IN OUT VOID *ProcArguments OPTIONAL,
|
||||
IN OUT MM_COMPLETION *Token,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN OUT EFI_STATUS *CpuStatus
|
||||
IN EFI_AP_PROCEDURE2 Procedure,
|
||||
IN UINTN CpuIndex,
|
||||
IN OUT VOID *ProcArguments OPTIONAL,
|
||||
IN OUT MM_COMPLETION *Token,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN OUT EFI_STATUS *CpuStatus
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1374,7 +1372,7 @@ InternalSmmStartupThisAp (
|
||||
**/
|
||||
BOOLEAN
|
||||
IsTokenInUse (
|
||||
IN SPIN_LOCK *Token
|
||||
IN SPIN_LOCK *Token
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1405,7 +1403,7 @@ IsApReady (
|
||||
**/
|
||||
BOOLEAN
|
||||
IsPresentAp (
|
||||
IN UINTN CpuIndex
|
||||
IN UINTN CpuIndex
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1439,11 +1437,11 @@ IsPresentAp (
|
||||
**/
|
||||
EFI_STATUS
|
||||
InternalSmmStartupAllAPs (
|
||||
IN EFI_AP_PROCEDURE2 Procedure,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN OUT VOID *ProcedureArguments OPTIONAL,
|
||||
IN OUT MM_COMPLETION *Token,
|
||||
IN OUT EFI_STATUS *CPUStatus
|
||||
IN EFI_AP_PROCEDURE2 Procedure,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN OUT VOID *ProcedureArguments OPTIONAL,
|
||||
IN OUT MM_COMPLETION *Token,
|
||||
IN OUT EFI_STATUS *CPUStatus
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1466,8 +1464,8 @@ InternalSmmStartupAllAPs (
|
||||
**/
|
||||
EFI_STATUS
|
||||
RegisterStartupProcedure (
|
||||
IN EFI_AP_PROCEDURE Procedure,
|
||||
IN OUT VOID *ProcedureArguments OPTIONAL
|
||||
IN EFI_AP_PROCEDURE Procedure,
|
||||
IN OUT VOID *ProcedureArguments OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
///
|
||||
/// SMM MP Protocol instance
|
||||
///
|
||||
EFI_MM_MP_PROTOCOL mSmmMp = {
|
||||
EFI_MM_MP_PROTOCOL mSmmMp = {
|
||||
EFI_MM_MP_PROTOCOL_REVISION,
|
||||
0,
|
||||
SmmMpGetNumberOfProcessors,
|
||||
@@ -37,8 +37,8 @@ EFI_MM_MP_PROTOCOL mSmmMp = {
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmMpGetNumberOfProcessors (
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
OUT UINTN *NumberOfProcessors
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
OUT UINTN *NumberOfProcessors
|
||||
)
|
||||
{
|
||||
if (NumberOfProcessors == NULL) {
|
||||
@@ -114,23 +114,23 @@ SmmMpGetNumberOfProcessors (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmMpDispatchProcedure (
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN EFI_AP_PROCEDURE2 Procedure,
|
||||
IN UINTN CpuNumber,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN OUT VOID *ProcedureArguments OPTIONAL,
|
||||
IN OUT MM_COMPLETION *Token,
|
||||
IN OUT EFI_STATUS *CPUStatus
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN EFI_AP_PROCEDURE2 Procedure,
|
||||
IN UINTN CpuNumber,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN OUT VOID *ProcedureArguments OPTIONAL,
|
||||
IN OUT MM_COMPLETION *Token,
|
||||
IN OUT EFI_STATUS *CPUStatus
|
||||
)
|
||||
{
|
||||
return InternalSmmStartupThisAp (
|
||||
Procedure,
|
||||
CpuNumber,
|
||||
ProcedureArguments,
|
||||
Token,
|
||||
TimeoutInMicroseconds,
|
||||
CPUStatus
|
||||
);
|
||||
Procedure,
|
||||
CpuNumber,
|
||||
ProcedureArguments,
|
||||
Token,
|
||||
TimeoutInMicroseconds,
|
||||
CPUStatus
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,21 +202,21 @@ SmmMpDispatchProcedure (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmMpBroadcastProcedure (
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN EFI_AP_PROCEDURE2 Procedure,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN OUT VOID *ProcedureArguments OPTIONAL,
|
||||
IN OUT MM_COMPLETION *Token,
|
||||
IN OUT EFI_STATUS *CPUStatus
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN EFI_AP_PROCEDURE2 Procedure,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN OUT VOID *ProcedureArguments OPTIONAL,
|
||||
IN OUT MM_COMPLETION *Token,
|
||||
IN OUT EFI_STATUS *CPUStatus
|
||||
)
|
||||
{
|
||||
return InternalSmmStartupAllAPs(
|
||||
Procedure,
|
||||
TimeoutInMicroseconds,
|
||||
ProcedureArguments,
|
||||
Token,
|
||||
CPUStatus
|
||||
);
|
||||
return InternalSmmStartupAllAPs (
|
||||
Procedure,
|
||||
TimeoutInMicroseconds,
|
||||
ProcedureArguments,
|
||||
Token,
|
||||
CPUStatus
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,8 +286,8 @@ SmmMpSetStartupProcedure (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmMpCheckForProcedure (
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN MM_COMPLETION Token
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN MM_COMPLETION Token
|
||||
)
|
||||
{
|
||||
if (Token == NULL) {
|
||||
@@ -329,11 +329,11 @@ SmmMpCheckForProcedure (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmMpWaitForProcedure (
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN MM_COMPLETION Token
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN MM_COMPLETION Token
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
do {
|
||||
Status = SmmMpCheckForProcedure (This, Token);
|
||||
@@ -341,4 +341,3 @@ SmmMpWaitForProcedure (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@@ -27,11 +27,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmMpGetNumberOfProcessors (
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
OUT UINTN *NumberOfProcessors
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
OUT UINTN *NumberOfProcessors
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
This service allows the caller to invoke a procedure one of the application processors (AP). This
|
||||
function uses an optional token parameter to support blocking and non-blocking modes. If the token
|
||||
@@ -96,13 +95,13 @@ SmmMpGetNumberOfProcessors (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmMpDispatchProcedure (
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN EFI_AP_PROCEDURE2 Procedure,
|
||||
IN UINTN CpuNumber,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN OUT VOID *ProcedureArguments OPTIONAL,
|
||||
IN OUT MM_COMPLETION *Token,
|
||||
IN OUT EFI_STATUS *CPUStatus
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN EFI_AP_PROCEDURE2 Procedure,
|
||||
IN UINTN CpuNumber,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN OUT VOID *ProcedureArguments OPTIONAL,
|
||||
IN OUT MM_COMPLETION *Token,
|
||||
IN OUT EFI_STATUS *CPUStatus
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -174,15 +173,14 @@ SmmMpDispatchProcedure (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmMpBroadcastProcedure (
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN EFI_AP_PROCEDURE2 Procedure,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN OUT VOID *ProcedureArguments OPTIONAL,
|
||||
IN OUT MM_COMPLETION *Token,
|
||||
IN OUT EFI_STATUS *CPUStatus
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN EFI_AP_PROCEDURE2 Procedure,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN OUT VOID *ProcedureArguments OPTIONAL,
|
||||
IN OUT MM_COMPLETION *Token,
|
||||
IN OUT EFI_STATUS *CPUStatus
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
This service allows the caller to set a startup procedure that will be executed when an AP powers
|
||||
up from a state where core configuration and context is lost. The procedure is execution has the
|
||||
@@ -246,8 +244,8 @@ SmmMpSetStartupProcedure (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmMpCheckForProcedure (
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN MM_COMPLETION Token
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN MM_COMPLETION Token
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -278,8 +276,8 @@ SmmMpCheckForProcedure (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmMpWaitForProcedure (
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN MM_COMPLETION Token
|
||||
IN CONST EFI_MM_MP_PROTOCOL *This,
|
||||
IN MM_COMPLETION Token
|
||||
);
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
VOID
|
||||
ActivateSmmProfile (
|
||||
IN UINTN CpuIndex
|
||||
IN UINTN CpuIndex
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -55,8 +55,8 @@ SmmProfileRecordSmiNum (
|
||||
**/
|
||||
VOID
|
||||
SmmProfilePFHandler (
|
||||
UINTN Rip,
|
||||
UINTN ErrorCode
|
||||
UINTN Rip,
|
||||
UINTN ErrorCode
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,6 @@ PageFaultIdtHandlerSmmProfile (
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Check if feature is supported by a processor.
|
||||
|
||||
@@ -116,20 +115,20 @@ GetCpuIndex (
|
||||
**/
|
||||
VOID
|
||||
GuardPagePFHandler (
|
||||
UINTN ErrorCode
|
||||
UINTN ErrorCode
|
||||
);
|
||||
|
||||
//
|
||||
// The flag indicates if execute-disable is supported by processor.
|
||||
//
|
||||
extern BOOLEAN mXdSupported;
|
||||
extern BOOLEAN mXdSupported;
|
||||
//
|
||||
// The flag indicates if execute-disable is enabled on processor.
|
||||
//
|
||||
extern BOOLEAN mXdEnabled;
|
||||
extern BOOLEAN mXdEnabled;
|
||||
//
|
||||
// The flag indicates if #DB will be setup in #PF handler.
|
||||
//
|
||||
extern BOOLEAN mSetupDebugTrap;
|
||||
extern BOOLEAN mSetupDebugTrap;
|
||||
|
||||
#endif // _SMM_PROFILE_H_
|
||||
|
@@ -22,41 +22,41 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// Configure the SMM_PROFILE DTS region size
|
||||
//
|
||||
#define SMM_PROFILE_DTS_SIZE (4 * 1024 * 1024) // 4M
|
||||
#define SMM_PROFILE_DTS_SIZE (4 * 1024 * 1024) // 4M
|
||||
|
||||
#define MAX_PF_PAGE_COUNT 0x2
|
||||
#define MAX_PF_PAGE_COUNT 0x2
|
||||
|
||||
#define PEBS_RECORD_NUMBER 0x2
|
||||
#define PEBS_RECORD_NUMBER 0x2
|
||||
|
||||
#define MAX_PF_ENTRY_COUNT 10
|
||||
#define MAX_PF_ENTRY_COUNT 10
|
||||
|
||||
//
|
||||
// This MACRO just enable unit test for the profile
|
||||
// Please disable it.
|
||||
//
|
||||
|
||||
#define IA32_PF_EC_ID (1u << 4)
|
||||
#define IA32_PF_EC_ID (1u << 4)
|
||||
|
||||
#define SMM_PROFILE_NAME L"SmmProfileData"
|
||||
#define SMM_PROFILE_NAME L"SmmProfileData"
|
||||
|
||||
//
|
||||
// CPU generic definition
|
||||
//
|
||||
#define CPUID1_EDX_XD_SUPPORT 0x100000
|
||||
#define MSR_EFER 0xc0000080
|
||||
#define MSR_EFER_XD 0x800
|
||||
#define CPUID1_EDX_XD_SUPPORT 0x100000
|
||||
#define MSR_EFER 0xc0000080
|
||||
#define MSR_EFER_XD 0x800
|
||||
|
||||
#define CPUID1_EDX_BTS_AVAILABLE 0x200000
|
||||
#define CPUID1_EDX_BTS_AVAILABLE 0x200000
|
||||
|
||||
#define DR6_SINGLE_STEP 0x4000
|
||||
#define RFLAG_TF 0x100
|
||||
#define DR6_SINGLE_STEP 0x4000
|
||||
#define RFLAG_TF 0x100
|
||||
|
||||
#define MSR_DEBUG_CTL 0x1D9
|
||||
#define MSR_DEBUG_CTL_LBR 0x1
|
||||
#define MSR_DEBUG_CTL_TR 0x40
|
||||
#define MSR_DEBUG_CTL_BTS 0x80
|
||||
#define MSR_DEBUG_CTL_BTINT 0x100
|
||||
#define MSR_DS_AREA 0x600
|
||||
#define MSR_DEBUG_CTL 0x1D9
|
||||
#define MSR_DEBUG_CTL_LBR 0x1
|
||||
#define MSR_DEBUG_CTL_TR 0x40
|
||||
#define MSR_DEBUG_CTL_BTS 0x80
|
||||
#define MSR_DEBUG_CTL_BTINT 0x100
|
||||
#define MSR_DS_AREA 0x600
|
||||
|
||||
#define HEAP_GUARD_NONSTOP_MODE \
|
||||
((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT6|BIT3|BIT2)) > BIT6)
|
||||
@@ -65,45 +65,45 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
((PcdGet8 (PcdNullPointerDetectionPropertyMask) & (BIT6|BIT1)) > BIT6)
|
||||
|
||||
typedef struct {
|
||||
EFI_PHYSICAL_ADDRESS Base;
|
||||
EFI_PHYSICAL_ADDRESS Top;
|
||||
EFI_PHYSICAL_ADDRESS Base;
|
||||
EFI_PHYSICAL_ADDRESS Top;
|
||||
} MEMORY_RANGE;
|
||||
|
||||
typedef struct {
|
||||
MEMORY_RANGE Range;
|
||||
BOOLEAN Present;
|
||||
BOOLEAN Nx;
|
||||
MEMORY_RANGE Range;
|
||||
BOOLEAN Present;
|
||||
BOOLEAN Nx;
|
||||
} MEMORY_PROTECTION_RANGE;
|
||||
|
||||
typedef struct {
|
||||
UINT64 HeaderSize;
|
||||
UINT64 MaxDataEntries;
|
||||
UINT64 MaxDataSize;
|
||||
UINT64 CurDataEntries;
|
||||
UINT64 CurDataSize;
|
||||
UINT64 TsegStart;
|
||||
UINT64 TsegSize;
|
||||
UINT64 NumSmis;
|
||||
UINT64 NumCpus;
|
||||
UINT64 HeaderSize;
|
||||
UINT64 MaxDataEntries;
|
||||
UINT64 MaxDataSize;
|
||||
UINT64 CurDataEntries;
|
||||
UINT64 CurDataSize;
|
||||
UINT64 TsegStart;
|
||||
UINT64 TsegSize;
|
||||
UINT64 NumSmis;
|
||||
UINT64 NumCpus;
|
||||
} SMM_PROFILE_HEADER;
|
||||
|
||||
typedef struct {
|
||||
UINT64 SmiNum;
|
||||
UINT64 CpuNum;
|
||||
UINT64 ApicId;
|
||||
UINT64 ErrorCode;
|
||||
UINT64 Instruction;
|
||||
UINT64 Address;
|
||||
UINT64 SmiCmd;
|
||||
UINT64 SmiNum;
|
||||
UINT64 CpuNum;
|
||||
UINT64 ApicId;
|
||||
UINT64 ErrorCode;
|
||||
UINT64 Instruction;
|
||||
UINT64 Address;
|
||||
UINT64 SmiCmd;
|
||||
} SMM_PROFILE_ENTRY;
|
||||
|
||||
extern SMM_S3_RESUME_STATE *mSmmS3ResumeState;
|
||||
extern UINTN gSmiExceptionHandlers[];
|
||||
extern BOOLEAN mXdSupported;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchXdSupported;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchMsrIa32MiscEnableSupported;
|
||||
extern UINTN *mPFEntryCount;
|
||||
extern UINT64 (*mLastPFEntryValue)[MAX_PF_ENTRY_COUNT];
|
||||
extern SMM_S3_RESUME_STATE *mSmmS3ResumeState;
|
||||
extern UINTN gSmiExceptionHandlers[];
|
||||
extern BOOLEAN mXdSupported;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchXdSupported;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchMsrIa32MiscEnableSupported;
|
||||
extern UINTN *mPFEntryCount;
|
||||
extern UINT64 (*mLastPFEntryValue)[MAX_PF_ENTRY_COUNT];
|
||||
extern UINT64 *(*mLastPFEntryPointer)[MAX_PF_ENTRY_COUNT];
|
||||
|
||||
//
|
||||
@@ -127,7 +127,7 @@ InitIdtr (
|
||||
**/
|
||||
BOOLEAN
|
||||
IsAddressSplit (
|
||||
IN EFI_PHYSICAL_ADDRESS Address
|
||||
IN EFI_PHYSICAL_ADDRESS Address
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -139,8 +139,8 @@ IsAddressSplit (
|
||||
**/
|
||||
BOOLEAN
|
||||
IsAddressValid (
|
||||
IN EFI_PHYSICAL_ADDRESS Address,
|
||||
IN BOOLEAN *Nx
|
||||
IN EFI_PHYSICAL_ADDRESS Address,
|
||||
IN BOOLEAN *Nx
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -161,7 +161,7 @@ SmiDefaultPFHandler (
|
||||
**/
|
||||
VOID
|
||||
ClearTrapFlag (
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
);
|
||||
|
||||
#endif // _SMM_PROFILE_H_
|
||||
|
@@ -18,53 +18,53 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include "PiSmmCpuDxeSmm.h"
|
||||
|
||||
typedef struct {
|
||||
UINT64 Signature; // Offset 0x00
|
||||
UINT16 Reserved1; // Offset 0x08
|
||||
UINT16 Reserved2; // Offset 0x0A
|
||||
UINT16 Reserved3; // Offset 0x0C
|
||||
UINT16 SmmCs; // Offset 0x0E
|
||||
UINT16 SmmDs; // Offset 0x10
|
||||
UINT16 SmmSs; // Offset 0x12
|
||||
UINT16 SmmOtherSegment; // Offset 0x14
|
||||
UINT16 Reserved4; // Offset 0x16
|
||||
UINT64 Reserved5; // Offset 0x18
|
||||
UINT64 Reserved6; // Offset 0x20
|
||||
UINT64 Reserved7; // Offset 0x28
|
||||
UINT64 SmmGdtPtr; // Offset 0x30
|
||||
UINT32 SmmGdtSize; // Offset 0x38
|
||||
UINT32 Reserved8; // Offset 0x3C
|
||||
UINT64 Reserved9; // Offset 0x40
|
||||
UINT64 Reserved10; // Offset 0x48
|
||||
UINT16 Reserved11; // Offset 0x50
|
||||
UINT16 Reserved12; // Offset 0x52
|
||||
UINT32 Reserved13; // Offset 0x54
|
||||
UINT64 Reserved14; // Offset 0x58
|
||||
UINT64 Signature; // Offset 0x00
|
||||
UINT16 Reserved1; // Offset 0x08
|
||||
UINT16 Reserved2; // Offset 0x0A
|
||||
UINT16 Reserved3; // Offset 0x0C
|
||||
UINT16 SmmCs; // Offset 0x0E
|
||||
UINT16 SmmDs; // Offset 0x10
|
||||
UINT16 SmmSs; // Offset 0x12
|
||||
UINT16 SmmOtherSegment; // Offset 0x14
|
||||
UINT16 Reserved4; // Offset 0x16
|
||||
UINT64 Reserved5; // Offset 0x18
|
||||
UINT64 Reserved6; // Offset 0x20
|
||||
UINT64 Reserved7; // Offset 0x28
|
||||
UINT64 SmmGdtPtr; // Offset 0x30
|
||||
UINT32 SmmGdtSize; // Offset 0x38
|
||||
UINT32 Reserved8; // Offset 0x3C
|
||||
UINT64 Reserved9; // Offset 0x40
|
||||
UINT64 Reserved10; // Offset 0x48
|
||||
UINT16 Reserved11; // Offset 0x50
|
||||
UINT16 Reserved12; // Offset 0x52
|
||||
UINT32 Reserved13; // Offset 0x54
|
||||
UINT64 Reserved14; // Offset 0x58
|
||||
} PROCESSOR_SMM_DESCRIPTOR;
|
||||
|
||||
extern CONST PROCESSOR_SMM_DESCRIPTOR gcPsd;
|
||||
extern CONST PROCESSOR_SMM_DESCRIPTOR gcPsd;
|
||||
|
||||
//
|
||||
// EFER register LMA bit
|
||||
//
|
||||
#define LMA BIT10
|
||||
#define LMA BIT10
|
||||
|
||||
///
|
||||
/// Macro used to simplify the lookup table entries of type CPU_SMM_SAVE_STATE_LOOKUP_ENTRY
|
||||
///
|
||||
#define SMM_CPU_OFFSET(Field) OFFSET_OF (SMRAM_SAVE_STATE_MAP, Field)
|
||||
#define SMM_CPU_OFFSET(Field) OFFSET_OF (SMRAM_SAVE_STATE_MAP, Field)
|
||||
|
||||
///
|
||||
/// Macro used to simplify the lookup table entries of type CPU_SMM_SAVE_STATE_REGISTER_RANGE
|
||||
///
|
||||
#define SMM_REGISTER_RANGE(Start, End) { Start, End, End - Start + 1 }
|
||||
#define SMM_REGISTER_RANGE(Start, End) { Start, End, End - Start + 1 }
|
||||
|
||||
///
|
||||
/// Structure used to describe a range of registers
|
||||
///
|
||||
typedef struct {
|
||||
EFI_SMM_SAVE_STATE_REGISTER Start;
|
||||
EFI_SMM_SAVE_STATE_REGISTER End;
|
||||
UINTN Length;
|
||||
EFI_SMM_SAVE_STATE_REGISTER Start;
|
||||
EFI_SMM_SAVE_STATE_REGISTER End;
|
||||
UINTN Length;
|
||||
} CPU_SMM_SAVE_STATE_REGISTER_RANGE;
|
||||
|
||||
///
|
||||
@@ -72,36 +72,36 @@ typedef struct {
|
||||
/// associated with each supported EFI_SMM_SAVE_STATE_REGISTER value
|
||||
///
|
||||
|
||||
#define SMM_SAVE_STATE_REGISTER_SMMREVID_INDEX 1
|
||||
#define SMM_SAVE_STATE_REGISTER_IOMISC_INDEX 2
|
||||
#define SMM_SAVE_STATE_REGISTER_IOMEMADDR_INDEX 3
|
||||
#define SMM_SAVE_STATE_REGISTER_MAX_INDEX 4
|
||||
#define SMM_SAVE_STATE_REGISTER_SMMREVID_INDEX 1
|
||||
#define SMM_SAVE_STATE_REGISTER_IOMISC_INDEX 2
|
||||
#define SMM_SAVE_STATE_REGISTER_IOMEMADDR_INDEX 3
|
||||
#define SMM_SAVE_STATE_REGISTER_MAX_INDEX 4
|
||||
|
||||
typedef struct {
|
||||
UINT8 Width32;
|
||||
UINT8 Width64;
|
||||
UINT16 Offset32;
|
||||
UINT16 Offset64Lo;
|
||||
UINT16 Offset64Hi;
|
||||
BOOLEAN Writeable;
|
||||
UINT8 Width32;
|
||||
UINT8 Width64;
|
||||
UINT16 Offset32;
|
||||
UINT16 Offset64Lo;
|
||||
UINT16 Offset64Hi;
|
||||
BOOLEAN Writeable;
|
||||
} CPU_SMM_SAVE_STATE_LOOKUP_ENTRY;
|
||||
|
||||
///
|
||||
/// Structure used to build a lookup table for the IOMisc width information
|
||||
///
|
||||
typedef struct {
|
||||
UINT8 Width;
|
||||
EFI_SMM_SAVE_STATE_IO_WIDTH IoWidth;
|
||||
UINT8 Width;
|
||||
EFI_SMM_SAVE_STATE_IO_WIDTH IoWidth;
|
||||
} CPU_SMM_SAVE_STATE_IO_WIDTH;
|
||||
|
||||
///
|
||||
/// Variables from SMI Handler
|
||||
///
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmbase;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmiStack;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmiCr3;
|
||||
extern volatile UINT8 gcSmiHandlerTemplate[];
|
||||
extern CONST UINT16 gcSmiHandlerSize;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmbase;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmiStack;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmiCr3;
|
||||
extern volatile UINT8 gcSmiHandlerTemplate[];
|
||||
extern CONST UINT16 gcSmiHandlerSize;
|
||||
|
||||
//
|
||||
// Variables used by SMI Handler
|
||||
@@ -112,76 +112,76 @@ IA32_DESCRIPTOR gSmiHandlerIdtr;
|
||||
/// Table used by GetRegisterIndex() to convert an EFI_SMM_SAVE_STATE_REGISTER
|
||||
/// value to an index into a table of type CPU_SMM_SAVE_STATE_LOOKUP_ENTRY
|
||||
///
|
||||
CONST CPU_SMM_SAVE_STATE_REGISTER_RANGE mSmmCpuRegisterRanges[] = {
|
||||
CONST CPU_SMM_SAVE_STATE_REGISTER_RANGE mSmmCpuRegisterRanges[] = {
|
||||
SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_GDTBASE, EFI_SMM_SAVE_STATE_REGISTER_LDTINFO),
|
||||
SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_ES, EFI_SMM_SAVE_STATE_REGISTER_RIP),
|
||||
SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_RFLAGS, EFI_SMM_SAVE_STATE_REGISTER_CR4),
|
||||
{ (EFI_SMM_SAVE_STATE_REGISTER)0, (EFI_SMM_SAVE_STATE_REGISTER)0, 0 }
|
||||
{ (EFI_SMM_SAVE_STATE_REGISTER)0, (EFI_SMM_SAVE_STATE_REGISTER)0, 0}
|
||||
};
|
||||
|
||||
///
|
||||
/// Lookup table used to retrieve the widths and offsets associated with each
|
||||
/// supported EFI_SMM_SAVE_STATE_REGISTER value
|
||||
///
|
||||
CONST CPU_SMM_SAVE_STATE_LOOKUP_ENTRY mSmmCpuWidthOffset[] = {
|
||||
{0, 0, 0, 0, 0, FALSE}, // Reserved
|
||||
CONST CPU_SMM_SAVE_STATE_LOOKUP_ENTRY mSmmCpuWidthOffset[] = {
|
||||
{ 0, 0, 0, 0, 0, FALSE }, // Reserved
|
||||
|
||||
//
|
||||
// Internally defined CPU Save State Registers. Not defined in PI SMM CPU Protocol.
|
||||
//
|
||||
{4, 4, SMM_CPU_OFFSET (x86.SMMRevId) , SMM_CPU_OFFSET (x64.SMMRevId) , 0 , FALSE}, // SMM_SAVE_STATE_REGISTER_SMMREVID_INDEX = 1
|
||||
{4, 4, SMM_CPU_OFFSET (x86.IOMisc) , SMM_CPU_OFFSET (x64.IOMisc) , 0 , FALSE}, // SMM_SAVE_STATE_REGISTER_IOMISC_INDEX = 2
|
||||
{4, 8, SMM_CPU_OFFSET (x86.IOMemAddr) , SMM_CPU_OFFSET (x64.IOMemAddr) , SMM_CPU_OFFSET (x64.IOMemAddr) + 4, FALSE}, // SMM_SAVE_STATE_REGISTER_IOMEMADDR_INDEX = 3
|
||||
{ 4, 4, SMM_CPU_OFFSET (x86.SMMRevId), SMM_CPU_OFFSET (x64.SMMRevId), 0, FALSE }, // SMM_SAVE_STATE_REGISTER_SMMREVID_INDEX = 1
|
||||
{ 4, 4, SMM_CPU_OFFSET (x86.IOMisc), SMM_CPU_OFFSET (x64.IOMisc), 0, FALSE }, // SMM_SAVE_STATE_REGISTER_IOMISC_INDEX = 2
|
||||
{ 4, 8, SMM_CPU_OFFSET (x86.IOMemAddr), SMM_CPU_OFFSET (x64.IOMemAddr), SMM_CPU_OFFSET (x64.IOMemAddr) + 4, FALSE }, // SMM_SAVE_STATE_REGISTER_IOMEMADDR_INDEX = 3
|
||||
|
||||
//
|
||||
// CPU Save State registers defined in PI SMM CPU Protocol.
|
||||
//
|
||||
{0, 8, 0 , SMM_CPU_OFFSET (x64.GdtBaseLoDword) , SMM_CPU_OFFSET (x64.GdtBaseHiDword), FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_GDTBASE = 4
|
||||
{0, 8, 0 , SMM_CPU_OFFSET (x64.IdtBaseLoDword) , SMM_CPU_OFFSET (x64.IdtBaseHiDword), FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_IDTBASE = 5
|
||||
{0, 8, 0 , SMM_CPU_OFFSET (x64.LdtBaseLoDword) , SMM_CPU_OFFSET (x64.LdtBaseHiDword), FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTBASE = 6
|
||||
{0, 0, 0 , 0 , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_GDTLIMIT = 7
|
||||
{0, 0, 0 , 0 , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_IDTLIMIT = 8
|
||||
{0, 0, 0 , 0 , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTLIMIT = 9
|
||||
{0, 0, 0 , 0 , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTINFO = 10
|
||||
{ 0, 8, 0, SMM_CPU_OFFSET (x64.GdtBaseLoDword), SMM_CPU_OFFSET (x64.GdtBaseHiDword), FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_GDTBASE = 4
|
||||
{ 0, 8, 0, SMM_CPU_OFFSET (x64.IdtBaseLoDword), SMM_CPU_OFFSET (x64.IdtBaseHiDword), FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_IDTBASE = 5
|
||||
{ 0, 8, 0, SMM_CPU_OFFSET (x64.LdtBaseLoDword), SMM_CPU_OFFSET (x64.LdtBaseHiDword), FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_LDTBASE = 6
|
||||
{ 0, 0, 0, 0, 0, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_GDTLIMIT = 7
|
||||
{ 0, 0, 0, 0, 0, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_IDTLIMIT = 8
|
||||
{ 0, 0, 0, 0, 0, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_LDTLIMIT = 9
|
||||
{ 0, 0, 0, 0, 0, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_LDTINFO = 10
|
||||
|
||||
{4, 4, SMM_CPU_OFFSET (x86._ES) , SMM_CPU_OFFSET (x64._ES) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_ES = 20
|
||||
{4, 4, SMM_CPU_OFFSET (x86._CS) , SMM_CPU_OFFSET (x64._CS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CS = 21
|
||||
{4, 4, SMM_CPU_OFFSET (x86._SS) , SMM_CPU_OFFSET (x64._SS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_SS = 22
|
||||
{4, 4, SMM_CPU_OFFSET (x86._DS) , SMM_CPU_OFFSET (x64._DS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_DS = 23
|
||||
{4, 4, SMM_CPU_OFFSET (x86._FS) , SMM_CPU_OFFSET (x64._FS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_FS = 24
|
||||
{4, 4, SMM_CPU_OFFSET (x86._GS) , SMM_CPU_OFFSET (x64._GS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_GS = 25
|
||||
{0, 4, 0 , SMM_CPU_OFFSET (x64._LDTR) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTR_SEL = 26
|
||||
{4, 4, SMM_CPU_OFFSET (x86._TR) , SMM_CPU_OFFSET (x64._TR) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_TR_SEL = 27
|
||||
{4, 8, SMM_CPU_OFFSET (x86._DR7) , SMM_CPU_OFFSET (x64._DR7) , SMM_CPU_OFFSET (x64._DR7) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_DR7 = 28
|
||||
{4, 8, SMM_CPU_OFFSET (x86._DR6) , SMM_CPU_OFFSET (x64._DR6) , SMM_CPU_OFFSET (x64._DR6) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_DR6 = 29
|
||||
{0, 8, 0 , SMM_CPU_OFFSET (x64._R8) , SMM_CPU_OFFSET (x64._R8) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R8 = 30
|
||||
{0, 8, 0 , SMM_CPU_OFFSET (x64._R9) , SMM_CPU_OFFSET (x64._R9) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R9 = 31
|
||||
{0, 8, 0 , SMM_CPU_OFFSET (x64._R10) , SMM_CPU_OFFSET (x64._R10) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R10 = 32
|
||||
{0, 8, 0 , SMM_CPU_OFFSET (x64._R11) , SMM_CPU_OFFSET (x64._R11) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R11 = 33
|
||||
{0, 8, 0 , SMM_CPU_OFFSET (x64._R12) , SMM_CPU_OFFSET (x64._R12) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R12 = 34
|
||||
{0, 8, 0 , SMM_CPU_OFFSET (x64._R13) , SMM_CPU_OFFSET (x64._R13) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R13 = 35
|
||||
{0, 8, 0 , SMM_CPU_OFFSET (x64._R14) , SMM_CPU_OFFSET (x64._R14) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R14 = 36
|
||||
{0, 8, 0 , SMM_CPU_OFFSET (x64._R15) , SMM_CPU_OFFSET (x64._R15) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R15 = 37
|
||||
{4, 8, SMM_CPU_OFFSET (x86._EAX) , SMM_CPU_OFFSET (x64._RAX) , SMM_CPU_OFFSET (x64._RAX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RAX = 38
|
||||
{4, 8, SMM_CPU_OFFSET (x86._EBX) , SMM_CPU_OFFSET (x64._RBX) , SMM_CPU_OFFSET (x64._RBX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RBX = 39
|
||||
{4, 8, SMM_CPU_OFFSET (x86._ECX) , SMM_CPU_OFFSET (x64._RCX) , SMM_CPU_OFFSET (x64._RCX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RCX = 40
|
||||
{4, 8, SMM_CPU_OFFSET (x86._EDX) , SMM_CPU_OFFSET (x64._RDX) , SMM_CPU_OFFSET (x64._RDX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RDX = 41
|
||||
{4, 8, SMM_CPU_OFFSET (x86._ESP) , SMM_CPU_OFFSET (x64._RSP) , SMM_CPU_OFFSET (x64._RSP) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RSP = 42
|
||||
{4, 8, SMM_CPU_OFFSET (x86._EBP) , SMM_CPU_OFFSET (x64._RBP) , SMM_CPU_OFFSET (x64._RBP) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RBP = 43
|
||||
{4, 8, SMM_CPU_OFFSET (x86._ESI) , SMM_CPU_OFFSET (x64._RSI) , SMM_CPU_OFFSET (x64._RSI) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RSI = 44
|
||||
{4, 8, SMM_CPU_OFFSET (x86._EDI) , SMM_CPU_OFFSET (x64._RDI) , SMM_CPU_OFFSET (x64._RDI) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RDI = 45
|
||||
{4, 8, SMM_CPU_OFFSET (x86._EIP) , SMM_CPU_OFFSET (x64._RIP) , SMM_CPU_OFFSET (x64._RIP) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RIP = 46
|
||||
{ 4, 4, SMM_CPU_OFFSET (x86._ES), SMM_CPU_OFFSET (x64._ES), 0, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_ES = 20
|
||||
{ 4, 4, SMM_CPU_OFFSET (x86._CS), SMM_CPU_OFFSET (x64._CS), 0, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_CS = 21
|
||||
{ 4, 4, SMM_CPU_OFFSET (x86._SS), SMM_CPU_OFFSET (x64._SS), 0, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_SS = 22
|
||||
{ 4, 4, SMM_CPU_OFFSET (x86._DS), SMM_CPU_OFFSET (x64._DS), 0, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_DS = 23
|
||||
{ 4, 4, SMM_CPU_OFFSET (x86._FS), SMM_CPU_OFFSET (x64._FS), 0, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_FS = 24
|
||||
{ 4, 4, SMM_CPU_OFFSET (x86._GS), SMM_CPU_OFFSET (x64._GS), 0, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_GS = 25
|
||||
{ 0, 4, 0, SMM_CPU_OFFSET (x64._LDTR), 0, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_LDTR_SEL = 26
|
||||
{ 4, 4, SMM_CPU_OFFSET (x86._TR), SMM_CPU_OFFSET (x64._TR), 0, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_TR_SEL = 27
|
||||
{ 4, 8, SMM_CPU_OFFSET (x86._DR7), SMM_CPU_OFFSET (x64._DR7), SMM_CPU_OFFSET (x64._DR7) + 4, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_DR7 = 28
|
||||
{ 4, 8, SMM_CPU_OFFSET (x86._DR6), SMM_CPU_OFFSET (x64._DR6), SMM_CPU_OFFSET (x64._DR6) + 4, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_DR6 = 29
|
||||
{ 0, 8, 0, SMM_CPU_OFFSET (x64._R8), SMM_CPU_OFFSET (x64._R8) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R8 = 30
|
||||
{ 0, 8, 0, SMM_CPU_OFFSET (x64._R9), SMM_CPU_OFFSET (x64._R9) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R9 = 31
|
||||
{ 0, 8, 0, SMM_CPU_OFFSET (x64._R10), SMM_CPU_OFFSET (x64._R10) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R10 = 32
|
||||
{ 0, 8, 0, SMM_CPU_OFFSET (x64._R11), SMM_CPU_OFFSET (x64._R11) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R11 = 33
|
||||
{ 0, 8, 0, SMM_CPU_OFFSET (x64._R12), SMM_CPU_OFFSET (x64._R12) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R12 = 34
|
||||
{ 0, 8, 0, SMM_CPU_OFFSET (x64._R13), SMM_CPU_OFFSET (x64._R13) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R13 = 35
|
||||
{ 0, 8, 0, SMM_CPU_OFFSET (x64._R14), SMM_CPU_OFFSET (x64._R14) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R14 = 36
|
||||
{ 0, 8, 0, SMM_CPU_OFFSET (x64._R15), SMM_CPU_OFFSET (x64._R15) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R15 = 37
|
||||
{ 4, 8, SMM_CPU_OFFSET (x86._EAX), SMM_CPU_OFFSET (x64._RAX), SMM_CPU_OFFSET (x64._RAX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RAX = 38
|
||||
{ 4, 8, SMM_CPU_OFFSET (x86._EBX), SMM_CPU_OFFSET (x64._RBX), SMM_CPU_OFFSET (x64._RBX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RBX = 39
|
||||
{ 4, 8, SMM_CPU_OFFSET (x86._ECX), SMM_CPU_OFFSET (x64._RCX), SMM_CPU_OFFSET (x64._RCX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RCX = 40
|
||||
{ 4, 8, SMM_CPU_OFFSET (x86._EDX), SMM_CPU_OFFSET (x64._RDX), SMM_CPU_OFFSET (x64._RDX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RDX = 41
|
||||
{ 4, 8, SMM_CPU_OFFSET (x86._ESP), SMM_CPU_OFFSET (x64._RSP), SMM_CPU_OFFSET (x64._RSP) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RSP = 42
|
||||
{ 4, 8, SMM_CPU_OFFSET (x86._EBP), SMM_CPU_OFFSET (x64._RBP), SMM_CPU_OFFSET (x64._RBP) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RBP = 43
|
||||
{ 4, 8, SMM_CPU_OFFSET (x86._ESI), SMM_CPU_OFFSET (x64._RSI), SMM_CPU_OFFSET (x64._RSI) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RSI = 44
|
||||
{ 4, 8, SMM_CPU_OFFSET (x86._EDI), SMM_CPU_OFFSET (x64._RDI), SMM_CPU_OFFSET (x64._RDI) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RDI = 45
|
||||
{ 4, 8, SMM_CPU_OFFSET (x86._EIP), SMM_CPU_OFFSET (x64._RIP), SMM_CPU_OFFSET (x64._RIP) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RIP = 46
|
||||
|
||||
{4, 8, SMM_CPU_OFFSET (x86._EFLAGS) , SMM_CPU_OFFSET (x64._RFLAGS) , SMM_CPU_OFFSET (x64._RFLAGS) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RFLAGS = 51
|
||||
{4, 8, SMM_CPU_OFFSET (x86._CR0) , SMM_CPU_OFFSET (x64._CR0) , SMM_CPU_OFFSET (x64._CR0) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CR0 = 52
|
||||
{4, 8, SMM_CPU_OFFSET (x86._CR3) , SMM_CPU_OFFSET (x64._CR3) , SMM_CPU_OFFSET (x64._CR3) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CR3 = 53
|
||||
{0, 4, 0 , SMM_CPU_OFFSET (x64._CR4) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CR4 = 54
|
||||
{ 4, 8, SMM_CPU_OFFSET (x86._EFLAGS), SMM_CPU_OFFSET (x64._RFLAGS), SMM_CPU_OFFSET (x64._RFLAGS) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RFLAGS = 51
|
||||
{ 4, 8, SMM_CPU_OFFSET (x86._CR0), SMM_CPU_OFFSET (x64._CR0), SMM_CPU_OFFSET (x64._CR0) + 4, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_CR0 = 52
|
||||
{ 4, 8, SMM_CPU_OFFSET (x86._CR3), SMM_CPU_OFFSET (x64._CR3), SMM_CPU_OFFSET (x64._CR3) + 4, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_CR3 = 53
|
||||
{ 0, 4, 0, SMM_CPU_OFFSET (x64._CR4), 0, FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_CR4 = 54
|
||||
};
|
||||
|
||||
///
|
||||
/// Lookup table for the IOMisc width information
|
||||
///
|
||||
CONST CPU_SMM_SAVE_STATE_IO_WIDTH mSmmCpuIoWidth[] = {
|
||||
CONST CPU_SMM_SAVE_STATE_IO_WIDTH mSmmCpuIoWidth[] = {
|
||||
{ 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // Undefined = 0
|
||||
{ 1, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // SMM_IO_LENGTH_BYTE = 1
|
||||
{ 2, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT16 }, // SMM_IO_LENGTH_WORD = 2
|
||||
@@ -195,7 +195,7 @@ CONST CPU_SMM_SAVE_STATE_IO_WIDTH mSmmCpuIoWidth[] = {
|
||||
///
|
||||
/// Lookup table for the IOMisc type information
|
||||
///
|
||||
CONST EFI_SMM_SAVE_STATE_IO_TYPE mSmmCpuIoType[] = {
|
||||
CONST EFI_SMM_SAVE_STATE_IO_TYPE mSmmCpuIoType[] = {
|
||||
EFI_SMM_SAVE_STATE_IO_TYPE_OUTPUT, // SMM_IO_TYPE_OUT_DX = 0
|
||||
EFI_SMM_SAVE_STATE_IO_TYPE_INPUT, // SMM_IO_TYPE_IN_DX = 1
|
||||
EFI_SMM_SAVE_STATE_IO_TYPE_STRING, // SMM_IO_TYPE_OUTS = 2
|
||||
@@ -237,11 +237,13 @@ GetRegisterIndex (
|
||||
UINTN Offset;
|
||||
|
||||
for (Index = 0, Offset = SMM_SAVE_STATE_REGISTER_MAX_INDEX; mSmmCpuRegisterRanges[Index].Length != 0; Index++) {
|
||||
if (Register >= mSmmCpuRegisterRanges[Index].Start && Register <= mSmmCpuRegisterRanges[Index].End) {
|
||||
if ((Register >= mSmmCpuRegisterRanges[Index].Start) && (Register <= mSmmCpuRegisterRanges[Index].End)) {
|
||||
return Register - mSmmCpuRegisterRanges[Index].Start + Offset;
|
||||
}
|
||||
|
||||
Offset += mSmmCpuRegisterRanges[Index].Length;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -265,10 +267,10 @@ GetRegisterIndex (
|
||||
**/
|
||||
EFI_STATUS
|
||||
ReadSaveStateRegisterByIndex (
|
||||
IN UINTN CpuIndex,
|
||||
IN UINTN RegisterIndex,
|
||||
IN UINTN Width,
|
||||
OUT VOID *Buffer
|
||||
IN UINTN CpuIndex,
|
||||
IN UINTN RegisterIndex,
|
||||
IN UINTN Width,
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
{
|
||||
SMRAM_SAVE_STATE_MAP *CpuSaveState;
|
||||
@@ -297,8 +299,8 @@ ReadSaveStateRegisterByIndex (
|
||||
//
|
||||
// Write return buffer
|
||||
//
|
||||
ASSERT(CpuSaveState != NULL);
|
||||
CopyMem(Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset32, Width);
|
||||
ASSERT (CpuSaveState != NULL);
|
||||
CopyMem (Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset32, Width);
|
||||
} else {
|
||||
//
|
||||
// If 64-bit mode width is zero, then the specified register can not be accessed
|
||||
@@ -317,14 +319,15 @@ ReadSaveStateRegisterByIndex (
|
||||
//
|
||||
// Write at most 4 of the lower bytes of the return buffer
|
||||
//
|
||||
CopyMem(Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, MIN(4, Width));
|
||||
CopyMem (Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, MIN (4, Width));
|
||||
if (Width > 4) {
|
||||
//
|
||||
// Write at most 4 of the upper bytes of the return buffer
|
||||
//
|
||||
CopyMem((UINT8 *)Buffer + 4, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, Width - 4);
|
||||
CopyMem ((UINT8 *)Buffer + 4, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, Width - 4);
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -382,7 +385,7 @@ ReadSaveStateRegister (
|
||||
//
|
||||
// Get SMM Revision ID
|
||||
//
|
||||
ReadSaveStateRegisterByIndex (CpuIndex, SMM_SAVE_STATE_REGISTER_SMMREVID_INDEX, sizeof(SmmRevId), &SmmRevId);
|
||||
ReadSaveStateRegisterByIndex (CpuIndex, SMM_SAVE_STATE_REGISTER_SMMREVID_INDEX, sizeof (SmmRevId), &SmmRevId);
|
||||
|
||||
//
|
||||
// See if the CPU supports the IOMisc register in the save state
|
||||
@@ -394,7 +397,7 @@ ReadSaveStateRegister (
|
||||
//
|
||||
// Get the IOMisc register value
|
||||
//
|
||||
ReadSaveStateRegisterByIndex (CpuIndex, SMM_SAVE_STATE_REGISTER_IOMISC_INDEX, sizeof(IoMisc.Uint32), &IoMisc.Uint32);
|
||||
ReadSaveStateRegisterByIndex (CpuIndex, SMM_SAVE_STATE_REGISTER_IOMISC_INDEX, sizeof (IoMisc.Uint32), &IoMisc.Uint32);
|
||||
|
||||
//
|
||||
// Check for the SMI_FLAG in IOMisc
|
||||
@@ -407,14 +410,15 @@ ReadSaveStateRegister (
|
||||
// Only support IN/OUT, but not INS/OUTS/REP INS/REP OUTS.
|
||||
//
|
||||
if ((mSmmCpuIoType[IoMisc.Bits.Type] != EFI_SMM_SAVE_STATE_IO_TYPE_INPUT) &&
|
||||
(mSmmCpuIoType[IoMisc.Bits.Type] != EFI_SMM_SAVE_STATE_IO_TYPE_OUTPUT)) {
|
||||
(mSmmCpuIoType[IoMisc.Bits.Type] != EFI_SMM_SAVE_STATE_IO_TYPE_OUTPUT))
|
||||
{
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
//
|
||||
// Compute index for the I/O Length and I/O Type lookup tables
|
||||
//
|
||||
if (mSmmCpuIoWidth[IoMisc.Bits.Length].Width == 0 || mSmmCpuIoType[IoMisc.Bits.Type] == 0) {
|
||||
if ((mSmmCpuIoWidth[IoMisc.Bits.Length].Width == 0) || (mSmmCpuIoType[IoMisc.Bits.Type] == 0)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -429,14 +433,14 @@ ReadSaveStateRegister (
|
||||
// Zero the IoInfo structure that will be returned in Buffer
|
||||
//
|
||||
IoInfo = (EFI_SMM_SAVE_STATE_IO_INFO *)Buffer;
|
||||
ZeroMem (IoInfo, sizeof(EFI_SMM_SAVE_STATE_IO_INFO));
|
||||
ZeroMem (IoInfo, sizeof (EFI_SMM_SAVE_STATE_IO_INFO));
|
||||
|
||||
//
|
||||
// Use lookup tables to help fill in all the fields of the IoInfo structure
|
||||
//
|
||||
IoInfo->IoPort = (UINT16)IoMisc.Bits.Port;
|
||||
IoInfo->IoPort = (UINT16)IoMisc.Bits.Port;
|
||||
IoInfo->IoWidth = mSmmCpuIoWidth[IoMisc.Bits.Length].IoWidth;
|
||||
IoInfo->IoType = mSmmCpuIoType[IoMisc.Bits.Type];
|
||||
IoInfo->IoType = mSmmCpuIoType[IoMisc.Bits.Type];
|
||||
ReadSaveStateRegister (CpuIndex, EFI_SMM_SAVE_STATE_REGISTER_RAX, mSmmCpuIoWidth[IoMisc.Bits.Length].Width, &IoInfo->IoData);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -525,11 +529,12 @@ WriteSaveStateRegister (
|
||||
if (Width > mSmmCpuWidthOffset[RegisterIndex].Width32) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Write SMM State register
|
||||
//
|
||||
ASSERT (CpuSaveState != NULL);
|
||||
CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset32, Buffer, Width);
|
||||
CopyMem ((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset32, Buffer, Width);
|
||||
} else {
|
||||
//
|
||||
// If 64-bit mode width is zero, then the specified register can not be accessed
|
||||
@@ -548,14 +553,15 @@ WriteSaveStateRegister (
|
||||
//
|
||||
// Write at most 4 of the lower bytes of SMM State register
|
||||
//
|
||||
CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, Buffer, MIN (4, Width));
|
||||
CopyMem ((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, Buffer, MIN (4, Width));
|
||||
if (Width > 4) {
|
||||
//
|
||||
// Write at most 4 of the upper bytes of SMM State register
|
||||
//
|
||||
CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, (UINT8 *)Buffer + 4, Width - 4);
|
||||
CopyMem ((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, (UINT8 *)Buffer + 4, Width - 4);
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -600,7 +606,7 @@ HookReturnFromSmm (
|
||||
|
||||
if (mSmmSaveStateRegisterLma == EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT) {
|
||||
OriginalInstructionPointer = (UINT64)CpuState->x86._EIP;
|
||||
CpuState->x86._EIP = (UINT32)NewInstructionPointer;
|
||||
CpuState->x86._EIP = (UINT32)NewInstructionPointer;
|
||||
//
|
||||
// Clear the auto HALT restart flag so the RSM instruction returns
|
||||
// program control to the instruction following the HLT instruction.
|
||||
@@ -615,6 +621,7 @@ HookReturnFromSmm (
|
||||
} else {
|
||||
CpuState->x64._RIP = (UINT32)NewInstructionPointer;
|
||||
}
|
||||
|
||||
//
|
||||
// Clear the auto HALT restart flag so the RSM instruction returns
|
||||
// program control to the instruction following the HLT instruction.
|
||||
@@ -623,6 +630,7 @@ HookReturnFromSmm (
|
||||
CpuState->x64.AutoHALTRestart &= ~BIT0;
|
||||
}
|
||||
}
|
||||
|
||||
return OriginalInstructionPointer;
|
||||
}
|
||||
|
||||
@@ -644,6 +652,7 @@ GetSmiHandlerSize (
|
||||
if (Size != 0) {
|
||||
return Size;
|
||||
}
|
||||
|
||||
return gcSmiHandlerSize;
|
||||
}
|
||||
|
||||
@@ -693,7 +702,7 @@ InstallSmiHandler (
|
||||
//
|
||||
Psd = (PROCESSOR_SMM_DESCRIPTOR *)(VOID *)((UINTN)SmBase + SMM_PSD_OFFSET);
|
||||
CopyMem (Psd, &gcPsd, sizeof (gcPsd));
|
||||
Psd->SmmGdtPtr = (UINT64)GdtBase;
|
||||
Psd->SmmGdtPtr = (UINT64)GdtBase;
|
||||
Psd->SmmGdtSize = (UINT32)GdtSize;
|
||||
|
||||
if (SmmCpuFeaturesGetSmiHandlerSize () != 0) {
|
||||
@@ -729,14 +738,14 @@ InstallSmiHandler (
|
||||
//
|
||||
// Set the value at the top of the CPU stack to the CPU Index
|
||||
//
|
||||
*(UINTN*)(UINTN)CpuSmiStack = CpuIndex;
|
||||
*(UINTN *)(UINTN)CpuSmiStack = CpuIndex;
|
||||
|
||||
//
|
||||
// Copy template to CPU specific SMI handler location
|
||||
//
|
||||
CopyMem (
|
||||
(VOID*)((UINTN)SmBase + SMM_HANDLER_OFFSET),
|
||||
(VOID*)gcSmiHandlerTemplate,
|
||||
(VOID *)((UINTN)SmBase + SMM_HANDLER_OFFSET),
|
||||
(VOID *)gcSmiHandlerTemplate,
|
||||
gcSmiHandlerSize
|
||||
);
|
||||
}
|
||||
|
@@ -8,11 +8,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "PiSmmCpuDxeSmm.h"
|
||||
|
||||
UINT64 mTimeoutTicker = 0;
|
||||
UINT64 mTimeoutTicker = 0;
|
||||
//
|
||||
// Number of counts in a roll-over cycle of the performance counter.
|
||||
//
|
||||
UINT64 mCycle = 0;
|
||||
UINT64 mCycle = 0;
|
||||
//
|
||||
// Flag to indicate the performance counter is count-up or count-down.
|
||||
//
|
||||
@@ -33,15 +33,15 @@ InitializeSmmTimer (
|
||||
|
||||
TimerFrequency = GetPerformanceCounterProperties (&Start, &End);
|
||||
mTimeoutTicker = DivU64x32 (
|
||||
MultU64x64(TimerFrequency, PcdGet64 (PcdCpuSmmApSyncTimeout)),
|
||||
MultU64x64 (TimerFrequency, PcdGet64 (PcdCpuSmmApSyncTimeout)),
|
||||
1000 * 1000
|
||||
);
|
||||
if (End < Start) {
|
||||
mCountDown = TRUE;
|
||||
mCycle = Start - End;
|
||||
mCycle = Start - End;
|
||||
} else {
|
||||
mCountDown = FALSE;
|
||||
mCycle = End - Start;
|
||||
mCycle = End - Start;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ StartSyncTimer (
|
||||
return GetPerformanceCounter ();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check if the SMM AP Sync timer is timeout.
|
||||
|
||||
@@ -68,7 +67,7 @@ StartSyncTimer (
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsSyncTimerTimeout (
|
||||
IN UINT64 Timer
|
||||
IN UINT64 Timer
|
||||
)
|
||||
{
|
||||
UINT64 CurrentTimer;
|
||||
@@ -106,5 +105,5 @@ IsSyncTimerTimeout (
|
||||
}
|
||||
}
|
||||
|
||||
return (BOOLEAN) (Delta >= mTimeoutTicker);
|
||||
return (BOOLEAN)(Delta >= mTimeoutTicker);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -9,8 +9,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "PiSmmCpuDxeSmm.h"
|
||||
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmmRelocationOriginalAddressPtr32;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchRebasedFlagAddr32;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchSmmRelocationOriginalAddressPtr32;
|
||||
X86_ASSEMBLY_PATCH_LABEL gPatchRebasedFlagAddr32;
|
||||
|
||||
UINTN mSmmRelocationOriginalAddress;
|
||||
volatile BOOLEAN *mRebasedFlag;
|
||||
@@ -42,14 +42,14 @@ SemaphoreHook (
|
||||
SMRAM_SAVE_STATE_MAP *CpuState;
|
||||
UINTN TempValue;
|
||||
|
||||
mRebasedFlag = RebasedFlag;
|
||||
mRebasedFlag = RebasedFlag;
|
||||
PatchInstructionX86 (
|
||||
gPatchRebasedFlagAddr32,
|
||||
(UINT32)(UINTN)mRebasedFlag,
|
||||
4
|
||||
);
|
||||
|
||||
CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);
|
||||
CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);
|
||||
mSmmRelocationOriginalAddress = HookReturnFromSmm (
|
||||
CpuIndex,
|
||||
CpuState,
|
||||
|
@@ -8,18 +8,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "PiSmmCpuDxeSmm.h"
|
||||
|
||||
EFI_PHYSICAL_ADDRESS mGdtBuffer;
|
||||
UINTN mGdtBufferSize;
|
||||
EFI_PHYSICAL_ADDRESS mGdtBuffer;
|
||||
UINTN mGdtBufferSize;
|
||||
|
||||
extern BOOLEAN mCetSupported;
|
||||
extern UINTN mSmmShadowStackSize;
|
||||
extern BOOLEAN mCetSupported;
|
||||
extern UINTN mSmmShadowStackSize;
|
||||
|
||||
X86_ASSEMBLY_PATCH_LABEL mPatchCetPl0Ssp;
|
||||
X86_ASSEMBLY_PATCH_LABEL mPatchCetInterruptSsp;
|
||||
X86_ASSEMBLY_PATCH_LABEL mPatchCetInterruptSspTable;
|
||||
UINT32 mCetPl0Ssp;
|
||||
UINT32 mCetInterruptSsp;
|
||||
UINT32 mCetInterruptSspTable;
|
||||
X86_ASSEMBLY_PATCH_LABEL mPatchCetPl0Ssp;
|
||||
X86_ASSEMBLY_PATCH_LABEL mPatchCetInterruptSsp;
|
||||
X86_ASSEMBLY_PATCH_LABEL mPatchCetInterruptSspTable;
|
||||
UINT32 mCetPl0Ssp;
|
||||
UINT32 mCetInterruptSsp;
|
||||
UINT32 mCetInterruptSspTable;
|
||||
|
||||
UINTN mSmmInterruptSspTables;
|
||||
|
||||
@@ -33,14 +33,14 @@ UINTN mSmmInterruptSspTables;
|
||||
VOID
|
||||
EFIAPI
|
||||
InitializeIdtIst (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN UINT8 Ist
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN UINT8 Ist
|
||||
)
|
||||
{
|
||||
IA32_IDT_GATE_DESCRIPTOR *IdtGate;
|
||||
|
||||
IdtGate = (IA32_IDT_GATE_DESCRIPTOR *)gcSmiIdtr.Base;
|
||||
IdtGate += ExceptionType;
|
||||
IdtGate = (IA32_IDT_GATE_DESCRIPTOR *)gcSmiIdtr.Base;
|
||||
IdtGate += ExceptionType;
|
||||
IdtGate->Bits.Reserved_0 = Ist;
|
||||
}
|
||||
|
||||
@@ -59,34 +59,34 @@ InitGdt (
|
||||
OUT UINTN *GdtStepSize
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
IA32_SEGMENT_DESCRIPTOR *GdtDescriptor;
|
||||
UINTN TssBase;
|
||||
UINTN GdtTssTableSize;
|
||||
UINT8 *GdtTssTables;
|
||||
UINTN GdtTableStepSize;
|
||||
UINTN Index;
|
||||
IA32_SEGMENT_DESCRIPTOR *GdtDescriptor;
|
||||
UINTN TssBase;
|
||||
UINTN GdtTssTableSize;
|
||||
UINT8 *GdtTssTables;
|
||||
UINTN GdtTableStepSize;
|
||||
|
||||
//
|
||||
// For X64 SMM, we allocate separate GDT/TSS for each CPUs to avoid TSS load contention
|
||||
// on each SMI entry.
|
||||
//
|
||||
GdtTssTableSize = (gcSmiGdtr.Limit + 1 + TSS_SIZE + 7) & ~7; // 8 bytes aligned
|
||||
mGdtBufferSize = GdtTssTableSize * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus;
|
||||
GdtTssTables = (UINT8*)AllocateCodePages (EFI_SIZE_TO_PAGES (mGdtBufferSize));
|
||||
mGdtBufferSize = GdtTssTableSize * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus;
|
||||
GdtTssTables = (UINT8 *)AllocateCodePages (EFI_SIZE_TO_PAGES (mGdtBufferSize));
|
||||
ASSERT (GdtTssTables != NULL);
|
||||
mGdtBuffer = (UINTN)GdtTssTables;
|
||||
mGdtBuffer = (UINTN)GdtTssTables;
|
||||
GdtTableStepSize = GdtTssTableSize;
|
||||
|
||||
for (Index = 0; Index < gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; Index++) {
|
||||
CopyMem (GdtTssTables + GdtTableStepSize * Index, (VOID*)(UINTN)gcSmiGdtr.Base, gcSmiGdtr.Limit + 1 + TSS_SIZE);
|
||||
CopyMem (GdtTssTables + GdtTableStepSize * Index, (VOID *)(UINTN)gcSmiGdtr.Base, gcSmiGdtr.Limit + 1 + TSS_SIZE);
|
||||
|
||||
//
|
||||
// Fixup TSS descriptors
|
||||
//
|
||||
TssBase = (UINTN)(GdtTssTables + GdtTableStepSize * Index + gcSmiGdtr.Limit + 1);
|
||||
GdtDescriptor = (IA32_SEGMENT_DESCRIPTOR *)(TssBase) - 2;
|
||||
GdtDescriptor->Bits.BaseLow = (UINT16)(UINTN)TssBase;
|
||||
GdtDescriptor->Bits.BaseMid = (UINT8)((UINTN)TssBase >> 16);
|
||||
TssBase = (UINTN)(GdtTssTables + GdtTableStepSize * Index + gcSmiGdtr.Limit + 1);
|
||||
GdtDescriptor = (IA32_SEGMENT_DESCRIPTOR *)(TssBase) - 2;
|
||||
GdtDescriptor->Bits.BaseLow = (UINT16)(UINTN)TssBase;
|
||||
GdtDescriptor->Bits.BaseMid = (UINT8)((UINTN)TssBase >> 16);
|
||||
GdtDescriptor->Bits.BaseHigh = (UINT8)((UINTN)TssBase >> 24);
|
||||
|
||||
if ((FeaturePcdGet (PcdCpuSmmStackGuard)) || ((PcdGet32 (PcdControlFlowEnforcementPropertyMask) != 0) && mCetSupported)) {
|
||||
@@ -118,15 +118,17 @@ GetProtectedModeCS (
|
||||
|
||||
AsmReadGdtr (&GdtrDesc);
|
||||
GdtEntryCount = (GdtrDesc.Limit + 1) / sizeof (IA32_SEGMENT_DESCRIPTOR);
|
||||
GdtEntry = (IA32_SEGMENT_DESCRIPTOR *) GdtrDesc.Base;
|
||||
GdtEntry = (IA32_SEGMENT_DESCRIPTOR *)GdtrDesc.Base;
|
||||
for (Index = 0; Index < GdtEntryCount; Index++) {
|
||||
if (GdtEntry->Bits.L == 0) {
|
||||
if (GdtEntry->Bits.Type > 8 && GdtEntry->Bits.DB == 1) {
|
||||
if ((GdtEntry->Bits.Type > 8) && (GdtEntry->Bits.DB == 1)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GdtEntry++;
|
||||
}
|
||||
|
||||
ASSERT (Index != GdtEntryCount);
|
||||
return Index * 8;
|
||||
}
|
||||
@@ -171,9 +173,9 @@ InitShadowStack (
|
||||
IN VOID *ShadowStack
|
||||
)
|
||||
{
|
||||
UINTN SmmShadowStackSize;
|
||||
UINT64 *InterruptSspTable;
|
||||
UINT32 InterruptSsp;
|
||||
UINTN SmmShadowStackSize;
|
||||
UINT64 *InterruptSspTable;
|
||||
UINT32 InterruptSsp;
|
||||
|
||||
if ((PcdGet32 (PcdControlFlowEnforcementPropertyMask) != 0) && mCetSupported) {
|
||||
SmmShadowStackSize = EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (PcdGet32 (PcdCpuSmmShadowStackSize)));
|
||||
@@ -188,14 +190,15 @@ InitShadowStack (
|
||||
//
|
||||
SmmShadowStackSize += EFI_PAGES_TO_SIZE (1);
|
||||
}
|
||||
mCetPl0Ssp = (UINT32)((UINTN)ShadowStack + SmmShadowStackSize - sizeof(UINT64));
|
||||
|
||||
mCetPl0Ssp = (UINT32)((UINTN)ShadowStack + SmmShadowStackSize - sizeof (UINT64));
|
||||
PatchInstructionX86 (mPatchCetPl0Ssp, mCetPl0Ssp, 4);
|
||||
DEBUG ((DEBUG_INFO, "mCetPl0Ssp - 0x%x\n", mCetPl0Ssp));
|
||||
DEBUG ((DEBUG_INFO, "ShadowStack - 0x%x\n", ShadowStack));
|
||||
DEBUG ((DEBUG_INFO, " SmmShadowStackSize - 0x%x\n", SmmShadowStackSize));
|
||||
|
||||
if (mSmmInterruptSspTables == 0) {
|
||||
mSmmInterruptSspTables = (UINTN)AllocateZeroPool(sizeof(UINT64) * 8 * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus);
|
||||
mSmmInterruptSspTables = (UINTN)AllocateZeroPool (sizeof (UINT64) * 8 * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus);
|
||||
ASSERT (mSmmInterruptSspTables != 0);
|
||||
DEBUG ((DEBUG_INFO, "mSmmInterruptSspTables - 0x%x\n", mSmmInterruptSspTables));
|
||||
}
|
||||
@@ -209,17 +212,16 @@ InitShadowStack (
|
||||
// Please refer to UefiCpuPkg/Library/CpuExceptionHandlerLib/X64 for the full stack frame at runtime.
|
||||
// According to SDM (ver. 075 June 2021), shadow stack should be 32 bytes aligned.
|
||||
//
|
||||
InterruptSsp = (UINT32)(((UINTN)ShadowStack + EFI_PAGES_TO_SIZE(1) - (sizeof(UINT64) * 4)) & ~0x1f);
|
||||
*(UINT64 *)(UINTN)InterruptSsp = (InterruptSsp - sizeof(UINT64) * 4) | 0x2;
|
||||
mCetInterruptSsp = InterruptSsp - sizeof(UINT64);
|
||||
InterruptSsp = (UINT32)(((UINTN)ShadowStack + EFI_PAGES_TO_SIZE (1) - (sizeof (UINT64) * 4)) & ~0x1f);
|
||||
*(UINT64 *)(UINTN)InterruptSsp = (InterruptSsp - sizeof (UINT64) * 4) | 0x2;
|
||||
mCetInterruptSsp = InterruptSsp - sizeof (UINT64);
|
||||
|
||||
mCetInterruptSspTable = (UINT32)(UINTN)(mSmmInterruptSspTables + sizeof(UINT64) * 8 * CpuIndex);
|
||||
InterruptSspTable = (UINT64 *)(UINTN)mCetInterruptSspTable;
|
||||
InterruptSspTable[1] = mCetInterruptSsp;
|
||||
mCetInterruptSspTable = (UINT32)(UINTN)(mSmmInterruptSspTables + sizeof (UINT64) * 8 * CpuIndex);
|
||||
InterruptSspTable = (UINT64 *)(UINTN)mCetInterruptSspTable;
|
||||
InterruptSspTable[1] = mCetInterruptSsp;
|
||||
PatchInstructionX86 (mPatchCetInterruptSsp, mCetInterruptSsp, 4);
|
||||
PatchInstructionX86 (mPatchCetInterruptSspTable, mCetInterruptSspTable, 4);
|
||||
DEBUG ((DEBUG_INFO, "mCetInterruptSsp - 0x%x\n", mCetInterruptSsp));
|
||||
DEBUG ((DEBUG_INFO, "mCetInterruptSspTable - 0x%x\n", mCetInterruptSspTable));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -14,17 +14,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// Current page index.
|
||||
//
|
||||
UINTN mPFPageIndex;
|
||||
UINTN mPFPageIndex;
|
||||
|
||||
//
|
||||
// Pool for dynamically creating page table in page fault handler.
|
||||
//
|
||||
UINT64 mPFPageBuffer;
|
||||
UINT64 mPFPageBuffer;
|
||||
|
||||
//
|
||||
// Store the uplink information for each page being used.
|
||||
//
|
||||
UINT64 *mPFPageUplink[MAX_PF_PAGE_COUNT];
|
||||
UINT64 *mPFPageUplink[MAX_PF_PAGE_COUNT];
|
||||
|
||||
/**
|
||||
Create SMM page table for S3 path.
|
||||
@@ -35,8 +35,8 @@ InitSmmS3Cr3 (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_PHYSICAL_ADDRESS Pages;
|
||||
UINT64 *PTEntry;
|
||||
EFI_PHYSICAL_ADDRESS Pages;
|
||||
UINT64 *PTEntry;
|
||||
|
||||
//
|
||||
// Generate PAE page table for the first 4GB memory space
|
||||
@@ -46,7 +46,7 @@ InitSmmS3Cr3 (
|
||||
//
|
||||
// Fill Page-Table-Level4 (PML4) entry
|
||||
//
|
||||
PTEntry = (UINT64*)AllocatePageTableMemory (1);
|
||||
PTEntry = (UINT64 *)AllocatePageTableMemory (1);
|
||||
ASSERT (PTEntry != NULL);
|
||||
*PTEntry = Pages | mAddressEncMask | PAGE_ATTRIBUTE_BITS;
|
||||
ZeroMem (PTEntry + 1, EFI_PAGE_SIZE - sizeof (*PTEntry));
|
||||
@@ -56,7 +56,7 @@ InitSmmS3Cr3 (
|
||||
//
|
||||
mSmmS3ResumeState->SmmS3Cr3 = (UINT32)(UINTN)PTEntry;
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ InitPagesForPFHandler (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
VOID *Address;
|
||||
VOID *Address;
|
||||
|
||||
//
|
||||
// Pre-Allocate memory for page fault handler
|
||||
@@ -77,9 +77,9 @@ InitPagesForPFHandler (
|
||||
Address = AllocatePages (MAX_PF_PAGE_COUNT);
|
||||
ASSERT (Address != NULL);
|
||||
|
||||
mPFPageBuffer = (UINT64)(UINTN) Address;
|
||||
mPFPageIndex = 0;
|
||||
ZeroMem ((VOID *) (UINTN) mPFPageBuffer, EFI_PAGE_SIZE * MAX_PF_PAGE_COUNT);
|
||||
mPFPageBuffer = (UINT64)(UINTN)Address;
|
||||
mPFPageIndex = 0;
|
||||
ZeroMem ((VOID *)(UINTN)mPFPageBuffer, EFI_PAGE_SIZE * MAX_PF_PAGE_COUNT);
|
||||
ZeroMem (mPFPageUplink, sizeof (mPFPageUplink));
|
||||
|
||||
return;
|
||||
@@ -93,16 +93,16 @@ InitPagesForPFHandler (
|
||||
**/
|
||||
VOID
|
||||
AcquirePage (
|
||||
UINT64 *Uplink
|
||||
UINT64 *Uplink
|
||||
)
|
||||
{
|
||||
UINT64 Address;
|
||||
UINT64 Address;
|
||||
|
||||
//
|
||||
// Get the buffer
|
||||
//
|
||||
Address = mPFPageBuffer + EFI_PAGES_TO_SIZE (mPFPageIndex);
|
||||
ZeroMem ((VOID *) (UINTN) Address, EFI_PAGE_SIZE);
|
||||
ZeroMem ((VOID *)(UINTN)Address, EFI_PAGE_SIZE);
|
||||
|
||||
//
|
||||
// Cut the previous uplink if it exists and wasn't overwritten
|
||||
@@ -114,7 +114,7 @@ AcquirePage (
|
||||
//
|
||||
// Link & Record the current uplink
|
||||
//
|
||||
*Uplink = Address | mAddressEncMask | PAGE_ATTRIBUTE_BITS;
|
||||
*Uplink = Address | mAddressEncMask | PAGE_ATTRIBUTE_BITS;
|
||||
mPFPageUplink[mPFPageIndex] = Uplink;
|
||||
|
||||
mPFPageIndex = (mPFPageIndex + 1) % MAX_PF_PAGE_COUNT;
|
||||
@@ -134,26 +134,26 @@ AcquirePage (
|
||||
**/
|
||||
VOID
|
||||
RestorePageTableAbove4G (
|
||||
UINT64 *PageTable,
|
||||
UINT64 PFAddress,
|
||||
UINTN CpuIndex,
|
||||
UINTN ErrorCode,
|
||||
BOOLEAN *IsValidPFAddress
|
||||
UINT64 *PageTable,
|
||||
UINT64 PFAddress,
|
||||
UINTN CpuIndex,
|
||||
UINTN ErrorCode,
|
||||
BOOLEAN *IsValidPFAddress
|
||||
)
|
||||
{
|
||||
UINTN PTIndex;
|
||||
UINT64 Address;
|
||||
BOOLEAN Nx;
|
||||
BOOLEAN Existed;
|
||||
UINTN Index;
|
||||
UINTN PFIndex;
|
||||
IA32_CR4 Cr4;
|
||||
BOOLEAN Enable5LevelPaging;
|
||||
UINTN PTIndex;
|
||||
UINT64 Address;
|
||||
BOOLEAN Nx;
|
||||
BOOLEAN Existed;
|
||||
UINTN Index;
|
||||
UINTN PFIndex;
|
||||
IA32_CR4 Cr4;
|
||||
BOOLEAN Enable5LevelPaging;
|
||||
|
||||
ASSERT ((PageTable != NULL) && (IsValidPFAddress != NULL));
|
||||
|
||||
Cr4.UintN = AsmReadCr4 ();
|
||||
Enable5LevelPaging = (BOOLEAN) (Cr4.Bits.LA57 == 1);
|
||||
Cr4.UintN = AsmReadCr4 ();
|
||||
Enable5LevelPaging = (BOOLEAN)(Cr4.Bits.LA57 == 1);
|
||||
|
||||
//
|
||||
// If page fault address is 4GB above.
|
||||
@@ -164,26 +164,28 @@ RestorePageTableAbove4G (
|
||||
// If it exists in page table but page fault is generated,
|
||||
// there are 2 possible reasons: 1. present flag is set to 0; 2. instruction fetch in protected memory range.
|
||||
//
|
||||
Existed = FALSE;
|
||||
PageTable = (UINT64*)(AsmReadCr3 () & PHYSICAL_ADDRESS_MASK);
|
||||
PTIndex = 0;
|
||||
Existed = FALSE;
|
||||
PageTable = (UINT64 *)(AsmReadCr3 () & PHYSICAL_ADDRESS_MASK);
|
||||
PTIndex = 0;
|
||||
if (Enable5LevelPaging) {
|
||||
PTIndex = BitFieldRead64 (PFAddress, 48, 56);
|
||||
}
|
||||
|
||||
if ((!Enable5LevelPaging) || ((PageTable[PTIndex] & IA32_PG_P) != 0)) {
|
||||
// PML5E
|
||||
if (Enable5LevelPaging) {
|
||||
PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
PageTable = (UINT64 *)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
}
|
||||
|
||||
PTIndex = BitFieldRead64 (PFAddress, 39, 47);
|
||||
if ((PageTable[PTIndex] & IA32_PG_P) != 0) {
|
||||
// PML4E
|
||||
PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
PTIndex = BitFieldRead64 (PFAddress, 30, 38);
|
||||
PageTable = (UINT64 *)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
PTIndex = BitFieldRead64 (PFAddress, 30, 38);
|
||||
if ((PageTable[PTIndex] & IA32_PG_P) != 0) {
|
||||
// PDPTE
|
||||
PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
PTIndex = BitFieldRead64 (PFAddress, 21, 29);
|
||||
PageTable = (UINT64 *)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
PTIndex = BitFieldRead64 (PFAddress, 21, 29);
|
||||
// PD
|
||||
if ((PageTable[PTIndex] & IA32_PG_PS) != 0) {
|
||||
//
|
||||
@@ -197,7 +199,7 @@ RestorePageTableAbove4G (
|
||||
//
|
||||
// 4KB page
|
||||
//
|
||||
PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask& PHYSICAL_ADDRESS_MASK);
|
||||
PageTable = (UINT64 *)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask& PHYSICAL_ADDRESS_MASK);
|
||||
if (PageTable != 0) {
|
||||
//
|
||||
// When there is a valid entry to map to 4KB page, need not create a new entry to map 2MB.
|
||||
@@ -217,7 +219,6 @@ RestorePageTableAbove4G (
|
||||
// If page entry does not existed in page table at all, create a new entry.
|
||||
//
|
||||
if (!Existed) {
|
||||
|
||||
if (IsAddressValid (PFAddress, &Nx)) {
|
||||
//
|
||||
// If page fault address above 4GB is in protected range but it causes a page fault exception,
|
||||
@@ -234,19 +235,20 @@ RestorePageTableAbove4G (
|
||||
//
|
||||
// Find the page table entry created just now.
|
||||
//
|
||||
PageTable = (UINT64*)(AsmReadCr3 () & PHYSICAL_ADDRESS_MASK);
|
||||
PageTable = (UINT64 *)(AsmReadCr3 () & PHYSICAL_ADDRESS_MASK);
|
||||
PFAddress = AsmReadCr2 ();
|
||||
// PML5E
|
||||
if (Enable5LevelPaging) {
|
||||
PTIndex = BitFieldRead64 (PFAddress, 48, 56);
|
||||
PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
PTIndex = BitFieldRead64 (PFAddress, 48, 56);
|
||||
PageTable = (UINT64 *)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
}
|
||||
|
||||
// PML4E
|
||||
PTIndex = BitFieldRead64 (PFAddress, 39, 47);
|
||||
PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
PTIndex = BitFieldRead64 (PFAddress, 39, 47);
|
||||
PageTable = (UINT64 *)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
// PDPTE
|
||||
PTIndex = BitFieldRead64 (PFAddress, 30, 38);
|
||||
PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
PTIndex = BitFieldRead64 (PFAddress, 30, 38);
|
||||
PageTable = (UINT64 *)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
// PD
|
||||
PTIndex = BitFieldRead64 (PFAddress, 21, 29);
|
||||
Address = PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK;
|
||||
@@ -257,18 +259,21 @@ RestorePageTableAbove4G (
|
||||
AcquirePage (&PageTable[PTIndex]);
|
||||
|
||||
// PTE
|
||||
PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
PageTable = (UINT64 *)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
for (Index = 0; Index < 512; Index++) {
|
||||
PageTable[Index] = Address | mAddressEncMask | PAGE_ATTRIBUTE_BITS;
|
||||
if (!IsAddressValid (Address, &Nx)) {
|
||||
PageTable[Index] = PageTable[Index] & (INTN)(INT32)(~PAGE_ATTRIBUTE_BITS);
|
||||
}
|
||||
|
||||
if (Nx && mXdSupported) {
|
||||
PageTable[Index] = PageTable[Index] | IA32_PG_NX;
|
||||
}
|
||||
|
||||
if (Address == (PFAddress & PHYSICAL_ADDRESS_MASK & ~((1ull << 12) - 1))) {
|
||||
PTIndex = Index;
|
||||
}
|
||||
|
||||
Address += SIZE_4KB;
|
||||
} // end for PT
|
||||
} else {
|
||||
@@ -281,6 +286,7 @@ RestorePageTableAbove4G (
|
||||
//
|
||||
PageTable[PTIndex] = PageTable[PTIndex] & (INTN)(INT32)(~PAGE_ATTRIBUTE_BITS);
|
||||
}
|
||||
|
||||
//
|
||||
// Set XD bit to 1
|
||||
//
|
||||
@@ -297,7 +303,7 @@ RestorePageTableAbove4G (
|
||||
//
|
||||
ASSERT (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT);
|
||||
if (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT) {
|
||||
PFIndex = mPFEntryCount[CpuIndex];
|
||||
PFIndex = mPFEntryCount[CpuIndex];
|
||||
mLastPFEntryValue[CpuIndex][PFIndex] = PageTable[PTIndex];
|
||||
mLastPFEntryPointer[CpuIndex][PFIndex] = &PageTable[PTIndex];
|
||||
mPFEntryCount[CpuIndex]++;
|
||||
@@ -326,7 +332,7 @@ RestorePageTableAbove4G (
|
||||
**/
|
||||
VOID
|
||||
ClearTrapFlag (
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
{
|
||||
SystemContext.SystemContextX64->Rflags &= (UINTN) ~BIT8;
|
||||
|
@@ -12,50 +12,50 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#pragma pack (1)
|
||||
|
||||
typedef struct _MSR_DS_AREA_STRUCT {
|
||||
UINT64 BTSBufferBase;
|
||||
UINT64 BTSIndex;
|
||||
UINT64 BTSAbsoluteMaximum;
|
||||
UINT64 BTSInterruptThreshold;
|
||||
UINT64 PEBSBufferBase;
|
||||
UINT64 PEBSIndex;
|
||||
UINT64 PEBSAbsoluteMaximum;
|
||||
UINT64 PEBSInterruptThreshold;
|
||||
UINT64 PEBSCounterReset[2];
|
||||
UINT64 Reserved;
|
||||
UINT64 BTSBufferBase;
|
||||
UINT64 BTSIndex;
|
||||
UINT64 BTSAbsoluteMaximum;
|
||||
UINT64 BTSInterruptThreshold;
|
||||
UINT64 PEBSBufferBase;
|
||||
UINT64 PEBSIndex;
|
||||
UINT64 PEBSAbsoluteMaximum;
|
||||
UINT64 PEBSInterruptThreshold;
|
||||
UINT64 PEBSCounterReset[2];
|
||||
UINT64 Reserved;
|
||||
} MSR_DS_AREA_STRUCT;
|
||||
|
||||
typedef struct _BRANCH_TRACE_RECORD {
|
||||
UINT64 LastBranchFrom;
|
||||
UINT64 LastBranchTo;
|
||||
UINT64 Rsvd0 : 4;
|
||||
UINT64 BranchPredicted : 1;
|
||||
UINT64 Rsvd1 : 59;
|
||||
UINT64 LastBranchFrom;
|
||||
UINT64 LastBranchTo;
|
||||
UINT64 Rsvd0 : 4;
|
||||
UINT64 BranchPredicted : 1;
|
||||
UINT64 Rsvd1 : 59;
|
||||
} BRANCH_TRACE_RECORD;
|
||||
|
||||
typedef struct _PEBS_RECORD {
|
||||
UINT64 Rflags;
|
||||
UINT64 LinearIP;
|
||||
UINT64 Rax;
|
||||
UINT64 Rbx;
|
||||
UINT64 Rcx;
|
||||
UINT64 Rdx;
|
||||
UINT64 Rsi;
|
||||
UINT64 Rdi;
|
||||
UINT64 Rbp;
|
||||
UINT64 Rsp;
|
||||
UINT64 R8;
|
||||
UINT64 R9;
|
||||
UINT64 R10;
|
||||
UINT64 R11;
|
||||
UINT64 R12;
|
||||
UINT64 R13;
|
||||
UINT64 R14;
|
||||
UINT64 R15;
|
||||
UINT64 Rflags;
|
||||
UINT64 LinearIP;
|
||||
UINT64 Rax;
|
||||
UINT64 Rbx;
|
||||
UINT64 Rcx;
|
||||
UINT64 Rdx;
|
||||
UINT64 Rsi;
|
||||
UINT64 Rdi;
|
||||
UINT64 Rbp;
|
||||
UINT64 Rsp;
|
||||
UINT64 R8;
|
||||
UINT64 R9;
|
||||
UINT64 R10;
|
||||
UINT64 R11;
|
||||
UINT64 R12;
|
||||
UINT64 R13;
|
||||
UINT64 R14;
|
||||
UINT64 R15;
|
||||
} PEBS_RECORD;
|
||||
|
||||
#pragma pack ()
|
||||
|
||||
#define PHYSICAL_ADDRESS_MASK ((1ull << 52) - SIZE_4KB)
|
||||
#define PHYSICAL_ADDRESS_MASK ((1ull << 52) - SIZE_4KB)
|
||||
|
||||
/**
|
||||
Update page table to map the memory correctly in order to make the instruction
|
||||
@@ -71,11 +71,11 @@ typedef struct _PEBS_RECORD {
|
||||
**/
|
||||
VOID
|
||||
RestorePageTableAbove4G (
|
||||
UINT64 *PageTable,
|
||||
UINT64 PFAddress,
|
||||
UINTN CpuIndex,
|
||||
UINTN ErrorCode,
|
||||
BOOLEAN *IsValidPFAddress
|
||||
UINT64 *PageTable,
|
||||
UINT64 PFAddress,
|
||||
UINTN CpuIndex,
|
||||
UINTN ErrorCode,
|
||||
BOOLEAN *IsValidPFAddress
|
||||
);
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user