public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH 1/1] MdeModulePkg/PciBusDxe: Fix boot hang with faulty PCI Option ROM
@ 2023-08-21  3:40 Nhi Pham via groups.io
  2023-08-24  1:14 ` 回复: [ ** SPAMMAIL ** ][edk2-devel] " gaoliming via groups.io
  0 siblings, 1 reply; 2+ messages in thread
From: Nhi Pham via groups.io @ 2023-08-21  3:40 UTC (permalink / raw)
  To: devel; +Cc: Nhi Pham, Jian J Wang, Liming Gao, Hao A Wu

A faulty PCI device has the Option ROM image size set to 0. UEFI reads
two headers PCI_EXPANSION_ROM_HEADER and PCI_DATA_STRUCTURE to get the
Option ROM information. Because the image size is 0, the Option ROM
header address never changes. As a result, UEFI keeps reading the same
two headers definitely. This patch is intended to fix it.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Hao A Wu <hao.a.wu@intel.c>
Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
index 89f5f64101a5..bd5ace18f6e4 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
@@ -506,13 +506,13 @@ LoadOpRomImage (
     Indicator    = RomPcir->Indicator;

     RomImageSize = RomImageSize + RomPcir->ImageLength * 512;

     RomBarOffset = RomBarOffset + RomPcir->ImageLength * 512;

-  } while (((Indicator & 0x80) == 0x00) && ((RomBarOffset - RomBar) < RomSize));

+  } while (((Indicator & 0x80) == 0x00) && ((RomBarOffset - RomBar) < RomSize) && (RomImageSize > 0));

 

   //

   // Some Legacy Cards do not report the correct ImageLength so used the maximum

   // of the legacy length and the PCIR Image Length

   //

-  if (CodeType == PCI_CODE_TYPE_PCAT_IMAGE) {

+  if ((RomImageSize > 0) && (CodeType == PCI_CODE_TYPE_PCAT_IMAGE)) {

     RomImageSize = MAX (RomImageSize, LegacyImageLength);

   }

 

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107907): https://edk2.groups.io/g/devel/message/107907
Mute This Topic: https://groups.io/mt/100867107/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



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

* 回复: [ ** SPAMMAIL ** ][edk2-devel] [PATCH 1/1] MdeModulePkg/PciBusDxe: Fix boot hang with faulty PCI Option ROM
  2023-08-21  3:40 [edk2-devel] [PATCH 1/1] MdeModulePkg/PciBusDxe: Fix boot hang with faulty PCI Option ROM Nhi Pham via groups.io
@ 2023-08-24  1:14 ` gaoliming via groups.io
  0 siblings, 0 replies; 2+ messages in thread
From: gaoliming via groups.io @ 2023-08-24  1:14 UTC (permalink / raw)
  To: devel, nhi; +Cc: 'Jian J Wang', 'Hao A Wu'

Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>

> -----邮件原件-----
> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Nhi Pham via
> groups.io
> 发送时间: 2023年8月21日 11:41
> 收件人: devel@edk2.groups.io
> 抄送: Nhi Pham <nhi@os.amperecomputing.com>; Jian J Wang
> <jian.j.wang@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Hao A
> Wu <hao.a.wu@intel.c>
> 主题: [ ** SPAMMAIL ** ][edk2-devel] [PATCH 1/1]
> MdeModulePkg/PciBusDxe: Fix boot hang with faulty PCI Option ROM
> 
> A faulty PCI device has the Option ROM image size set to 0. UEFI reads
> two headers PCI_EXPANSION_ROM_HEADER and PCI_DATA_STRUCTURE to
> get the
> Option ROM information. Because the image size is 0, the Option ROM
> header address never changes. As a result, UEFI keeps reading the same
> two headers definitely. This patch is intended to fix it.
> 
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Hao A Wu <hao.a.wu@intel.c>
> Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
> ---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
> b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
> index 89f5f64101a5..bd5ace18f6e4 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
> @@ -506,13 +506,13 @@ LoadOpRomImage (
>      Indicator    = RomPcir->Indicator;
> 
>      RomImageSize = RomImageSize + RomPcir->ImageLength * 512;
> 
>      RomBarOffset = RomBarOffset + RomPcir->ImageLength * 512;
> 
> -  } while (((Indicator & 0x80) == 0x00) && ((RomBarOffset - RomBar) <
> RomSize));
> 
> +  } while (((Indicator & 0x80) == 0x00) && ((RomBarOffset - RomBar) <
> RomSize) && (RomImageSize > 0));
> 
> 
> 
>    //
> 
>    // Some Legacy Cards do not report the correct ImageLength so used the
> maximum
> 
>    // of the legacy length and the PCIR Image Length
> 
>    //
> 
> -  if (CodeType == PCI_CODE_TYPE_PCAT_IMAGE) {
> 
> +  if ((RomImageSize > 0) && (CodeType == PCI_CODE_TYPE_PCAT_IMAGE))
> {
> 
>      RomImageSize = MAX (RomImageSize, LegacyImageLength);
> 
>    }
> 
> 
> 
> --
> 2.25.1
> 
> 
> 
> 
> 





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107991): https://edk2.groups.io/g/devel/message/107991
Mute This Topic: https://groups.io/mt/100927966/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



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

end of thread, other threads:[~2023-08-24  1:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-21  3:40 [edk2-devel] [PATCH 1/1] MdeModulePkg/PciBusDxe: Fix boot hang with faulty PCI Option ROM Nhi Pham via groups.io
2023-08-24  1:14 ` 回复: [ ** SPAMMAIL ** ][edk2-devel] " gaoliming via groups.io

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