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