]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h
UefiCpuPkg/PiSmmCpuDxeSmm: Enable/Restore XD in SMM
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / SmmProfile.h
1 /** @file
2 SMM profile header file.
3
4 Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _SMM_PROFILE_H_
16 #define _SMM_PROFILE_H_
17
18 #include "SmmProfileInternal.h"
19
20 ///
21 /// MSR Register Index
22 ///
23 #define MSR_IA32_MISC_ENABLE 0x1A0
24 #define B_XD_DISABLE_BIT BIT34
25
26 //
27 // External functions
28 //
29
30 /**
31 Initialize processor environment for SMM profile.
32
33 @param CpuIndex The index of the processor.
34
35 **/
36 VOID
37 ActivateSmmProfile (
38 IN UINTN CpuIndex
39 );
40
41 /**
42 Initialize SMM profile in SMM CPU entry point.
43
44 @param[in] Cr3 The base address of the page tables to use in SMM.
45
46 **/
47 VOID
48 InitSmmProfile (
49 UINT32 Cr3
50 );
51
52 /**
53 Increase SMI number in each SMI entry.
54
55 **/
56 VOID
57 SmmProfileRecordSmiNum (
58 VOID
59 );
60
61 /**
62 The Page fault handler to save SMM profile data.
63
64 @param Rip The RIP when exception happens.
65 @param ErrorCode The Error code of exception.
66
67 **/
68 VOID
69 SmmProfilePFHandler (
70 UINTN Rip,
71 UINTN ErrorCode
72 );
73
74 /**
75 Updates page table to make some memory ranges (like system memory) absent
76 and make some memory ranges (like MMIO) present and execute disable. It also
77 update 2MB-page to 4KB-page for some memory ranges.
78
79 **/
80 VOID
81 SmmProfileStart (
82 VOID
83 );
84
85 /**
86 Page fault IDT handler for SMM Profile.
87
88 **/
89 VOID
90 EFIAPI
91 PageFaultIdtHandlerSmmProfile (
92 VOID
93 );
94
95
96 /**
97 Check if XD feature is supported by a processor.
98
99 @param[in,out] Buffer The pointer to private data buffer.
100
101 **/
102 VOID
103 EFIAPI
104 CheckFeatureSupported (
105 IN OUT VOID *Buffer
106 );
107
108 /**
109 Enable XD feature.
110
111 **/
112 VOID
113 ActivateXd (
114 VOID
115 );
116
117 /**
118 Update page table according to protected memory ranges and the 4KB-page mapped memory ranges.
119
120 **/
121 VOID
122 InitPaging (
123 VOID
124 );
125
126 /**
127 Check if XD and BTS features are supported by all processors.
128
129 **/
130 VOID
131 CheckProcessorFeature (
132 VOID
133 );
134
135 extern BOOLEAN mXdSupported;
136 extern BOOLEAN mXdEnabled;
137
138 #endif // _SMM_PROFILE_H_