2 SMM Base Helper SMM driver.
4 This driver is the counterpart of the SMM Base On SMM Base2 Thunk driver. It
5 provides helping services in SMM to the SMM Base On SMM Base2 Thunk driver.
7 Caution: This module requires additional review when modified.
8 This driver will have external input - communicate buffer in SMM mode.
9 This external input must be validated carefully to avoid security issue like
10 buffer overflow, integer overflow.
12 SmmHandlerEntry() will receive untrusted input and do validation.
14 Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
15 This program and the accompanying materials
16 are licensed and made available under the terms and conditions of the BSD License
17 which accompanies this distribution. The full text of the license may be found at
18 http://opensource.org/licenses/bsd-license.php
20 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
21 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
26 #include <Library/DebugLib.h>
27 #include <Library/UefiBootServicesTableLib.h>
28 #include <Library/SmmServicesTableLib.h>
29 #include <Library/BaseLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/PeCoffLib.h>
32 #include <Library/DevicePathLib.h>
33 #include <Library/CacheMaintenanceLib.h>
34 #include <Library/MemoryAllocationLib.h>
35 #include <Library/SynchronizationLib.h>
36 #include <Library/CpuLib.h>
37 #include <Library/PcdLib.h>
38 #include <Guid/SmmBaseThunkCommunication.h>
39 #include <Protocol/SmmBaseHelperReady.h>
40 #include <Protocol/SmmCpu.h>
41 #include <Protocol/LoadedImage.h>
42 #include <Protocol/SmmCpuSaveState.h>
43 #include <Protocol/MpService.h>
44 #include <Protocol/LoadPe32Image.h>
45 #include <Protocol/SmmReadyToLock.h>
46 #include <Protocol/SmmAccess2.h>
49 Register SMM image to SMRAM profile.
51 @param[in] FilePath File path of the image.
52 @param[in] ImageBuffer Image base address.
53 @param[in] NumberOfPage Number of page.
55 @retval TRUE Register success.
56 @retval FALSE Register fail.
60 RegisterSmramProfileImage (
61 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
62 IN PHYSICAL_ADDRESS ImageBuffer
,
67 Unregister SMM image from SMRAM profile.
69 @param[in] FilePath File path of the image.
70 @param[in] ImageBuffer Image base address.
71 @param[in] NumberOfPage Number of page.
73 @retval TRUE Unregister success.
74 @retval FALSE Unregister fail.
78 UnregisterSmramProfileImage (
79 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
80 IN PHYSICAL_ADDRESS ImageBuffer
,
85 /// Structure for tracking paired information of registered Framework SMI handler
86 /// and correpsonding dispatch handle for SMI handler thunk.
90 EFI_HANDLE DispatchHandle
;
91 EFI_HANDLE SmmImageHandle
;
92 EFI_SMM_CALLBACK_ENTRY_POINT CallbackAddress
;
93 VOID
*CommunicationBuffer
;
99 /// PI SMM CPU Save State register index
101 EFI_SMM_SAVE_STATE_REGISTER Register
;
103 /// Offset in Framework SMST
106 } CPU_SAVE_STATE_CONVERSION
;
108 #define CPU_SAVE_STATE_GET_OFFSET(Field) (UINTN)(&(((EFI_SMM_CPU_SAVE_STATE *) 0)->Ia32SaveState.Field))
111 EFI_HANDLE mDispatchHandle
;
112 EFI_SMM_CPU_PROTOCOL
*mSmmCpu
;
113 EFI_PE32_IMAGE_PROTOCOL
*mLoadPe32Image
;
114 EFI_GUID mEfiSmmCpuIoGuid
= EFI_SMM_CPU_IO_GUID
;
115 EFI_SMM_BASE_HELPER_READY_PROTOCOL
*mSmmBaseHelperReady
;
116 EFI_SMM_SYSTEM_TABLE
*mFrameworkSmst
;
117 UINTN mNumberOfProcessors
;
118 BOOLEAN mLocked
= FALSE
;
119 BOOLEAN mPageTableHookEnabled
;
120 BOOLEAN mHookInitialized
;
121 UINT64
*mCpuStatePageTable
;
124 VOID
*mOriginalHandler
;
125 EFI_SMM_CPU_SAVE_STATE
*mShadowSaveState
;
126 EFI_SMRAM_DESCRIPTOR
*mSmramRanges
;
127 UINTN mSmramRangeCount
;
129 LIST_ENTRY mCallbackInfoListHead
= INITIALIZE_LIST_HEAD_VARIABLE (mCallbackInfoListHead
);
131 CPU_SAVE_STATE_CONVERSION mCpuSaveStateConvTable
[] = {
132 {EFI_SMM_SAVE_STATE_REGISTER_LDTBASE
, CPU_SAVE_STATE_GET_OFFSET(LDTBase
)},
133 {EFI_SMM_SAVE_STATE_REGISTER_ES
, CPU_SAVE_STATE_GET_OFFSET(ES
)},
134 {EFI_SMM_SAVE_STATE_REGISTER_CS
, CPU_SAVE_STATE_GET_OFFSET(CS
)},
135 {EFI_SMM_SAVE_STATE_REGISTER_SS
, CPU_SAVE_STATE_GET_OFFSET(SS
)},
136 {EFI_SMM_SAVE_STATE_REGISTER_DS
, CPU_SAVE_STATE_GET_OFFSET(DS
)},
137 {EFI_SMM_SAVE_STATE_REGISTER_FS
, CPU_SAVE_STATE_GET_OFFSET(FS
)},
138 {EFI_SMM_SAVE_STATE_REGISTER_GS
, CPU_SAVE_STATE_GET_OFFSET(GS
)},
139 {EFI_SMM_SAVE_STATE_REGISTER_TR_SEL
, CPU_SAVE_STATE_GET_OFFSET(TR
)},
140 {EFI_SMM_SAVE_STATE_REGISTER_DR7
, CPU_SAVE_STATE_GET_OFFSET(DR7
)},
141 {EFI_SMM_SAVE_STATE_REGISTER_DR6
, CPU_SAVE_STATE_GET_OFFSET(DR6
)},
142 {EFI_SMM_SAVE_STATE_REGISTER_RAX
, CPU_SAVE_STATE_GET_OFFSET(EAX
)},
143 {EFI_SMM_SAVE_STATE_REGISTER_RBX
, CPU_SAVE_STATE_GET_OFFSET(EBX
)},
144 {EFI_SMM_SAVE_STATE_REGISTER_RCX
, CPU_SAVE_STATE_GET_OFFSET(ECX
)},
145 {EFI_SMM_SAVE_STATE_REGISTER_RDX
, CPU_SAVE_STATE_GET_OFFSET(EDX
)},
146 {EFI_SMM_SAVE_STATE_REGISTER_RSP
, CPU_SAVE_STATE_GET_OFFSET(ESP
)},
147 {EFI_SMM_SAVE_STATE_REGISTER_RBP
, CPU_SAVE_STATE_GET_OFFSET(EBP
)},
148 {EFI_SMM_SAVE_STATE_REGISTER_RSI
, CPU_SAVE_STATE_GET_OFFSET(ESI
)},
149 {EFI_SMM_SAVE_STATE_REGISTER_RDI
, CPU_SAVE_STATE_GET_OFFSET(EDI
)},
150 {EFI_SMM_SAVE_STATE_REGISTER_RIP
, CPU_SAVE_STATE_GET_OFFSET(EIP
)},
151 {EFI_SMM_SAVE_STATE_REGISTER_RFLAGS
, CPU_SAVE_STATE_GET_OFFSET(EFLAGS
)},
152 {EFI_SMM_SAVE_STATE_REGISTER_CR0
, CPU_SAVE_STATE_GET_OFFSET(CR0
)},
153 {EFI_SMM_SAVE_STATE_REGISTER_CR3
, CPU_SAVE_STATE_GET_OFFSET(CR3
)}
161 PageFaultHandlerHook (
166 Read CpuSaveStates from PI for Framework use.
168 The function reads PI style CpuSaveStates of CpuIndex-th CPU for Framework driver use. If
169 ToRead is specified, the CpuSaveStates will be copied to ToRead, otherwise copied to
170 mFrameworkSmst->CpuSaveState[CpuIndex].
172 @param[in] CpuIndex The zero-based CPU index.
173 @param[in, out] ToRead If not NULL, CpuSaveStates will be copied to it.
179 IN OUT EFI_SMM_CPU_SAVE_STATE
*ToRead
184 EFI_SMM_CPU_STATE
*State
;
185 EFI_SMI_CPU_SAVE_STATE
*SaveState
;
187 State
= (EFI_SMM_CPU_STATE
*)gSmst
->CpuSaveState
[CpuIndex
];
188 if (ToRead
!= NULL
) {
189 SaveState
= &ToRead
->Ia32SaveState
;
191 SaveState
= &mFrameworkSmst
->CpuSaveState
[CpuIndex
].Ia32SaveState
;
195 // Note that SMBASE/SMMRevId/IORestart/AutoHALTRestart are in same location in IA32 and X64 CPU Save State Map.
197 SaveState
->SMBASE
= State
->x86
.SMBASE
;
198 SaveState
->SMMRevId
= State
->x86
.SMMRevId
;
199 SaveState
->IORestart
= State
->x86
.IORestart
;
200 SaveState
->AutoHALTRestart
= State
->x86
.AutoHALTRestart
;
202 for (Index
= 0; Index
< sizeof (mCpuSaveStateConvTable
) / sizeof (CPU_SAVE_STATE_CONVERSION
); Index
++) {
204 /// Try to use SMM CPU Protocol to access CPU save states if possible
206 Status
= mSmmCpu
->ReadSaveState (
208 (UINTN
)sizeof (UINT32
),
209 mCpuSaveStateConvTable
[Index
].Register
,
211 ((UINT8
*)SaveState
) + mCpuSaveStateConvTable
[Index
].Offset
213 ASSERT_EFI_ERROR (Status
);
218 Write CpuSaveStates from Framework into PI.
220 The function writes back CpuSaveStates of CpuIndex-th CPU from PI to Framework. If
221 ToWrite is specified, it contains the CpuSaveStates to write from, otherwise CpuSaveStates
222 to write from mFrameworkSmst->CpuSaveState[CpuIndex].
224 @param[in] CpuIndex The zero-based CPU index.
225 @param[in] ToWrite If not NULL, CpuSaveStates to write from.
231 IN EFI_SMM_CPU_SAVE_STATE
*ToWrite
236 EFI_SMM_CPU_STATE
*State
;
237 EFI_SMI_CPU_SAVE_STATE
*SaveState
;
239 State
= (EFI_SMM_CPU_STATE
*)gSmst
->CpuSaveState
[CpuIndex
];
241 if (ToWrite
!= NULL
) {
242 SaveState
= &ToWrite
->Ia32SaveState
;
244 SaveState
= &mFrameworkSmst
->CpuSaveState
[CpuIndex
].Ia32SaveState
;
248 // SMMRevId is read-only.
249 // Note that SMBASE/IORestart/AutoHALTRestart are in same location in IA32 and X64 CPU Save State Map.
251 State
->x86
.SMBASE
= SaveState
->SMBASE
;
252 State
->x86
.IORestart
= SaveState
->IORestart
;
253 State
->x86
.AutoHALTRestart
= SaveState
->AutoHALTRestart
;
255 for (Index
= 0; Index
< sizeof (mCpuSaveStateConvTable
) / sizeof (CPU_SAVE_STATE_CONVERSION
); Index
++) {
256 Status
= mSmmCpu
->WriteSaveState (
258 (UINTN
)sizeof (UINT32
),
259 mCpuSaveStateConvTable
[Index
].Register
,
261 ((UINT8
*)SaveState
) +
262 mCpuSaveStateConvTable
[Index
].Offset
268 Read or write a page that contains CpuSaveStates. Read is from PI to Framework.
269 Write is from Framework to PI.
271 This function reads or writes a page that contains CpuSaveStates. The page contains Framework
272 CpuSaveStates. On read, it reads PI style CpuSaveStates and fill the page up. On write, it
273 writes back from the page content to PI CpuSaveStates struct.
274 The first Framework CpuSaveStates (for CPU 0) is from mFrameworkSmst->CpuSaveState which is
275 page aligned. Because Framework CpuSaveStates are continuous, we can know which CPUs' SaveStates
276 are in the page start from PageAddress.
278 @param[in] PageAddress The base address for a page.
279 @param[in] IsRead TRUE for Read, FALSE for Write.
283 ReadWriteCpuStatePage (
284 IN UINT64 PageAddress
,
288 UINTN FirstSSIndex
; // Index of first CpuSaveState in the page
289 UINTN LastSSIndex
; // Index of last CpuSaveState in the page
290 BOOLEAN FirstSSAligned
; // Whether first CpuSaveState is page-aligned
291 BOOLEAN LastSSAligned
; // Whether the end of last CpuSaveState is page-aligned
295 FirstSSIndex
= ((UINTN
)PageAddress
- (UINTN
)mFrameworkSmst
->CpuSaveState
) / sizeof (EFI_SMM_CPU_SAVE_STATE
);
296 FirstSSAligned
= TRUE
;
297 if (((UINTN
)PageAddress
- (UINTN
)mFrameworkSmst
->CpuSaveState
) % sizeof (EFI_SMM_CPU_SAVE_STATE
) != 0) {
299 FirstSSAligned
= FALSE
;
301 LastSSIndex
= ((UINTN
)PageAddress
+ SIZE_4KB
- (UINTN
)mFrameworkSmst
->CpuSaveState
- 1) / sizeof (EFI_SMM_CPU_SAVE_STATE
);
302 LastSSAligned
= TRUE
;
303 if (((UINTN
)PageAddress
+ SIZE_4KB
- (UINTN
)mFrameworkSmst
->CpuSaveState
) % sizeof (EFI_SMM_CPU_SAVE_STATE
) != 0) {
305 LastSSAligned
= FALSE
;
307 for (CpuIndex
= FirstSSIndex
; CpuIndex
<= LastSSIndex
&& CpuIndex
< mNumberOfProcessors
; CpuIndex
++) {
309 ReadCpuSaveState (CpuIndex
, NULL
);
311 WriteCpuSaveState (CpuIndex
, NULL
);
314 if (!FirstSSAligned
) {
315 ReadCpuSaveState (FirstSSIndex
- 1, mShadowSaveState
);
316 ClippedSize
= (UINTN
)&mFrameworkSmst
->CpuSaveState
[FirstSSIndex
] & (SIZE_4KB
- 1);
318 CopyMem ((VOID
*)(UINTN
)PageAddress
, (VOID
*)((UINTN
)(mShadowSaveState
+ 1) - ClippedSize
), ClippedSize
);
320 CopyMem ((VOID
*)((UINTN
)(mShadowSaveState
+ 1) - ClippedSize
), (VOID
*)(UINTN
)PageAddress
, ClippedSize
);
321 WriteCpuSaveState (FirstSSIndex
- 1, mShadowSaveState
);
324 if (!LastSSAligned
&& LastSSIndex
+ 1 < mNumberOfProcessors
) {
325 ReadCpuSaveState (LastSSIndex
+ 1, mShadowSaveState
);
326 ClippedSize
= SIZE_4KB
- ((UINTN
)&mFrameworkSmst
->CpuSaveState
[LastSSIndex
+ 1] & (SIZE_4KB
- 1));
328 CopyMem (&mFrameworkSmst
->CpuSaveState
[LastSSIndex
+ 1], mShadowSaveState
, ClippedSize
);
330 CopyMem (mShadowSaveState
, &mFrameworkSmst
->CpuSaveState
[LastSSIndex
+ 1], ClippedSize
);
331 WriteCpuSaveState (LastSSIndex
+ 1, mShadowSaveState
);
337 The page fault handler that on-demand read PI CpuSaveStates for framework use. If the fault
338 is not targeted to mFrameworkSmst->CpuSaveState range, the function will return FALSE to let
339 PageFaultHandlerHook know it needs to pass the fault over to original page fault handler.
341 @retval TRUE The page fault is correctly handled.
342 @retval FALSE The page fault is not handled and is passed through to original handler.
353 UINTN NumCpuStatePages
;
355 ASSERT (mPageTableHookEnabled
);
356 AcquireSpinLock (&mPFLock
);
358 PageTable
= (UINT64
*)(UINTN
)(AsmReadCr3 () & mPhyMask
);
359 PFAddress
= AsmReadCr2 ();
360 NumCpuStatePages
= EFI_SIZE_TO_PAGES (mNumberOfProcessors
* sizeof (EFI_SMM_CPU_SAVE_STATE
));
362 if (((UINTN
)mFrameworkSmst
->CpuSaveState
& ~(SIZE_2MB
-1)) == (PFAddress
& ~(SIZE_2MB
-1))) {
363 if ((UINTN
)mFrameworkSmst
->CpuSaveState
<= PFAddress
&&
364 PFAddress
< (UINTN
)mFrameworkSmst
->CpuSaveState
+ EFI_PAGES_TO_SIZE (NumCpuStatePages
)
366 mCpuStatePageTable
[BitFieldRead64 (PFAddress
, 12, 20)] |= BIT0
| BIT1
; // present and rw
368 ReadWriteCpuStatePage (PFAddress
& ~(SIZE_4KB
-1), TRUE
);
375 ReleaseSpinLock (&mPFLock
);
380 Write back the dirty Framework CpuSaveStates to PI.
382 The function scans the page table for dirty pages in mFrameworkSmst->CpuSaveState
383 to write back to PI CpuSaveStates. It is meant to be called on each SmmBaseHelper SMI
384 callback after Framework handler is called.
388 WriteBackDirtyPages (
392 UINTN NumCpuStatePages
;
397 NumCpuStatePages
= EFI_SIZE_TO_PAGES (mNumberOfProcessors
* sizeof (EFI_SMM_CPU_SAVE_STATE
));
398 PTStartIndex
= (UINTN
)BitFieldRead64 ((UINT64
) (UINTN
) mFrameworkSmst
->CpuSaveState
, 12, 20);
399 PTEndIndex
= (UINTN
)BitFieldRead64 ((UINT64
) (UINTN
) mFrameworkSmst
->CpuSaveState
+ EFI_PAGES_TO_SIZE(NumCpuStatePages
) - 1, 12, 20);
400 for (PTIndex
= PTStartIndex
; PTIndex
<= PTEndIndex
; PTIndex
++) {
401 if ((mCpuStatePageTable
[PTIndex
] & (BIT0
|BIT6
)) == (BIT0
|BIT6
)) { // present and dirty?
402 ReadWriteCpuStatePage (mCpuStatePageTable
[PTIndex
] & mPhyMask
, FALSE
);
408 Hook IDT with our page fault handler so that the on-demand paging works on page fault.
410 The function hooks the IDT with PageFaultHandlerHook to get on-demand paging work for
411 PI<->Framework CpuSaveStates marshalling. It also saves original handler for pass-through
416 HookPageFaultHandler (
420 IA32_DESCRIPTOR Idtr
;
421 IA32_IDT_GATE_DESCRIPTOR
*IdtGateDesc
;
424 InitializeSpinLock (&mPFLock
);
427 IdtGateDesc
= (IA32_IDT_GATE_DESCRIPTOR
*) Idtr
.Base
;
428 OffsetUpper
= *(UINT32
*)((UINT64
*)IdtGateDesc
+ 1);
429 mOriginalHandler
= (VOID
*)(UINTN
)(LShiftU64 (OffsetUpper
, 32) + IdtGateDesc
[14].Bits
.OffsetLow
+ (IdtGateDesc
[14].Bits
.OffsetHigh
<< 16));
430 IdtGateDesc
[14].Bits
.OffsetLow
= (UINT32
)((UINTN
)PageFaultHandlerHook
& ((1 << 16) - 1));
431 IdtGateDesc
[14].Bits
.OffsetHigh
= (UINT32
)(((UINTN
)PageFaultHandlerHook
>> 16) & ((1 << 16) - 1));
435 Initialize page table for pages contain HookData.
437 The function initialize PDE for 2MB range that contains HookData. If the related PDE points
438 to a 2MB page, a page table will be allocated and initialized for 4KB pages. Otherwise we juse
439 use the original page table.
441 @param[in] HookData Based on which to initialize page table.
443 @return The pointer to a Page Table that points to 4KB pages which contain HookData.
446 InitCpuStatePageTable (
458 // Initialize physical address mask
459 // NOTE: Physical memory above virtual address limit is not supported !!!
461 AsmCpuid (0x80000008, (UINT32
*)&Index
, NULL
, NULL
, NULL
);
462 mPhyMask
= LShiftU64 (1, (UINT8
)Index
) - 1;
463 mPhyMask
&= (1ull << 48) - EFI_PAGE_SIZE
;
465 HookAddress
= (UINT64
)(UINTN
)HookData
;
466 PageTable
= (UINT64
*)(UINTN
)(AsmReadCr3 () & mPhyMask
);
467 PageTable
= (UINT64
*)(UINTN
)(PageTable
[BitFieldRead64 (HookAddress
, 39, 47)] & mPhyMask
);
468 PageTable
= (UINT64
*)(UINTN
)(PageTable
[BitFieldRead64 (HookAddress
, 30, 38)] & mPhyMask
);
470 Pdpte
= (UINT64
*)(UINTN
)PageTable
;
471 Pde
= Pdpte
[BitFieldRead64 (HookAddress
, 21, 29)];
472 ASSERT ((Pde
& BIT0
) != 0); // Present and 2M Page
474 if ((Pde
& BIT7
) == 0) { // 4KB Page Directory
475 PageTable
= (UINT64
*)(UINTN
)(Pde
& mPhyMask
);
477 ASSERT ((Pde
& mPhyMask
) == (HookAddress
& ~(SIZE_2MB
-1))); // 2MB Page Point to HookAddress
478 PageTable
= AllocatePages (1);
479 ASSERT (PageTable
!= NULL
);
480 Address
= HookAddress
& ~(SIZE_2MB
-1);
481 for (Index
= 0; Index
< 512; Index
++) {
482 PageTable
[Index
] = Address
| BIT0
| BIT1
; // Present and RW
485 Pdpte
[BitFieldRead64 (HookAddress
, 21, 29)] = (UINT64
)(UINTN
)PageTable
| BIT0
| BIT1
; // Present and RW
491 Mark all the CpuSaveStates as not present.
493 The function marks all CpuSaveStates memory range as not present so that page fault can be triggered
494 on CpuSaveStates access. It is meant to be called on each SmmBaseHelper SMI callback before Framework
497 @param[in] CpuSaveState The base of CpuSaveStates.
502 IN EFI_SMM_CPU_SAVE_STATE
*CpuSaveState
509 PTStartIndex
= BitFieldRead64 ((UINTN
)CpuSaveState
, 12, 20);
510 PTEndIndex
= BitFieldRead64 ((UINTN
)CpuSaveState
+ mNumberOfProcessors
* sizeof (EFI_SMM_CPU_SAVE_STATE
) - 1, 12, 20);
511 for (Index
= PTStartIndex
; Index
<= PTEndIndex
; Index
++) {
512 mCpuStatePageTable
[Index
] &= ~(BIT0
|BIT5
|BIT6
); // not present nor accessed nor dirty
517 Framework SMST SmmInstallConfigurationTable() Thunk.
519 This thunk calls the PI SMM SmmInstallConfigurationTable() and then update the configuration
520 table related fields in the Framework SMST because the PI SMM SmmInstallConfigurationTable()
521 function may modify these fields.
523 @param[in] SystemTable A pointer to the SMM System Table.
524 @param[in] Guid A pointer to the GUID for the entry to add, update, or remove.
525 @param[in] Table A pointer to the buffer of the table to add.
526 @param[in] TableSize The size of the table to install.
528 @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.
529 @retval EFI_INVALID_PARAMETER Guid is not valid.
530 @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.
531 @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.
535 SmmInstallConfigurationTable (
536 IN EFI_SMM_SYSTEM_TABLE
*SystemTable
,
544 Status
= gSmst
->SmmInstallConfigurationTable (gSmst
, Guid
, Table
, TableSize
);
545 if (!EFI_ERROR (Status
)) {
546 mFrameworkSmst
->NumberOfTableEntries
= gSmst
->NumberOfTableEntries
;
547 mFrameworkSmst
->SmmConfigurationTable
= gSmst
->SmmConfigurationTable
;
553 Initialize all the stuff needed for on-demand paging hooks for PI<->Framework
554 CpuSaveStates marshalling.
556 @param[in] FrameworkSmst Framework SMM system table pointer.
561 IN EFI_SMM_SYSTEM_TABLE
*FrameworkSmst
564 UINTN NumCpuStatePages
;
569 mPageTableHookEnabled
= FALSE
;
570 NumCpuStatePages
= EFI_SIZE_TO_PAGES (mNumberOfProcessors
* sizeof (EFI_SMM_CPU_SAVE_STATE
));
572 // Only hook page table for X64 image and less than 2MB needed to hold all CPU Save States
574 if (EFI_IMAGE_MACHINE_TYPE_SUPPORTED(EFI_IMAGE_MACHINE_X64
) && NumCpuStatePages
<= EFI_SIZE_TO_PAGES (SIZE_2MB
)) {
576 // Allocate double page size to make sure all CPU Save States are in one 2MB page.
578 CpuStatePage
= (UINTN
)AllocatePages (NumCpuStatePages
* 2);
579 ASSERT (CpuStatePage
!= 0);
580 Bottom2MPage
= CpuStatePage
& ~(SIZE_2MB
-1);
581 Top2MPage
= (CpuStatePage
+ EFI_PAGES_TO_SIZE (NumCpuStatePages
* 2) - 1) & ~(SIZE_2MB
-1);
582 if (Bottom2MPage
== Top2MPage
||
583 CpuStatePage
+ EFI_PAGES_TO_SIZE (NumCpuStatePages
* 2) - Top2MPage
>= EFI_PAGES_TO_SIZE (NumCpuStatePages
)
586 // If the allocated 4KB pages are within the same 2MB page or higher portion is larger, use higher portion pages.
588 FrameworkSmst
->CpuSaveState
= (EFI_SMM_CPU_SAVE_STATE
*)(CpuStatePage
+ EFI_PAGES_TO_SIZE (NumCpuStatePages
));
589 FreePages ((VOID
*)CpuStatePage
, NumCpuStatePages
);
591 FrameworkSmst
->CpuSaveState
= (EFI_SMM_CPU_SAVE_STATE
*)CpuStatePage
;
592 FreePages ((VOID
*)(CpuStatePage
+ EFI_PAGES_TO_SIZE (NumCpuStatePages
)), NumCpuStatePages
);
595 // Add temporary working buffer for hooking
597 mShadowSaveState
= (EFI_SMM_CPU_SAVE_STATE
*) AllocatePool (sizeof (EFI_SMM_CPU_SAVE_STATE
));
598 ASSERT (mShadowSaveState
!= NULL
);
600 // Allocate and initialize 4KB Page Table for hooking CpuSaveState.
601 // Replace the original 2MB PDE with new 4KB page table.
603 mCpuStatePageTable
= InitCpuStatePageTable (FrameworkSmst
->CpuSaveState
);
605 // Mark PTE for CpuSaveState as non-exist.
607 HookCpuStateMemory (FrameworkSmst
->CpuSaveState
);
608 HookPageFaultHandler ();
610 mPageTableHookEnabled
= TRUE
;
612 mHookInitialized
= TRUE
;
616 Construct a Framework SMST based on the PI SMM SMST.
618 @return Pointer to the constructed Framework SMST.
620 EFI_SMM_SYSTEM_TABLE
*
621 ConstructFrameworkSmst (
625 EFI_SMM_SYSTEM_TABLE
*FrameworkSmst
;
627 FrameworkSmst
= (EFI_SMM_SYSTEM_TABLE
*)AllocatePool (sizeof (EFI_SMM_SYSTEM_TABLE
));
628 ASSERT (FrameworkSmst
!= NULL
);
631 /// Copy same things from PI SMST to Framework SMST
633 CopyMem (FrameworkSmst
, gSmst
, (UINTN
)(&((EFI_SMM_SYSTEM_TABLE
*)0)->SmmIo
));
635 &FrameworkSmst
->SmmIo
,
637 sizeof (EFI_SMM_SYSTEM_TABLE
) - (UINTN
)(&((EFI_SMM_SYSTEM_TABLE
*)0)->SmmIo
)
641 /// Update Framework SMST
643 FrameworkSmst
->Hdr
.Revision
= EFI_SMM_SYSTEM_TABLE_REVISION
;
644 CopyGuid (&FrameworkSmst
->EfiSmmCpuIoGuid
, &mEfiSmmCpuIoGuid
);
646 mHookInitialized
= FALSE
;
647 FrameworkSmst
->CpuSaveState
= (EFI_SMM_CPU_SAVE_STATE
*)AllocateZeroPool (mNumberOfProcessors
* sizeof (EFI_SMM_CPU_SAVE_STATE
));
648 ASSERT (FrameworkSmst
->CpuSaveState
!= NULL
);
651 /// Do not support floating point state now
653 FrameworkSmst
->CpuOptionalFloatingPointState
= NULL
;
655 FrameworkSmst
->SmmInstallConfigurationTable
= SmmInstallConfigurationTable
;
657 return FrameworkSmst
;
661 Load a given Framework SMM driver into SMRAM and invoke its entry point.
663 @param[in] ParentImageHandle Parent Image Handle.
664 @param[in] FilePath Location of the image to be installed as the handler.
665 @param[in] SourceBuffer Optional source buffer in case the image file
667 @param[in] SourceSize Size of the source image file, if in memory.
668 @param[out] ImageHandle The handle that the base driver uses to decode
669 the handler. Unique among SMM handlers only,
670 not unique across DXE/EFI.
672 @retval EFI_SUCCESS The operation was successful.
673 @retval EFI_OUT_OF_RESOURCES There were no additional SMRAM resources to load the handler
674 @retval EFI_UNSUPPORTED Can not find its copy in normal memory.
675 @retval EFI_INVALID_PARAMETER The handlers was not the correct image type
679 IN EFI_HANDLE ParentImageHandle
,
680 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
681 IN VOID
*SourceBuffer
,
683 OUT EFI_HANDLE
*ImageHandle
689 EFI_PHYSICAL_ADDRESS DstBuffer
;
691 if (FilePath
== NULL
|| ImageHandle
== NULL
) {
692 return EFI_INVALID_PARAMETER
;
697 OrgPageCount
= PageCount
;
698 DstBuffer
= (UINTN
)-1;
699 Status
= gSmst
->SmmAllocatePages (
701 EfiRuntimeServicesCode
,
705 if (EFI_ERROR (Status
)) {
709 Status
= mLoadPe32Image
->LoadPeImage (
719 EFI_LOAD_PE_IMAGE_ATTRIBUTE_NONE
721 if (EFI_ERROR (Status
)) {
722 FreePages ((VOID
*)(UINTN
)DstBuffer
, OrgPageCount
);
724 } while (Status
== EFI_BUFFER_TOO_SMALL
);
726 if (!EFI_ERROR (Status
)) {
728 /// Update MP state in Framework SMST before transferring control to Framework SMM driver entry point
730 mFrameworkSmst
->SmmStartupThisAp
= gSmst
->SmmStartupThisAp
;
731 mFrameworkSmst
->NumberOfCpus
= mNumberOfProcessors
;
732 mFrameworkSmst
->CurrentlyExecutingCpu
= gSmst
->CurrentlyExecutingCpu
;
734 RegisterSmramProfileImage (FilePath
, DstBuffer
, PageCount
);
735 Status
= gBS
->StartImage (*ImageHandle
, NULL
, NULL
);
736 if (EFI_ERROR (Status
)) {
737 mLoadPe32Image
->UnLoadPeImage (mLoadPe32Image
, *ImageHandle
);
739 FreePages ((VOID
*)(UINTN
)DstBuffer
, PageCount
);
740 UnregisterSmramProfileImage (FilePath
, DstBuffer
, PageCount
);
748 This function check if the address is in SMRAM.
750 @param Buffer the buffer address to be checked.
751 @param Length the buffer length to be checked.
753 @retval TRUE this address is in SMRAM.
754 @retval FALSE this address is NOT in SMRAM.
758 IN EFI_PHYSICAL_ADDRESS Buffer
,
764 for (Index
= 0; Index
< mSmramRangeCount
; Index
++) {
765 if (((Buffer
>= mSmramRanges
[Index
].CpuStart
) && (Buffer
< mSmramRanges
[Index
].CpuStart
+ mSmramRanges
[Index
].PhysicalSize
)) ||
766 ((mSmramRanges
[Index
].CpuStart
>= Buffer
) && (mSmramRanges
[Index
].CpuStart
< Buffer
+ Length
))) {
775 This function check if the address refered by Buffer and Length is valid.
777 @param Buffer the buffer address to be checked.
778 @param Length the buffer length to be checked.
780 @retval TRUE this address is valid.
781 @retval FALSE this address is NOT valid.
789 if (Buffer
> (MAX_ADDRESS
- Length
)) {
795 if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS
)Buffer
, (UINT64
)Length
)) {
802 Thunk service of EFI_SMM_BASE_PROTOCOL.Register().
804 @param[in, out] FunctionData Pointer to SMMBASE_FUNCTION_DATA.
808 IN OUT SMMBASE_FUNCTION_DATA
*FunctionData
813 if (mLocked
|| FunctionData
->Args
.Register
.LegacyIA32Binary
) {
814 Status
= EFI_UNSUPPORTED
;
817 FunctionData
->SmmBaseImageHandle
,
818 FunctionData
->Args
.Register
.FilePath
,
819 FunctionData
->Args
.Register
.SourceBuffer
,
820 FunctionData
->Args
.Register
.SourceSize
,
821 FunctionData
->Args
.Register
.ImageHandle
824 FunctionData
->Status
= Status
;
828 Thunk service of EFI_SMM_BASE_PROTOCOL.UnRegister().
830 @param[in, out] FunctionData Pointer to SMMBASE_FUNCTION_DATA.
834 IN OUT SMMBASE_FUNCTION_DATA
*FunctionData
838 /// Unregister not supported now
840 FunctionData
->Status
= EFI_UNSUPPORTED
;
844 Search for Framework SMI handler information according to specific PI SMM dispatch handle.
846 @param[in] DispatchHandle The unique handle assigned by SmiHandlerRegister().
848 @return Pointer to CALLBACK_INFO. If NULL, no callback info record is found.
852 IN EFI_HANDLE DispatchHandle
857 Node
= GetFirstNode (&mCallbackInfoListHead
);
858 while (!IsNull (&mCallbackInfoListHead
, Node
)) {
859 if (((CALLBACK_INFO
*)Node
)->DispatchHandle
== DispatchHandle
) {
860 return (CALLBACK_INFO
*)Node
;
862 Node
= GetNextNode (&mCallbackInfoListHead
, Node
);
868 Callback thunk for Framework SMI handler.
870 This thunk functions calls the Framework SMI handler and converts the return value
871 defined from Framework SMI handlers to a correpsonding return value defined by PI SMM.
873 @param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
874 @param[in] Context Points to an optional handler context which was specified when the
875 handler was registered.
876 @param[in, out] CommBuffer A pointer to a collection of data in memory that will
877 be conveyed from a non-SMM environment into an SMM environment.
878 @param[in, out] CommBufferSize The size of the CommBuffer.
880 @retval EFI_SUCCESS The interrupt was handled and quiesced. No other handlers
881 should still be called.
882 @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED The interrupt has been quiesced but other handlers should
884 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING The interrupt is still pending and other handlers should still
886 @retval EFI_INTERRUPT_PENDING The interrupt could not be quiesced.
891 IN EFI_HANDLE DispatchHandle
,
892 IN CONST VOID
*Context OPTIONAL
,
893 IN OUT VOID
*CommBuffer OPTIONAL
,
894 IN OUT UINTN
*CommBufferSize OPTIONAL
898 CALLBACK_INFO
*CallbackInfo
;
902 /// Before transferring the control into the Framework SMI handler, update CPU Save States
903 /// and MP states in the Framework SMST.
906 if (!mHookInitialized
) {
907 InitHook (mFrameworkSmst
);
909 if (mPageTableHookEnabled
) {
910 HookCpuStateMemory (mFrameworkSmst
->CpuSaveState
);
913 for (CpuIndex
= 0; CpuIndex
< mNumberOfProcessors
; CpuIndex
++) {
914 ReadCpuSaveState (CpuIndex
, NULL
);
918 mFrameworkSmst
->SmmStartupThisAp
= gSmst
->SmmStartupThisAp
;
919 mFrameworkSmst
->NumberOfCpus
= mNumberOfProcessors
;
920 mFrameworkSmst
->CurrentlyExecutingCpu
= gSmst
->CurrentlyExecutingCpu
;
923 /// Search for Framework SMI handler information
925 CallbackInfo
= GetCallbackInfo (DispatchHandle
);
926 ASSERT (CallbackInfo
!= NULL
);
929 /// Thunk into original Framwork SMI handler
931 Status
= (CallbackInfo
->CallbackAddress
) (
932 CallbackInfo
->SmmImageHandle
,
933 CallbackInfo
->CommunicationBuffer
,
934 CallbackInfo
->SourceSize
937 /// Save CPU Save States in case any of them was modified
939 if (mPageTableHookEnabled
) {
940 WriteBackDirtyPages ();
942 for (CpuIndex
= 0; CpuIndex
< mNumberOfProcessors
; CpuIndex
++) {
943 WriteCpuSaveState (CpuIndex
, NULL
);
948 /// Conversion of returned status code
951 case EFI_HANDLER_SUCCESS
:
952 Status
= EFI_WARN_INTERRUPT_SOURCE_QUIESCED
;
954 case EFI_HANDLER_CRITICAL_EXIT
:
955 case EFI_HANDLER_SOURCE_QUIESCED
:
956 Status
= EFI_SUCCESS
;
958 case EFI_HANDLER_SOURCE_PENDING
:
959 Status
= EFI_WARN_INTERRUPT_SOURCE_PENDING
;
966 Thunk service of EFI_SMM_BASE_PROTOCOL.RegisterCallback().
968 @param[in, out] FunctionData Pointer to SMMBASE_FUNCTION_DATA.
972 IN OUT SMMBASE_FUNCTION_DATA
*FunctionData
975 CALLBACK_INFO
*Buffer
;
978 FunctionData
->Status
= EFI_UNSUPPORTED
;
983 /// Note that MakeLast and FloatingPointSave options are not supported in PI SMM
987 /// Allocate buffer for callback thunk information
989 Buffer
= (CALLBACK_INFO
*)AllocateZeroPool (sizeof (CALLBACK_INFO
));
990 if (Buffer
== NULL
) {
991 FunctionData
->Status
= EFI_OUT_OF_RESOURCES
;
996 /// Fill SmmImageHandle and CallbackAddress into the thunk
998 Buffer
->SmmImageHandle
= FunctionData
->Args
.RegisterCallback
.SmmImageHandle
;
999 Buffer
->CallbackAddress
= FunctionData
->Args
.RegisterCallback
.CallbackAddress
;
1002 /// Register the thunk code as a root SMI handler
1004 FunctionData
->Status
= gSmst
->SmiHandlerRegister (
1007 &Buffer
->DispatchHandle
1009 if (EFI_ERROR (FunctionData
->Status
)) {
1015 /// Save this callback info
1017 InsertTailList (&mCallbackInfoListHead
, &Buffer
->Link
);
1022 Thunk service of EFI_SMM_BASE_PROTOCOL.SmmAllocatePool().
1024 @param[in, out] FunctionData Pointer to SMMBASE_FUNCTION_DATA.
1027 HelperAllocatePool (
1028 IN OUT SMMBASE_FUNCTION_DATA
*FunctionData
1032 FunctionData
->Status
= EFI_UNSUPPORTED
;
1034 FunctionData
->Status
= gSmst
->SmmAllocatePool (
1035 FunctionData
->Args
.AllocatePool
.PoolType
,
1036 FunctionData
->Args
.AllocatePool
.Size
,
1037 FunctionData
->Args
.AllocatePool
.Buffer
1043 Thunk service of EFI_SMM_BASE_PROTOCOL.SmmFreePool().
1045 @param[in, out] FunctionData Pointer to SMMBASE_FUNCTION_DATA.
1049 IN OUT SMMBASE_FUNCTION_DATA
*FunctionData
1053 FunctionData
->Status
= EFI_UNSUPPORTED
;
1055 FreePool (FunctionData
->Args
.FreePool
.Buffer
);
1056 FunctionData
->Status
= EFI_SUCCESS
;
1061 Thunk service of EFI_SMM_BASE_PROTOCOL.Communicate().
1063 @param[in, out] FunctionData Pointer to SMMBASE_FUNCTION_DATA.
1067 IN OUT SMMBASE_FUNCTION_DATA
*FunctionData
1071 CALLBACK_INFO
*CallbackInfo
;
1073 if (FunctionData
->Args
.Communicate
.CommunicationBuffer
== NULL
) {
1074 FunctionData
->Status
= EFI_INVALID_PARAMETER
;
1078 Node
= GetFirstNode (&mCallbackInfoListHead
);
1079 while (!IsNull (&mCallbackInfoListHead
, Node
)) {
1080 CallbackInfo
= (CALLBACK_INFO
*)Node
;
1082 if (FunctionData
->Args
.Communicate
.ImageHandle
== CallbackInfo
->SmmImageHandle
) {
1083 CallbackInfo
->CommunicationBuffer
= FunctionData
->Args
.Communicate
.CommunicationBuffer
;
1084 CallbackInfo
->SourceSize
= FunctionData
->Args
.Communicate
.SourceSize
;
1087 /// The message was successfully posted.
1089 FunctionData
->Status
= EFI_SUCCESS
;
1092 Node
= GetNextNode (&mCallbackInfoListHead
, Node
);
1095 FunctionData
->Status
= EFI_INVALID_PARAMETER
;
1099 Communication service SMI Handler entry.
1101 This SMI handler provides services for the SMM Base Thunk driver.
1103 Caution: This function may receive untrusted input during runtime.
1104 The communicate buffer is external input, so this function will do operations only if the communicate
1105 buffer is outside of SMRAM so that returning the status code in the buffer won't overwrite anywhere in SMRAM.
1107 @param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
1108 @param[in] RegisterContext Points to an optional handler context which was specified when the
1109 handler was registered.
1110 @param[in, out] CommBuffer A pointer to a collection of data in memory that will
1111 be conveyed from a non-SMM environment into an SMM environment.
1112 @param[in, out] CommBufferSize The size of the CommBuffer.
1114 @retval EFI_SUCCESS The interrupt was handled and quiesced. No other handlers
1115 should still be called.
1116 @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED The interrupt has been quiesced but other handlers should
1118 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING The interrupt is still pending and other handlers should still
1120 @retval EFI_INTERRUPT_PENDING The interrupt could not be quiesced.
1125 IN EFI_HANDLE DispatchHandle
,
1126 IN CONST VOID
*RegisterContext
,
1127 IN OUT VOID
*CommBuffer
,
1128 IN OUT UINTN
*CommBufferSize
1131 SMMBASE_FUNCTION_DATA
*FunctionData
;
1133 ASSERT (CommBuffer
!= NULL
);
1134 ASSERT (CommBufferSize
!= NULL
);
1136 if (*CommBufferSize
== sizeof (SMMBASE_FUNCTION_DATA
) &&
1137 IsAddressValid ((UINTN
)CommBuffer
, *CommBufferSize
)) {
1138 FunctionData
= (SMMBASE_FUNCTION_DATA
*)CommBuffer
;
1140 switch (FunctionData
->Function
) {
1141 case SmmBaseFunctionRegister
:
1142 Register (FunctionData
);
1144 case SmmBaseFunctionUnregister
:
1145 UnRegister (FunctionData
);
1147 case SmmBaseFunctionRegisterCallback
:
1148 RegisterCallback (FunctionData
);
1150 case SmmBaseFunctionAllocatePool
:
1151 HelperAllocatePool (FunctionData
);
1153 case SmmBaseFunctionFreePool
:
1154 HelperFreePool (FunctionData
);
1156 case SmmBaseFunctionCommunicate
:
1157 HelperCommunicate (FunctionData
);
1160 DEBUG ((EFI_D_WARN
, "SmmBaseHelper: invalid SMM Base function.\n"));
1161 FunctionData
->Status
= EFI_UNSUPPORTED
;
1168 Smm Ready To Lock event notification handler.
1170 It sets a flag indicating that SMRAM has been locked.
1172 @param[in] Protocol Points to the protocol's unique identifier.
1173 @param[in] Interface Points to the interface instance.
1174 @param[in] Handle The handle on which the interface was installed.
1176 @retval EFI_SUCCESS Notification handler runs successfully.
1180 SmmReadyToLockEventNotify (
1181 IN CONST EFI_GUID
*Protocol
,
1183 IN EFI_HANDLE Handle
1191 Entry point function of the SMM Base Helper SMM driver.
1193 @param[in] ImageHandle The firmware allocated handle for the EFI image.
1194 @param[in] SystemTable A pointer to the EFI System Table.
1196 @retval EFI_SUCCESS The entry point is executed successfully.
1197 @retval other Some error occurs when executing this entry point.
1202 IN EFI_HANDLE ImageHandle
,
1203 IN EFI_SYSTEM_TABLE
*SystemTable
1207 EFI_MP_SERVICES_PROTOCOL
*MpServices
;
1209 UINTN NumberOfEnabledProcessors
;
1211 EFI_SMM_ACCESS2_PROTOCOL
*SmmAccess
;
1216 /// Locate SMM CPU Protocol which is used later to retrieve/update CPU Save States
1218 Status
= gSmst
->SmmLocateProtocol (&gEfiSmmCpuProtocolGuid
, NULL
, (VOID
**) &mSmmCpu
);
1219 ASSERT_EFI_ERROR (Status
);
1222 /// Locate PE32 Image Protocol which is used later to load Framework SMM driver
1224 Status
= SystemTable
->BootServices
->LocateProtocol (&gEfiLoadPeImageProtocolGuid
, NULL
, (VOID
**) &mLoadPe32Image
);
1225 ASSERT_EFI_ERROR (Status
);
1228 // Get MP Services Protocol
1230 Status
= SystemTable
->BootServices
->LocateProtocol (&gEfiMpServiceProtocolGuid
, NULL
, (VOID
**)&MpServices
);
1231 ASSERT_EFI_ERROR (Status
);
1234 // Use MP Services Protocol to retrieve the number of processors and number of enabled processors
1236 Status
= MpServices
->GetNumberOfProcessors (MpServices
, &mNumberOfProcessors
, &NumberOfEnabledProcessors
);
1237 ASSERT_EFI_ERROR (Status
);
1240 /// Interface structure of SMM BASE Helper Ready Protocol is allocated from UEFI pool
1241 /// instead of SMM pool so that SMM Base Thunk driver can access it in Non-SMM mode.
1243 Status
= gBS
->AllocatePool (
1244 EfiBootServicesData
,
1245 sizeof (EFI_SMM_BASE_HELPER_READY_PROTOCOL
),
1246 (VOID
**)&mSmmBaseHelperReady
1248 ASSERT_EFI_ERROR (Status
);
1251 /// Construct Framework SMST from PI SMST
1253 mFrameworkSmst
= ConstructFrameworkSmst ();
1254 mSmmBaseHelperReady
->FrameworkSmst
= mFrameworkSmst
;
1255 mSmmBaseHelperReady
->ServiceEntry
= SmmHandlerEntry
;
1258 // Get SMRAM information
1260 Status
= gBS
->LocateProtocol (&gEfiSmmAccess2ProtocolGuid
, NULL
, (VOID
**)&SmmAccess
);
1261 ASSERT_EFI_ERROR (Status
);
1264 Status
= SmmAccess
->GetCapabilities (SmmAccess
, &Size
, NULL
);
1265 ASSERT (Status
== EFI_BUFFER_TOO_SMALL
);
1267 Status
= gSmst
->SmmAllocatePool (
1268 EfiRuntimeServicesData
,
1270 (VOID
**)&mSmramRanges
1272 ASSERT_EFI_ERROR (Status
);
1274 Status
= SmmAccess
->GetCapabilities (SmmAccess
, &Size
, mSmramRanges
);
1275 ASSERT_EFI_ERROR (Status
);
1277 mSmramRangeCount
= Size
/ sizeof (EFI_SMRAM_DESCRIPTOR
);
1280 // Register SMM Ready To Lock Protocol notification
1282 Status
= gSmst
->SmmRegisterProtocolNotify (
1283 &gEfiSmmReadyToLockProtocolGuid
,
1284 SmmReadyToLockEventNotify
,
1287 ASSERT_EFI_ERROR (Status
);
1290 /// Register SMM Base Helper services for SMM Base Thunk driver
1292 Status
= gSmst
->SmiHandlerRegister (SmmHandlerEntry
, &gEfiSmmBaseThunkCommunicationGuid
, &mDispatchHandle
);
1293 ASSERT_EFI_ERROR (Status
);
1296 /// Install EFI SMM Base Helper Protocol in the UEFI handle database
1298 Status
= gBS
->InstallProtocolInterface (
1300 &gEfiSmmBaseHelperReadyProtocolGuid
,
1301 EFI_NATIVE_INTERFACE
,
1304 ASSERT_EFI_ERROR (Status
);