public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/PciBus: Fix system hang when no PCI Option ROM exists
@ 2018-12-12 15:10 Ruiyu Ni
  2018-12-12 18:17 ` Ard Biesheuvel
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Ruiyu Ni @ 2018-12-12 15:10 UTC (permalink / raw)
  To: edk2-devel; +Cc: Chiu Chasel, Hao A Wu, Jian J Wang

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1394

When there is no PCI option ROM exists, today's logic still creates
virtual BAR for option ROM using Length = 0, Alignment = (-1).
It causes the final MEM32 alignment requirement is as big as
0xFFFFFFFF_FFFFFFFF.

The patch fixes this issue by only creating virtual BAR for option
ROM when there is PCI option ROM.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Chiu Chasel <chasel.chiu@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
index 7255bcfbbc..ee5c77147e 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
@@ -515,10 +515,12 @@ PciHostBridgeResourceAllocator (
       // All devices' Option ROM share the same MEM32 resource.
       //
       MaxOptionRomSize = GetMaxOptionRomSize (RootBridgeDev);
-      RootBridgeDev->PciBar[0].BarType   = PciBarTypeOpRom;
-      RootBridgeDev->PciBar[0].Length    = MaxOptionRomSize;
-      RootBridgeDev->PciBar[0].Alignment = MaxOptionRomSize - 1;
-      GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge, PMem32Bridge, Mem64Bridge, PMem64Bridge);
+      if (MaxOptionRomSize != 0) {
+        RootBridgeDev->PciBar[0].BarType   = PciBarTypeOpRom;
+        RootBridgeDev->PciBar[0].Length    = MaxOptionRomSize;
+        RootBridgeDev->PciBar[0].Alignment = MaxOptionRomSize - 1;
+        GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge, PMem32Bridge, Mem64Bridge, PMem64Bridge);
+      }
 
       //
       // Create resourcemap by going through all the devices subject to this root bridge
-- 
2.16.1.windows.1



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

* Re: [PATCH] MdeModulePkg/PciBus: Fix system hang when no PCI Option ROM exists
  2018-12-12 15:10 [PATCH] MdeModulePkg/PciBus: Fix system hang when no PCI Option ROM exists Ruiyu Ni
@ 2018-12-12 18:17 ` Ard Biesheuvel
  2018-12-13  0:26   ` Chiu, Chasel
  2018-12-13  1:39 ` Wang, Jian J
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Ard Biesheuvel @ 2018-12-12 18:17 UTC (permalink / raw)
  To: Ruiyu Ni; +Cc: edk2-devel@lists.01.org, Wu, Hao A

On Wed, 12 Dec 2018 at 16:08, Ruiyu Ni <ruiyu.ni@intel.com> wrote:
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1394
>
> When there is no PCI option ROM exists, today's logic still creates
> virtual BAR for option ROM using Length = 0, Alignment = (-1).
> It causes the final MEM32 alignment requirement is as big as
> 0xFFFFFFFF_FFFFFFFF.
>
> The patch fixes this issue by only creating virtual BAR for option
> ROM when there is PCI option ROM.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Chiu Chasel <chasel.chiu@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>

Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> index 7255bcfbbc..ee5c77147e 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> @@ -515,10 +515,12 @@ PciHostBridgeResourceAllocator (
>        // All devices' Option ROM share the same MEM32 resource.
>        //
>        MaxOptionRomSize = GetMaxOptionRomSize (RootBridgeDev);
> -      RootBridgeDev->PciBar[0].BarType   = PciBarTypeOpRom;
> -      RootBridgeDev->PciBar[0].Length    = MaxOptionRomSize;
> -      RootBridgeDev->PciBar[0].Alignment = MaxOptionRomSize - 1;
> -      GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge, PMem32Bridge, Mem64Bridge, PMem64Bridge);
> +      if (MaxOptionRomSize != 0) {
> +        RootBridgeDev->PciBar[0].BarType   = PciBarTypeOpRom;
> +        RootBridgeDev->PciBar[0].Length    = MaxOptionRomSize;
> +        RootBridgeDev->PciBar[0].Alignment = MaxOptionRomSize - 1;
> +        GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge, PMem32Bridge, Mem64Bridge, PMem64Bridge);
> +      }
>
>        //
>        // Create resourcemap by going through all the devices subject to this root bridge
> --
> 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	[flat|nested] 6+ messages in thread

* Re: [PATCH] MdeModulePkg/PciBus: Fix system hang when no PCI Option ROM exists
  2018-12-12 18:17 ` Ard Biesheuvel
@ 2018-12-13  0:26   ` Chiu, Chasel
  0 siblings, 0 replies; 6+ messages in thread
From: Chiu, Chasel @ 2018-12-13  0:26 UTC (permalink / raw)
  To: Ard Biesheuvel, Ni, Ruiyu; +Cc: Wu, Hao A, edk2-devel@lists.01.org


Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ard Biesheuvel
Sent: Thursday, December 13, 2018 2:17 AM
To: Ni, Ruiyu <ruiyu.ni@intel.com>
Cc: Wu, Hao A <hao.a.wu@intel.com>; edk2-devel@lists.01.org
Subject: Re: [edk2] [PATCH] MdeModulePkg/PciBus: Fix system hang when no PCI Option ROM exists

