public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] IntelFrameworkModule/LegacyBios: Use reserved memory for legacy data
@ 2018-04-25  7:06 Ruiyu Ni
  2018-04-28  5:40 ` Zeng, Star
  0 siblings, 1 reply; 2+ messages in thread
From: Ruiyu Ni @ 2018-04-25  7:06 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng

Certain Legacy USB implementation needs to access legacy data (BDA,
etc.) from SMM environment. While currently it's not allowed to
access BS memory from SMM after EndofDxe, change the legacy data
to use reserved memory type.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
---
 IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c      | 13 +++++++++++--
 .../Csm/LegacyBiosDxe/LegacyBiosInterface.h                 |  4 +++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
index fca08a8fa2..a96f9b5610 100644
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
+++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
@@ -46,7 +46,8 @@ BOOLEAN               mEndOfDxe                = FALSE;
   Do an AllocatePages () of type AllocateMaxAddress for EfiBootServicesCode
   memory.
 
-  @param  AllocateType               Allocated Legacy Memory Type
+  @param  AllocateType               The type of allocation to perform.
+  @param  MemoryType                 The type of memory to allocate.
   @param  StartPageAddress           Start address of range
   @param  Pages                      Number of pages to allocate
   @param  Result                     Result of allocation
@@ -58,6 +59,7 @@ BOOLEAN               mEndOfDxe                = FALSE;
 EFI_STATUS
 AllocateLegacyMemory (
   IN  EFI_ALLOCATE_TYPE         AllocateType,
+  IN  EFI_MEMORY_TYPE           MemoryType,
   IN  EFI_PHYSICAL_ADDRESS      StartPageAddress,
   IN  UINTN                     Pages,
   OUT EFI_PHYSICAL_ADDRESS      *Result
@@ -72,7 +74,7 @@ AllocateLegacyMemory (
   MemPage = (EFI_PHYSICAL_ADDRESS) (UINTN) StartPageAddress;
   Status = gBS->AllocatePages (
                   AllocateType,
-                  EfiBootServicesCode,
+                  MemoryType,
                   Pages,
                   &MemPage
                   );
@@ -974,6 +976,7 @@ LegacyBiosInstall (
   //
   AllocateLegacyMemory (
     AllocateAddress,
+    EfiReservedMemoryType,
     0,
     1,
     &MemoryAddress
@@ -999,6 +1002,7 @@ LegacyBiosInstall (
 
   Status = AllocateLegacyMemory (
              AllocateAddress,
+             EfiReservedMemoryType,
              CONVENTIONAL_MEMORY_TOP - MemorySize,
              EFI_SIZE_TO_PAGES (MemorySize),
              &MemoryAddress
@@ -1027,6 +1031,7 @@ LegacyBiosInstall (
   for (MemStart = MemoryAddress; MemStart < MemoryAddress + MemorySize; MemStart += 0x1000) {
     Status = AllocateLegacyMemory (
                AllocateAddress,
+               EfiBootServicesCode,
                MemStart,
                1,
                &StartAddress
@@ -1046,6 +1051,7 @@ LegacyBiosInstall (
   ASSERT ((MemorySize & 0xFFF) == 0);  
   Status = AllocateLegacyMemory (
              AllocateMaxAddress,
+             EfiBootServicesCode,
              CONVENTIONAL_MEMORY_TOP,
              EFI_SIZE_TO_PAGES (MemorySize),
              &MemoryAddressUnder1MB
@@ -1059,6 +1065,7 @@ LegacyBiosInstall (
   //
   Status = AllocateLegacyMemory (
              AllocateMaxAddress,
+             EfiReservedMemoryType,
              CONVENTIONAL_MEMORY_TOP,
              (sizeof (LOW_MEMORY_THUNK) / EFI_PAGE_SIZE) + 2,
              &MemoryAddress
@@ -1086,6 +1093,7 @@ LegacyBiosInstall (
   //   
   Status = AllocateLegacyMemory (
              AllocateMaxAddress,
+             EfiBootServicesCode,
              0x1000000,
              EFI_SIZE_TO_PAGES (MemorySize),
              &MemoryAddress
@@ -1096,6 +1104,7 @@ LegacyBiosInstall (
     //   
     Status = AllocateLegacyMemory (
                AllocateMaxAddress,
+               EfiBootServicesCode,
                0xFFFFFFFF,
                EFI_SIZE_TO_PAGES (MemorySize),
                &MemoryAddress
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
index cc2fc9fc13..595fe0eade 100644
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
+++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
@@ -1264,7 +1264,8 @@ GenerateSoftInit (
   Do an AllocatePages () of type AllocateMaxAddress for EfiBootServicesCode
   memory.
 
-  @param  AllocateType               Allocated Legacy Memory Type
+  @param  AllocateType               The type of allocation to perform.
+  @param  MemoryType                 The type of memory to allocate.
   @param  StartPageAddress           Start address of range
   @param  Pages                      Number of pages to allocate
   @param  Result                     Result of allocation
@@ -1276,6 +1277,7 @@ GenerateSoftInit (
 EFI_STATUS
 AllocateLegacyMemory (
   IN  EFI_ALLOCATE_TYPE         AllocateType,
+  IN  EFI_MEMORY_TYPE           MemoryType,
   IN  EFI_PHYSICAL_ADDRESS      StartPageAddress,
   IN  UINTN                     Pages,
   OUT EFI_PHYSICAL_ADDRESS      *Result
-- 
2.16.1.windows.1



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

* Re: [PATCH] IntelFrameworkModule/LegacyBios: Use reserved memory for legacy data
  2018-04-25  7:06 [PATCH] IntelFrameworkModule/LegacyBios: Use reserved memory for legacy data Ruiyu Ni
@ 2018-04-28  5:40 ` Zeng, Star
  0 siblings, 0 replies; 2+ messages in thread
