2 Instance of SMM memory check library.
4 SMM memory check library library implementation. This library consumes SMM_ACCESS2_PROTOCOL
5 to get SMRAM information. In order to use this library instance, the platform should produce
6 all SMRAM range via SMM_ACCESS2_PROTOCOL, including the range for firmware (like SMM Core
7 and SMM driver) and/or specific dedicated hardware.
9 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
10 SPDX-License-Identifier: BSD-2-Clause-Patent
17 #include <Library/BaseLib.h>
18 #include <Library/BaseMemoryLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/MemoryAllocationLib.h>
21 #include <Library/UefiBootServicesTableLib.h>
22 #include <Library/DxeServicesTableLib.h>
23 #include <Library/SmmServicesTableLib.h>
24 #include <Library/UefiLib.h>
25 #include <Library/HobLib.h>
26 #include <Protocol/SmmAccess2.h>
27 #include <Protocol/SmmReadyToLock.h>
28 #include <Protocol/SmmEndOfDxe.h>
29 #include <Guid/MemoryAttributesTable.h>
32 // attributes for reserved memory before it is promoted to system memory
34 #define EFI_MEMORY_PRESENT 0x0100000000000000ULL
35 #define EFI_MEMORY_INITIALIZED 0x0200000000000000ULL
36 #define EFI_MEMORY_TESTED 0x0400000000000000ULL
38 EFI_SMRAM_DESCRIPTOR
*mSmmMemLibInternalSmramRanges
;
39 UINTN mSmmMemLibInternalSmramCount
;
42 // Maximum support address used to check input buffer
44 EFI_PHYSICAL_ADDRESS mSmmMemLibInternalMaximumSupportAddress
= 0;
46 UINTN mMemoryMapEntryCount
;
47 EFI_MEMORY_DESCRIPTOR
*mMemoryMap
;
48 UINTN mDescriptorSize
;
50 EFI_GCD_MEMORY_SPACE_DESCRIPTOR
*mSmmMemLibGcdMemSpace
= NULL
;
51 UINTN mSmmMemLibGcdMemNumberOfDesc
= 0;
53 EFI_MEMORY_ATTRIBUTES_TABLE
*mSmmMemLibMemoryAttributesTable
= NULL
;
55 VOID
*mRegistrationEndOfDxe
;
56 VOID
*mRegistrationReadyToLock
;
58 BOOLEAN mSmmMemLibSmmReadyToLock
= FALSE
;
61 Calculate and save the maximum support address.
65 SmmMemLibInternalCalculateMaximumSupportAddress (
71 UINT8 PhysicalAddressBits
;
74 // Get physical address bits supported.
76 Hob
= GetFirstHob (EFI_HOB_TYPE_CPU
);
78 PhysicalAddressBits
= ((EFI_HOB_CPU
*) Hob
)->SizeOfMemorySpace
;
80 AsmCpuid (0x80000000, &RegEax
, NULL
, NULL
, NULL
);
81 if (RegEax
>= 0x80000008) {
82 AsmCpuid (0x80000008, &RegEax
, NULL
, NULL
, NULL
);
83 PhysicalAddressBits
= (UINT8
) RegEax
;
85 PhysicalAddressBits
= 36;
89 // IA-32e paging translates 48-bit linear addresses to 52-bit physical addresses.
91 ASSERT (PhysicalAddressBits
<= 52);
92 if (PhysicalAddressBits
> 48) {
93 PhysicalAddressBits
= 48;
97 // Save the maximum support address in one global variable
99 mSmmMemLibInternalMaximumSupportAddress
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)(LShiftU64 (1, PhysicalAddressBits
) - 1);
100 DEBUG ((DEBUG_INFO
, "mSmmMemLibInternalMaximumSupportAddress = 0x%lx\n", mSmmMemLibInternalMaximumSupportAddress
));
104 This function check if the buffer is valid per processor architecture and not overlap with SMRAM.
106 @param Buffer The buffer start address to be checked.
107 @param Length The buffer length to be checked.
109 @retval TRUE This buffer is valid per processor architecture and not overlap with SMRAM.
110 @retval FALSE This buffer is not valid per processor architecture or overlap with SMRAM.
114 SmmIsBufferOutsideSmmValid (
115 IN EFI_PHYSICAL_ADDRESS Buffer
,
123 // NOTE: (B:0->L:4G) is invalid for IA32, but (B:1->L:4G-1)/(B:4G-1->L:1) is valid.
125 if ((Length
> mSmmMemLibInternalMaximumSupportAddress
) ||
126 (Buffer
> mSmmMemLibInternalMaximumSupportAddress
) ||
127 ((Length
!= 0) && (Buffer
> (mSmmMemLibInternalMaximumSupportAddress
- (Length
- 1)))) ) {
133 "SmmIsBufferOutsideSmmValid: Overflow: Buffer (0x%lx) - Length (0x%lx), MaximumSupportAddress (0x%lx)\n",
136 mSmmMemLibInternalMaximumSupportAddress
141 for (Index
= 0; Index
< mSmmMemLibInternalSmramCount
; Index
++) {
142 if (((Buffer
>= mSmmMemLibInternalSmramRanges
[Index
].CpuStart
) && (Buffer
< mSmmMemLibInternalSmramRanges
[Index
].CpuStart
+ mSmmMemLibInternalSmramRanges
[Index
].PhysicalSize
)) ||
143 ((mSmmMemLibInternalSmramRanges
[Index
].CpuStart
>= Buffer
) && (mSmmMemLibInternalSmramRanges
[Index
].CpuStart
< Buffer
+ Length
))) {
146 "SmmIsBufferOutsideSmmValid: Overlap: Buffer (0x%lx) - Length (0x%lx), ",
152 "CpuStart (0x%lx) - PhysicalSize (0x%lx)\n",
153 mSmmMemLibInternalSmramRanges
[Index
].CpuStart
,
154 mSmmMemLibInternalSmramRanges
[Index
].PhysicalSize
161 // Check override for Valid Communication Region
163 if (mSmmMemLibSmmReadyToLock
) {
164 EFI_MEMORY_DESCRIPTOR
*MemoryMap
;
165 BOOLEAN InValidCommunicationRegion
;
167 InValidCommunicationRegion
= FALSE
;
168 MemoryMap
= mMemoryMap
;
169 for (Index
= 0; Index
< mMemoryMapEntryCount
; Index
++) {
170 if ((Buffer
>= MemoryMap
->PhysicalStart
) &&
171 (Buffer
+ Length
<= MemoryMap
->PhysicalStart
+ LShiftU64 (MemoryMap
->NumberOfPages
, EFI_PAGE_SHIFT
))) {
172 InValidCommunicationRegion
= TRUE
;
174 MemoryMap
= NEXT_MEMORY_DESCRIPTOR(MemoryMap
, mDescriptorSize
);
177 if (!InValidCommunicationRegion
) {
180 "SmmIsBufferOutsideSmmValid: Not in ValidCommunicationRegion: Buffer (0x%lx) - Length (0x%lx)\n",
188 // Check untested memory as invalid communication buffer.
190 for (Index
= 0; Index
< mSmmMemLibGcdMemNumberOfDesc
; Index
++) {
191 if (((Buffer
>= mSmmMemLibGcdMemSpace
[Index
].BaseAddress
) && (Buffer
< mSmmMemLibGcdMemSpace
[Index
].BaseAddress
+ mSmmMemLibGcdMemSpace
[Index
].Length
)) ||
192 ((mSmmMemLibGcdMemSpace
[Index
].BaseAddress
>= Buffer
) && (mSmmMemLibGcdMemSpace
[Index
].BaseAddress
< Buffer
+ Length
))) {
195 "SmmIsBufferOutsideSmmValid: In Untested Memory Region: Buffer (0x%lx) - Length (0x%lx)\n",
204 // Check UEFI runtime memory with EFI_MEMORY_RO as invalid communication buffer.
206 if (mSmmMemLibMemoryAttributesTable
!= NULL
) {
207 EFI_MEMORY_DESCRIPTOR
*Entry
;
209 Entry
= (EFI_MEMORY_DESCRIPTOR
*)(mSmmMemLibMemoryAttributesTable
+ 1);
210 for (Index
= 0; Index
< mSmmMemLibMemoryAttributesTable
->NumberOfEntries
; Index
++) {
211 if (Entry
->Type
== EfiRuntimeServicesCode
|| Entry
->Type
== EfiRuntimeServicesData
) {
212 if ((Entry
->Attribute
& EFI_MEMORY_RO
) != 0) {
213 if (((Buffer
>= Entry
->PhysicalStart
) && (Buffer
< Entry
->PhysicalStart
+ LShiftU64 (Entry
->NumberOfPages
, EFI_PAGE_SHIFT
))) ||
214 ((Entry
->PhysicalStart
>= Buffer
) && (Entry
->PhysicalStart
< Buffer
+ Length
))) {
217 "SmmIsBufferOutsideSmmValid: In RuntimeCode Region: Buffer (0x%lx) - Length (0x%lx)\n",
225 Entry
= NEXT_MEMORY_DESCRIPTOR (Entry
, mSmmMemLibMemoryAttributesTable
->DescriptorSize
);
233 Copies a source buffer (non-SMRAM) to a destination buffer (SMRAM).
235 This function copies a source buffer (non-SMRAM) to a destination buffer (SMRAM).
236 It checks if source buffer is valid per processor architecture and not overlap with SMRAM.
237 If the check passes, it copies memory and returns EFI_SUCCESS.
238 If the check fails, it return EFI_SECURITY_VIOLATION.
239 The implementation must be reentrant.
241 @param DestinationBuffer The pointer to the destination buffer of the memory copy.
242 @param SourceBuffer The pointer to the source buffer of the memory copy.
243 @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.
245 @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with SMRAM.
246 @retval EFI_SUCCESS Memory is copied.
252 OUT VOID
*DestinationBuffer
,
253 IN CONST VOID
*SourceBuffer
,
257 if (!SmmIsBufferOutsideSmmValid ((EFI_PHYSICAL_ADDRESS
)(UINTN
)SourceBuffer
, Length
)) {
258 DEBUG ((DEBUG_ERROR
, "SmmCopyMemToSmram: Security Violation: Source (0x%x), Length (0x%x)\n", SourceBuffer
, Length
));
259 return EFI_SECURITY_VIOLATION
;
261 CopyMem (DestinationBuffer
, SourceBuffer
, Length
);
266 Copies a source buffer (SMRAM) to a destination buffer (NON-SMRAM).
268 This function copies a source buffer (non-SMRAM) to a destination buffer (SMRAM).
269 It checks if destination buffer is valid per processor architecture and not overlap with SMRAM.
270 If the check passes, it copies memory and returns EFI_SUCCESS.
271 If the check fails, it returns EFI_SECURITY_VIOLATION.
272 The implementation must be reentrant.
274 @param DestinationBuffer The pointer to the destination buffer of the memory copy.
275 @param SourceBuffer The pointer to the source buffer of the memory copy.
276 @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.
278 @retval EFI_SECURITY_VIOLATION The DestinationBuffer is invalid per processor architecture or overlap with SMRAM.
279 @retval EFI_SUCCESS Memory is copied.
284 SmmCopyMemFromSmram (
285 OUT VOID
*DestinationBuffer
,
286 IN CONST VOID
*SourceBuffer
,
290 if (!SmmIsBufferOutsideSmmValid ((EFI_PHYSICAL_ADDRESS
)(UINTN
)DestinationBuffer
, Length
)) {
291 DEBUG ((DEBUG_ERROR
, "SmmCopyMemFromSmram: Security Violation: Destination (0x%x), Length (0x%x)\n", DestinationBuffer
, Length
));
292 return EFI_SECURITY_VIOLATION
;
294 CopyMem (DestinationBuffer
, SourceBuffer
, Length
);
299 Copies a source buffer (NON-SMRAM) to a destination buffer (NON-SMRAM).
301 This function copies a source buffer (non-SMRAM) to a destination buffer (SMRAM).
302 It checks if source buffer and destination buffer are valid per processor architecture and not overlap with SMRAM.
303 If the check passes, it copies memory and returns EFI_SUCCESS.
304 If the check fails, it returns EFI_SECURITY_VIOLATION.
305 The implementation must be reentrant, and it must handle the case where source buffer overlaps destination buffer.
307 @param DestinationBuffer The pointer to the destination buffer of the memory copy.
308 @param SourceBuffer The pointer to the source buffer of the memory copy.
309 @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.
311 @retval EFI_SECURITY_VIOLATION The DestinationBuffer is invalid per processor architecture or overlap with SMRAM.
312 @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with SMRAM.
313 @retval EFI_SUCCESS Memory is copied.
319 OUT VOID
*DestinationBuffer
,
320 IN CONST VOID
*SourceBuffer
,
324 if (!SmmIsBufferOutsideSmmValid ((EFI_PHYSICAL_ADDRESS
)(UINTN
)DestinationBuffer
, Length
)) {
325 DEBUG ((DEBUG_ERROR
, "SmmCopyMem: Security Violation: Destination (0x%x), Length (0x%x)\n", DestinationBuffer
, Length
));
326 return EFI_SECURITY_VIOLATION
;
328 if (!SmmIsBufferOutsideSmmValid ((EFI_PHYSICAL_ADDRESS
)(UINTN
)SourceBuffer
, Length
)) {
329 DEBUG ((DEBUG_ERROR
, "SmmCopyMem: Security Violation: Source (0x%x), Length (0x%x)\n", SourceBuffer
, Length
));
330 return EFI_SECURITY_VIOLATION
;
332 CopyMem (DestinationBuffer
, SourceBuffer
, Length
);
337 Fills a target buffer (NON-SMRAM) with a byte value.
339 This function fills a target buffer (non-SMRAM) with a byte value.
340 It checks if target buffer is valid per processor architecture and not overlap with SMRAM.
341 If the check passes, it fills memory and returns EFI_SUCCESS.
342 If the check fails, it returns EFI_SECURITY_VIOLATION.
344 @param Buffer The memory to set.
345 @param Length The number of bytes to set.
346 @param Value The value with which to fill Length bytes of Buffer.
348 @retval EFI_SECURITY_VIOLATION The Buffer is invalid per processor architecture or overlap with SMRAM.
349 @retval EFI_SUCCESS Memory is set.
360 if (!SmmIsBufferOutsideSmmValid ((EFI_PHYSICAL_ADDRESS
)(UINTN
)Buffer
, Length
)) {
361 DEBUG ((DEBUG_ERROR
, "SmmSetMem: Security Violation: Source (0x%x), Length (0x%x)\n", Buffer
, Length
));
362 return EFI_SECURITY_VIOLATION
;
364 SetMem (Buffer
, Length
, Value
);
370 Only record untested memory as invalid communication buffer.
373 SmmMemLibInternalGetGcdMemoryMap (
377 UINTN NumberOfDescriptors
;
378 EFI_GCD_MEMORY_SPACE_DESCRIPTOR
*MemSpaceMap
;
382 Status
= gDS
->GetMemorySpaceMap (&NumberOfDescriptors
, &MemSpaceMap
);
383 if (EFI_ERROR (Status
)) {
387 mSmmMemLibGcdMemNumberOfDesc
= 0;
388 for (Index
= 0; Index
< NumberOfDescriptors
; Index
++) {
389 if (MemSpaceMap
[Index
].GcdMemoryType
== EfiGcdMemoryTypeReserved
&&
390 (MemSpaceMap
[Index
].Capabilities
& (EFI_MEMORY_PRESENT
| EFI_MEMORY_INITIALIZED
| EFI_MEMORY_TESTED
)) ==
391 (EFI_MEMORY_PRESENT
| EFI_MEMORY_INITIALIZED
)
393 mSmmMemLibGcdMemNumberOfDesc
++;
397 mSmmMemLibGcdMemSpace
= AllocateZeroPool (mSmmMemLibGcdMemNumberOfDesc
* sizeof (EFI_GCD_MEMORY_SPACE_DESCRIPTOR
));
398 ASSERT (mSmmMemLibGcdMemSpace
!= NULL
);
399 if (mSmmMemLibGcdMemSpace
== NULL
) {
400 mSmmMemLibGcdMemNumberOfDesc
= 0;
401 gBS
->FreePool (MemSpaceMap
);
405 mSmmMemLibGcdMemNumberOfDesc
= 0;
406 for (Index
= 0; Index
< NumberOfDescriptors
; Index
++) {
407 if (MemSpaceMap
[Index
].GcdMemoryType
== EfiGcdMemoryTypeReserved
&&
408 (MemSpaceMap
[Index
].Capabilities
& (EFI_MEMORY_PRESENT
| EFI_MEMORY_INITIALIZED
| EFI_MEMORY_TESTED
)) ==
409 (EFI_MEMORY_PRESENT
| EFI_MEMORY_INITIALIZED
)
412 &mSmmMemLibGcdMemSpace
[mSmmMemLibGcdMemNumberOfDesc
],
414 sizeof(EFI_GCD_MEMORY_SPACE_DESCRIPTOR
)
416 mSmmMemLibGcdMemNumberOfDesc
++;
420 gBS
->FreePool (MemSpaceMap
);
424 Get UEFI MemoryAttributesTable.
427 SmmMemLibInternalGetUefiMemoryAttributesTable (
432 EFI_MEMORY_ATTRIBUTES_TABLE
*MemoryAttributesTable
;
433 UINTN MemoryAttributesTableSize
;
435 Status
= EfiGetSystemConfigurationTable (&gEfiMemoryAttributesTableGuid
, (VOID
**)&MemoryAttributesTable
);
436 if (!EFI_ERROR (Status
) && (MemoryAttributesTable
!= NULL
)) {
437 MemoryAttributesTableSize
= sizeof(EFI_MEMORY_ATTRIBUTES_TABLE
) + MemoryAttributesTable
->DescriptorSize
* MemoryAttributesTable
->NumberOfEntries
;
438 mSmmMemLibMemoryAttributesTable
= AllocateCopyPool (MemoryAttributesTableSize
, MemoryAttributesTable
);
439 ASSERT (mSmmMemLibMemoryAttributesTable
!= NULL
);
444 Notification for SMM EndOfDxe protocol.
446 @param[in] Protocol Points to the protocol's unique identifier.
447 @param[in] Interface Points to the interface instance.
448 @param[in] Handle The handle on which the interface was installed.
450 @retval EFI_SUCCESS Notification runs successfully.
454 SmmLibInternalEndOfDxeNotify (
455 IN CONST EFI_GUID
*Protocol
,
463 EFI_MEMORY_DESCRIPTOR
*MemoryMap
;
464 EFI_MEMORY_DESCRIPTOR
*MemoryMapStart
;
465 EFI_MEMORY_DESCRIPTOR
*SmmMemoryMapStart
;
466 UINTN MemoryMapEntryCount
;
467 UINTN DescriptorSize
;
468 UINT32 DescriptorVersion
;
473 Status
= gBS
->GetMemoryMap (
480 ASSERT (Status
== EFI_BUFFER_TOO_SMALL
);
483 Status
= gBS
->AllocatePool (EfiBootServicesData
, MemoryMapSize
, (VOID
**)&MemoryMap
);
484 ASSERT (MemoryMap
!= NULL
);
486 Status
= gBS
->GetMemoryMap (
493 if (EFI_ERROR (Status
)) {
494 gBS
->FreePool (MemoryMap
);
496 } while (Status
== EFI_BUFFER_TOO_SMALL
);
501 mDescriptorSize
= DescriptorSize
;
502 MemoryMapEntryCount
= MemoryMapSize
/DescriptorSize
;
503 MemoryMapStart
= MemoryMap
;
504 mMemoryMapEntryCount
= 0;
505 for (Index
= 0; Index
< MemoryMapEntryCount
; Index
++) {
506 switch (MemoryMap
->Type
) {
507 case EfiReservedMemoryType
:
508 case EfiRuntimeServicesCode
:
509 case EfiRuntimeServicesData
:
510 case EfiACPIMemoryNVS
:
511 mMemoryMapEntryCount
++;
514 MemoryMap
= NEXT_MEMORY_DESCRIPTOR(MemoryMap
, DescriptorSize
);
516 MemoryMap
= MemoryMapStart
;
521 mMemoryMap
= AllocatePool (mMemoryMapEntryCount
*DescriptorSize
);
522 ASSERT (mMemoryMap
!= NULL
);
523 SmmMemoryMapStart
= mMemoryMap
;
524 for (Index
= 0; Index
< MemoryMapEntryCount
; Index
++) {
525 switch (MemoryMap
->Type
) {
526 case EfiReservedMemoryType
:
527 case EfiRuntimeServicesCode
:
528 case EfiRuntimeServicesData
:
529 case EfiACPIMemoryNVS
:
530 CopyMem (mMemoryMap
, MemoryMap
, DescriptorSize
);
531 mMemoryMap
= NEXT_MEMORY_DESCRIPTOR(mMemoryMap
, DescriptorSize
);
534 MemoryMap
= NEXT_MEMORY_DESCRIPTOR(MemoryMap
, DescriptorSize
);
536 mMemoryMap
= SmmMemoryMapStart
;
537 MemoryMap
= MemoryMapStart
;
539 gBS
->FreePool (MemoryMap
);
542 // Get additional information from GCD memory map.
544 SmmMemLibInternalGetGcdMemoryMap ();
547 // Get UEFI memory attributes table.
549 SmmMemLibInternalGetUefiMemoryAttributesTable ();
555 Notification for SMM ReadyToLock protocol.
557 @param[in] Protocol Points to the protocol's unique identifier.
558 @param[in] Interface Points to the interface instance.
559 @param[in] Handle The handle on which the interface was installed.
561 @retval EFI_SUCCESS Notification runs successfully.
565 SmmLibInternalReadyToLockNotify (
566 IN CONST EFI_GUID
*Protocol
,
571 mSmmMemLibSmmReadyToLock
= TRUE
;
575 The constructor function initializes the Smm Mem library
577 @param ImageHandle The firmware allocated handle for the EFI image.
578 @param SystemTable A pointer to the EFI System Table.
580 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
585 SmmMemLibConstructor (
586 IN EFI_HANDLE ImageHandle
,
587 IN EFI_SYSTEM_TABLE
*SystemTable
591 EFI_SMM_ACCESS2_PROTOCOL
*SmmAccess
;
595 // Get SMRAM information
597 Status
= gBS
->LocateProtocol (&gEfiSmmAccess2ProtocolGuid
, NULL
, (VOID
**)&SmmAccess
);
598 ASSERT_EFI_ERROR (Status
);
601 Status
= SmmAccess
->GetCapabilities (SmmAccess
, &Size
, NULL
);
602 ASSERT (Status
== EFI_BUFFER_TOO_SMALL
);
604 mSmmMemLibInternalSmramRanges
= AllocatePool (Size
);
605 ASSERT (mSmmMemLibInternalSmramRanges
!= NULL
);
607 Status
= SmmAccess
->GetCapabilities (SmmAccess
, &Size
, mSmmMemLibInternalSmramRanges
);
608 ASSERT_EFI_ERROR (Status
);
610 mSmmMemLibInternalSmramCount
= Size
/ sizeof (EFI_SMRAM_DESCRIPTOR
);
613 // Calculate and save maximum support address
615 SmmMemLibInternalCalculateMaximumSupportAddress ();
618 // Register EndOfDxe to get UEFI memory map
620 Status
= gSmst
->SmmRegisterProtocolNotify (&gEfiSmmEndOfDxeProtocolGuid
, SmmLibInternalEndOfDxeNotify
, &mRegistrationEndOfDxe
);
621 ASSERT_EFI_ERROR (Status
);
624 // Register ready to lock so that we can know when to check valid SMRAM region
626 Status
= gSmst
->SmmRegisterProtocolNotify (&gEfiSmmReadyToLockProtocolGuid
, SmmLibInternalReadyToLockNotify
, &mRegistrationReadyToLock
);
627 ASSERT_EFI_ERROR (Status
);
633 The destructor function frees resource used in the Smm Mem library
635 @param[in] ImageHandle The firmware allocated handle for the EFI image.
636 @param[in] SystemTable A pointer to the EFI System Table.
638 @retval EFI_SUCCESS The deconstructor always returns EFI_SUCCESS.
642 SmmMemLibDestructor (
643 IN EFI_HANDLE ImageHandle
,
644 IN EFI_SYSTEM_TABLE
*SystemTable
647 FreePool (mSmmMemLibInternalSmramRanges
);
649 gSmst
->SmmRegisterProtocolNotify (&gEfiSmmEndOfDxeProtocolGuid
, NULL
, &mRegistrationEndOfDxe
);
650 gSmst
->SmmRegisterProtocolNotify (&gEfiSmmReadyToLockProtocolGuid
, NULL
, &mRegistrationReadyToLock
);