2 SMM profile internal header file.
4 Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef _SMM_PROFILE_INTERNAL_H_
10 #define _SMM_PROFILE_INTERNAL_H_
12 #include <Protocol/SmmReadyToLock.h>
13 #include <Library/UefiRuntimeServicesTableLib.h>
14 #include <Library/DxeServicesTableLib.h>
15 #include <Library/CpuLib.h>
16 #include <IndustryStandard/Acpi.h>
18 #include "SmmProfileArch.h"
21 // Configure the SMM_PROFILE DTS region size
23 #define SMM_PROFILE_DTS_SIZE (4 * 1024 * 1024) // 4M
25 #define MAX_PF_PAGE_COUNT 0x2
27 #define PEBS_RECORD_NUMBER 0x2
29 #define MAX_PF_ENTRY_COUNT 10
32 // This MACRO just enable unit test for the profile
36 #define IA32_PF_EC_ID (1u << 4)
38 #define SMM_PROFILE_NAME L"SmmProfileData"
41 // CPU generic definition
43 #define CPUID1_EDX_XD_SUPPORT 0x100000
44 #define MSR_EFER 0xc0000080
45 #define MSR_EFER_XD 0x800
47 #define CPUID1_EDX_BTS_AVAILABLE 0x200000
49 #define DR6_SINGLE_STEP 0x4000
50 #define RFLAG_TF 0x100
52 #define MSR_DEBUG_CTL 0x1D9
53 #define MSR_DEBUG_CTL_LBR 0x1
54 #define MSR_DEBUG_CTL_TR 0x40
55 #define MSR_DEBUG_CTL_BTS 0x80
56 #define MSR_DEBUG_CTL_BTINT 0x100
57 #define MSR_DS_AREA 0x600
59 #define HEAP_GUARD_NONSTOP_MODE \
60 ((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT6|BIT3|BIT2)) > BIT6)
62 #define NULL_DETECTION_NONSTOP_MODE \
63 ((PcdGet8 (PcdNullPointerDetectionPropertyMask) & (BIT6|BIT1)) > BIT6)
66 EFI_PHYSICAL_ADDRESS Base
;
67 EFI_PHYSICAL_ADDRESS Top
;
74 } MEMORY_PROTECTION_RANGE
;
78 UINT64 MaxDataEntries
;
80 UINT64 CurDataEntries
;
98 extern SMM_S3_RESUME_STATE
*mSmmS3ResumeState
;
99 extern UINTN gSmiExceptionHandlers
[];
100 extern BOOLEAN mXdSupported
;
101 X86_ASSEMBLY_PATCH_LABEL gPatchXdSupported
;
102 extern UINTN
*mPFEntryCount
;
103 extern UINT64 (*mLastPFEntryValue
)[MAX_PF_ENTRY_COUNT
];
104 extern UINT64
*(*mLastPFEntryPointer
)[MAX_PF_ENTRY_COUNT
];
107 // Internal functions
111 Update IDT table to replace page fault handler and INT 1 handler.
120 Check if the memory address will be mapped by 4KB-page.
122 @param Address The address of Memory.
127 IN EFI_PHYSICAL_ADDRESS Address
131 Check if the memory address will be mapped by 4KB-page.
133 @param Address The address of Memory.
134 @param Nx The flag indicates if the memory is execute-disable.
139 IN EFI_PHYSICAL_ADDRESS Address
,
144 Page Fault handler for SMM use.
148 SmiDefaultPFHandler (
155 @param SystemContext A pointer to the processor context when
156 the interrupt occurred on the processor.
161 IN OUT EFI_SYSTEM_CONTEXT SystemContext
164 #endif // _SMM_PROFILE_H_