]>
Commit | Line | Data |
---|---|---|
529a5a86 MK |
1 | /** @file\r |
2 | SMM profile internal header file.\r | |
3 | \r | |
4c214f82 | 4 | Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>\r |
0acd8697 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
529a5a86 MK |
6 | \r |
7 | **/\r | |
8 | \r | |
9 | #ifndef _SMM_PROFILE_INTERNAL_H_\r | |
10 | #define _SMM_PROFILE_INTERNAL_H_\r | |
11 | \r | |
529a5a86 MK |
12 | #include <Protocol/SmmReadyToLock.h>\r |
13 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
14 | #include <Library/DxeServicesTableLib.h>\r | |
15 | #include <Library/CpuLib.h>\r | |
16 | #include <IndustryStandard/Acpi.h>\r | |
17 | \r | |
18 | #include "SmmProfileArch.h"\r | |
19 | \r | |
20 | //\r | |
21 | // Configure the SMM_PROFILE DTS region size\r | |
22 | //\r | |
23 | #define SMM_PROFILE_DTS_SIZE (4 * 1024 * 1024) // 4M\r | |
24 | \r | |
25 | #define MAX_PF_PAGE_COUNT 0x2\r | |
26 | \r | |
27 | #define PEBS_RECORD_NUMBER 0x2\r | |
28 | \r | |
29 | #define MAX_PF_ENTRY_COUNT 10\r | |
30 | \r | |
31 | //\r | |
32 | // This MACRO just enable unit test for the profile\r | |
33 | // Please disable it.\r | |
34 | //\r | |
35 | \r | |
529a5a86 MK |
36 | #define IA32_PF_EC_ID (1u << 4)\r |
37 | \r | |
38 | #define SMM_PROFILE_NAME L"SmmProfileData"\r | |
39 | \r | |
40 | //\r | |
41 | // CPU generic definition\r | |
42 | //\r | |
43 | #define CPUID1_EDX_XD_SUPPORT 0x100000\r | |
44 | #define MSR_EFER 0xc0000080\r | |
45 | #define MSR_EFER_XD 0x800\r | |
46 | \r | |
47 | #define CPUID1_EDX_BTS_AVAILABLE 0x200000\r | |
48 | \r | |
49 | #define DR6_SINGLE_STEP 0x4000\r | |
50 | #define RFLAG_TF 0x100\r | |
51 | \r | |
52 | #define MSR_DEBUG_CTL 0x1D9\r | |
53 | #define MSR_DEBUG_CTL_LBR 0x1\r | |
54 | #define MSR_DEBUG_CTL_TR 0x40\r | |
55 | #define MSR_DEBUG_CTL_BTS 0x80\r | |
56 | #define MSR_DEBUG_CTL_BTINT 0x100\r | |
529a5a86 MK |
57 | #define MSR_DS_AREA 0x600\r |
58 | \r | |
09afd9a4 JW |
59 | #define HEAP_GUARD_NONSTOP_MODE \\r |
60 | ((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT6|BIT3|BIT2)) > BIT6)\r | |
61 | \r | |
62 | #define NULL_DETECTION_NONSTOP_MODE \\r | |
63 | ((PcdGet8 (PcdNullPointerDetectionPropertyMask) & (BIT6|BIT1)) > BIT6)\r | |
64 | \r | |
529a5a86 MK |
65 | typedef struct {\r |
66 | EFI_PHYSICAL_ADDRESS Base;\r | |
67 | EFI_PHYSICAL_ADDRESS Top;\r | |
68 | } MEMORY_RANGE;\r | |
69 | \r | |
70 | typedef struct {\r | |
71 | MEMORY_RANGE Range;\r | |
72 | BOOLEAN Present;\r | |
73 | BOOLEAN Nx;\r | |
74 | } MEMORY_PROTECTION_RANGE;\r | |
75 | \r | |
76 | typedef struct {\r | |
77 | UINT64 HeaderSize;\r | |
78 | UINT64 MaxDataEntries;\r | |
79 | UINT64 MaxDataSize;\r | |
80 | UINT64 CurDataEntries;\r | |
81 | UINT64 CurDataSize;\r | |
82 | UINT64 TsegStart;\r | |
83 | UINT64 TsegSize;\r | |
84 | UINT64 NumSmis;\r | |
85 | UINT64 NumCpus;\r | |
86 | } SMM_PROFILE_HEADER;\r | |
87 | \r | |
88 | typedef struct {\r | |
89 | UINT64 SmiNum;\r | |
90 | UINT64 CpuNum;\r | |
91 | UINT64 ApicId;\r | |
92 | UINT64 ErrorCode;\r | |
93 | UINT64 Instruction;\r | |
94 | UINT64 Address;\r | |
95 | UINT64 SmiCmd;\r | |
96 | } SMM_PROFILE_ENTRY;\r | |
97 | \r | |
98 | extern SMM_S3_RESUME_STATE *mSmmS3ResumeState;\r | |
99 | extern UINTN gSmiExceptionHandlers[];\r | |
100 | extern BOOLEAN mXdSupported;\r | |
3c5ce64f | 101 | X86_ASSEMBLY_PATCH_LABEL gPatchXdSupported;\r |
529a5a86 MK |
102 | extern UINTN *mPFEntryCount;\r |
103 | extern UINT64 (*mLastPFEntryValue)[MAX_PF_ENTRY_COUNT];\r | |
104 | extern UINT64 *(*mLastPFEntryPointer)[MAX_PF_ENTRY_COUNT];\r | |
105 | \r | |
106 | //\r | |
107 | // Internal functions\r | |
108 | //\r | |
109 | \r | |
110 | /**\r | |
111 | Update IDT table to replace page fault handler and INT 1 handler.\r | |
112 | \r | |
113 | **/\r | |
114 | VOID\r | |
115 | InitIdtr (\r | |
116 | VOID\r | |
117 | );\r | |
118 | \r | |
119 | /**\r | |
120 | Check if the memory address will be mapped by 4KB-page.\r | |
121 | \r | |
122 | @param Address The address of Memory.\r | |
123 | \r | |
124 | **/\r | |
125 | BOOLEAN\r | |
126 | IsAddressSplit (\r | |
127 | IN EFI_PHYSICAL_ADDRESS Address\r | |
128 | );\r | |
129 | \r | |
130 | /**\r | |
131 | Check if the memory address will be mapped by 4KB-page.\r | |
132 | \r | |
133 | @param Address The address of Memory.\r | |
134 | @param Nx The flag indicates if the memory is execute-disable.\r | |
135 | \r | |
136 | **/\r | |
137 | BOOLEAN\r | |
138 | IsAddressValid (\r | |
139 | IN EFI_PHYSICAL_ADDRESS Address,\r | |
140 | IN BOOLEAN *Nx\r | |
141 | );\r | |
142 | \r | |
143 | /**\r | |
144 | Page Fault handler for SMM use.\r | |
145 | \r | |
146 | **/\r | |
147 | VOID\r | |
148 | SmiDefaultPFHandler (\r | |
149 | VOID\r | |
150 | );\r | |
151 | \r | |
152 | /**\r | |
153 | Clear TF in FLAGS.\r | |
154 | \r | |
155 | @param SystemContext A pointer to the processor context when\r | |
156 | the interrupt occurred on the processor.\r | |
157 | \r | |
158 | **/\r | |
159 | VOID\r | |
160 | ClearTrapFlag (\r | |
161 | IN OUT EFI_SYSTEM_CONTEXT SystemContext\r | |
162 | );\r | |
163 | \r | |
164 | #endif // _SMM_PROFILE_H_\r |