From: Zeng, Star @ 2018-04-28  5:40 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Zeng, Star

Please also update the function comment "   Do an AllocatePages () of type AllocateMaxAddress for EfiBootServicesCode
   memory."


With that, Reviewed-by: Star Zeng <star.zeng@intel.com>.


Thanks,
Star
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Wednesday, April 25, 2018 3:06 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>
Subject: [edk2] [PATCH] IntelFrameworkModule/LegacyBios: Use reserved memory for legacy data

Certain Legacy USB implementation needs to access legacy data (BDA,
etc.) from SMM environment. While currently it's not allowed to access BS memory from SMM after EndofDxe, change the legacy data to use reserved memory type.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
---
 IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c      | 13 +++++++++++--
 .../Csm/LegacyBiosDxe/LegacyBiosInterface.h                 |  4 +++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
index fca08a8fa2..a96f9b5610 100644
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
+++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
@@ -46,7 +46,8 @@ BOOLEAN               mEndOfDxe                = FALSE;
   Do an AllocatePages () of type AllocateMaxAddress for EfiBootServicesCode
   memory.
 
-  @param  AllocateType               Allocated Legacy Memory Type
+  @param  AllocateType               The type of allocation to perform.
+  @param  MemoryType                 The type of memory to allocate.
   @param  StartPageAddress           Start address of range
   @param  Pages                      Number of pages to allocate
   @param  Result                     Result of allocation
