VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h@ 106901

Last change on this file since 106901 was 101291, checked in by vboxsync, 17 months ago

EFI/FirmwareNew: Make edk2-stable202308 build on all supported platforms (using gcc at least, msvc not tested yet), bugref:4643

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette