public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 0/2] MdeModulePkg SmmCore: Fix hang issue when LMFA enable
@ 2016-12-01  6:49 Liming Gao
  2016-12-01  6:49 ` [Patch 1/2] MdeModulePkg SmmIpl: Fill Smram range for SMM driver " Liming Gao
  2016-12-01  6:49 ` [Patch 2/2] MdeModulePkg PiSmmCore: Retrieve Smram base address from system table Liming Gao
  0 siblings, 2 replies; 5+ messages in thread
From: Liming Gao @ 2016-12-01  6:49 UTC (permalink / raw)
  To: edk2-devel


Liming Gao (2):
  MdeModulePkg SmmIpl: Fill Smram range for SMM driver when LMFA enable
  MdeModulePkg PiSmmCore: Retrieve Smram base address from system table

 MdeModulePkg/Core/PiSmmCore/PiSmmCore.h   |  1 +
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf |  2 ++
 MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c    | 39 ++++++++++++++++++++---
 MdeModulePkg/Core/PiSmmCore/Pool.c        | 51 ++++++-------------------------
 4 files changed, 47 insertions(+), 46 deletions(-)

-- 
2.8.0.windows.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Patch 1/2] MdeModulePkg SmmIpl: Fill Smram range for SMM driver when LMFA enable
  2016-12-01  6:49 [Patch 0/2] MdeModulePkg SmmCore: Fix hang issue when LMFA enable Liming Gao
@ 2016-12-01  6:49 ` Liming Gao
  2016-12-09 10:20   ` Zeng, Star
  2016-12-01  6:49 ` [Patch 2/2] MdeModulePkg PiSmmCore: Retrieve Smram base address from system table Liming Gao
  1 sibling, 1 reply; 5+ messages in thread
From: Liming Gao @ 2016-12-01  6:49 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Jiewen Yao

Allocate the additional Smram range to describe the reserved smram for
SMM core and driver when LMFA feature is enabled.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
---
 MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c | 39 +++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
index 18bec84..fd7027d 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
@@ -973,6 +973,10 @@ ExecuteSmmCoreFromSmram (
       // 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;
+      //
+      // Reserved Smram Region for SmmCore is not used, and remove it from SmramRangeCount.
+      //
+      gSmmCorePrivate->SmramRangeCount --;
     } else {
       DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR: Loading module at fixed address at address failed\n"));
       //
@@ -1299,6 +1303,7 @@ GetFullSmramRanges (
   UINTN                             Index2;
   EFI_SMRAM_DESCRIPTOR              *FullSmramRanges;
   UINTN                             TempSmramRangeCount;
+  UINTN                             AdditionSmramRangeCount;
   EFI_SMRAM_DESCRIPTOR              *TempSmramRanges;
   UINTN                             SmramRangeCount;
   EFI_SMRAM_DESCRIPTOR              *SmramRanges;
@@ -1332,12 +1337,23 @@ GetFullSmramRanges (
     }
   }
 
+  //
+  // Reserve one entry for SMM Core in the full SMRAM ranges.
+  //
+  AdditionSmramRangeCount = 1;
+  if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {
+    //
+    // Reserve two entries for all SMM drivers and SMM Core in the full SMRAM ranges.
+    //
+    AdditionSmramRangeCount = 2;
+  }
+
   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;
+    *FullSmramRangeCount = SmramRangeCount + AdditionSmramRangeCount;
     Size = (*FullSmramRangeCount) * sizeof (EFI_SMRAM_DESCRIPTOR);
     FullSmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocateZeroPool (Size);
     ASSERT (FullSmramRanges != NULL);
@@ -1449,10 +1465,9 @@ GetFullSmramRanges (
   ASSERT (TempSmramRangeCount <= MaxCount);
 
   //
-  // Sort the entries,
-  // and reserve one entry for SMM Core in the full SMRAM ranges.
+  // Sort the entries
   //
-  FullSmramRanges = AllocateZeroPool ((TempSmramRangeCount + 1) * sizeof (EFI_SMRAM_DESCRIPTOR));
+  FullSmramRanges = AllocateZeroPool ((TempSmramRangeCount + AdditionSmramRangeCount) * sizeof (EFI_SMRAM_DESCRIPTOR));
   ASSERT (FullSmramRanges != NULL);
   *FullSmramRangeCount = 0;
   do {
@@ -1472,7 +1487,7 @@ GetFullSmramRanges (
     TempSmramRanges[Index].PhysicalSize = 0;
   } while (*FullSmramRangeCount < TempSmramRangeCount);
   ASSERT (*FullSmramRangeCount == TempSmramRangeCount);
-  *FullSmramRangeCount += 1;
+  *FullSmramRangeCount += AdditionSmramRangeCount;
 
   FreePool (SmramRanges);
   FreePool (SmramReservedRanges);
@@ -1510,6 +1525,7 @@ SmmIplEntry (
   EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE    *LMFAConfigurationTable;
   EFI_CPU_ARCH_PROTOCOL           *CpuArch;
   EFI_STATUS                      SetAttrStatus;
+  EFI_SMRAM_DESCRIPTOR            *SmramRangeSmmDriver;
 
   //
   // Fill in the image handle of the SMM IPL so the SMM Core can use this as the 
@@ -1619,6 +1635,19 @@ SmmIplEntry (
         //
         DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: TSEG BASE is %x. \n", LMFAConfigurationTable->SmramBase));
       }
+
+      //
+      // Fill the Smram range for all SMM code
+      //
+      SmramRangeSmmDriver = &gSmmCorePrivate->SmramRanges[gSmmCorePrivate->SmramRangeCount - 2];
+      SmramRangeSmmDriver->CpuStart      = mCurrentSmramRange->CpuStart;
+      SmramRangeSmmDriver->PhysicalStart = mCurrentSmramRange->PhysicalStart;
+      SmramRangeSmmDriver->RegionState   = mCurrentSmramRange->RegionState | EFI_ALLOCATED;
+      SmramRangeSmmDriver->PhysicalSize  = SmmCodeSize;
+
+      mCurrentSmramRange->PhysicalSize  -= SmmCodeSize;
+      mCurrentSmramRange->CpuStart       = mCurrentSmramRange->CpuStart + SmmCodeSize;
+      mCurrentSmramRange->PhysicalStart  = mCurrentSmramRange->PhysicalStart + SmmCodeSize;
     }
     //
     // Load SMM Core into SMRAM and execute it from SMRAM
-- 
2.8.0.windows.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Patch 2/2] MdeModulePkg PiSmmCore: Retrieve Smram base address from system table
  2016-12-01  6:49 [Patch 0/2] MdeModulePkg SmmCore: Fix hang issue when LMFA enable Liming Gao
  2016-12-01  6:49 ` [Patch 1/2] MdeModulePkg SmmIpl: Fill Smram range for SMM driver " Liming Gao
@ 2016-12-01  6:49 ` Liming Gao
  1 sibling, 0 replies; 5+ messages in thread
From: Liming Gao @ 2016-12-01  6:49 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Jiewen Yao

PiSmmIpl records LoadModuleAtFixAddressSmramBase in LMFAConfigurationTable.
Update PiSmmCore to directly get the address from this system table.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
---
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.h   |  1 +
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf |  2 ++
 MdeModulePkg/Core/PiSmmCore/Pool.c        | 51 ++++++-------------------------
 3 files changed, 13 insertions(+), 41 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
index 9b72ded..168fbe9 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
@@ -37,6 +37,7 @@
 #include <Guid/EventGroup.h>
 #include <Guid/EventLegacyBios.h>
 #include <Guid/MemoryProfile.h>
+#include <Guid/LoadModuleAtFixedAddress.h>
 
 #include <Library/BaseLib.h>
 #include <Library/BaseMemoryLib.h>
diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
index c256e90..f380fc5 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
@@ -98,6 +98,8 @@
   ## SOMETIMES_PRODUCES   ## GUID # Install protocol
   gEdkiiSmmMemoryProfileGuid
   gEdkiiPiSmmMemoryAttributesTableGuid          ## SOMETIMES_PRODUCES   ## SystemTable
+  ## SOMETIMES_CONSUMES   ## SystemTable
+  gLoadFixedAddressConfigurationTableGuid
 
 [UserExtensions.TianoCore."ExtraFiles"]
   PiSmmCoreExtra.uni
diff --git a/MdeModulePkg/Core/PiSmmCore/Pool.c b/MdeModulePkg/Core/PiSmmCore/Pool.c
index b638aad..0006588 100644
--- a/MdeModulePkg/Core/PiSmmCore/Pool.c
+++ b/MdeModulePkg/Core/PiSmmCore/Pool.c
@@ -35,9 +35,8 @@ SmmInitializeMemoryServices (
   )
 {
   UINTN                  Index;
- 	UINT64                 SmmCodeSize;
- 	UINTN                  CurrentSmramRangesIndex;
- 	UINT64                 MaxSize;
+  EFI_STATUS             Status;
+  EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE    *LMFAConfigurationTable;
 
   //
   // Initialize Pool list
@@ -45,45 +44,15 @@ SmmInitializeMemoryServices (
   for (Index = ARRAY_SIZE (mSmmPoolLists); Index > 0;) {
     InitializeListHead (&mSmmPoolLists[--Index]);
   }
-  CurrentSmramRangesIndex = 0;
-  //
-  // If Loading Module At fixed Address feature is enabled, cache the SMRAM base here
-  //
-  if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {
-    //
-    // Build tool will calculate the smm code size and then patch the PcdLoadFixAddressSmmCodePageNumber
-    //
-    SmmCodeSize = LShiftU64 (PcdGet32(PcdLoadFixAddressSmmCodePageNumber), EFI_PAGE_SHIFT);
-    
-    //
-    // Find the largest SMRAM range between 1MB and 4GB that is at least 256KB - 4K in size
-    //
-    for (Index = 0, MaxSize = SIZE_256KB - EFI_PAGE_SIZE; Index < SmramRangeCount; Index++) {
-      //
-      // Skip any SMRAM region that is already allocated, needs testing, or needs ECC initialization
-      //
-      if ((SmramRanges[Index].RegionState & (EFI_ALLOCATED | EFI_NEEDS_TESTING | EFI_NEEDS_ECC_INITIALIZATION)) != 0) {
-        continue;
-      }
-
-      if (SmramRanges[Index].CpuStart >= BASE_1MB) {
-        if ((SmramRanges[Index].CpuStart + SmramRanges[Index].PhysicalSize - 1) <= MAX_ADDRESS) {
-          if (SmramRanges[Index].PhysicalSize >= MaxSize) {
-            MaxSize = SmramRanges[Index].PhysicalSize;
-            CurrentSmramRangesIndex = Index;
-          }
-        }
-      }
-    }
-    gLoadModuleAtFixAddressSmramBase = SmramRanges[CurrentSmramRangesIndex].CpuStart;
-    
-    //
-    // cut out a memory range from this SMRAM range with the size SmmCodeSize to hold SMM driver code
-    // A notable thing is that SMM core is already loaded into this range.
-    //
-    SmramRanges[CurrentSmramRangesIndex].CpuStart     = SmramRanges[CurrentSmramRangesIndex].CpuStart + SmmCodeSize; 
-    SmramRanges[CurrentSmramRangesIndex].PhysicalSize = SmramRanges[CurrentSmramRangesIndex].PhysicalSize - SmmCodeSize;
+
+  Status = EfiGetSystemConfigurationTable (
+            &gLoadFixedAddressConfigurationTableGuid,
+           (VOID **) &LMFAConfigurationTable
+           );
+  if (!EFI_ERROR (Status) && LMFAConfigurationTable != NULL) {
+    gLoadModuleAtFixAddressSmramBase = LMFAConfigurationTable->SmramBase;
   }
+
   //
   // Add Free SMRAM regions
   //
-- 
2.8.0.windows.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Patch 1/2] MdeModulePkg SmmIpl: Fill Smram range for SMM driver when LMFA enable
  2016-12-01  6:49 ` [Patch 1/2] MdeModulePkg SmmIpl: Fill Smram range for SMM driver " Liming Gao
