All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] OvmfPkg/PlatformPei: allow platform to specify start of PCI MMIO region
@ 2013-11-08 17:49 Wei Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Wei Liu @ 2013-11-08 17:49 UTC (permalink / raw)
  To: xen-devel, edk2-devel; +Cc: Wei Liu

The original code calculates the start of PCI MMIO region automatically,
which is not desirable when running under Xen, as Xen is responsible of
setting up respective regions.

This patch makes it possible to specify start of PCI MMIO so OVMF can
honor the region set up by Xen.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 OvmfPkg/OvmfPkg.dec                 |    3 +++
 OvmfPkg/PlatformPei/Platform.c      |   13 +++++++++++--
 OvmfPkg/PlatformPei/PlatformPei.inf |    1 +
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index d874f0c..4a041d1 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -68,6 +68,9 @@
   gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxTargetLimit|31|UINT16|6
   gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxLunLimit|7|UINT32|7
 
+  ## Allow platform to specify where to start PCI MMIO region
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPciMmioBaseAddress|0x0|UINT32|8
+
 [PcdsDynamic, PcdsDynamicEx]
   gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2
 
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index fb56e99..74001cc 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -197,7 +197,7 @@ MemMapInitialization (
   //
   // address       purpose   size
   // ------------  --------  -------------------------
-  // max(top, 2g)  PCI MMIO  0xFC000000 - max(top, 2g)
+  // MMIO_START    PCI MMIO  0xFC000000 - MMIO_START
   // 0xFC000000    gap                           44 MB
   // 0xFEC00000    IO-APIC                        4 KB
   // 0xFEC01000    gap                         1020 KB
@@ -205,7 +205,16 @@ MemMapInitialization (
   // 0xFED00400    gap                         1023 KB
   // 0xFEE00000    LAPIC                          1 MB
   //
-  AddIoMemoryRangeHob (TopOfMemory < BASE_2GB ? BASE_2GB : TopOfMemory, 0xFC000000);
+  // if PcdOvmfPciMmioBaseAddress is set
+  //   MMIO_START = PcdOvmfPciMmioBaseAddress
+  // else
+  //   MMIO_START = max(top, 2g)
+
+  if (PcdGet32(PcdOvmfPciMmioBaseAddress) > 0)
+    AddIoMemoryRangeHob (PcdGet32(PcdOvmfPciMmioBaseAddress), 0xFC000000);
+  else
+    AddIoMemoryRangeHob (TopOfMemory < BASE_2GB ? BASE_2GB : TopOfMemory, 0xFC000000);
+
   AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_4KB);
   AddIoMemoryBaseSizeHob (0xFED00000, SIZE_1KB);
   AddIoMemoryBaseSizeHob (PcdGet32(PcdCpuLocalApicBaseAddress), SIZE_1MB);
diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
index 3d5cbbb..64d9323 100644
--- a/OvmfPkg/PlatformPei/PlatformPei.inf
+++ b/OvmfPkg/PlatformPei/PlatformPei.inf
@@ -61,6 +61,7 @@
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize
   gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPciMmioBaseAddress
   gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
-- 
1.7.10.4

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

* Re: [PATCH] OvmfPkg/PlatformPei: allow platform to specify start of PCI MMIO region
       [not found] <1383932979-10329-1-git-send-email-wei.liu2@citrix.com>
@ 2013-11-08 18:25 ` Konrad Rzeszutek Wilk
  2013-11-08 18:51   ` Wei Liu
       [not found]   ` <20131108185102.GL12679@zion.uk.xensource.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Konrad Rzeszutek Wilk @ 2013-11-08 18:25 UTC (permalink / raw)
  To: Wei Liu; +Cc: edk2-devel, xen-devel

On Fri, Nov 08, 2013 at 05:49:39PM +0000, Wei Liu wrote:
> The original code calculates the start of PCI MMIO region automatically,
> which is not desirable when running under Xen, as Xen is responsible of
> setting up respective regions.

What if Xen (hvmloader) also moves the MMIO to a different place and
size? (Basically make e820_host option work with HVM)?

> 
> This patch makes it possible to specify start of PCI MMIO so OVMF can
> honor the region set up by Xen.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
>  OvmfPkg/OvmfPkg.dec                 |    3 +++
>  OvmfPkg/PlatformPei/Platform.c      |   13 +++++++++++--
>  OvmfPkg/PlatformPei/PlatformPei.inf |    1 +
>  3 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
> index d874f0c..4a041d1 100644
> --- a/OvmfPkg/OvmfPkg.dec
> +++ b/OvmfPkg/OvmfPkg.dec
> @@ -68,6 +68,9 @@
>    gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxTargetLimit|31|UINT16|6
>    gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxLunLimit|7|UINT32|7
>  
> +  ## Allow platform to specify where to start PCI MMIO region
> +  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPciMmioBaseAddress|0x0|UINT32|8
> +
>  [PcdsDynamic, PcdsDynamicEx]
>    gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2
>  
> diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
> index fb56e99..74001cc 100644
> --- a/OvmfPkg/PlatformPei/Platform.c
> +++ b/OvmfPkg/PlatformPei/Platform.c
> @@ -197,7 +197,7 @@ MemMapInitialization (
>    //
>    // address       purpose   size
>    // ------------  --------  -------------------------
> -  // max(top, 2g)  PCI MMIO  0xFC000000 - max(top, 2g)
> +  // MMIO_START    PCI MMIO  0xFC000000 - MMIO_START
>    // 0xFC000000    gap                           44 MB
>    // 0xFEC00000    IO-APIC                        4 KB
>    // 0xFEC01000    gap                         1020 KB
> @@ -205,7 +205,16 @@ MemMapInitialization (
>    // 0xFED00400    gap                         1023 KB
>    // 0xFEE00000    LAPIC                          1 MB
>    //
> -  AddIoMemoryRangeHob (TopOfMemory < BASE_2GB ? BASE_2GB : TopOfMemory, 0xFC000000);
> +  // if PcdOvmfPciMmioBaseAddress is set
> +  //   MMIO_START = PcdOvmfPciMmioBaseAddress
> +  // else
> +  //   MMIO_START = max(top, 2g)
> +
> +  if (PcdGet32(PcdOvmfPciMmioBaseAddress) > 0)
> +    AddIoMemoryRangeHob (PcdGet32(PcdOvmfPciMmioBaseAddress), 0xFC000000);
> +  else
> +    AddIoMemoryRangeHob (TopOfMemory < BASE_2GB ? BASE_2GB : TopOfMemory, 0xFC000000);
> +
>    AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_4KB);
>    AddIoMemoryBaseSizeHob (0xFED00000, SIZE_1KB);
>    AddIoMemoryBaseSizeHob (PcdGet32(PcdCpuLocalApicBaseAddress), SIZE_1MB);
> diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
> index 3d5cbbb..64d9323 100644
> --- a/OvmfPkg/PlatformPei/PlatformPei.inf
> +++ b/OvmfPkg/PlatformPei/PlatformPei.inf
> @@ -61,6 +61,7 @@
>    gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase
>    gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize
>    gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress
> +  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPciMmioBaseAddress
>    gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize
>    gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
>    gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

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

* Re: [PATCH] OvmfPkg/PlatformPei: allow platform to specify start of PCI MMIO region
  2013-11-08 18:25 ` [PATCH] OvmfPkg/PlatformPei: allow platform to specify start of PCI MMIO region Konrad Rzeszutek Wilk
@ 2013-11-08 18:51   ` Wei Liu
       [not found]   ` <20131108185102.GL12679@zion.uk.xensource.com>
  1 sibling, 0 replies; 4+ messages in thread
From: Wei Liu @ 2013-11-08 18:51 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk; +Cc: edk2-devel, Wei Liu, xen-devel

On Fri, Nov 08, 2013 at 01:25:34PM -0500, Konrad Rzeszutek Wilk wrote:
> On Fri, Nov 08, 2013 at 05:49:39PM +0000, Wei Liu wrote:
> > The original code calculates the start of PCI MMIO region automatically,
> > which is not desirable when running under Xen, as Xen is responsible of
> > setting up respective regions.
> 
> What if Xen (hvmloader) also moves the MMIO to a different place and
> size? (Basically make e820_host option work with HVM)?
> 

Good point. We probably need to find a way to retrieve the actual
information during runtime.

Wei.

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

* Re: [PATCH] OvmfPkg/PlatformPei: allow platform to specify start of PCI MMIO region
       [not found]   ` <20131108185102.GL12679@zion.uk.xensource.com>
@ 2013-11-11  9:45     ` Ian Campbell
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Campbell @ 2013-11-11  9:45 UTC (permalink / raw)
  To: Wei Liu; +Cc: edk2-devel, xen-devel

On Fri, 2013-11-08 at 18:51 +0000, Wei Liu wrote:
> On Fri, Nov 08, 2013 at 01:25:34PM -0500, Konrad Rzeszutek Wilk wrote:
> > On Fri, Nov 08, 2013 at 05:49:39PM +0000, Wei Liu wrote:
> > > The original code calculates the start of PCI MMIO region automatically,
> > > which is not desirable when running under Xen, as Xen is responsible of
> > > setting up respective regions.
> > 
> > What if Xen (hvmloader) also moves the MMIO to a different place and
> > size?

> > (Basically make e820_host option work with HVM)?

This doesn't exist yet, does it?

> Good point. We probably need to find a way to retrieve the actual
> information during runtime.

In the SeaBIOS case hvmloader passes the e820 map to the BIOS (via
struct seabios_info) to consume. This then gets modified as SeaBIOS
allocates memory and is eventually made available to the OS. (both
hvmloader and SeaBIOS will likely need to be extended if/when e820_host
gets implemented for HVM)

Perhaps hvmloadr/OVMF need a similar mechanism to communicate memory
regions and/or PCI bus configuration from hvmloader to UEFI?

Ian.

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

end of thread, other threads:[~2013-11-11  9:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1383932979-10329-1-git-send-email-wei.liu2@citrix.com>
2013-11-08 18:25 ` [PATCH] OvmfPkg/PlatformPei: allow platform to specify start of PCI MMIO region Konrad Rzeszutek Wilk
2013-11-08 18:51   ` Wei Liu
     [not found]   ` <20131108185102.GL12679@zion.uk.xensource.com>
2013-11-11  9:45     ` Ian Campbell
2013-11-08 17:49 Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.