I just pulled the edk2-svn-offline code and took a look.
And I found Jordan had a commit for the attached patch which has been committed 
in SVN at 18031 and I also have git-svn r18031 in local. Is it still needed in 
this temporary git repo?

Thanks,
Star
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Laszlo 
Ersek
Sent: Friday, July 24, 2015 6:12 AM
To: Justen, Jordan L
Cc: edk2-devel@lists.01.org
Subject: Re: [edk2] Temporary git repo - Re: TianoCore Subversion down?

On 07/23/15 20:57, Jordan Justen wrote:
> I queued up the patches you collected:

(What, top posting? "You too, Brutus?" :))

> 
> https://github.com/tianocore/edk2-svn-offline/commits/master
> 
> Thanks again for collecting them up!

Awesome, thank you!

Laszlo

> 
> -Jordan
> 
> On 2015-07-23 10:50:14, Laszlo Ersek wrote:
>> On 07/23/15 19:31, Jordan Justen wrote:
>>> On 2015-07-23 10:04:26, Laszlo Ersek wrote:
>>>> On 07/23/15 02:06, Jordan Justen wrote:
>>>>> Okay. Based on Laszlo's request, I setup a temporary git repo to 
>>>>> collect up the changes that should have been committed to svn the 
>>>>> past week.
>>>>>
>>>>> https://github.com/tianocore/edk2-svn-offline
>>>>>
>>>>> So far, I added the 2 commits that made it to svn but didn't get 
>>>>> mirrored to the git-svn mirror. Let me know if I should add 
>>>>> something to the branch.
>>>>>
>>>>> Here's the git commands to setup a new svn-offline remote:
>>>>>
>>>>> git remote add svn-offline 
>>>>> https://github.com/tianocore/edk2-svn-offline.git
>>>>
>>>> ... This was *hard*.
>>>>
>>>> I reached back to the past on the list (actually, on both lists, 
>>>> old and new), to a few days before the SF outage started. (Outage 
>>>> start: 16th, I reached back to the 13th or so.)
>>>>
>>>> I collected *all* patches from that timeframe that are now ready 
>>>> for merging (and would already have been merged, if not for the SF outage).
>>>>
>>>> In total, that's 27 patches. I verified maintainer and/or key 
>>>> package contributor Reviewed-by tags as the criterion for including 
>>>> a patch or a series. I also picked up all tags posted as feedback. 
>>>> Sometimes the maintainer requested trivial changes but gave his R-b 
>>>> immediately; I effected those changes. Finally, I reformatted a few 
>>>> blatantly misformatted commit messages, fixed a gcc build error 
>>>> (discussed and approved on the list), noted my minimal changes, and 
>>>> then added my S-o-b at the bottom of all patches I rounded up.
>>>
>>> Thanks Laszlo!
>>>
>>> One request, can you change the commit message on:
>>> "IntelFrameworkModulePkg/GenericBdsLib: remove AcpiS3->S3Save() call"
>>>
>>> Cc: Yao, Jiewen <jiewen....@intel.com>
>>>
>>>   =>
>>>
>>> Cc: "Yao, Jiewen" <jiewen....@intel.com>
>>>
>>>   or
>>>
>>> Cc: Jiewen Yao <jiewen....@intel.com>
>>>
>>
>> Aaargh. You noted this earlier, and I fixed it up, actually -- in 
>> another branch that I did not end up posting, after all. If you 
>> recall, there was a short interval when this specific patch appeared 
>> to be rejected, so I prepared a v3 locally, dropping this patch, and 
>> slightly updating the commit messages of those coming after it. (No 
>> other
>> changes.) And, I fixed the above Cc on that v3, local branch.
>>
>> Now, after Jeff discussed the question with Jiewen, Jeff agreed that 
>> this patch was okay ultimately. So I returned to v2, picked up the 
>> tags again from the list -- and forgot to redo the CC fix.
>>
>> In any case, I corrected it now, and force-pushed the rebased branch 
>> (with no other changes) to the same location. Its head changed from 
>> dfa837e to 2eb8300. Please re-fetch it.
>>
>>> Actually, my personal opinion is that Cc entries can be dropped when 
>>> merging upstream, but I don't have a strong feeling on it. Is there 
>>> an argument for leaving them?
>>
>> Yes, I quite like them. It's nice to see who was originally on CC. 
>> Also, removing them is too much work. :)
>>
>> And, in the Linux kernel at least, when a patch is cherry-picked to a 
>> stable branch (or tree), the original participants (author, 
>> reviewers, Cc's etc) get fresh emails about that fact. That's also nice.
>>
>> Thanks!
>> Laszlo
>>
>>>
>>> -Jordan
>>>
>>>> You can find the patches in:
>>>>
>>>> https://github.com/lersek/edk2/commits/merge_this_please
>>>>
>>>> They are based on top of your svn-offline/master branch (currently 
>>>> at 53c8704060e9fb4ba5ec2e92a5e6f188a3237ab0, "Daryl has changed 
>>>> positions and I am taking over maintaining for now.").
>>>>
>>>> Please *merge* this branch into svn-offline/master -- it will be a 
>>>> fast-forward, and no merge commit will be created.
>>>>
>>>> After that, everyone should pull from your "svn-offline/master", 
>>>> and resume working off that.
>>>>
>>>> Here's a summary of the patches that I picked up, in order. Any
>>>> (trivial) changes I did are marked with "-->".
>>>>
>>>>   [edk2] [PATCH v2 0/6] OvmfPkg: save S3 state at EndOfDxe
>>>>   http://thread.gmane.org/gmane.comp.bios.tianocore.devel/17384
>>>>   Message-Id: <1436892487-17202-1-git-send-email-ler...@redhat.com>
>>>>
>>>>   [edk2] [PATCH v2 0/6] ArmVirtPkg/ArmVirtQemu: support SMBIOS
>>>>   http://thread.gmane.org/gmane.comp.bios.edk2.devel/144
>>>>   Message-Id: <1437477015-31200-1-git-send-email-ler...@redhat.com>
>>>>
>>>>   [edk2] [PATCH] NetworkPkg: Fix bug in IpSecImpl.c caused by missing 
>>>> parentheses
>>>>   http://thread.gmane.org/gmane.comp.bios.edk2.devel/23
>>>>   Message-Id: <1437109652-26456-1-git-send-email-br...@cran.org.uk>
>>>>   --> incorporating trivial changes suggested by Siyuan
>>>>
>>>>   [edk2] [PATCH] Maintainers.txt: ARM packages maintainer update
>>>>   http://thread.gmane.org/gmane.comp.bios.edk2.devel/52
>>>>   Message-Id: 
>>>> <1437148284-16942-1-git-send-email-leif.lindh...@linaro.org>
>>>>
>>>>   [edk2] [PATCH] BaseTools/Common: fix heap overrun in ReadMemoryFileLine 
>>>> ()
>>>>   http://thread.gmane.org/gmane.comp.bios.edk2.devel/56
>>>>   Message-Id: 
>>>> <1437157378-31683-1-git-send-email-ard.biesheu...@linaro.org>
>>>>
>>>>   [edk2] [PATCH v2] MdeModulePkg: Remove TransmitReceive() and ActiveChild 
>>>> dependency
>>>>   http://thread.gmane.org/gmane.comp.bios.tianocore.devel/17417/focus=94
>>>>   Message-Id: 
>>>> <1437359434-11592-1-git-send-email-jiaxin...@intel.com>
>>>>
>>>>   [edk2] [patch] NetworkPkg: Fix the issue EfiPxeBcDhcp()may return wrong 
>>>> status.
>>>>   http://thread.gmane.org/gmane.comp.bios.edk2.devel/102
>>>>   Message-Id: <6c40a76c-8fd3-454d-87c1-809b086afb94@LUBOZHAN-MOBL.local>
>>>>   --> updated copyright year as Siyuan asked
>>>>
>>>>   [edk2] [patch] MdeModulePkg: Fix the issue EfiPxeBcDhcp()may return 
>>>> wrong status.
>>>>   http://thread.gmane.org/gmane.comp.bios.edk2.devel/101
>>>>   Message-Id: <b1f41f78-e42a-46e8-8a10-af9f095f542a@LUBOZHAN-MOBL.local>
>>>>   --> updated copyright year as Siyuan asked
>>>>
>>>>   [edk2] [Patch] ShellPkg: Fix bad TimeZone (TZ) conversion.
>>>>   http://thread.gmane.org/gmane.comp.bios.edk2.devel/57
>>>>   Message-Id: <0755eef5-682f-454e-a24f-2cc7ca040...@apple.com>
>>>>   --> synthetized Jaben's R-b from his response in the thread
>>>>
>>>>   [edk2] [patch] MdeModulePkg:Correct the parameter order in match2 sample 
>>>> opcode
>>>>   http://thread.gmane.org/gmane.comp.bios.edk2.devel/118
>>>>   Message-Id: 
>>>> <1437383587-10968-1-git-send-email-dandan...@intel.com>
>>>>
>>>>   [edk2] [patch] MdeModulePkg:Check the case caused by mismatch
>>>>   http://thread.gmane.org/gmane.comp.bios.edk2.devel/127
>>>>   Message-Id: 
>>>> <1437446204-10520-1-git-send-email-dandan...@intel.com>
>>>>
>>>>   [edk2] [PATCH 0/2] Correct address pointers from AuthVariableLib
>>>>   http://thread.gmane.org/gmane.comp.bios.edk2.devel/133
>>>>   Message-Id: <1437469312-14652-1-git-send-email-star.z...@intel.com>
>>>>   --> squashed minimal gcc build fixup, approved by Star
>>>>
>>>>   [edk2] [Patch v3] NetworkPkg: Add old IPv4_DEVICE_PATH and 
>>>> IPv6_DEVICE_PATH support
>>>>   http://thread.gmane.org/gmane.comp.bios.tianocore.devel/17557
>>>>   Message-Id: <e8f0dd84-6256-4591-b772-24a2d79370a4@FANWANG2-MOBL1.local>
>>>>   --> rewrapped commit message
>>>>
>>>>   [edk2] [Patch v3] MdeModulePkg: Add old IPv4_DEVICE_PATH support for new 
>>>> IScsiDxe
>>>>   http://thread.gmane.org/gmane.comp.bios.tianocore.devel/17558
>>>>   Message-Id: <78716473-f072-42b8-8468-ea3552320f15@FANWANG2-MOBL1.local>
>>>>   --> rewrapped commit message
>>>>
>>>>   [edk2] [PATCH] Make AutoGen.h array declaration match AutoGen.c 
>>>> definition
>>>>   http://thread.gmane.org/gmane.comp.bios.edk2.devel/179
>>>>   Message-Id: <001d01d0c42b$362a15f0$a27e41d0$@notabs.org>
>>>>
>>>>   [edk2] [PATCH] ShellPkg: Fix the ASSERT issue in Shell 'for' loop
>>>>   http://thread.gmane.org/gmane.comp.bios.edk2.devel/182
>>>>   Message-Id: <1437550864-41772-1-git-send-email-shumin....@intel.com>
>>>>   --> updated commit message as requested by Jaben
>>>>
>>>> I'm reasonably sure that all ready-to-merge patches have been included.
>>>>
>>>> I smoke tested the branch with the following command lines (both 
>>>> building and running):
>>>>
>>>>   build -a X64 -p OvmfPkg/OvmfPkgX64.dsc -D SECURE_BOOT_ENABLE \
>>>>       -t GCC48 -b DEBUG
>>>>
>>>>   build -a AARCH64 -t GCC48 -p ArmVirtPkg/ArmVirtQemu.dsc -b DEBUG \
>>>>       -D DEBUG_PRINT_ERROR_LEVEL=0x8040004F -D INTEL_BDS \
>>>>       -D SECURE_BOOT_ENABLE
>>>>
>>>> I will respond in each individual thread too.
>>>>
>>>> Thanks
>>>> Laszlo
>>>>
>>>>>
>>>>> -Jordan
>>>>>
>>>>> Forwarded message from Laszlo Ersek (2015-07-22 13:52:38):
>>>>>> On 07/22/15 22:39, Jordan Justen wrote:
>>>>>>> On 2015-07-22 12:57:13, Laszlo Ersek wrote:
>>>>>>>> On 07/22/15 21:44, Bruce Cran wrote:
>>>>>>>>> On 7/22/2015 4:18 AM, Laszlo Ersek wrote:
>>>>>>>>>> How about someone creates a temporary branch off the github 
>>>>>>>>>> master branch, and applies all new patches from the list that 
>>>>>>>>>> have been reviewed thus far? Then once SVN is back up, the 
>>>>>>>>>> patches from that git branch could be committed to SVN by a 
>>>>>>>>>> single person, in one go, nicely ordered.
>>>>>>>>>
>>>>>>>>> Wouldn't a fork be preferable? Anyone can create one, and it 
>>>>>>>>> doesn't pollute the main repository.
>>>>>>>>
>>>>>>>> The branch should be owned by an Intel associate, trusted by 
>>>>>>>> the entire community. Having the same level access as needed by 
>>>>>>>> the current main git repo / master branch too. The point is 
>>>>>>>> that *everyone* should start working against this new branch, until 
>>>>>>>> SVN returns to life.
>>>>>>>
>>>>>>> I don't think it is a good idea to temporarily setup an 
>>>>>>> alternate official 'upstream'. Unlike if we were using git, we 
>>>>>>> can't just push the branch back to the main server once it comes 
>>>>>>> back online. Instead, we'll have to use git-svn dcommit, and 
>>>>>>> this will put all the patches onto a diverged branch.
>>>>>>
>>>>>> Yes, that's the idea, sort of. Patches would be collected on a 
>>>>>> non-master branch in git, with the branch being forked off from 
>>>>>> current master. Once SVN returns, the patches from the special 
>>>>>> branch would be formatted, applied to a git-svn clone with git-am 
>>>>>> manually, and then committed with git-svn dcommit. Then these 
>>>>>> patches would percolate to the git mirror (master branch) as 
>>>>>> usual, and the temporary / special branch could be simply deleted.
>>>>>>
>>>>>>> As you suggest, I can see trying to collect up the outstanding 
>>>>>>> ready-to-merge patches onto a temporary branch so they don't get lost.
>>>>>>> Maybe I could just try to collect patches into a svn-offline 
>>>>>>> branch in my personal repo? I guess we could also put a 
>>>>>>> temporary repo at github.com/tianocore/edk2-svn-offline...
>>>>>>
>>>>>> Separate repo, or separate (special, temporary) branch in the 
>>>>>> current main repo -- they're about the same. So yes, that's the 
>>>>>> idea. For me all of these solutions are acceptable, as long as 
>>>>>> there is consensus that everyone starts submitting patches, and testing, 
>>>>>> against that one branch.
>>>>>>
>>>>>> For direct SVN, and git-svn users, this would indeed mean a local 
>>>>>> change of repository.
>>>>>>
>>>>>>>
>>>>>>>>> SF have posted an update
>>>>>>>>> (http://sourceforge.net/blog/sourceforge-infrastructure-and-service-restoration-update-for-722/):
>>>>>>>>
>>>>>>>> Yeah, I saw it.
>>>>>>>>
>>>>>>>>> - SourceForge Allura Subversion (SVN) service 
>>>>>>>>> \u2013*offline,*filesystem checks complete, data restoration 
>>>>>>>>> at 50%.  Restoration priority after Git and Hg services. _ETA TBD_, 
>>>>>>>>> Future update will provide ETA.
>>>>>>>>
>>>>>>>> Yeah, they don't know when they'll know an ETA. I guess we can 
>>>>>>>> forget about SVN until next week.
>>>>>>>>
>>>>>>>> I'll cease all edk2 activity until the SVN repo is back up. 
>>>>>>>> This is intolerable.
>>>>>>>
>>>>>>> I agree. When it went offline last week, I couldn't imagine the 
>>>>>>> downtime would stretch on for a week.
>>>>>>>
>>>>>>> I hope that anyone trying to push back on switching to from svn 
>>>>>>> to git can see how dependent the svn centralized model leaves us 
>>>>>>> on a single server.
>>>>>>>
>>>>>>> With git, although there would be some hiccups, it would be much 
>>>>>>> more feasible to setup a temporary alternate upstream location 
>>>>>>> in the event that the main server goes offline...
>>>>>>
>>>>>> Right; at least commit hashes would be stable, clones could be 
>>>>>> updated trivially (by adding a new remote only), and the new 
>>>>>> patches could be simply pushed back to the original repo from the 
>>>>>> temporary location once the former came back, without git-format-patch / 
>>>>>> git-am / git-svn-dcommit.
>>>>>>
>>>>>> Thanks
>>>>>> Laszlo
>>>>> _______________________________________________
>>>>> edk2-devel mailing list
>>>>> edk2-devel@lists.01.org
>>>>> https://lists.01.org/mailman/listinfo/edk2-devel
>>>>>
>>>>
>>

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
--- Begin Message ---
Revision: 18031
          http://sourceforge.net/p/edk2/code/18031
Author:   lzeng14
Date:     2015-07-16 13:20:57 +0000 (Thu, 16 Jul 2015)
Log Message:
-----------
MdeModulePkg PiSmmCore: Remove a hidden assumption of SMRAM reservation

that assumes the SMRAM reserved range is only at the end of the SMRAM 
descriptor.

          //
          // This range has reserved area, calculate the left free size
          //
          gSmmCorePrivate->SmramRanges[Index].PhysicalSize = 
SmramResRegion->SmramReservedStart - 
gSmmCorePrivate->SmramRanges[Index].CpuStart;

Imagine the following scenario where we just reserve the first page of the 
SMRAM range:

SMRAM Descriptor:
  Start: 0x80000000
  Size: 0x02000000

Reserved Range:
  Start: 0x80000000
  Size: 0x00001000

In this case the adjustment to the SMRAM range size yields zero: ReservedStart 
- SMRAM Start is 0x80000000 - 0x80000000 = 0.
So even though most of the range is still free the IPL code decides its 
unusable.

The problem comes from the email thread: [edk2] PiSmmIpl SMRAM Reservation 
Logic.
http://thread.gmane.org/gmane.comp.bios.tianocore.devel/15268

Also to follow the idea in the email thread, the patch is to
1. Keep only one copy of full SMRAM ranges in gSmmCorePrivate->SmramRanges,
split record for SmmConfiguration->SmramReservedRegions and SMM Core that
will be marked to be EFI_ALLOCATED in gSmmCorePrivate->SmramRanges.
2. Handle SmmConfiguration->SmramReservedRegions at beginning of, at end of,
in the middle of, or cross multiple SmramRanges.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.z...@intel.com>
Reviewed-by: Jiewen Yao <jiewen....@intel.com>

Modified Paths:
--------------
    trunk/edk2/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
    trunk/edk2/MdeModulePkg/Core/PiSmmCore/PiSmmCorePrivateData.h
    trunk/edk2/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
    
trunk/edk2/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c
    
trunk/edk2/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationServices.h

Modified: trunk/edk2/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
===================================================================
--- trunk/edk2/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c  2015-07-16 11:27:05 UTC 
(rev 18030)
+++ trunk/edk2/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c  2015-07-16 13:20:57 UTC 
(rev 18031)
@@ -523,10 +523,10 @@
   //
   // Copy FullSmramRanges to SMRAM
   //
-  mFullSmramRangeCount = gSmmCorePrivate->FullSmramRangeCount;
+  mFullSmramRangeCount = gSmmCorePrivate->SmramRangeCount;
   mFullSmramRanges = AllocatePool (mFullSmramRangeCount * sizeof 
(EFI_SMRAM_DESCRIPTOR));
   ASSERT (mFullSmramRanges != NULL);
-  CopyMem (mFullSmramRanges, gSmmCorePrivate->FullSmramRanges, 
mFullSmramRangeCount * sizeof (EFI_SMRAM_DESCRIPTOR));
+  CopyMem (mFullSmramRanges, gSmmCorePrivate->SmramRanges, 
mFullSmramRangeCount * sizeof (EFI_SMRAM_DESCRIPTOR));

   //
   // Register all SMI Handlers required by the SMM Core

Modified: trunk/edk2/MdeModulePkg/Core/PiSmmCore/PiSmmCorePrivateData.h
===================================================================
--- trunk/edk2/MdeModulePkg/Core/PiSmmCore/PiSmmCorePrivateData.h       
2015-07-16 11:27:05 UTC (rev 18030)
+++ trunk/edk2/MdeModulePkg/Core/PiSmmCore/PiSmmCorePrivateData.h       
2015-07-16 13:20:57 UTC (rev 18031)
@@ -120,9 +120,6 @@
   EFI_PHYSICAL_ADDRESS            PiSmmCoreImageBase;
   UINT64                          PiSmmCoreImageSize;
   EFI_PHYSICAL_ADDRESS            PiSmmCoreEntryPoint;
-
-  UINTN                           FullSmramRangeCount;
-  EFI_SMRAM_DESCRIPTOR            *FullSmramRanges;
 } SMM_CORE_PRIVATE_DATA;

 #endif

Modified: trunk/edk2/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
===================================================================
--- trunk/edk2/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c   2015-07-16 11:27:05 UTC 
(rev 18030)
+++ trunk/edk2/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c   2015-07-16 13:20:57 UTC 
(rev 18031)
@@ -861,17 +861,21 @@
 /**
   Load the SMM Core image into SMRAM and executes the SMM Core from SMRAM.

-  @param[in] SmramRange  Descriptor for the range of SMRAM to reload the
-                         currently executing image.
-  @param[in] Context     Context to pass into SMM Core
+  @param[in, out] SmramRange            Descriptor for the range of SMRAM to 
reload the
+                                        currently executing image, the rang of 
SMRAM to
+                                        hold SMM Core will be excluded.
+  @param[in, out] SmramRangeSmmCore     Descriptor for the range of SMRAM to 
hold SMM Core.

+  @param[in]      Context               Context to pass into SMM Core
+
   @return  EFI_STATUS

 **/
 EFI_STATUS
 ExecuteSmmCoreFromSmram (
-  IN EFI_SMRAM_DESCRIPTOR  *SmramRange,
-  IN VOID                  *Context
+  IN OUT EFI_SMRAM_DESCRIPTOR   *SmramRange,
+  IN OUT EFI_SMRAM_DESCRIPTOR   *SmramRangeSmmCore,
+  IN     VOID                   *Context
   )
 {
   EFI_STATUS                    Status;
@@ -879,7 +883,6 @@
   UINTN                         SourceSize;
   PE_COFF_LOADER_IMAGE_CONTEXT  ImageContext;
   UINTN                         PageCount;
-  EFI_PHYSICAL_ADDRESS          DestinationBuffer;
   EFI_IMAGE_ENTRY_POINT         EntryPoint;

   //
@@ -924,7 +927,7 @@
       // Since the memory range to load SMM CORE will be cut out in SMM core, 
so no need to allocate and free this range
       //
       PageCount = 0;
-     } else {
+    } else {
       DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR: Loading module at fixed 
address at address failed\n"));
       //
       // Allocate memory for the image being loaded from the 
EFI_SRAM_DESCRIPTOR
@@ -936,12 +939,15 @@
       ASSERT (SmramRange->PhysicalSize > EFI_PAGES_TO_SIZE (PageCount));

       SmramRange->PhysicalSize -= EFI_PAGES_TO_SIZE (PageCount);
-      DestinationBuffer = SmramRange->CpuStart + SmramRange->PhysicalSize;
+      SmramRangeSmmCore->CpuStart = SmramRange->CpuStart + 
SmramRange->PhysicalSize;
+      SmramRangeSmmCore->PhysicalStart = SmramRange->PhysicalStart + 
SmramRange->PhysicalSize;
+      SmramRangeSmmCore->RegionState = SmramRange->RegionState | EFI_ALLOCATED;
+      SmramRangeSmmCore->PhysicalSize = EFI_PAGES_TO_SIZE (PageCount);

       //
-      // Align buffer on section boundry
+      // Align buffer on section boundary
       //
-      ImageContext.ImageAddress = DestinationBuffer;
+      ImageContext.ImageAddress = SmramRangeSmmCore->CpuStart;
     }
   } else {
     //
@@ -954,12 +960,15 @@
     ASSERT (SmramRange->PhysicalSize > EFI_PAGES_TO_SIZE (PageCount));

     SmramRange->PhysicalSize -= EFI_PAGES_TO_SIZE (PageCount);
-    DestinationBuffer = SmramRange->CpuStart + SmramRange->PhysicalSize;
+    SmramRangeSmmCore->CpuStart = SmramRange->CpuStart + 
SmramRange->PhysicalSize;
+    SmramRangeSmmCore->PhysicalStart = SmramRange->PhysicalStart + 
SmramRange->PhysicalSize;
+    SmramRangeSmmCore->RegionState = SmramRange->RegionState | EFI_ALLOCATED;
+    SmramRangeSmmCore->PhysicalSize = EFI_PAGES_TO_SIZE (PageCount);

     //
-    // Align buffer on section boundry
+    // Align buffer on section boundary
     //
-    ImageContext.ImageAddress = DestinationBuffer;
+    ImageContext.ImageAddress = SmramRangeSmmCore->CpuStart;
   }

   ImageContext.ImageAddress += ImageContext.SectionAlignment - 1;
@@ -1006,20 +1015,431 @@
   }

   //
-  // If the load operation, relocate operation, or the image execution return 
an
-  // error, then free memory allocated from the EFI_SRAM_DESCRIPTOR specified 
by
-  // SmramRange
+  // Always free memory allocted by GetFileBufferByFilePath ()
   //
-  if (EFI_ERROR (Status)) {
-    SmramRange->PhysicalSize += EFI_PAGES_TO_SIZE (PageCount);
+  FreePool (SourceBuffer);
+
+  return Status;
+}
+
+/**
+  SMM split SMRAM entry.
+
+  @param[in, out] RangeToCompare             Pointer to EFI_SMRAM_DESCRIPTOR 
to compare.
+  @param[in, out] ReservedRangeToCompare     Pointer to 
EFI_SMM_RESERVED_SMRAM_REGION to compare.
+  @param[out]     Ranges                     Output pointer to hold split 
EFI_SMRAM_DESCRIPTOR entry.
+  @param[in, out] RangeCount                 Pointer to range count.
+  @param[out]     ReservedRanges             Output pointer to hold split 
EFI_SMM_RESERVED_SMRAM_REGION entry.
+  @param[in, out] ReservedRangeCount         Pointer to reserved range count.
+  @param[out]     FinalRanges                Output pointer to hold split 
final EFI_SMRAM_DESCRIPTOR entry
+                                             that no need to be split anymore.
+  @param[in, out] FinalRangeCount            Pointer to final range count.
+
+**/
+VOID
+SmmSplitSmramEntry (
+  IN OUT EFI_SMRAM_DESCRIPTOR           *RangeToCompare,
+  IN OUT EFI_SMM_RESERVED_SMRAM_REGION  *ReservedRangeToCompare,
+  OUT    EFI_SMRAM_DESCRIPTOR           *Ranges,
+  IN OUT UINTN                          *RangeCount,
+  OUT    EFI_SMM_RESERVED_SMRAM_REGION  *ReservedRanges,
+  IN OUT UINTN                          *ReservedRangeCount,
+  OUT    EFI_SMRAM_DESCRIPTOR           *FinalRanges,
+  IN OUT UINTN                          *FinalRangeCount
+  )
+{
+  UINT64    RangeToCompareEnd;
+  UINT64    ReservedRangeToCompareEnd;
+
+  RangeToCompareEnd         = RangeToCompare->CpuStart + 
RangeToCompare->PhysicalSize;
+  ReservedRangeToCompareEnd = ReservedRangeToCompare->SmramReservedStart + 
ReservedRangeToCompare->SmramReservedSize;
+
+  if ((RangeToCompare->CpuStart >= ReservedRangeToCompare->SmramReservedStart) 
&&
+      (RangeToCompare->CpuStart < ReservedRangeToCompareEnd)) {
+    if (RangeToCompareEnd < ReservedRangeToCompareEnd) {
+      //
+      // Case 1:
+      //
+      // RangeToCompare  ReservedRangeToCompare
+      //                 ----                    ----    
----------------------------------------
+      //                 |  |                    |  | -> 1.1. 
ReservedRangeToCompare
+      // ----            |  |                    |--|    
----------------------------------------
+      // |  |            |  |                    |  |
+      // |  |            |  |                    |  | -> 1.2. 
FinalRanges[*FinalRangeCount] and increment *FinalRangeCount
+      // |  |            |  |                    |  |         
RangeToCompare->PhysicalSize = 0
+      // ----            |  |                    |--|    
----------------------------------------
+      //                 |  |                    |  | -> 1.3. 
ReservedRanges[*ReservedRangeCount] and increment *ReservedRangeCount
+      //                 ----                    ----    
----------------------------------------
+      //
+
+      //
+      // 1.1. Update ReservedRangeToCompare.
+      //
+      ReservedRangeToCompare->SmramReservedSize = RangeToCompare->CpuStart - 
ReservedRangeToCompare->SmramReservedStart;
+      //
+      // 1.2. Update FinalRanges[FinalRangeCount] and increment 
*FinalRangeCount.
+      //      Zero RangeToCompare->PhysicalSize.
+      //
+      FinalRanges[*FinalRangeCount].CpuStart      = RangeToCompare->CpuStart;
+      FinalRanges[*FinalRangeCount].PhysicalStart = 
RangeToCompare->PhysicalStart;
+      FinalRanges[*FinalRangeCount].RegionState   = 
RangeToCompare->RegionState | EFI_ALLOCATED;
+      FinalRanges[*FinalRangeCount].PhysicalSize  = 
RangeToCompare->PhysicalSize;
+      *FinalRangeCount += 1;
+      RangeToCompare->PhysicalSize = 0;
+      //
+      // 1.3. Update ReservedRanges[*ReservedRangeCount] and increment 
*ReservedRangeCount.
+      //
+      ReservedRanges[*ReservedRangeCount].SmramReservedStart = 
FinalRanges[*FinalRangeCount - 1].CpuStart + FinalRanges[*FinalRangeCount - 
1].PhysicalSize;
+      ReservedRanges[*ReservedRangeCount].SmramReservedSize  = 
ReservedRangeToCompareEnd - RangeToCompareEnd;
+      *ReservedRangeCount += 1;
+    } else {
+      //
+      // Case 2:
+      //
+      // RangeToCompare  ReservedRangeToCompare
+      //                 ----                    ----    
----------------------------------------
+      //                 |  |                    |  | -> 2.1. 
ReservedRangeToCompare
+      // ----            |  |                    |--|    
----------------------------------------
+      // |  |            |  |                    |  |
+      // |  |            |  |                    |  | -> 2.2. 
FinalRanges[*FinalRangeCount] and increment *FinalRangeCount
+      // |  |            |  |                    |  |
+      // |  |            ----                    |--|    
----------------------------------------
+      // |  |                                    |  | -> 2.3. RangeToCompare
+      // ----                                    ----    
----------------------------------------
+      //
+
+      //
+      // 2.1. Update ReservedRangeToCompare.
+      //
+      ReservedRangeToCompare->SmramReservedSize = RangeToCompare->CpuStart - 
ReservedRangeToCompare->SmramReservedStart;
+      //
+      // 2.2. Update FinalRanges[FinalRangeCount] and increment 
*FinalRangeCount.
+      //
+      FinalRanges[*FinalRangeCount].CpuStart      = RangeToCompare->CpuStart;
+      FinalRanges[*FinalRangeCount].PhysicalStart = 
RangeToCompare->PhysicalStart;
+      FinalRanges[*FinalRangeCount].RegionState   = 
RangeToCompare->RegionState | EFI_ALLOCATED;
+      FinalRanges[*FinalRangeCount].PhysicalSize  = ReservedRangeToCompareEnd 
- RangeToCompare->CpuStart;
+      *FinalRangeCount += 1;
+      //
+      // 2.3. Update RangeToCompare.
+      //
+      RangeToCompare->CpuStart      += FinalRanges[*FinalRangeCount - 
1].PhysicalSize;
+      RangeToCompare->PhysicalStart += FinalRanges[*FinalRangeCount - 
1].PhysicalSize;
+      RangeToCompare->PhysicalSize  -= FinalRanges[*FinalRangeCount - 
1].PhysicalSize;
+    }
+  } else if ((ReservedRangeToCompare->SmramReservedStart >= 
RangeToCompare->CpuStart) &&
+             (ReservedRangeToCompare->SmramReservedStart < RangeToCompareEnd)) 
{
+    if (ReservedRangeToCompareEnd < RangeToCompareEnd) {
+      //
+      // Case 3:
+      //
+      // RangeToCompare  ReservedRangeToCompare
+      // ----                                    ----    
----------------------------------------
+      // |  |                                    |  | -> 3.1. RangeToCompare
+      // |  |            ----                    |--|    
----------------------------------------
+      // |  |            |  |                    |  |
+      // |  |            |  |                    |  | -> 3.2. 
FinalRanges[*FinalRangeCount] and increment *FinalRangeCount
+      // |  |            |  |                    |  |         
ReservedRangeToCompare->SmramReservedSize = 0
+      // |  |            ----                    |--|    
----------------------------------------
+      // |  |                                    |  | -> 3.3. 
Ranges[*RangeCount] and increment *RangeCount
+      // ----                                    ----    
----------------------------------------
+      //
+
+      //
+      // 3.1. Update RangeToCompare.
+      //
+      RangeToCompare->PhysicalSize = 
ReservedRangeToCompare->SmramReservedStart - RangeToCompare->CpuStart;
+      //
+      // 3.2. Update FinalRanges[FinalRangeCount] and increment 
*FinalRangeCount.
+      //      Zero ReservedRangeToCompare->SmramReservedSize.
+      //
+      FinalRanges[*FinalRangeCount].CpuStart      = 
ReservedRangeToCompare->SmramReservedStart;
+      FinalRanges[*FinalRangeCount].PhysicalStart = 
RangeToCompare->PhysicalStart + RangeToCompare->PhysicalSize;
+      FinalRanges[*FinalRangeCount].RegionState   = 
RangeToCompare->RegionState | EFI_ALLOCATED;
+      FinalRanges[*FinalRangeCount].PhysicalSize  = 
ReservedRangeToCompare->SmramReservedSize;
+      *FinalRangeCount += 1;
+      ReservedRangeToCompare->SmramReservedSize = 0;
+      //
+      // 3.3. Update Ranges[*RangeCount] and increment *RangeCount.
+      //
+      Ranges[*RangeCount].CpuStart      = FinalRanges[*FinalRangeCount - 
1].CpuStart + FinalRanges[*FinalRangeCount - 1].PhysicalSize;
+      Ranges[*RangeCount].PhysicalStart = FinalRanges[*FinalRangeCount - 
1].PhysicalStart + FinalRanges[*FinalRangeCount - 1].PhysicalSize;
+      Ranges[*RangeCount].RegionState   = RangeToCompare->RegionState;
+      Ranges[*RangeCount].PhysicalSize  = RangeToCompareEnd - 
ReservedRangeToCompareEnd;
+      *RangeCount += 1;
+    } else {
+      //
+      // Case 4:
+      //
+      // RangeToCompare  ReservedRangeToCompare
+      // ----                                    ----    
--------------------------------------
+      // |  |                                    |  | -> 4.1. RangeToCompare
+      // |  |            ----                    |--|    
--------------------------------------
+      // |  |            |  |                    |  |
+      // |  |            |  |                    |  | -> 4.2. 
FinalRanges[*FinalRangeCount] and increment *FinalRangeCount
+      // |  |            |  |                    |  |
+      // ----            |  |                    |--|    
--------------------------------------
+      //                 |  |                    |  | -> 4.3. 
ReservedRangeToCompare
+      //                 ----                    ----    
--------------------------------------
+      //
+
+      //
+      // 4.1. Update RangeToCompare.
+      //
+      RangeToCompare->PhysicalSize = 
ReservedRangeToCompare->SmramReservedStart - RangeToCompare->CpuStart;
+      //
+      // 4.2. Update FinalRanges[FinalRangeCount] and increment 
*FinalRangeCount.
+      //
+      FinalRanges[*FinalRangeCount].CpuStart      = 
ReservedRangeToCompare->SmramReservedStart;
+      FinalRanges[*FinalRangeCount].PhysicalStart = 
RangeToCompare->PhysicalStart + RangeToCompare->PhysicalSize;
+      FinalRanges[*FinalRangeCount].RegionState   = 
RangeToCompare->RegionState | EFI_ALLOCATED;
+      FinalRanges[*FinalRangeCount].PhysicalSize  = RangeToCompareEnd - 
ReservedRangeToCompare->SmramReservedStart;
+      *FinalRangeCount += 1;
+      //
+      // 4.3. Update ReservedRangeToCompare.
+      //
+      ReservedRangeToCompare->SmramReservedStart += 
FinalRanges[*FinalRangeCount - 1].PhysicalSize;
+      ReservedRangeToCompare->SmramReservedSize  -= 
FinalRanges[*FinalRangeCount - 1].PhysicalSize;
+    }
   }
+}

+/**
+  Returns if SMRAM range and SMRAM reserved range are overlapped.
+
+  @param[in] RangeToCompare             Pointer to EFI_SMRAM_DESCRIPTOR to 
compare.
+  @param[in] ReservedRangeToCompare     Pointer to 
EFI_SMM_RESERVED_SMRAM_REGION to compare.
+
+  @retval TRUE  There is overlap.
+  @retval FALSE There is no overlap.
+
+**/
+BOOLEAN
+SmmIsSmramOverlap (
+  IN EFI_SMRAM_DESCRIPTOR           *RangeToCompare,
+  IN EFI_SMM_RESERVED_SMRAM_REGION  *ReservedRangeToCompare
+  )
+{
+  UINT64    RangeToCompareEnd;
+  UINT64    ReservedRangeToCompareEnd;
+
+  RangeToCompareEnd         = RangeToCompare->CpuStart + 
RangeToCompare->PhysicalSize;
+  ReservedRangeToCompareEnd = ReservedRangeToCompare->SmramReservedStart + 
ReservedRangeToCompare->SmramReservedSize;
+
+  if ((RangeToCompare->CpuStart >= ReservedRangeToCompare->SmramReservedStart) 
&&
+      (RangeToCompare->CpuStart < ReservedRangeToCompareEnd)) {
+    return TRUE;
+  } else if ((ReservedRangeToCompare->SmramReservedStart >= 
RangeToCompare->CpuStart) &&
+             (ReservedRangeToCompare->SmramReservedStart < RangeToCompareEnd)) 
{
+    return TRUE;
+  }
+  return FALSE;
+}
+
+/**
+  Get full SMRAM ranges.
+
+  It will get SMRAM ranges from SmmAccess protocol and SMRAM reserved ranges 
from
+  SmmConfiguration protocol, split the entries if there is overlap between 
them.
+  It will also reserve one entry for SMM core.
+
+  @param[out] FullSmramRangeCount   Output pointer to full SMRAM range count.
+
+  @return Pointer to full SMRAM ranges.
+
+**/
+EFI_SMRAM_DESCRIPTOR *
+GetFullSmramRanges (
+  OUT UINTN     *FullSmramRangeCount
+  )
+{
+  EFI_STATUS                        Status;
+  EFI_SMM_CONFIGURATION_PROTOCOL    *SmmConfiguration;
+  UINTN                             Size;
+  UINTN                             Index;
+  UINTN                             Index2;
+  EFI_SMRAM_DESCRIPTOR              *FullSmramRanges;
+  UINTN                             TempSmramRangeCount;
+  EFI_SMRAM_DESCRIPTOR              *TempSmramRanges;
+  UINTN                             SmramRangeCount;
+  EFI_SMRAM_DESCRIPTOR              *SmramRanges;
+  UINTN                             SmramReservedCount;
+  EFI_SMM_RESERVED_SMRAM_REGION     *SmramReservedRanges;
+  UINTN                             MaxCount;
+  BOOLEAN                           Rescan;
+
   //
-  // Always free memory allocted by GetFileBufferByFilePath ()
+  // Get SMM Configuration Protocol if it is present.
   //
-  FreePool (SourceBuffer);
+  SmmConfiguration = NULL;
+  Status = gBS->LocateProtocol (&gEfiSmmConfigurationProtocolGuid, NULL, (VOID 
**) &SmmConfiguration);

-  return Status;
+  //
+  // Get SMRAM information.
+  //
+  Size = 0;
+  Status = mSmmAccess->GetCapabilities (mSmmAccess, &Size, NULL);
+  ASSERT (Status == EFI_BUFFER_TOO_SMALL);
+
+  SmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);
+
+  //
+  // Get SMRAM reserved region count.
+  //
+  SmramReservedCount = 0;
+  if (SmmConfiguration != NULL) {
+    while 
(SmmConfiguration->SmramReservedRegions[SmramReservedCount].SmramReservedSize 
!= 0) {
+      SmramReservedCount++;
+    }
+  }
+
+  if (SmramReservedCount == 0) {
+    //
+    // No reserved SMRAM entry from SMM Configuration Protocol.
+    // Reserve one entry for SMM Core in the full SMRAM ranges.
+    //
+    *FullSmramRangeCount = SmramRangeCount + 1;
+    Size = (*FullSmramRangeCount) * sizeof (EFI_SMRAM_DESCRIPTOR);
+    FullSmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocateZeroPool (Size);
+    ASSERT (FullSmramRanges != NULL);
+
+    Status = mSmmAccess->GetCapabilities (mSmmAccess, &Size, FullSmramRanges);
+    ASSERT_EFI_ERROR (Status);
+
+    return FullSmramRanges;
+  }
+
+  //
+  // Why MaxCount = X + 2 * Y?
+  // Take Y = 1 as example below, Y > 1 case is just the iteration of Y = 1.
+  //
+  //   X = 1 Y = 1     MaxCount = 3 = 1 + 2 * 1
+  //   ----            ----
+  //   |  |  ----      |--|
+  //   |  |  |  |  ->  |  |
+  //   |  |  ----      |--|
+  //   ----            ----
+  //
+  //   X = 2 Y = 1     MaxCount = 4 = 2 + 2 * 1
+  //   ----            ----
+  //   |  |            |  |
+  //   |  |  ----      |--|
+  //   |  |  |  |      |  |
+  //   |--|  |  |  ->  |--|
+  //   |  |  |  |      |  |
+  //   |  |  ----      |--|
+  //   |  |            |  |
+  //   ----            ----
+  //
+  //   X = 3 Y = 1     MaxCount = 5 = 3 + 2 * 1
+  //   ----            ----
+  //   |  |            |  |
+  //   |  |  ----      |--|
+  //   |--|  |  |      |--|
+  //   |  |  |  |  ->  |  |
+  //   |--|  |  |      |--|
+  //   |  |  ----      |--|
+  //   |  |            |  |
+  //   ----            ----
+  //
+  //   ......
+  //
+  MaxCount = SmramRangeCount + 2 * SmramReservedCount;
+
+  Size = MaxCount * sizeof (EFI_SMM_RESERVED_SMRAM_REGION);
+  SmramReservedRanges = (EFI_SMM_RESERVED_SMRAM_REGION *) AllocateZeroPool 
(Size);
+  ASSERT (SmramReservedRanges != NULL);
+  for (Index = 0; Index < SmramReservedCount; Index++) {
+    CopyMem (&SmramReservedRanges[Index], 
&SmmConfiguration->SmramReservedRegions[Index], sizeof 
(EFI_SMM_RESERVED_SMRAM_REGION));
+  }
+
+  Size = MaxCount * sizeof (EFI_SMRAM_DESCRIPTOR);
+  TempSmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocateZeroPool (Size);
+  ASSERT (TempSmramRanges != NULL);
+  TempSmramRangeCount = 0;
+
+  SmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocateZeroPool (Size);
+  ASSERT (SmramRanges != NULL);
+  Status = mSmmAccess->GetCapabilities (mSmmAccess, &Size, SmramRanges);
+  ASSERT_EFI_ERROR (Status);
+
+  do {
+    Rescan = FALSE;
+    for (Index = 0; (Index < SmramRangeCount) && !Rescan; Index++) {
+      //
+      // Skip zero size entry.
+      //
+      if (SmramRanges[Index].PhysicalSize != 0) {
+        for (Index2 = 0; (Index2 < SmramReservedCount) && !Rescan; Index2++) {
+          //
+          // Skip zero size entry.
+          //
+          if (SmramReservedRanges[Index2].SmramReservedSize != 0) {
+            if (SmmIsSmramOverlap (
+                  &SmramRanges[Index],
+                  &SmramReservedRanges[Index2]
+                  )) {
+              //
+              // There is overlap, need to split entry and then rescan.
+              //
+              SmmSplitSmramEntry (
+                &SmramRanges[Index],
+                &SmramReservedRanges[Index2],
+                SmramRanges,
+                &SmramRangeCount,
+                SmramReservedRanges,
+                &SmramReservedCount,
+                TempSmramRanges,
+                &TempSmramRangeCount
+                );
+              Rescan = TRUE;
+            }
+          }
+        }
+        if (!Rescan) {
+          //
+          // No any overlap, copy the entry to the temp SMRAM ranges.
+          // Zero SmramRanges[Index].PhysicalSize = 0;
+          //
+          CopyMem (&TempSmramRanges[TempSmramRangeCount++], 
&SmramRanges[Index], sizeof (EFI_SMRAM_DESCRIPTOR));
+          SmramRanges[Index].PhysicalSize = 0;
+        }
+      }
+    }
+  } while (Rescan);
+  ASSERT (TempSmramRangeCount <= MaxCount);
+
+  //
+  // Sort the entries,
+  // and reserve one entry for SMM Core in the full SMRAM ranges.
+  //
+  FullSmramRanges = AllocateZeroPool ((TempSmramRangeCount + 1) * sizeof 
(EFI_SMRAM_DESCRIPTOR));
+  ASSERT (FullSmramRanges != NULL);
+  *FullSmramRangeCount = 0;
+  do {
+    for (Index = 0; Index < TempSmramRangeCount; Index++) {
+      if (TempSmramRanges[Index].PhysicalSize != 0) {
+        break;
+      }
+    }
+    ASSERT (Index < TempSmramRangeCount);
+    for (Index2 = 0; Index2 < TempSmramRangeCount; Index2++) {
+      if ((Index2 != Index) && (TempSmramRanges[Index2].PhysicalSize != 0) && 
(TempSmramRanges[Index2].CpuStart < TempSmramRanges[Index].CpuStart)) {
+        Index = Index2;
+      }
+    }
+    CopyMem (&FullSmramRanges[*FullSmramRangeCount], &TempSmramRanges[Index], 
sizeof (EFI_SMRAM_DESCRIPTOR));
+    *FullSmramRangeCount += 1;
+    TempSmramRanges[Index].PhysicalSize = 0;
+  } while (*FullSmramRangeCount < TempSmramRangeCount);
+  ASSERT (*FullSmramRangeCount == TempSmramRangeCount);
+  *FullSmramRangeCount += 1;
+
+  FreePool (SmramRanges);
+  FreePool (SmramReservedRanges);
+  FreePool (TempSmramRanges);
+
+  return FullSmramRanges;
 }

 /**
@@ -1044,10 +1464,7 @@
   )
 {
   EFI_STATUS                      Status;
-  EFI_SMM_CONFIGURATION_PROTOCOL  *SmmConfiguration;
-  UINTN                           Size;
   UINTN                           Index;
-  EFI_SMM_RESERVED_SMRAM_REGION   *SmramResRegion;
   UINT64                          MaxSize;
   VOID                            *Registration;
   UINT64                          SmmCodeSize;
@@ -1074,36 +1491,9 @@
   Status = gBS->LocateProtocol (&gEfiSmmControl2ProtocolGuid, NULL, (VOID 
**)&mSmmControl2);
   ASSERT_EFI_ERROR (Status);

-  //
-  // Get SMM Configuration Protocol if it is present
-  //
-  SmmConfiguration = NULL;
-  Status = gBS->LocateProtocol (&gEfiSmmConfigurationProtocolGuid, NULL, (VOID 
**) &SmmConfiguration);
+  gSmmCorePrivate->SmramRanges = GetFullSmramRanges 
(&gSmmCorePrivate->SmramRangeCount);

   //
-  // Get SMRAM information
-  //
-  Size = 0;
-  Status = mSmmAccess->GetCapabilities (mSmmAccess, &Size, NULL);
-  ASSERT (Status == EFI_BUFFER_TOO_SMALL);
-
-  gSmmCorePrivate->SmramRanges = (EFI_SMRAM_DESCRIPTOR *)AllocatePool (Size);
-  ASSERT (gSmmCorePrivate->SmramRanges != NULL);
-
-  Status = mSmmAccess->GetCapabilities (mSmmAccess, &Size, 
gSmmCorePrivate->SmramRanges);
-  ASSERT_EFI_ERROR (Status);
-
-  gSmmCorePrivate->SmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);
-
-  //
-  // Save a full copy
-  //
-  gSmmCorePrivate->FullSmramRangeCount = gSmmCorePrivate->SmramRangeCount;
-  gSmmCorePrivate->FullSmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocatePool 
(Size);
-  ASSERT (gSmmCorePrivate->FullSmramRanges != NULL);
-  CopyMem (gSmmCorePrivate->FullSmramRanges, gSmmCorePrivate->SmramRanges, 
Size);
-
-  //
   // Open all SMRAM ranges
   //
   Status = mSmmAccess->Open (mSmmAccess);
@@ -1113,26 +1503,6 @@
   // Print debug message that the SMRAM window is now open.
   //
   DEBUG ((DEBUG_INFO, "SMM IPL opened SMRAM window\n"));
-
-  //
-  // Subtract SMRAM any reserved SMRAM regions.
-  //
-  if (SmmConfiguration != NULL) {
-    SmramResRegion = SmmConfiguration->SmramReservedRegions;
-    while (SmramResRegion->SmramReservedSize != 0) {
-      for (Index = 0; Index < gSmmCorePrivate->SmramRangeCount; Index ++) {
-        if ((SmramResRegion->SmramReservedStart >= 
gSmmCorePrivate->SmramRanges[Index].CpuStart)  &&      \
-           ((SmramResRegion->SmramReservedStart + 
SmramResRegion->SmramReservedSize) <=   \
-           (gSmmCorePrivate->SmramRanges[Index].CpuStart + 
gSmmCorePrivate->SmramRanges[Index].PhysicalSize))) {
-          //
-          // This range has reserved area, calculate the left free size
-          //
-          gSmmCorePrivate->SmramRanges[Index].PhysicalSize = 
SmramResRegion->SmramReservedStart - 
gSmmCorePrivate->SmramRanges[Index].CpuStart;
-        }
-      }
-      SmramResRegion++;
-    }
-  }

   //
   // Find the largest SMRAM range between 1MB and 4GB that is at least 256KB - 
4K in size
@@ -1214,7 +1584,11 @@
     //
     // Load SMM Core into SMRAM and execute it from SMRAM
     //
-    Status = ExecuteSmmCoreFromSmram (mCurrentSmramRange, gSmmCorePrivate);
+    Status = ExecuteSmmCoreFromSmram (
+               mCurrentSmramRange,
+               &gSmmCorePrivate->SmramRanges[gSmmCorePrivate->SmramRangeCount 
- 1],
+               gSmmCorePrivate
+               );
     if (EFI_ERROR (Status)) {
       //
       // Print error message that the SMM Core failed to be loaded and 
executed.
@@ -1262,7 +1636,6 @@
     // Free all allocated resources
     //
     FreePool (gSmmCorePrivate->SmramRanges);
-    FreePool (gSmmCorePrivate->FullSmramRanges);

     return EFI_UNSUPPORTED;
   }

Modified: 
trunk/edk2/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c
===================================================================
--- 
trunk/edk2/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c
  2015-07-16 11:27:05 UTC (rev 18030)
+++ 
trunk/edk2/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c
  2015-07-16 13:20:57 UTC (rev 18031)
@@ -919,11 +919,11 @@
   //
   SmmInitializeMemoryServices (SmmCorePrivate->SmramRangeCount, 
SmmCorePrivate->SmramRanges);

-  mSmmCoreMemoryAllocLibSmramRangeCount = SmmCorePrivate->FullSmramRangeCount;
+  mSmmCoreMemoryAllocLibSmramRangeCount = SmmCorePrivate->SmramRangeCount;
   Size = mSmmCoreMemoryAllocLibSmramRangeCount * sizeof (EFI_SMRAM_DESCRIPTOR);
   mSmmCoreMemoryAllocLibSmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocatePool 
(Size);
   ASSERT (mSmmCoreMemoryAllocLibSmramRanges != NULL);
-  CopyMem (mSmmCoreMemoryAllocLibSmramRanges, SmmCorePrivate->FullSmramRanges, 
Size);
+  CopyMem (mSmmCoreMemoryAllocLibSmramRanges, SmmCorePrivate->SmramRanges, 
Size);

   return EFI_SUCCESS;
 }

Modified: 
trunk/edk2/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationServices.h
===================================================================
--- 
trunk/edk2/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationServices.h
    2015-07-16 11:27:05 UTC (rev 18030)
+++ 
trunk/edk2/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationServices.h
    2015-07-16 13:20:57 UTC (rev 18031)
@@ -94,9 +94,6 @@
   EFI_PHYSICAL_ADDRESS            PiSmmCoreImageBase;
   UINT64                          PiSmmCoreImageSize;
   EFI_PHYSICAL_ADDRESS            PiSmmCoreEntryPoint;
-
-  UINTN                           FullSmramRangeCount;
-  EFI_SMRAM_DESCRIPTOR            *FullSmramRanges;
 } SMM_CORE_PRIVATE_DATA;

 /**


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-commits mailing list
edk2-comm...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-commits

--- End Message ---
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to