[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [edk2] [PATCH RFC v2 7/7] OvmfPkg: introduce XenMemMapInitialization



Regarding patches 5-7, it seems like the mem-map code flow could be
more shared. It is a bit challenging to unravel things though.

I guess the only specific thing I can really point out is that
PcdPciAllowFullEnumeration should be initialized in a different patch,
and not within the mem-map init path.

-Jordan

On Tue, Nov 19, 2013 at 12:38 PM, Wei Liu <wei.liu2@xxxxxxxxxx> wrote:
> This function parses Xen OVMF info and arrange memory maps accordingly.
> It also sets PcdPciAllowFullEnumeration to false to prevent OVMF from
> playing with PCI devices.
>
> Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
> ---
>  OvmfPkg/OvmfPkgIa32.dsc             |    5 ++-
>  OvmfPkg/OvmfPkgIa32X64.dsc          |    5 ++-
>  OvmfPkg/OvmfPkgX64.dsc              |    5 ++-
>  OvmfPkg/PlatformPei/Platform.c      |   81 
> ++++++++++++++++++++++++++++++++++-
>  OvmfPkg/PlatformPei/PlatformPei.inf |    1 +
>  5 files changed, 89 insertions(+), 8 deletions(-)
>
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 760bd41..4b465fe 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -222,7 +222,7 @@
>  !else
>    DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
>  !endif
> -  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
> +  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
>    UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
>
>  [LibraryClasses.common.DXE_DRIVER]
> @@ -320,6 +320,7 @@
>    gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
>    gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
>    gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdPciAllowFullEnumeration|TRUE
>
>
>  
> ################################################################################
> @@ -342,7 +343,7 @@
>    MdeModulePkg/Core/Pei/PeiMain.inf
>    MdeModulePkg/Universal/PCD/Pei/Pcd.inf  {
>      <LibraryClasses>
> -      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
> +      PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
>    }
>    IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
>    MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 268d722..d26145d 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -227,7 +227,7 @@
>  !else
>    DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
>  !endif
> -  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
> +  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
>    UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
>
>  [LibraryClasses.common.DXE_DRIVER]
> @@ -326,6 +326,7 @@
>    gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
>    gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
>    gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdPciAllowFullEnumeration|TRUE
>
>
>  
> ################################################################################
> @@ -348,7 +349,7 @@
>    MdeModulePkg/Core/Pei/PeiMain.inf
>    MdeModulePkg/Universal/PCD/Pei/Pcd.inf  {
>      <LibraryClasses>
> -      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
> +      PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
>    }
>    IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
>    MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index 53945d0..b2792aa 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -227,7 +227,7 @@
>  !else
>    DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
>  !endif
> -  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
> +  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
>    UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
>
>  [LibraryClasses.common.DXE_DRIVER]
> @@ -325,6 +325,7 @@
>    gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
>    gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
>    gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdPciAllowFullEnumeration|TRUE
>
>
>  
> ################################################################################
> @@ -347,7 +348,7 @@
>    MdeModulePkg/Core/Pei/PeiMain.inf
>    MdeModulePkg/Universal/PCD/Pei/Pcd.inf  {
>      <LibraryClasses>
> -      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
> +      PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
>    }
>    IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
>    MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
> index 9b7828f..f9ffc25 100644
> --- a/OvmfPkg/PlatformPei/Platform.c
> +++ b/OvmfPkg/PlatformPei/Platform.c
> @@ -34,6 +34,10 @@
>  #include <Guid/MemoryTypeInformation.h>
>  #include <Ppi/MasterBootMode.h>
>  #include <IndustryStandard/Pci22.h>
> +#include <Guid/XenInfo.h>
> +#include <IndustryStandard/E820.h>
> +#include <Library/ResourcePublicationLib.h>
> +#include <Library/MtrrLib.h>
>
>  #include "Platform.h"
>  #include "Cmos.h"
> @@ -163,6 +167,72 @@ AddUntestedMemoryRangeHob (
>    AddUntestedMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - 
> MemoryBase));
>  }
>
> +VOID
> +XenMemMapInitialization (
> +  VOID
> +  )
> +{
> +  EFI_HOB_GUID_TYPE *GuidHob;
> +  EFI_XEN_INFO *Info;
> +
> +  DEBUG ((EFI_D_ERROR, "Using memory map provided by Xen\n"));
> +
> +  GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
> +
> +  ASSERT (GuidHob != NULL);
> +
> +  Info = GET_GUID_HOB_DATA (GuidHob);
> +
> +  //
> +  // Create Memory Type Information HOB
> +  //
> +  BuildGuidDataHob (
> +    &gEfiMemoryTypeInformationGuid,
> +    mDefaultMemoryTypeInformation,
> +    sizeof(mDefaultMemoryTypeInformation)
> +    );
> +
> +  //
> +  // Add PCI IO Port space available for PCI resource allocations.
> +  //
> +  BuildResourceDescriptorHob (
> +    EFI_RESOURCE_IO,
> +    EFI_RESOURCE_ATTRIBUTE_PRESENT     |
> +    EFI_RESOURCE_ATTRIBUTE_INITIALIZED,
> +    0xC000,
> +    0x4000
> +    );
> +
> +  //
> +  // Video memory + Legacy BIOS region
> +  //
> +  AddIoMemoryRangeHob (0x0A0000, BASE_1MB);
> +
> +  //
> +  // Parse RAM in E820 map
> +  //
> +  if (Info->E820EntryCount > 0) {
> +    EFI_E820_ENTRY64 *E820Map, *Entry;
> +    UINT16 Loop;
> +
> +    E820Map = Info->E820;
> +    for (Loop = 0; Loop < Info->E820EntryCount; Loop++) {
> +      Entry = E820Map + Loop;
> +
> +      // only care about RAM
> +      if (Entry->Type != EfiAcpiAddressRangeMemory)
> +        continue;
> +
> +      if (Entry->BaseAddr >= BASE_4GB)
> +        AddUntestedMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);
> +      else
> +        AddMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);
> +
> +      MtrrSetMemoryAttribute (Entry->BaseAddr, Entry->Length, 
> CacheWriteBack);
> +    }
> +  }
> +}
> +
>
>  VOID
>  MemMapInitialization (
> @@ -346,7 +416,11 @@ InitializePlatform (
>
>    XenLeaf = XenDetect ();
>
> -  TopOfMemory = MemDetect ();
> +  if (XenLeaf != 0) {
> +    PublishPeiMemory ();
> +    PcdSetBool (PcdPciAllowFullEnumeration, FALSE);
> +  } else
> +    TopOfMemory = MemDetect ();
>
>    if (XenLeaf != 0) {
>      DEBUG ((EFI_D_INFO, "Xen was detected\n"));
> @@ -357,7 +431,10 @@ InitializePlatform (
>
>    PeiFvInitialization ();
>
> -  MemMapInitialization (TopOfMemory);
> +  if (XenLeaf != 0)
> +    XenMemMapInitialization ();
> +  else
> +    MemMapInitialization (TopOfMemory);
>
>    MiscInitialization ();
>
> diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf 
> b/OvmfPkg/PlatformPei/PlatformPei.inf
> index 3d5cbbb..221afb2 100644
> --- a/OvmfPkg/PlatformPei/PlatformPei.inf
> +++ b/OvmfPkg/PlatformPei/PlatformPei.inf
> @@ -65,6 +65,7 @@
>    gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
>    gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
>    gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdPciAllowFullEnumeration
>    gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress
>
>  [Ppis]
> --
> 1.7.10.4
>
>
> ------------------------------------------------------------------------------
> Shape the Mobile Experience: Free Subscription
> Software experts and developers: Be at the forefront of tech innovation.
> Intel(R) Software Adrenaline delivers strategic insight and game-changing
> conversations that shape the rapidly evolving mobile landscape. Sign up now.
> http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.sourceforge.net/lists/listinfo/edk2-devel

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.