- Status = gBS->FreePages (MapPagesBase, MapPagesCount);\r
- ASSERT_EFI_ERROR (Status);\r
+ if (PcdGetBool (PcdQ35SmramAtDefaultSmbase)) {\r
+ //\r
+ // The initial SMRAM Save State Map has been covered as part of a larger\r
+ // reserved memory allocation in PlatformPei's InitializeRamRegions(). That\r
+ // allocation is supposed to survive into OS runtime; we must not release\r
+ // any part of it. Only re-assert the containment here.\r
+ //\r
+ ASSERT (SMM_DEFAULT_SMBASE <= MapPagesBase);\r
+ ASSERT (\r
+ (MapPagesBase + EFI_PAGES_TO_SIZE (MapPagesCount) <=\r
+ SMM_DEFAULT_SMBASE + MCH_DEFAULT_SMBASE_SIZE)\r
+ );\r
+ } else {\r
+ Status = gBS->FreePages (MapPagesBase, MapPagesCount);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r