1 | /** @file
|
---|
2 | X64 processor specific header file to enable SMM profile.
|
---|
3 |
|
---|
4 | Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #ifndef _SMM_PROFILE_ARCH_H_
|
---|
10 | #define _SMM_PROFILE_ARCH_H_
|
---|
11 |
|
---|
12 | #pragma pack (1)
|
---|
13 |
|
---|
14 | typedef struct _MSR_DS_AREA_STRUCT {
|
---|
15 | UINT64 BTSBufferBase;
|
---|
16 | UINT64 BTSIndex;
|
---|
17 | UINT64 BTSAbsoluteMaximum;
|
---|
18 | UINT64 BTSInterruptThreshold;
|
---|
19 | UINT64 PEBSBufferBase;
|
---|
20 | UINT64 PEBSIndex;
|
---|
21 | UINT64 PEBSAbsoluteMaximum;
|
---|
22 | UINT64 PEBSInterruptThreshold;
|
---|
23 | UINT64 PEBSCounterReset[2];
|
---|
24 | UINT64 Reserved;
|
---|
25 | } MSR_DS_AREA_STRUCT;
|
---|
26 |
|
---|
27 | typedef struct _BRANCH_TRACE_RECORD {
|
---|
28 | UINT64 LastBranchFrom;
|
---|
29 | UINT64 LastBranchTo;
|
---|
30 | UINT64 Rsvd0 : 4;
|
---|
31 | UINT64 BranchPredicted : 1;
|
---|
32 | UINT64 Rsvd1 : 59;
|
---|
33 | } BRANCH_TRACE_RECORD;
|
---|
34 |
|
---|
35 | typedef struct _PEBS_RECORD {
|
---|
36 | UINT64 Rflags;
|
---|
37 | UINT64 LinearIP;
|
---|
38 | UINT64 Rax;
|
---|
39 | UINT64 Rbx;
|
---|
40 | UINT64 Rcx;
|
---|
41 | UINT64 Rdx;
|
---|
42 | UINT64 Rsi;
|
---|
43 | UINT64 Rdi;
|
---|
44 | UINT64 Rbp;
|
---|
45 | UINT64 Rsp;
|
---|
46 | UINT64 R8;
|
---|
47 | UINT64 R9;
|
---|
48 | UINT64 R10;
|
---|
49 | UINT64 R11;
|
---|
50 | UINT64 R12;
|
---|
51 | UINT64 R13;
|
---|
52 | UINT64 R14;
|
---|
53 | UINT64 R15;
|
---|
54 | } PEBS_RECORD;
|
---|
55 |
|
---|
56 | #pragma pack ()
|
---|
57 |
|
---|
58 | #define PHYSICAL_ADDRESS_MASK ((1ull << 52) - SIZE_4KB)
|
---|
59 |
|
---|
60 | /**
|
---|
61 | Update page table to map the memory correctly in order to make the instruction
|
---|
62 | which caused page fault execute successfully. And it also save the original page
|
---|
63 | table to be restored in single-step exception.
|
---|
64 |
|
---|
65 | @param PageTable PageTable Address.
|
---|
66 | @param PFAddress The memory address which caused page fault exception.
|
---|
67 | @param CpuIndex The index of the processor.
|
---|
68 | @param ErrorCode The Error code of exception.
|
---|
69 | @param IsValidPFAddress The flag indicates if SMM profile data need be added.
|
---|
70 |
|
---|
71 | **/
|
---|
72 | VOID
|
---|
73 | RestorePageTableAbove4G (
|
---|
74 | UINT64 *PageTable,
|
---|
75 | UINT64 PFAddress,
|
---|
76 | UINTN CpuIndex,
|
---|
77 | UINTN ErrorCode,
|
---|
78 | BOOLEAN *IsValidPFAddress
|
---|
79 | );
|
---|
80 |
|
---|
81 | /**
|
---|
82 | Create SMM page table for S3 path.
|
---|
83 |
|
---|
84 | **/
|
---|
85 | VOID
|
---|
86 | InitSmmS3Cr3 (
|
---|
87 | VOID
|
---|
88 | );
|
---|
89 |
|
---|
90 | /**
|
---|
91 | Allocate pages for creating 4KB-page based on 2MB-page when page fault happens.
|
---|
92 |
|
---|
93 | **/
|
---|
94 | VOID
|
---|
95 | InitPagesForPFHandler (
|
---|
96 | VOID
|
---|
97 | );
|
---|
98 |
|
---|
99 | #endif // _SMM_PROFILE_ARCH_H_
|
---|