On Wed, 12 Dec 2018 at 16:08, Ruiyu Ni <ruiyu.ni@intel.com> wrote:
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1394
>
> When there is no PCI option ROM exists, today's logic still creates 
> virtual BAR for option ROM using Length = 0, Alignment = (-1).
> It causes the final MEM32 alignment requirement is as big as 
> 0xFFFFFFFF_FFFFFFFF.
>
> The patch fixes this issue by only creating virtual BAR for option ROM 
> when there is PCI option ROM.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Chiu Chasel <chasel.chiu@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>

Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c 
> b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> index 7255bcfbbc..ee5c77147e 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> @@ -515,10 +515,12 @@ PciHostBridgeResourceAllocator (
>        // All devices' Option ROM share the same MEM32 resource.
>        //
>        MaxOptionRomSize = GetMaxOptionRomSize (RootBridgeDev);
> -      RootBridgeDev->PciBar[0].BarType   = PciBarTypeOpRom;
> -      RootBridgeDev->PciBar[0].Length    = MaxOptionRomSize;
> -      RootBridgeDev->PciBar[0].Alignment = MaxOptionRomSize - 1;
> -      GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge, PMem32Bridge, Mem64Bridge, PMem64Bridge);
> +      if (MaxOptionRomSize != 0) {
> +        RootBridgeDev->PciBar[0].BarType   = PciBarTypeOpRom;
> +        RootBridgeDev->PciBar[0].Length    = MaxOptionRomSize;
> +        RootBridgeDev->PciBar[0].Alignment = MaxOptionRomSize - 1;
> +        GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge, PMem32Bridge, Mem64Bridge, PMem64Bridge);
> +      }
>
>        //
>        // Create resourcemap by going through all the devices subject 
> to this root bridge
> --
> 2.16.1.windows.1
>
> _______________________________________________
> 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


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

* Re: [PATCH] MdeModulePkg/PciBus: Fix system hang when no PCI Option ROM exists
  2018-12-12 15:10 [PATCH] MdeModulePkg/PciBus: Fix system hang when no PCI Option ROM exists Ruiyu Ni
  2018-12-12 18:17 ` Ard Biesheuvel
@ 2018-12-13  1:39 ` Wang, Jian J
  2018-12-13 12:48 ` Wu, Hao A
  2018-12-14 14:16 ` Philippe Mathieu-Daudé
  3 siblings, 0 replies; 6+ messages in thread
From: Wang, Jian J @ 2018-12-13  1:39 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Chiu, Chasel, Wu, Hao A


Reviewed-by: Jian J Wang <jian.j.wang@intel.com>


> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Wednesday, December 12, 2018 11:10 PM
> To: edk2-devel@lists.01.org
> Cc: Chiu, Chasel <chasel.chiu@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Wang, Jian J <jian.j.wang@intel.com>
> Subject: [PATCH] MdeModulePkg/PciBus: Fix system hang when no PCI Option
> ROM exists
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1394
> 
> When there is no PCI option ROM exists, today's logic still creates
> virtual BAR for option ROM using Length = 0, Alignment = (-1).
> It causes the final MEM32 alignment requirement is as big as
> 0xFFFFFFFF_FFFFFFFF.
> 
> The patch fixes this issue by only creating virtual BAR for option
> ROM when there is PCI option ROM.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Chiu Chasel <chasel.chiu@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> ---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> index 7255bcfbbc..ee5c77147e 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> @@ -515,10 +515,12 @@ PciHostBridgeResourceAllocator (
>        // All devices' Option ROM share the same MEM32 resource.
>        //
>        MaxOptionRomSize = GetMaxOptionRomSize (RootBridgeDev);
> -      RootBridgeDev->PciBar[0].BarType   = PciBarTypeOpRom;
> -      RootBridgeDev->PciBar[0].Length    = MaxOptionRomSize;
> -      RootBridgeDev->PciBar[0].Alignment = MaxOptionRomSize - 1;
> -      GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge,
> PMem32Bridge, Mem64Bridge, PMem64Bridge);
> +      if (MaxOptionRomSize != 0) {
> +        RootBridgeDev->PciBar[0].BarType   = PciBarTypeOpRom;
> +        RootBridgeDev->PciBar[0].Length    = MaxOptionRomSize;
> +        RootBridgeDev->PciBar[0].Alignment = MaxOptionRomSize - 1;
> +        GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge,
> PMem32Bridge, Mem64Bridge, PMem64Bridge);
> +      }
> 
>        //
>        // Create resourcemap by going through all the devices subject to this root
> bridge
> --
> 2.16.1.windows.1



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

* Re: [PATCH] MdeModulePkg/PciBus: Fix system hang when no PCI Option ROM exists
  2018-12-12 15:10 [PATCH] MdeModulePkg/PciBus: Fix system hang when no PCI Option ROM exists Ruiyu Ni
  2018-12-12 18:17 ` Ard Biesheuvel
  2018-12-13  1:39 ` Wang, Jian J
