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 - 2015, 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 <Guid/SmmBaseThunkCommunication.h>
38 #include <Protocol/SmmBaseHelperReady.h>
39 #include <Protocol/SmmCpu.h>
40 #include <Protocol/LoadedImage.h>
41 #include <Protocol/SmmCpuSaveState.h>
42 #include <Protocol/MpService.h>
43 #include <Protocol/LoadPe32Image.h>
44 #include <Protocol/SmmReadyToLock.h>
45 #include <Protocol/SmmAccess2.h>
48 Register SMM image to SMRAM profile.
50 @param[in] FilePath File path of the image.
51 @param[in] ImageBuffer Image base address.
52 @param[in] NumberOfPage Number of page.
54 @retval TRUE Register success.
55 @retval FALSE Register fail.
59 RegisterSmramProfileImage (
60 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
61 IN PHYSICAL_ADDRESS ImageBuffer
,
66 Unregister SMM image from SMRAM profile.
68 @param[in] FilePath File path of the image.
69 @param[in] ImageBuffer Image base address.
70 @param[in] NumberOfPage Number of page.
72 @retval TRUE Unregister success.
73 @retval FALSE Unregister fail.
77 UnregisterSmramProfileImage (
78 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
79 IN PHYSICAL_ADDRESS ImageBuffer
,
84 /// Structure for tracking paired information of registered Framework SMI handler
85 /// and correpsonding dispatch handle for SMI handler thunk.
89 EFI_HANDLE DispatchHandle
;
90 EFI_HANDLE SmmImageHandle
;
91 EFI_SMM_CALLBACK_ENTRY_POINT CallbackAddress
;
92 VOID
*CommunicationBuffer
;
98 /// PI SMM CPU Save State register index
100 EFI_SMM_SAVE_STATE_REGISTER Register
;
102 /// Offset in Framework SMST
105 } CPU_SAVE_STATE_CONVERSION
;
107 #define CPU_SAVE_STATE_GET_OFFSET(Field) (UINTN)(&(((EFI_SMM_CPU_SAVE_STATE *) 0)->Ia32SaveState.Field))
110 EFI_HANDLE mDispatchHandle
;
111 EFI_SMM_CPU_PROTOCOL
*mSmmCpu
;
112 EFI_PE32_IMAGE_PROTOCOL
*mLoadPe32Image
;
113 EFI_GUID mEfiSmmCpuIoGuid
= EFI_SMM_CPU_IO_GUID
;
114 EFI_SMM_BASE_HELPER_READY_PROTOCOL
*mSmmBaseHelperReady
;
115 EFI_SMM_SYSTEM_TABLE
*mFrameworkSmst
;
116 UINTN mNumberOfProcessors
;
117 BOOLEAN mLocked
= FALSE
;
118 BOOLEAN mPageTableHookEnabled
;
119 BOOLEAN mHookInitialized
;
120 UINT64
*mCpuStatePageTable
;
123 VOID
*mOriginalHandler
;
124 EFI_SMM_CPU_SAVE_STATE
*mShadowSaveState
;
125 EFI_SMRAM_DESCRIPTOR
*mSmramRanges
;
126 UINTN mSmramRangeCount
;
128 LIST_ENTRY mCallbackInfoListHead
= INITIALIZE_LIST_HEAD_VARIABLE (mCallbackInfoListHead
);
130 CPU_SAVE_STATE_CONVERSION mCpuSaveStateConvTable
[] = {
131 {EFI_SMM_SAVE_STATE_REGISTER_LDTBASE
, CPU_SAVE_STATE_GET_OFFSET(LDTBase
)},
132 {EFI_SMM_SAVE_STATE_REGISTER_ES
, CPU_SAVE_STATE_GET_OFFSET(ES
)},
133 {EFI_SMM_SAVE_STATE_REGISTER_CS
, CPU_SAVE_STATE_GET_OFFSET(CS
)},
134 {EFI_SMM_SAVE_STATE_REGISTER_SS
, CPU_SAVE_STATE_GET_OFFSET(SS
)},
135 {EFI_SMM_SAVE_STATE_REGISTER_DS
, CPU_SAVE_STATE_GET_OFFSET(DS
)},
136 {EFI_SMM_SAVE_STATE_REGISTER_FS
, CPU_SAVE_STATE_GET_OFFSET(FS
)},
137 {EFI_SMM_SAVE_STATE_REGISTER_GS
, CPU_SAVE_STATE_GET_OFFSET(GS
)},
138 {EFI_SMM_SAVE_STATE_REGISTER_TR_SEL
, CPU_SAVE_STATE_GET_OFFSET(TR
)},
139 {EFI_SMM_SAVE_STATE_REGISTER_DR7
, CPU_SAVE_STATE_GET_OFFSET(DR7
)},
140 {EFI_SMM_SAVE_STATE_REGISTER_DR6
, CPU_SAVE_STATE_GET_OFFSET(DR6
)},
141 {EFI_SMM_SAVE_STATE_REGISTER_RAX
, CPU_SAVE_STATE_GET_OFFSET(EAX
)},
142 {EFI_SMM_SAVE_STATE_REGISTER_RBX
, CPU_SAVE_STATE_GET_OFFSET(EBX
)},
143 {EFI_SMM_SAVE_STATE_REGISTER_RCX
, CPU_SAVE_STATE_GET_OFFSET(ECX
)},
144 {EFI_SMM_SAVE_STATE_REGISTER_RDX
, CPU_SAVE_STATE_GET_OFFSET(EDX
)},
145 {EFI_SMM_SAVE_STATE_REGISTER_RSP
, CPU_SAVE_STATE_GET_OFFSET(ESP
)},
146 {EFI_SMM_SAVE_STATE_REGISTER_RBP
, CPU_SAVE_STATE_GET_OFFSET(EBP
)},
147 {EFI_SMM_SAVE_STATE_REGISTER_RSI
, CPU_SAVE_STATE_GET_OFFSET(ESI
)},
148 {EFI_SMM_SAVE_STATE_REGISTER_RDI
, CPU_SAVE_STATE_GET_OFFSET(EDI
)},
149 {EFI_SMM_SAVE_STATE_REGISTER_RIP
, CPU_SAVE_STATE_GET_OFFSET(EIP
)},
150 {EFI_SMM_SAVE_STATE_REGISTER_RFLAGS
, CPU_SAVE_STATE_GET_OFFSET(EFLAGS
)},
151 {EFI_SMM_SAVE_STATE_REGISTER_CR0
, CPU_SAVE_STATE_GET_OFFSET(CR0
)},
152 {EFI_SMM_SAVE_STATE_REGISTER_CR3
, CPU_SAVE_STATE_GET_OFFSET(CR3
)}
160 PageFaultHandlerHook (
165 Read CpuSaveStates from PI for Framework use.
167 The function reads PI style CpuSaveStates of CpuIndex-th CPU for Framework driver use. If
168 ToRead is specified, the CpuSaveStates will be copied to ToRead, otherwise copied to
169 mFrameworkSmst->CpuSaveState[CpuIndex].
171 @param[in] CpuIndex The zero-based CPU index.
172 @param[in, out] ToRead If not NULL, CpuSaveStates will be copied to it.
178 IN OUT EFI_SMM_CPU_SAVE_STATE
*ToRead
183 EFI_SMM_CPU_STATE
*State
;
184 EFI_SMI_CPU_SAVE_STATE
*SaveState
;
186 State
= (EFI_SMM_CPU_STATE
*)gSmst
->CpuSaveState
[CpuIndex
];
187 if (ToRead
!= NULL
) {
188 SaveState
= &ToRead
->Ia32SaveState
;
190 SaveState
= &mFrameworkSmst
->CpuSaveState
[CpuIndex
].Ia32SaveState
;
194 // Note that SMBASE/SMMRevId/IORestart/AutoHALTRestart are in same location in IA32 and X64 CPU Save State Map.
196 SaveState
->SMBASE
= State
->x86
.SMBASE
;
197 SaveState
->SMMRevId
= State
->x86
.SMMRevId
;
198 SaveState
->IORestart
= State
->x86
.IORestart
;
199 SaveState
->AutoHALTRestart
= State
->x86
.AutoHALTRestart
;
201 for (Index
= 0; Index
< sizeof (mCpuSaveStateConvTable
) / sizeof (CPU_SAVE_STATE_CONVERSION
); Index
++) {
203 /// Try to use SMM CPU Protocol to access CPU save states if possible
205 Status
= mSmmCpu
->ReadSaveState (
207 (UINTN
)sizeof (UINT32
),
208 mCpuSaveStateConvTable
[Index
].Register
,
210 ((UINT8
*)SaveState
) + mCpuSaveStateConvTable
[Index
].Offset
212 ASSERT_EFI_ERROR (Status
);
217 Write CpuSaveStates from Framework into PI.
219 The function writes back CpuSaveStates of CpuIndex-th CPU from PI to Framework. If
220 ToWrite is specified, it contains the CpuSaveStates to write from, otherwise CpuSaveStates
221 to write from mFrameworkSmst->CpuSaveState[CpuIndex].
223 @param[in] CpuIndex The zero-based CPU index.
224 @param[in] ToWrite If not NULL, CpuSaveStates to write from.
230 IN EFI_SMM_CPU_SAVE_STATE
*ToWrite
235 EFI_SMM_CPU_STATE
*State
;
236 EFI_SMI_CPU_SAVE_STATE
*SaveState
;
238 State
= (EFI_SMM_CPU_STATE
*)gSmst
->CpuSaveState
[CpuIndex
];
240 if (ToWrite
!= NULL
) {
241 SaveState
= &ToWrite
->Ia32SaveState
;
243 SaveState
= &mFrameworkSmst
->CpuSaveState
[CpuIndex
].Ia32SaveState
;
247 // SMMRevId is read-only.
248 // Note that SMBASE/IORestart/AutoHALTRestart are in same location in IA32 and X64 CPU Save State Map.
250 State
->x86
.SMBASE
= SaveState
->SMBASE
;
251 State
->x86
.IORestart
= SaveState
->IORestart
;
252 State
->x86
.AutoHALTRestart
= SaveState
->AutoHALTRestart
;
254 for (Index
= 0; Index
< sizeof (mCpuSaveStateConvTable
) / sizeof (CPU_SAVE_STATE_CONVERSION
); Index
++) {
255 Status
= mSmmCpu
->WriteSaveState (
257 (UINTN
)sizeof (UINT32
),
258 mCpuSaveStateConvTable
[Index
].Register
,
260 ((UINT8
*)SaveState
) +
261 mCpuSaveStateConvTable
[Index
].Offset
267 Read or write a page that contains CpuSaveStates. Read is from PI to Framework.
268 Write is from Framework to PI.
270 This function reads or writes a page that contains CpuSaveStates. The page contains Framework
271 CpuSaveStates. On read, it reads PI style CpuSaveStates and fill the page up. On write, it
272 writes back from the page content to PI CpuSaveStates struct.
273 The first Framework CpuSaveStates (for CPU 0) is from mFrameworkSmst->CpuSaveState which is
274 page aligned. Because Framework CpuSaveStates are continuous, we can know which CPUs' SaveStates
275 are in the page start from PageAddress.
277 @param[in] PageAddress The base address for a page.
278 @param[in] IsRead TRUE for Read, FALSE for Write.
282 ReadWriteCpuStatePage (
283 IN UINT64 PageAddress
,
287 UINTN FirstSSIndex
; // Index of first CpuSaveState in the page
288 UINTN LastSSIndex
; // Index of last CpuSaveState in the page
289 BOOLEAN FirstSSAligned
; // Whether first CpuSaveState is page-aligned
290 BOOLEAN LastSSAligned
; // Whether the end of last CpuSaveState is page-aligned
294 FirstSSIndex
= ((UINTN
)PageAddress
- (UINTN
)mFrameworkSmst
->CpuSaveState
) / sizeof (EFI_SMM_CPU_SAVE_STATE
);
295 FirstSSAligned
= TRUE
;
296 if (((UINTN
)PageAddress
- (UINTN
)mFrameworkSmst
->CpuSaveState
) % sizeof (EFI_SMM_CPU_SAVE_STATE
) != 0) {
298 FirstSSAligned
= FALSE
;
300 LastSSIndex
= ((UINTN
)PageAddress
+ SIZE_4KB
- (UINTN
)mFrameworkSmst
->CpuSaveState
- 1) / sizeof (EFI_SMM_CPU_SAVE_STATE
);
301 LastSSAligned
= TRUE
;
302 if (((UINTN
)PageAddress
+ SIZE_4KB
- (UINTN
)mFrameworkSmst
->CpuSaveState
) % sizeof (EFI_SMM_CPU_SAVE_STATE
) != 0) {
304 LastSSAligned
= FALSE
;
306 for (CpuIndex
= FirstSSIndex
; CpuIndex
<= LastSSIndex
&& CpuIndex
< mNumberOfProcessors
; CpuIndex
++) {
308 ReadCpuSaveState (CpuIndex
, NULL
);
310 WriteCpuSaveState (CpuIndex
, NULL
);
313 if (!FirstSSAligned
) {
314 ReadCpuSaveState (FirstSSIndex
- 1, mShadowSaveState
);
315 ClippedSize
= (UINTN
)&mFrameworkSmst
->CpuSaveState
[FirstSSIndex
] & (SIZE_4KB
- 1);
317 CopyMem ((VOID
*)(UINTN
)PageAddress
, (VOID
*)((UINTN
)(mShadowSaveState
+ 1) - ClippedSize
), ClippedSize
);
319 CopyMem ((VOID
*)((UINTN
)(mShadowSaveState
+ 1) - ClippedSize
), (VOID
*)(UINTN
)PageAddress
, ClippedSize
);
320 WriteCpuSaveState (FirstSSIndex
- 1, mShadowSaveState
);
323 if (!LastSSAligned
&& LastSSIndex
+ 1 < mNumberOfProcessors
) {
324 ReadCpuSaveState (LastSSIndex
+ 1, mShadowSaveState
);
325 ClippedSize
= SIZE_4KB
- ((UINTN
)&mFrameworkSmst
->CpuSaveState
[LastSSIndex
+ 1] & (SIZE_4KB
- 1));
327 CopyMem (&mFrameworkSmst
->CpuSaveState
[LastSSIndex
+ 1], mShadowSaveState
, ClippedSize
);
329 CopyMem (mShadowSaveState
, &mFrameworkSmst
->CpuSaveState
[LastSSIndex
+ 1], ClippedSize
);
330 WriteCpuSaveState (LastSSIndex
+ 1, mShadowSaveState
);
336 The page fault handler that on-demand read PI CpuSaveStates for framework use. If the fault
337 is not targeted to mFrameworkSmst->CpuSaveState range, the function will return FALSE to let
338 PageFaultHandlerHook know it needs to pass the fault over to original page fault handler.
340 @retval TRUE The page fault is correctly handled.
341 @retval FALSE The page fault is not handled and is passed through to original handler.
352 UINTN NumCpuStatePages
;
354 ASSERT (mPageTableHookEnabled
);
355 AcquireSpinLock (&mPFLock
);
357 PageTable
= (UINT64
*)(UINTN
)(AsmReadCr3 () & mPhyMask
);
358 PFAddress
= AsmReadCr2 ();
359 NumCpuStatePages
= EFI_SIZE_TO_PAGES (mNumberOfProcessors
* sizeof (EFI_SMM_CPU_SAVE_STATE
));
361 if (((UINTN
)mFrameworkSmst
->CpuSaveState
& ~(SIZE_2MB
-1)) == (PFAddress
& ~(SIZE_2MB
-1))) {
362 if ((UINTN
)mFrameworkSmst
->CpuSaveState
<= PFAddress
&&
363 PFAddress
< (UINTN
)mFrameworkSmst
->CpuSaveState
+ EFI_PAGES_TO_SIZE (NumCpuStatePages
)
365 mCpuStatePageTable
[BitFieldRead64 (PFAddress
, 12, 20)] |= BIT0
| BIT1
; // present and rw
367 ReadWriteCpuStatePage (PFAddress
& ~(SIZE_4KB
-1), TRUE
);
374 ReleaseSpinLock (&mPFLock
);
379 Write back the dirty Framework CpuSaveStates to PI.
381 The function scans the page table for dirty pages in mFrameworkSmst->CpuSaveState
382 to write back to PI CpuSaveStates. It is meant to be called on each SmmBaseHelper SMI
383 callback after Framework handler is called.
387 WriteBackDirtyPages (
391 UINTN NumCpuStatePages
;
396 NumCpuStatePages
= EFI_SIZE_TO_PAGES (mNumberOfProcessors
* sizeof (EFI_SMM_CPU_SAVE_STATE
));
397 PTStartIndex
= (UINTN
)BitFieldRead64 ((UINT64
) (UINTN
) mFrameworkSmst
->CpuSaveState
, 12, 20);
398 PTEndIndex
= (UINTN
)BitFieldRead64 ((UINT64
) (UINTN
) mFrameworkSmst
->CpuSaveState
+ EFI_PAGES_TO_SIZE(NumCpuStatePages
) - 1, 12, 20);
399 for (PTIndex
= PTStartIndex
; PTIndex
<= PTEndIndex
; PTIndex
++) {
400 if ((mCpuStatePageTable
[PTIndex
] & (BIT0
|BIT6
)) == (BIT0
|BIT6
)) { // present and dirty?
401 ReadWriteCpuStatePage (mCpuStatePageTable
[PTIndex
] & mPhyMask
, FALSE
);
407 Hook IDT with our page fault handler so that the on-demand paging works on page fault.
409 The function hooks the IDT with PageFaultHandlerHook to get on-demand paging work for
410 PI<->Framework CpuSaveStates marshalling. It also saves original handler for pass-through
415 HookPageFaultHandler (
419 IA32_DESCRIPTOR Idtr
;
420 IA32_IDT_GATE_DESCRIPTOR
*IdtGateDesc
;
423 InitializeSpinLock (&mPFLock
);
426 IdtGateDesc
= (IA32_IDT_GATE_DESCRIPTOR
*) Idtr
.Base
;
427 OffsetUpper
= *(UINT32
*)((UINT64
*)IdtGateDesc
+ 1);
428 mOriginalHandler
= (VOID
*)(UINTN
)(LShiftU64 (OffsetUpper
, 32) + IdtGateDesc
[14].Bits
.OffsetLow
+ (IdtGateDesc
[14].Bits
.OffsetHigh
<< 16));
429 IdtGateDesc
[14].Bits
.OffsetLow
= (UINT32
)((UINTN
)PageFaultHandlerHook
& ((1 << 16) - 1));
430 IdtGateDesc
[14].Bits
.OffsetHigh
= (UINT32
)(((UINTN
)PageFaultHandlerHook
>> 16) & ((1 << 16) - 1));
434 Initialize page table for pages contain HookData.
436 The function initialize PDE for 2MB range that contains HookData. If the related PDE points
437 to a 2MB page, a page table will be allocated and initialized for 4KB pages. Otherwise we juse
438 use the original page table.
440 @param[in] HookData Based on which to initialize page table.
442 @return The pointer to a Page Table that points to 4KB pages which contain HookData.
445 InitCpuStatePageTable (
457 // Initialize physical address mask
458 // NOTE: Physical memory above virtual address limit is not supported !!!
460 AsmCpuid (0x80000008, (UINT32
*)&Index
, NULL
, NULL
, NULL
);
461 mPhyMask
= LShiftU64 (1, (UINT8
)Index
) - 1;
462 mPhyMask
&= (1ull << 48) - EFI_PAGE_SIZE
;
464 HookAddress
= (UINT64
)(UINTN
)HookData
;
465 PageTable
= (UINT64
*)(UINTN
)(AsmReadCr3 () & mPhyMask
);
466 PageTable
= (UINT64
*)(UINTN
)(PageTable
[BitFieldRead64 (HookAddress
, 39, 47)] & mPhyMask
);
467 PageTable
= (UINT64
*)(UINTN
)(PageTable
[BitFieldRead64 (HookAddress
, 30, 38)] & mPhyMask
);
469 Pdpte
= (UINT64
*)(UINTN
)PageTable
;
470 Pde
= Pdpte
[BitFieldRead64 (HookAddress
, 21, 29)];
471 ASSERT ((Pde
& BIT0
) != 0); // Present and 2M Page
473 if ((Pde
& BIT7
) == 0) { // 4KB Page Directory
474 PageTable
= (UINT64
*)(UINTN
)(Pde
& mPhyMask
);
476 ASSERT ((Pde
& mPhyMask
) == (HookAddress
& ~(SIZE_2MB
-1))); // 2MB Page Point to HookAddress
477 PageTable
= AllocatePages (1);
478 ASSERT (PageTable
!= NULL
);
479 Address
= HookAddress
& ~(SIZE_2MB
-1);
480 for (Index
= 0; Index
< 512; Index
++) {
481 PageTable
[Index
] = Address
| BIT0
| BIT1
; // Present and RW
484 Pdpte
[BitFieldRead64 (HookAddress
, 21, 29)] = (UINT64
)(UINTN
)PageTable
| BIT0
| BIT1
; // Present and RW
490 Mark all the CpuSaveStates as not present.
492 The function marks all CpuSaveStates memory range as not present so that page fault can be triggered
493 on CpuSaveStates access. It is meant to be called on each SmmBaseHelper SMI callback before Framework
496 @param[in] CpuSaveState The base of CpuSaveStates.
501 IN EFI_SMM_CPU_SAVE_STATE
*CpuSaveState
508 PTStartIndex
= BitFieldRead64 ((UINTN
)CpuSaveState
, 12, 20);
509 PTEndIndex
= BitFieldRead64 ((UINTN
)CpuSaveState
+ mNumberOfProcessors
* sizeof (EFI_SMM_CPU_SAVE_STATE
) - 1, 12, 20);
510 for (Index
= PTStartIndex
; Index
<= PTEndIndex
; Index
++) {
511 mCpuStatePageTable
[Index
] &= ~(BIT0
|BIT5
|BIT6
); // not present nor accessed nor dirty
516 Framework SMST SmmInstallConfigurationTable() Thunk.
518 This thunk calls the PI SMM SmmInstallConfigurationTable() and then update the configuration
519 table related fields in the Framework SMST because the PI SMM SmmInstallConfigurationTable()
520 function may modify these fields.
522 @param[in] SystemTable A pointer to the SMM System Table.
523 @param[in] Guid A pointer to the GUID for the entry to add, update, or remove.
524 @param[in] Table A pointer to the buffer of the table to add.
525 @param[in] TableSize The size of the table to install.
527 @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.
528 @retval EFI_INVALID_PARAMETER Guid is not valid.
529 @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.
530 @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.
534 SmmInstallConfigurationTable (
535 IN EFI_SMM_SYSTEM_TABLE
*SystemTable
,
543 Status
= gSmst
->SmmInstallConfigurationTable (gSmst
, Guid
, Table
, TableSize
);
544 if (!EFI_ERROR (Status
)) {
545 mFrameworkSmst
->NumberOfTableEntries
= gSmst
->NumberOfTableEntries
;
546 mFrameworkSmst
->SmmConfigurationTable
= gSmst
->SmmConfigurationTable
;
552 Initialize all the stuff needed for on-demand paging hooks for PI<->Framework
553 CpuSaveStates marshalling.
555 @param[in] FrameworkSmst Framework SMM system table pointer.
560 IN EFI_SMM_SYSTEM_TABLE
*FrameworkSmst
563 UINTN NumCpuStatePages
;
568 mPageTableHookEnabled
= FALSE
;
569 NumCpuStatePages
= EFI_SIZE_TO_PAGES (mNumberOfProcessors
* sizeof (EFI_SMM_CPU_SAVE_STATE
));
571 // Only hook page table for X64 image and less than 2MB needed to hold all CPU Save States
573 if (EFI_IMAGE_MACHINE_TYPE_SUPPORTED(EFI_IMAGE_MACHINE_X64
) && NumCpuStatePages
<= EFI_SIZE_TO_PAGES (SIZE_2MB
)) {
575 // Allocate double page size to make sure all CPU Save States are in one 2MB page.
577 CpuStatePage
= (UINTN
)AllocatePages (NumCpuStatePages
* 2);
578 ASSERT (CpuStatePage
!= 0);
579 Bottom2MPage
= CpuStatePage
& ~(SIZE_2MB
-1);
580 Top2MPage
= (CpuStatePage
+ EFI_PAGES_TO_SIZE (NumCpuStatePages
* 2) - 1) & ~(SIZE_2MB
-1);
581 if (Bottom2MPage
== Top2MPage
||
582 CpuStatePage
+ EFI_PAGES_TO_SIZE (NumCpuStatePages
* 2) - Top2MPage
>= EFI_PAGES_TO_SIZE (NumCpuStatePages
)
585 // If the allocated 4KB pages are within the same 2MB page or higher portion is larger, use higher portion pages.
587 FrameworkSmst
->CpuSaveState
= (EFI_SMM_CPU_SAVE_STATE
*)(CpuStatePage
+ EFI_PAGES_TO_SIZE (NumCpuStatePages
));
588 FreePages ((VOID
*)CpuStatePage
, NumCpuStatePages
);
590 FrameworkSmst
->CpuSaveState
= (EFI_SMM_CPU_SAVE_STATE
*)CpuStatePage
;
591 FreePages ((VOID
*)(CpuStatePage
+ EFI_PAGES_TO_SIZE (NumCpuStatePages
)), NumCpuStatePages
);
594 // Add temporary working buffer for hooking
596 mShadowSaveState
= (EFI_SMM_CPU_SAVE_STATE
*) AllocatePool (sizeof (EFI_SMM_CPU_SAVE_STATE
));
597 ASSERT (mShadowSaveState
!= NULL
);
599 // Allocate and initialize 4KB Page Table for hooking CpuSaveState.
600 // Replace the original 2MB PDE with new 4KB page table.
602 mCpuStatePageTable
= InitCpuStatePageTable (FrameworkSmst
->CpuSaveState
);
604 // Mark PTE for CpuSaveState as non-exist.
606 HookCpuStateMemory (FrameworkSmst
->CpuSaveState
);
607 HookPageFaultHandler ();
609 mPageTableHookEnabled
= TRUE
;
611 mHookInitialized
= TRUE
;
615 Construct a Framework SMST based on the PI SMM SMST.
617 @return Pointer to the constructed Framework SMST.
619 EFI_SMM_SYSTEM_TABLE
*
620 ConstructFrameworkSmst (
624 EFI_SMM_SYSTEM_TABLE
*FrameworkSmst
;
626 FrameworkSmst
= (EFI_SMM_SYSTEM_TABLE
*)AllocatePool (sizeof (EFI_SMM_SYSTEM_TABLE
));
627 ASSERT (FrameworkSmst
!= NULL
);
630 /// Copy same things from PI SMST to Framework SMST
632 CopyMem (FrameworkSmst
, gSmst
, (UINTN
)(&((EFI_SMM_SYSTEM_TABLE
*)0)->SmmIo
));
634 &FrameworkSmst
->SmmIo
,
636 sizeof (EFI_SMM_SYSTEM_TABLE
) - (UINTN
)(&((EFI_SMM_SYSTEM_TABLE
*)0)->SmmIo
)
640 /// Update Framework SMST
642 FrameworkSmst
->Hdr
.Revision
= EFI_SMM_SYSTEM_TABLE_REVISION
;
643 CopyGuid (&FrameworkSmst
->EfiSmmCpuIoGuid
, &mEfiSmmCpuIoGuid
);
645 mHookInitialized
= FALSE
;
646 FrameworkSmst
->CpuSaveState
= (EFI_SMM_CPU_SAVE_STATE
*)AllocateZeroPool (mNumberOfProcessors
* sizeof (EFI_SMM_CPU_SAVE_STATE
));
647 ASSERT (FrameworkSmst
->CpuSaveState
!= NULL
);
650 /// Do not support floating point state now
652 FrameworkSmst
->CpuOptionalFloatingPointState
= NULL
;
654 FrameworkSmst
->SmmInstallConfigurationTable
= SmmInstallConfigurationTable
;
656 return FrameworkSmst
;
660 Load a given Framework SMM driver into SMRAM and invoke its entry point.
662 @param[in] ParentImageHandle Parent Image Handle.
663 @param[in] FilePath Location of the image to be installed as the handler.
664 @param[in] SourceBuffer Optional source buffer in case the image file
666 @param[in] SourceSize Size of the source image file, if in memory.
667 @param[out] ImageHandle The handle that the base driver uses to decode
668 the handler. Unique among SMM handlers only,
669 not unique across DXE/EFI.
671 @retval EFI_SUCCESS The operation was successful.
672 @retval EFI_OUT_OF_RESOURCES There were no additional SMRAM resources to load the handler
673 @retval EFI_UNSUPPORTED Can not find its copy in normal memory.
674 @retval EFI_INVALID_PARAMETER The handlers was not the correct image type
678 IN EFI_HANDLE ParentImageHandle
,
679 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
680 IN VOID
*SourceBuffer
,
682 OUT EFI_HANDLE
*ImageHandle
688 EFI_PHYSICAL_ADDRESS DstBuffer
;
690 if (FilePath
== NULL
|| ImageHandle
== NULL
) {
691 return EFI_INVALID_PARAMETER
;
696 OrgPageCount
= PageCount
;
697 DstBuffer
= (UINTN
)-1;
698 Status
= gSmst
->SmmAllocatePages (
700 EfiRuntimeServicesCode
,
704 if (EFI_ERROR (Status
)) {
708 Status
= mLoadPe32Image
->LoadPeImage (
718 EFI_LOAD_PE_IMAGE_ATTRIBUTE_NONE
720 if (EFI_ERROR (Status
)) {
721 FreePages ((VOID
*)(UINTN
)DstBuffer
, OrgPageCount
);
723 } while (Status
== EFI_BUFFER_TOO_SMALL
);
725 if (!EFI_ERROR (Status
)) {
727 /// Update MP state in Framework SMST before transferring control to Framework SMM driver entry point
729 mFrameworkSmst
->SmmStartupThisAp
= gSmst
->SmmStartupThisAp
;
730 mFrameworkSmst
->NumberOfCpus
= mNumberOfProcessors
;
731 mFrameworkSmst
->CurrentlyExecutingCpu
= gSmst
->CurrentlyExecutingCpu
;
733 RegisterSmramProfileImage (FilePath
, DstBuffer
, PageCount
);
734 Status
= gBS
->StartImage (*ImageHandle
, NULL
, NULL
);
735 if (EFI_ERROR (Status
)) {
736 UnregisterSmramProfileImage (FilePath
, DstBuffer
, PageCount
);
737 mLoadPe32Image
->UnLoadPeImage (mLoadPe32Image
, *ImageHandle
);
739 FreePages ((VOID
*)(UINTN
)DstBuffer
, PageCount
);
747 This function check if the address is in SMRAM.
749 @param Buffer the buffer address to be checked.
750 @param Length the buffer length to be checked.
752 @retval TRUE this address is in SMRAM.
753 @retval FALSE this address is NOT in SMRAM.
757 IN EFI_PHYSICAL_ADDRESS Buffer
,
763 for (Index
= 0; Index
< mSmramRangeCount
; Index
++) {
764 if (((Buffer
>= mSmramRanges
[Index
].CpuStart
) && (Buffer
< mSmramRanges
[Index
].CpuStart
+ mSmramRanges
[Index
].PhysicalSize
)) ||
765 ((mSmramRanges
[Index
].CpuStart
>= Buffer
) && (mSmramRanges
[Index
].CpuStart
< Buffer
+ Length
))) {
774 This function check if the address refered by Buffer and Length is valid.
776 @param Buffer the buffer address to be checked.
777 @param Length the buffer length to be checked.
779 @retval TRUE this address is valid.
780 @retval FALSE this address is NOT valid.
788 if (Buffer
> (MAX_ADDRESS
- Length
)) {
794 if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS
)Buffer
, (UINT64
)Length
)) {
801 Thunk service of EFI_SMM_BASE_PROTOCOL.Register().
803 @param[in, out] FunctionData Pointer to SMMBASE_FUNCTION_DATA.
807 IN OUT SMMBASE_FUNCTION_DATA
*FunctionData
812 if (mLocked
|| FunctionData
->Args
.Register
.LegacyIA32Binary
) {
813 Status
= EFI_UNSUPPORTED
;
816 FunctionData
->SmmBaseImageHandle
,
817 FunctionData
->Args
.Register
.FilePath
,
818 FunctionData
->Args
.Register
.SourceBuffer
,
819 FunctionData
->Args
.Register
.SourceSize
,
820 FunctionData
->Args
.Register
.ImageHandle
823 FunctionData
->Status
= Status
;
827 Thunk service of EFI_SMM_BASE_PROTOCOL.UnRegister().
829 @param[in, out] FunctionData Pointer to SMMBASE_FUNCTION_DATA.
833 IN OUT SMMBASE_FUNCTION_DATA
*FunctionData
837 /// Unregister not supported now
839 FunctionData
->Status
= EFI_UNSUPPORTED
;
843 Search for Framework SMI handler information according to specific PI SMM dispatch handle.
845 @param[in] DispatchHandle The unique handle assigned by SmiHandlerRegister().
847 @return Pointer to CALLBACK_INFO. If NULL, no callback info record is found.
851 IN EFI_HANDLE DispatchHandle
856 Node
= GetFirstNode (&mCallbackInfoListHead
);
857 while (!IsNull (&mCallbackInfoListHead
, Node
)) {
858 if (((CALLBACK_INFO
*)Node
)->DispatchHandle
== DispatchHandle
) {
859 return (CALLBACK_INFO
*)Node
;
861 Node
= GetNextNode (&mCallbackInfoListHead
, Node
);
867 Callback thunk for Framework SMI handler.
869 This thunk functions calls the Framework SMI handler and converts the return value
870 defined from Framework SMI handlers to a correpsonding return value defined by PI SMM.
872 @param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
873 @param[in] Context Points to an optional handler context which was specified when the
874 handler was registered.
875 @param[in, out] CommBuffer A pointer to a collection of data in memory that will
876 be conveyed from a non-SMM environment into an SMM environment.
877 @param[in, out] CommBufferSize The size of the CommBuffer.
879 @retval EFI_SUCCESS The interrupt was handled and quiesced. No other handlers
880 should still be called.
881 @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED The interrupt has been quiesced but other handlers should
883 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING The interrupt is still pending and other handlers should still
885 @retval EFI_INTERRUPT_PENDING The interrupt could not be quiesced.
890 IN EFI_HANDLE DispatchHandle
,
891 IN CONST VOID
*Context OPTIONAL
,
892 IN OUT VOID
*CommBuffer OPTIONAL
,
893 IN OUT UINTN
*CommBufferSize OPTIONAL
897 CALLBACK_INFO
*CallbackInfo
;
901 /// Before transferring the control into the Framework SMI handler, update CPU Save States
902 /// and MP states in the Framework SMST.
905 if (!mHookInitialized
) {
906 InitHook (mFrameworkSmst
);
908 if (mPageTableHookEnabled
) {
909 HookCpuStateMemory (mFrameworkSmst
->CpuSaveState
);
912 for (CpuIndex
= 0; CpuIndex
< mNumberOfProcessors
; CpuIndex
++) {
913 ReadCpuSaveState (CpuIndex
, NULL
);
917 mFrameworkSmst
->SmmStartupThisAp
= gSmst
->SmmStartupThisAp
;
918 mFrameworkSmst
->NumberOfCpus
= mNumberOfProcessors
;
919 mFrameworkSmst
->CurrentlyExecutingCpu
= gSmst
->CurrentlyExecutingCpu
;
922 /// Search for Framework SMI handler information
924 CallbackInfo
= GetCallbackInfo (DispatchHandle
);
925 ASSERT (CallbackInfo
!= NULL
);
928 /// Thunk into original Framwork SMI handler
930 Status
= (CallbackInfo
->CallbackAddress
) (
931 CallbackInfo
->SmmImageHandle
,
932 CallbackInfo
->CommunicationBuffer
,
933 CallbackInfo
->SourceSize
936 /// Save CPU Save States in case any of them was modified
938 if (mPageTableHookEnabled
) {
939 WriteBackDirtyPages ();
941 for (CpuIndex
= 0; CpuIndex
< mNumberOfProcessors
; CpuIndex
++) {
942 WriteCpuSaveState (CpuIndex
, NULL
);
947 /// Conversion of returned status code
950 case EFI_HANDLER_SUCCESS
:
951 Status
= EFI_WARN_INTERRUPT_SOURCE_QUIESCED
;
953 case EFI_HANDLER_CRITICAL_EXIT
:
954 case EFI_HANDLER_SOURCE_QUIESCED
:
955 Status
= EFI_SUCCESS
;
957 case EFI_HANDLER_SOURCE_PENDING
:
958 Status
= EFI_WARN_INTERRUPT_SOURCE_PENDING
;
965 Thunk service of EFI_SMM_BASE_PROTOCOL.RegisterCallback().
967 @param[in, out] FunctionData Pointer to SMMBASE_FUNCTION_DATA.
971 IN OUT SMMBASE_FUNCTION_DATA
*FunctionData
974 CALLBACK_INFO
*Buffer
;
977 FunctionData
->Status
= EFI_UNSUPPORTED
;
982 /// Note that MakeLast and FloatingPointSave options are not supported in PI SMM
986 /// Allocate buffer for callback thunk information
988 Buffer
= (CALLBACK_INFO
*)AllocateZeroPool (sizeof (CALLBACK_INFO
));
989 if (Buffer
== NULL
) {
990 FunctionData
->Status
= EFI_OUT_OF_RESOURCES
;
995 /// Fill SmmImageHandle and CallbackAddress into the thunk
997 Buffer
->SmmImageHandle
= FunctionData
->Args
.RegisterCallback
.SmmImageHandle
;
998 Buffer
->CallbackAddress
= FunctionData
->Args
.RegisterCallback
.CallbackAddress
;
1001 /// Register the thunk code as a root SMI handler
1003 FunctionData
->Status
= gSmst
->SmiHandlerRegister (
1006 &Buffer
->DispatchHandle
1008 if (EFI_ERROR (FunctionData
->Status
)) {
1014 /// Save this callback info
1016 InsertTailList (&mCallbackInfoListHead
, &Buffer
->Link
);
1021 Thunk service of EFI_SMM_BASE_PROTOCOL.SmmAllocatePool().
1023 @param[in, out] FunctionData Pointer to SMMBASE_FUNCTION_DATA.
1026 HelperAllocatePool (
1027 IN OUT SMMBASE_FUNCTION_DATA
*FunctionData
1031 FunctionData
->Status
= EFI_UNSUPPORTED
;
1033 FunctionData
->Status
= gSmst
->SmmAllocatePool (
1034 FunctionData
->Args
.AllocatePool
.PoolType
,
1035 FunctionData
->Args
.AllocatePool
.Size
,
1036 FunctionData
->Args
.AllocatePool
.Buffer
1042 Thunk service of EFI_SMM_BASE_PROTOCOL.SmmFreePool().
1044 @param[in, out] FunctionData Pointer to SMMBASE_FUNCTION_DATA.
1048 IN OUT SMMBASE_FUNCTION_DATA
*FunctionData
1052 FunctionData
->Status
= EFI_UNSUPPORTED
;
1054 FreePool (FunctionData
->Args
.FreePool
.Buffer
);
1055 FunctionData
->Status
= EFI_SUCCESS
;
1060 Thunk service of EFI_SMM_BASE_PROTOCOL.Communicate().
1062 @param[in, out] FunctionData Pointer to SMMBASE_FUNCTION_DATA.
1066 IN OUT SMMBASE_FUNCTION_DATA
*FunctionData
1070 CALLBACK_INFO
*CallbackInfo
;
1072 if (FunctionData
->Args
.Communicate
.CommunicationBuffer
== NULL
) {
1073 FunctionData
->Status
= EFI_INVALID_PARAMETER
;
1077 Node
= GetFirstNode (&mCallbackInfoListHead
);
1078 while (!IsNull (&mCallbackInfoListHead
, Node
)) {
1079 CallbackInfo
= (CALLBACK_INFO
*)Node
;
1081 if (FunctionData
->Args
.Communicate
.ImageHandle
== CallbackInfo
->SmmImageHandle
) {
1082 CallbackInfo
->CommunicationBuffer
= FunctionData
->Args
.Communicate
.CommunicationBuffer
;
1083 CallbackInfo
->SourceSize
= FunctionData
->Args
.Communicate
.SourceSize
;
1086 /// The message was successfully posted.
1088 FunctionData
->Status
= EFI_SUCCESS
;
1091 Node
= GetNextNode (&mCallbackInfoListHead
, Node
);
1094 FunctionData
->Status
= EFI_INVALID_PARAMETER
;
1098 Communication service SMI Handler entry.
1100 This SMI handler provides services for the SMM Base Thunk driver.
1102 Caution: This function may receive untrusted input during runtime.
1103 The communicate buffer is external input, so this function will do operations only if the communicate
1104 buffer is outside of SMRAM so that returning the status code in the buffer won't overwrite anywhere in SMRAM.
1106 @param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
1107 @param[in] RegisterContext Points to an optional handler context which was specified when the
1108 handler was registered.
1109 @param[in, out] CommBuffer A pointer to a collection of data in memory that will
1110 be conveyed from a non-SMM environment into an SMM environment.
1111 @param[in, out] CommBufferSize The size of the CommBuffer.
1113 @retval EFI_SUCCESS The interrupt was handled and quiesced. No other handlers
1114 should still be called.
1115 @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED The interrupt has been quiesced but other handlers should
1117 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING The interrupt is still pending and other handlers should still
1119 @retval EFI_INTERRUPT_PENDING The interrupt could not be quiesced.
1124 IN EFI_HANDLE DispatchHandle
,
1125 IN CONST VOID
*RegisterContext
,
1126 IN OUT VOID
*CommBuffer
,
1127 IN OUT UINTN
*CommBufferSize
1130 SMMBASE_FUNCTION_DATA
*FunctionData
;
1132 ASSERT (CommBuffer
!= NULL
);
1133 ASSERT (CommBufferSize
!= NULL
);
1135 if (*CommBufferSize
== sizeof (SMMBASE_FUNCTION_DATA
) &&
1136 IsAddressValid ((UINTN
)CommBuffer
, *CommBufferSize
)) {
1137 FunctionData
= (SMMBASE_FUNCTION_DATA
*)CommBuffer
;
1139 switch (FunctionData
->Function
) {
1140 case SmmBaseFunctionRegister
:
1141 Register (FunctionData
);
1143 case SmmBaseFunctionUnregister
:
1144 UnRegister (FunctionData
);
1146 case SmmBaseFunctionRegisterCallback
:
1147 RegisterCallback (FunctionData
);
1149 case SmmBaseFunctionAllocatePool
:
1150 HelperAllocatePool (FunctionData
);
1152 case SmmBaseFunctionFreePool
:
1153 HelperFreePool (FunctionData
);
1155 case SmmBaseFunctionCommunicate
:
1156 HelperCommunicate (FunctionData
);
1159 DEBUG ((EFI_D_WARN
, "SmmBaseHelper: invalid SMM Base function.\n"));
1160 FunctionData
->Status
= EFI_UNSUPPORTED
;
1167 Smm Ready To Lock event notification handler.
1169 It sets a flag indicating that SMRAM has been locked.
1171 @param[in] Protocol Points to the protocol's unique identifier.
1172 @param[in] Interface Points to the interface instance.
1173 @param[in] Handle The handle on which the interface was installed.
1175 @retval EFI_SUCCESS Notification handler runs successfully.
1179 SmmReadyToLockEventNotify (
1180 IN CONST EFI_GUID
*Protocol
,
1182 IN EFI_HANDLE Handle
1190 Entry point function of the SMM Base Helper SMM driver.
1192 @param[in] ImageHandle The firmware allocated handle for the EFI image.
1193 @param[in] SystemTable A pointer to the EFI System Table.
1195 @retval EFI_SUCCESS The entry point is executed successfully.
1196 @retval other Some error occurs when executing this entry point.
1201 IN EFI_HANDLE ImageHandle
,
1202 IN EFI_SYSTEM_TABLE
*SystemTable
1206 EFI_MP_SERVICES_PROTOCOL
*MpServices
;
1208 UINTN NumberOfEnabledProcessors
;
1210 EFI_SMM_ACCESS2_PROTOCOL
*SmmAccess
;
1215 /// Locate SMM CPU Protocol which is used later to retrieve/update CPU Save States
1217 Status
= gSmst
->SmmLocateProtocol (&gEfiSmmCpuProtocolGuid
, NULL
, (VOID
**) &mSmmCpu
);
1218 ASSERT_EFI_ERROR (Status
);
1221 /// Locate PE32 Image Protocol which is used later to load Framework SMM driver
1223 Status
= SystemTable
->BootServices
->LocateProtocol (&gEfiLoadPeImageProtocolGuid
, NULL
, (VOID
**) &mLoadPe32Image
);
1224 ASSERT_EFI_ERROR (Status
);
1227 // Get MP Services Protocol
1229 Status
= SystemTable
->BootServices
->LocateProtocol (&gEfiMpServiceProtocolGuid
, NULL
, (VOID
**)&MpServices
);
1230 ASSERT_EFI_ERROR (Status
);
1233 // Use MP Services Protocol to retrieve the number of processors and number of enabled processors
1235 Status
= MpServices
->GetNumberOfProcessors (MpServices
, &mNumberOfProcessors
, &NumberOfEnabledProcessors
);
1236 ASSERT_EFI_ERROR (Status
);
1239 /// Interface structure of SMM BASE Helper Ready Protocol is allocated from UEFI pool
1240 /// instead of SMM pool so that SMM Base Thunk driver can access it in Non-SMM mode.
1242 Status
= gBS
->AllocatePool (
1243 EfiBootServicesData
,
1244 sizeof (EFI_SMM_BASE_HELPER_READY_PROTOCOL
),
1245 (VOID
**)&mSmmBaseHelperReady
1247 ASSERT_EFI_ERROR (Status
);
1250 /// Construct Framework SMST from PI SMST
1252 mFrameworkSmst
= ConstructFrameworkSmst ();
1253 mSmmBaseHelperReady
->FrameworkSmst
= mFrameworkSmst
;
1254 mSmmBaseHelperReady
->ServiceEntry
= SmmHandlerEntry
;
1257 // Get SMRAM information
1259 Status
= gBS
->LocateProtocol (&gEfiSmmAccess2ProtocolGuid
, NULL
, (VOID
**)&SmmAccess
);
1260 ASSERT_EFI_ERROR (Status
);
1263 Status
= SmmAccess
->GetCapabilities (SmmAccess
, &Size
, NULL
);
1264 ASSERT (Status
== EFI_BUFFER_TOO_SMALL
);
1266 Status
= gSmst
->SmmAllocatePool (
1267 EfiRuntimeServicesData
,
1269 (VOID
**)&mSmramRanges
1271 ASSERT_EFI_ERROR (Status
);
1273 Status
= SmmAccess
->GetCapabilities (SmmAccess
, &Size
, mSmramRanges
);
1274 ASSERT_EFI_ERROR (Status
);
1276 mSmramRangeCount
= Size
/ sizeof (EFI_SMRAM_DESCRIPTOR
);
1279 // Register SMM Ready To Lock Protocol notification
1281 Status
= gSmst
->SmmRegisterProtocolNotify (
1282 &gEfiSmmReadyToLockProtocolGuid
,
1283 SmmReadyToLockEventNotify
,
1286 ASSERT_EFI_ERROR (Status
);
1289 /// Register SMM Base Helper services for SMM Base Thunk driver
1291 Status
= gSmst
->SmiHandlerRegister (SmmHandlerEntry
, &gEfiSmmBaseThunkCommunicationGuid
, &mDispatchHandle
);
1292 ASSERT_EFI_ERROR (Status
);
1295 /// Install EFI SMM Base Helper Protocol in the UEFI handle database
1297 Status
= gBS
->InstallProtocolInterface (
1299 &gEfiSmmBaseHelperReadyProtocolGuid
,
1300 EFI_NATIVE_INTERFACE
,
1303 ASSERT_EFI_ERROR (Status
);