@@ -58,6 +59,7 @@ BOOLEAN               mEndOfDxe                = FALSE;
 EFI_STATUS
 AllocateLegacyMemory (
   IN  EFI_ALLOCATE_TYPE         AllocateType,
+  IN  EFI_MEMORY_TYPE           MemoryType,
   IN  EFI_PHYSICAL_ADDRESS      StartPageAddress,
   IN  UINTN                     Pages,
   OUT EFI_PHYSICAL_ADDRESS      *Result
@@ -72,7 +74,7 @@ AllocateLegacyMemory (
   MemPage = (EFI_PHYSICAL_ADDRESS) (UINTN) StartPageAddress;
   Status = gBS->AllocatePages (
                   AllocateType,
-                  EfiBootServicesCode,
+                  MemoryType,
                   Pages,
                   &MemPage
                   );
@@ -974,6 +976,7 @@ LegacyBiosInstall (
   //
   AllocateLegacyMemory (
     AllocateAddress,
+    EfiReservedMemoryType,
     0,
     1,
     &MemoryAddress
@@ -999,6 +1002,7 @@ LegacyBiosInstall (
 
   Status = AllocateLegacyMemory (
              AllocateAddress,
+             EfiReservedMemoryType,
              CONVENTIONAL_MEMORY_TOP - MemorySize,
              EFI_SIZE_TO_PAGES (MemorySize),
              &MemoryAddress
@@ -1027,6 +1031,7 @@ LegacyBiosInstall (
   for (MemStart = MemoryAddress; MemStart < MemoryAddress + MemorySize; MemStart += 0x1000) {
     Status = AllocateLegacyMemory (
                AllocateAddress,
+               EfiBootServicesCode,
                MemStart,
                1,
                &StartAddress
@@ -1046,6 +1051,7 @@ LegacyBiosInstall (
   ASSERT ((MemorySize & 0xFFF) == 0);  
   Status = AllocateLegacyMemory (
              AllocateMaxAddress,
+             EfiBootServicesCode,
              CONVENTIONAL_MEMORY_TOP,
              EFI_SIZE_TO_PAGES (MemorySize),
              &MemoryAddressUnder1MB
@@ -1059,6 +1065,7 @@ LegacyBiosInstall (
   //
   Status = AllocateLegacyMemory (
              AllocateMaxAddress,
+             EfiReservedMemoryType,
              CONVENTIONAL_MEMORY_TOP,
              (sizeof (LOW_MEMORY_THUNK) / EFI_PAGE_SIZE) + 2,
              &MemoryAddress
@@ -1086,6 +1093,7 @@ LegacyBiosInstall (
   //   
   Status = AllocateLegacyMemory (
              AllocateMaxAddress,
+             EfiBootServicesCode,
              0x1000000,
              EFI_SIZE_TO_PAGES (MemorySize),
              &MemoryAddress
@@ -1096,6 +1104,7 @@ LegacyBiosInstall (
     //   
     Status = AllocateLegacyMemory (
                AllocateMaxAddress,
+               EfiBootServicesCode,
                0xFFFFFFFF,
                EFI_SIZE_TO_PAGES (MemorySize),
                &MemoryAddress
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
index cc2fc9fc13..595fe0eade 100644
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
+++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
@@ -1264,7 +1264,8 @@ GenerateSoftInit (
   Do an AllocatePages () of type AllocateMaxAddress for EfiBootServicesCode
   memory.
 
-  @param  AllocateType               Allocated Legacy Memory Type
+  @param  AllocateType               The type of allocation to perform.
+  @param  MemoryType                 The type of memory to allocate.
   @param  StartPageAddress           Start address of range
   @param  Pages                      Number of pages to allocate
   @param  Result                     Result of allocation
@@ -1276,6 +1277,7 @@ GenerateSoftInit (  EFI_STATUS  AllocateLegacyMemory (
   IN  EFI_ALLOCATE_TYPE         AllocateType,
+  IN  EFI_MEMORY_TYPE           MemoryType,
   IN  EFI_PHYSICAL_ADDRESS      StartPageAddress,
   IN  UINTN                     Pages,
   OUT EFI_PHYSICAL_ADDRESS      *Result
--
2.16.1.windows.1

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


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

end of thread, other threads:[~2018-04-28  5:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-25  7:06 [PATCH] IntelFrameworkModule/LegacyBios: Use reserved memory for legacy data Ruiyu Ni
2018-04-28  5:40 ` Zeng, Star

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