@ 2018-12-13 12:48 ` Wu, Hao A
  2018-12-14 14:16 ` Philippe Mathieu-Daudé
  3 siblings, 0 replies; 6+ messages in thread
From: Wu, Hao A @ 2018-12-13 12:48 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Ruiyu Ni
> Sent: Wednesday, December 12, 2018 11:10 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A
> Subject: [edk2] [PATCH] MdeModulePkg/PciBus: Fix system hang when no
> PCI Option ROM exists
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1394
> 
> When there is no PCI option ROM exists, today's logic still creates
> virtual BAR for option ROM using Length = 0, Alignment = (-1).
> It causes the final MEM32 alignment requirement is as big as
> 0xFFFFFFFF_FFFFFFFF.
> 
> The patch fixes this issue by only creating virtual BAR for option
> ROM when there is PCI option ROM.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Chiu Chasel <chasel.chiu@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> ---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> index 7255bcfbbc..ee5c77147e 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> @@ -515,10 +515,12 @@ PciHostBridgeResourceAllocator (
>        // All devices' Option ROM share the same MEM32 resource.
>        //
>        MaxOptionRomSize = GetMaxOptionRomSize (RootBridgeDev);
> -      RootBridgeDev->PciBar[0].BarType   = PciBarTypeOpRom;
> -      RootBridgeDev->PciBar[0].Length    = MaxOptionRomSize;
> -      RootBridgeDev->PciBar[0].Alignment = MaxOptionRomSize - 1;
> -      GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge,
> PMem32Bridge, Mem64Bridge, PMem64Bridge);
> +      if (MaxOptionRomSize != 0) {
> +        RootBridgeDev->PciBar[0].BarType   = PciBarTypeOpRom;
> +        RootBridgeDev->PciBar[0].Length    = MaxOptionRomSize;
> +        RootBridgeDev->PciBar[0].Alignment = MaxOptionRomSize - 1;
> +        GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge,
> PMem32Bridge, Mem64Bridge, PMem64Bridge);
> +      }

Reviewed-by: Hao Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu

> 
>        //
>        // Create resourcemap by going through all the devices subject to this
> root bridge
> --
> 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	[flat|nested] 6+ messages in thread

* Re: [PATCH] MdeModulePkg/PciBus: Fix system hang when no PCI Option ROM exists
  2018-12-12 15:10 [PATCH] MdeModulePkg/PciBus: Fix system hang when no PCI Option ROM exists Ruiyu Ni
                   ` (2 preceding siblings ...)
  2018-12-13 12:48 ` Wu, Hao A
@ 2018-12-14 14:16 ` Philippe Mathieu-Daudé
  3 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-12-14 14:16 UTC (permalink / raw)
  To: Ruiyu Ni, edk2-devel; +Cc: Hao A Wu

On 12/12/18 4:10 PM, Ruiyu Ni wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1394
> 
> When there is no PCI option ROM exists, today's logic still creates
> virtual BAR for option ROM using Length = 0, Alignment = (-1).
> It causes the final MEM32 alignment requirement is as big as
> 0xFFFFFFFF_FFFFFFFF.
> 
> The patch fixes this issue by only creating virtual BAR for option
> ROM when there is PCI option ROM.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Chiu Chasel <chasel.chiu@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> ---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> index 7255bcfbbc..ee5c77147e 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
> @@ -515,10 +515,12 @@ PciHostBridgeResourceAllocator (
>        // All devices' Option ROM share the same MEM32 resource.
>        //
>        MaxOptionRomSize = GetMaxOptionRomSize (RootBridgeDev);
> -      RootBridgeDev->PciBar[0].BarType   = PciBarTypeOpRom;
> -      RootBridgeDev->PciBar[0].Length    = MaxOptionRomSize;
> -      RootBridgeDev->PciBar[0].Alignment = MaxOptionRomSize - 1;
> -      GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge, PMem32Bridge, Mem64Bridge, PMem64Bridge);
> +      if (MaxOptionRomSize != 0) {
> +        RootBridgeDev->PciBar[0].BarType   = PciBarTypeOpRom;
> +        RootBridgeDev->PciBar[0].Length    = MaxOptionRomSize;
> +        RootBridgeDev->PciBar[0].Alignment = MaxOptionRomSize - 1;
> +        GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge, PMem32Bridge, Mem64Bridge, PMem64Bridge);
> +      }
>  
>        //
>        // Create resourcemap by going through all the devices subject to this root bridge
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


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

end of thread, other threads:[~2018-12-14 14:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-12 15:10 [PATCH] MdeModulePkg/PciBus: Fix system hang when no PCI Option ROM exists Ruiyu Ni
2018-12-12 18:17 ` Ard Biesheuvel
2018-12-13  0:26   ` Chiu, Chasel
2018-12-13  1:39 ` Wang, Jian J
2018-12-13 12:48 ` Wu, Hao A
2018-12-14 14:16 ` Philippe Mathieu-Daudé

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