@ 2016-12-09 10:20   ` Zeng, Star
  2016-12-12  1:48     ` Gao, Liming
  0 siblings, 1 reply; 5+ messages in thread
From: Zeng, Star @ 2016-12-09 10:20 UTC (permalink / raw)
  To: Liming Gao, edk2-devel; +Cc: Jiewen Yao, star.zeng

Liming,

A small comment added inline.
With that update, Reviewed-by: Star Zeng <star.zeng@intel.com> to this 
patch series.

On 2016/12/1 14:49, Liming Gao wrote:
> Allocate the additional Smram range to describe the reserved smram for
> SMM core and driver when LMFA feature is enabled.
>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Liming Gao <liming.gao@intel.com>
> ---
>  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c | 39 +++++++++++++++++++++++++++++-----
>  1 file changed, 34 insertions(+), 5 deletions(-)
>
> diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
> index 18bec84..fd7027d 100644
> --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
> +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
> @@ -973,6 +973,10 @@ ExecuteSmmCoreFromSmram (
>        // 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;
> +      //
> +      // Reserved Smram Region for SmmCore is not used, and remove it from SmramRangeCount.
> +      //
> +      gSmmCorePrivate->SmramRangeCount --;
>      } else {
>        DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR: Loading module at fixed address at address failed\n"));
>        //
> @@ -1299,6 +1303,7 @@ GetFullSmramRanges (
>    UINTN                             Index2;
>    EFI_SMRAM_DESCRIPTOR              *FullSmramRanges;
>    UINTN                             TempSmramRangeCount;
> +  UINTN                             AdditionSmramRangeCount;
>    EFI_SMRAM_DESCRIPTOR              *TempSmramRanges;
>    UINTN                             SmramRangeCount;
>    EFI_SMRAM_DESCRIPTOR              *SmramRanges;
> @@ -1332,12 +1337,23 @@ GetFullSmramRanges (
>      }
>    }
>
> +  //
> +  // Reserve one entry for SMM Core in the full SMRAM ranges.

You have moved comment "Reserve one entry for SMM Core in the full SMRAM 
ranges." to here.

> +  //
> +  AdditionSmramRangeCount = 1;
> +  if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {
> +    //
> +    // Reserve two entries for all SMM drivers and SMM Core in the full SMRAM ranges.
> +    //
> +    AdditionSmramRangeCount = 2;
> +  }
> +
>    if (SmramReservedCount == 0) {
>      //
>      // No reserved SMRAM entry from SMM Configuration Protocol.
>      // Reserve one entry for SMM Core in the full SMRAM ranges.

Since you have move comment "Reserve one entry for SMM Core in the full 
SMRAM ranges." to the code above, how about remove it in this comments?

Thanks,
Star

>      //
> -    *FullSmramRangeCount = SmramRangeCount + 1;
> +    *FullSmramRangeCount = SmramRangeCount + AdditionSmramRangeCount;
>      Size = (*FullSmramRangeCount) * sizeof (EFI_SMRAM_DESCRIPTOR);
>      FullSmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocateZeroPool (Size);
>      ASSERT (FullSmramRanges != NULL);
> @@ -1449,10 +1465,9 @@ GetFullSmramRanges (
>    ASSERT (TempSmramRangeCount <= MaxCount);
>
>    //
> -  // Sort the entries,
> -  // and reserve one entry for SMM Core in the full SMRAM ranges.
> +  // Sort the entries
>    //
> -  FullSmramRanges = AllocateZeroPool ((TempSmramRangeCount + 1) * sizeof (EFI_SMRAM_DESCRIPTOR));
> +  FullSmramRanges = AllocateZeroPool ((TempSmramRangeCount + AdditionSmramRangeCount) * sizeof (EFI_SMRAM_DESCRIPTOR));
>    ASSERT (FullSmramRanges != NULL);
>    *FullSmramRangeCount = 0;
>    do {
> @@ -1472,7 +1487,7 @@ GetFullSmramRanges (
>      TempSmramRanges[Index].PhysicalSize = 0;
>    } while (*FullSmramRangeCount < TempSmramRangeCount);
>    ASSERT (*FullSmramRangeCount == TempSmramRangeCount);
> -  *FullSmramRangeCount += 1;
> +  *FullSmramRangeCount += AdditionSmramRangeCount;
>
>    FreePool (SmramRanges);
>    FreePool (SmramReservedRanges);
> @@ -1510,6 +1525,7 @@ SmmIplEntry (
>    EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE    *LMFAConfigurationTable;
>    EFI_CPU_ARCH_PROTOCOL           *CpuArch;
>    EFI_STATUS                      SetAttrStatus;
> +  EFI_SMRAM_DESCRIPTOR            *SmramRangeSmmDriver;
>
>    //
>    // Fill in the image handle of the SMM IPL so the SMM Core can use this as the
> @@ -1619,6 +1635,19 @@ SmmIplEntry (
>          //
>          DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: TSEG BASE is %x. \n", LMFAConfigurationTable->SmramBase));
>        }
> +
> +      //
> +      // Fill the Smram range for all SMM code
> +      //
> +      SmramRangeSmmDriver = &gSmmCorePrivate->SmramRanges[gSmmCorePrivate->SmramRangeCount - 2];
> +      SmramRangeSmmDriver->CpuStart      = mCurrentSmramRange->CpuStart;
> +      SmramRangeSmmDriver->PhysicalStart = mCurrentSmramRange->PhysicalStart;
> +      SmramRangeSmmDriver->RegionState   = mCurrentSmramRange->RegionState | EFI_ALLOCATED;
> +      SmramRangeSmmDriver->PhysicalSize  = SmmCodeSize;
> +
> +      mCurrentSmramRange->PhysicalSize  -= SmmCodeSize;
> +      mCurrentSmramRange->CpuStart       = mCurrentSmramRange->CpuStart + SmmCodeSize;
> +      mCurrentSmramRange->PhysicalStart  = mCurrentSmramRange->PhysicalStart + SmmCodeSize;
>      }
>      //
>      // Load SMM Core into SMRAM and execute it from SMRAM
>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Patch 1/2] MdeModulePkg SmmIpl: Fill Smram range for SMM driver when LMFA enable
  2016-12-09 10:20   ` Zeng, Star
@ 2016-12-12  1:48     ` Gao, Liming
  0 siblings, 0 replies; 5+ messages in thread
From: Gao, Liming @ 2016-12-12  1:48 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org; +Cc: Yao, Jiewen

Agree. Thanks!

> -----Original Message-----
> From: Zeng, Star
> Sent: Friday, December 09, 2016 6:20 PM
> To: Gao, Liming <liming.gao@intel.com>; edk2-devel@lists.01.org
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Zeng, Star <star.zeng@intel.com>
> Subject: Re: [edk2] [Patch 1/2] MdeModulePkg SmmIpl: Fill Smram range for
> SMM driver when LMFA enable
> 
> Liming,
> 
> A small comment added inline.
> With that update, Reviewed-by: Star Zeng <star.zeng@intel.com> to this
> patch series.
> 
> On 2016/12/1 14:49, Liming Gao wrote:
> > Allocate the additional Smram range to describe the reserved smram for
> > SMM core and driver when LMFA feature is enabled.
> >
> > Cc: Star Zeng <star.zeng@intel.com>
> > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Liming Gao <liming.gao@intel.com>
> > ---
> >  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c | 39
> +++++++++++++++++++++++++++++-----
> >  1 file changed, 34 insertions(+), 5 deletions(-)
> >
> > diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
> b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
> > index 18bec84..fd7027d 100644
> > --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
> > +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
> > @@ -973,6 +973,10 @@ ExecuteSmmCoreFromSmram (
> >        // 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;
> > +      //
> > +      // Reserved Smram Region for SmmCore is not used, and remove it
> from SmramRangeCount.
> > +      //
> > +      gSmmCorePrivate->SmramRangeCount --;
> >      } else {
> >        DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR: Loading
> module at fixed address at address failed\n"));
> >        //
> > @@ -1299,6 +1303,7 @@ GetFullSmramRanges (
> >    UINTN                             Index2;
> >    EFI_SMRAM_DESCRIPTOR              *FullSmramRanges;
> >    UINTN                             TempSmramRangeCount;
> > +  UINTN                             AdditionSmramRangeCount;
> >    EFI_SMRAM_DESCRIPTOR              *TempSmramRanges;
> >    UINTN                             SmramRangeCount;
> >    EFI_SMRAM_DESCRIPTOR              *SmramRanges;
> > @@ -1332,12 +1337,23 @@ GetFullSmramRanges (
> >      }
> >    }
> >
> > +  //
> > +  // Reserve one entry for SMM Core in the full SMRAM ranges.
> 
> You have moved comment "Reserve one entry for SMM Core in the full
> SMRAM
> ranges." to here.
> 
> > +  //
> > +  AdditionSmramRangeCount = 1;
> > +  if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {
> > +    //
> > +    // Reserve two entries for all SMM drivers and SMM Core in the full
> SMRAM ranges.
> > +    //
> > +    AdditionSmramRangeCount = 2;
> > +  }
> > +
> >    if (SmramReservedCount == 0) {
> >      //
> >      // No reserved SMRAM entry from SMM Configuration Protocol.
> >      // Reserve one entry for SMM Core in the full SMRAM ranges.
> 
> Since you have move comment "Reserve one entry for SMM Core in the full
> SMRAM ranges." to the code above, how about remove it in this comments?
> 
> Thanks,
> Star
> 
> >      //
> > -    *FullSmramRangeCount = SmramRangeCount + 1;
> > +    *FullSmramRangeCount = SmramRangeCount +
> AdditionSmramRangeCount;
> >      Size = (*FullSmramRangeCount) * sizeof (EFI_SMRAM_DESCRIPTOR);
> >      FullSmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocateZeroPool
> (Size);
> >      ASSERT (FullSmramRanges != NULL);
> > @@ -1449,10 +1465,9 @@ GetFullSmramRanges (
> >    ASSERT (TempSmramRangeCount <= MaxCount);
> >
> >    //
> > -  // Sort the entries,
> > -  // and reserve one entry for SMM Core in the full SMRAM ranges.
> > +  // Sort the entries
> >    //
> > -  FullSmramRanges = AllocateZeroPool ((TempSmramRangeCount + 1) *
> sizeof (EFI_SMRAM_DESCRIPTOR));
> > +  FullSmramRanges = AllocateZeroPool ((TempSmramRangeCount +
> AdditionSmramRangeCount) * sizeof (EFI_SMRAM_DESCRIPTOR));
> >    ASSERT (FullSmramRanges != NULL);
> >    *FullSmramRangeCount = 0;
> >    do {
> > @@ -1472,7 +1487,7 @@ GetFullSmramRanges (
> >      TempSmramRanges[Index].PhysicalSize = 0;
> >    } while (*FullSmramRangeCount < TempSmramRangeCount);
> >    ASSERT (*FullSmramRangeCount == TempSmramRangeCount);
> > -  *FullSmramRangeCount += 1;
> > +  *FullSmramRangeCount += AdditionSmramRangeCount;
> >
> >    FreePool (SmramRanges);
> >    FreePool (SmramReservedRanges);
> > @@ -1510,6 +1525,7 @@ SmmIplEntry (
> >    EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE
> *LMFAConfigurationTable;
> >    EFI_CPU_ARCH_PROTOCOL           *CpuArch;
> >    EFI_STATUS                      SetAttrStatus;
> > +  EFI_SMRAM_DESCRIPTOR            *SmramRangeSmmDriver;
> >
> >    //
> >    // Fill in the image handle of the SMM IPL so the SMM Core can use this as
> the
> > @@ -1619,6 +1635,19 @@ SmmIplEntry (
> >          //
> >          DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: TSEG BASE
> is %x. \n", LMFAConfigurationTable->SmramBase));
> >        }
> > +
> > +      //
> > +      // Fill the Smram range for all SMM code
> > +      //
> > +      SmramRangeSmmDriver = &gSmmCorePrivate-
> >SmramRanges[gSmmCorePrivate->SmramRangeCount - 2];
> > +      SmramRangeSmmDriver->CpuStart      = mCurrentSmramRange-
> >CpuStart;
> > +      SmramRangeSmmDriver->PhysicalStart = mCurrentSmramRange-
> >PhysicalStart;
> > +      SmramRangeSmmDriver->RegionState   = mCurrentSmramRange-
> >RegionState | EFI_ALLOCATED;
> > +      SmramRangeSmmDriver->PhysicalSize  = SmmCodeSize;
> > +
> > +      mCurrentSmramRange->PhysicalSize  -= SmmCodeSize;
> > +      mCurrentSmramRange->CpuStart       = mCurrentSmramRange-
> >CpuStart + SmmCodeSize;
> > +      mCurrentSmramRange->PhysicalStart  = mCurrentSmramRange-
> >PhysicalStart + SmmCodeSize;
> >      }
> >      //
> >      // Load SMM Core into SMRAM and execute it from SMRAM
> >



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-12-12  1:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-01  6:49 [Patch 0/2] MdeModulePkg SmmCore: Fix hang issue when LMFA enable Liming Gao
2016-12-01  6:49 ` [Patch 1/2] MdeModulePkg SmmIpl: Fill Smram range for SMM driver " Liming Gao
2016-12-09 10:20   ` Zeng, Star
2016-12-12  1:48     ` Gao, Liming
2016-12-01  6:49 ` [Patch 2/2] MdeModulePkg PiSmmCore: Retrieve Smram base address from system table Liming Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox