From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from IMSVA.IN.MEGATRENDS.COM (IMSVA.IN.MEGATRENDS.COM [14.98.235.2]) by mx.groups.io with SMTP id smtpd.web12.1864.1575453989653549602 for ; Wed, 04 Dec 2019 02:06:30 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=SPF record not found (domain: amiindia.co.in, ip: 14.98.235.2, mailfrom: sivaramann@amiindia.co.in) Received: from IMSVA.IN.MEGATRENDS.COM (IMSVA.IN.MEGATRENDS.COM [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 16B1682058; Wed, 4 Dec 2019 15:43:27 +0530 (IST) Received: from IMSVA.IN.MEGATRENDS.COM (IMSVA.IN.MEGATRENDS.COM [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E6D5D82055; Wed, 4 Dec 2019 15:43:26 +0530 (IST) Received: from webmail.amiindia.co.in (venus2.in.megatrends.com [10.0.0.7]) by IMSVA.IN.MEGATRENDS.COM (Postfix) with ESMTPS; Wed, 4 Dec 2019 15:43:26 +0530 (IST) Received: from VENUS1.in.megatrends.com ([fe80::951:7975:6ecf:eae5]) by Venus2.in.megatrends.com ([fe80::2002:4a07:4f17:c09b%14]) with mapi id 14.03.0248.002; Wed, 4 Dec 2019 15:36:25 +0530 From: "Sivaraman Nainar" To: "devel@edk2.groups.io" CC: "Wu, Jiaxin" Subject: reg: [edk2] [PATCH v1] NetworkPkg/SNPDxe: Validate the Memory BAR as per UEFI Spec Thread-Topic: [edk2] [PATCH v1] NetworkPkg/SNPDxe: Validate the Memory BAR as per UEFI Spec Thread-Index: AdWbeGdXACx7BsgKQou3Y0Gp/Y38pwO/2f7AAASoLRA= Date: Wed, 4 Dec 2019 10:06:24 +0000 Message-ID: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [106.198.90.211] MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSVA-9.1.0.1817-8.5.0.1020-25082.006 X-TM-AS-Result: No--11.551-5.0-31-10 X-imss-scan-details: No--11.551-5.0-31-10 X-TMASE-Version: IMSVA-9.1.0.1817-8.5.1020-25082.006 X-TMASE-Result: 10--11.551100-10.000000 X-TMASE-MatchedRID: f3WjXhSioeneXhoYTo4O1X4neC0h7SADBGvINcfHqheOSVCvVHWJJ7Me apFjC2iROG+C3yGUyy7L2oPdJK38miirxlIJMr5pLFirdaqw+KF+CWCcHScOE/meJRfwluYG+WA X4qDxTxF8wxbc9zd2B0mlX2scVfePArfIDVjQDX7BtFDYGmaWKhrL4FDGAJ+FCwWRLqiC/UqTvZ kBseIwt0mu4uFjBmMBf9krIFPI8jVu7xCoxCPC8oDcpVWyPxAMqAn+yHbzwCcwMfxyID/dnSKFM AffXyNK5boxPkD0a9PkDSnQ4pt5DQ5VocU4CFzq5rnnDTmVbKrQevMKEpazywZamccMPRne3yZ/ GJmw8EZSLd7cFdaYX9T42FdBOMA8kfRhdidsajMURSScn+QSXsidYBYDjITpLzP5snaeb1S8mof WgmFAh58Ulv1u8xn0FNURJV8gtgReaZX1kLyBquOWZGqAFV+4APTctuLa8/rGGNKPcTiwgxmInu jT8zxxcGizYjZcGqAXI958XY81SQ== X-TMASE-SNAP-Result: 1.821001.0001-0-1-12:0,22:0,33:0,34:0-0 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_B4DE137BDB63634BAC03BD9DE765F197029AE4D966VENUS1inmegat_" --_000_B4DE137BDB63634BAC03BD9DE765F197029AE4D966VENUS1inmegat_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2335 This patch is to check the PCI Memory Base Address Register is valid or not= . *** a\NetworkPkg\SnpDxe\Snp.c 2019-11-11 16:53:40.773300500 +0530 --- b\NetworkPkg\SnpDxe\Snp.c 2019-11-03 18:46:= 02.000000000 +0530 *************** SimpleNetworkDriverStart ( *** 266,272 **** UINT8 BarIndex; PXE_STATFLAGS InitStatFlags; EFI_PCI_IO_PROTOCOL *PciIo; ! EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR *BarDesc =3D NULL; BOOLEAN FoundIoBar; BOOLEAN FoundMemoryBar; --- 266,272 ---- UINT8 BarIndex; PXE_STATFLAGS InitStatFlags; EFI_PCI_IO_PROTOCOL *PciIo; ! EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *BarDesc; BOOLEAN FoundIoBar; BOOLEAN FoundMemoryBar; *************** SimpleNetworkDriverStart ( *** 481,494 **** } else if (EFI_ERROR (Status)) { goto Error_DeleteSNP; } ! //PXE boot fails with cards having non-continuous BAR. ! // From UEFI Spec, GetBarAttributes can have only descriptor= s of type ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR ! // and ACPI_END_TAG_DESCRIPTOR. ! if( BarDesc->Header.Header.Byte !=3D ACPI_QWORD_ADDRESS_SPACE_DESCRIP= TOR ) { ! FreePool (BarDesc); ! continue; ! } ! if ((!FoundMemoryBar) && (BarDesc->ResType =3D=3D ACPI_ADDRESS_SPACE_= TYPE_MEM)) { Snp->MemoryBarIndex =3D BarIndex; FoundMemoryBar =3D TRUE; --- 481,487 ---- } else if (EFI_ERROR (Status)) { goto Error_DeleteSNP; } ! if ((!FoundMemoryBar) && (BarDesc->ResType =3D=3D ACPI_ADDRESS_SPACE_= TYPE_MEM)) { Snp->MemoryBarIndex =3D BarIndex; FoundMemoryBar =3D TRUE; --_000_B4DE137BDB63634BAC03BD9DE765F197029AE4D966VENUS1inmegat_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

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

 

This patch is to check the PCI Memory Base Addres= s Register is valid or not.

 

*** a\NetworkPkg\SnpDxe\Snp.c   &n= bsp;       2019-11-11 16:53:40.773300500 += ;0530

--- b\NetworkPkg\SnpDxe\Snp.c   &n= bsp;            = ;             2= 019-11-03 18:46:02.000000000 +0530

*************** SimpleNetworkDriverStart (

*** 266,272 ****

    UINT8    &= nbsp;           &nbs= p;            &= nbsp;       BarIndex;

    PXE_STATFLAGS   = ;            &n= bsp;            = ; InitStatFlags;

    EFI_PCI_IO_PROTOCOL  = ;            &n= bsp;        *PciIo;

!   EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRI= PTOR   *BarDesc =3D NULL;

    BOOLEAN    = ;            &n= bsp;            = ;      FoundIoBar;

    BOOLEAN    = ;            &n= bsp;            = ;      FoundMemoryBar;

 

--- 266,272 ----

    UINT8    &= nbsp;           &nbs= p;            &= nbsp;       BarIndex;

   PXE_STATFLAGS   =             &nb= sp;            = InitStatFlags;

    EFI_PCI_IO_PROTOCOL  = ;            &n= bsp;        *PciIo;

!   EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR&n= bsp;        *BarDesc;

    BOOLEAN    = ;            &n= bsp;            = ;      FoundIoBar;

    BOOLEAN    = ;             &= nbsp;           &nbs= p;     FoundMemoryBar;

 

*************** SimpleNetworkDriverStart (

*** 481,494 ****

      } else if (EFI_ERR= OR (Status)) {

        goto E= rror_DeleteSNP;

      }

!         = ;     //PXE boot fails with cards having non-continuous= BAR.

!         = ;     // From UEFI Spec, GetBarAttributes can have only= descriptors of type ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR

!     // and ACPI_END_TAG_DES= CRIPTOR.

!     if( BarDesc->Header.= Header.Byte !=3D ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR )  {

!       FreePool (B= arDesc);

!       continue;

!     }

!    

      if ((!FoundMe= moryBar) && (BarDesc->ResType =3D=3D ACPI_ADDRESS_SPACE_TYPE_MEM= )) {

        Snp-&g= t;MemoryBarIndex =3D BarIndex;

        FoundM= emoryBar      =3D TRUE;

--- 481,487 ----

      } else if (EFI_ERR= OR (Status)) {

        goto E= rror_DeleteSNP;

      }

!

      if ((!FoundMe= moryBar) && (BarDesc->ResType =3D=3D ACPI_ADDRESS_SPACE_TYPE_MEM= )) {

        Snp-&g= t;MemoryBarIndex =3D BarIndex;

        FoundM= emoryBar      =3D TRUE;

 

--_000_B4DE137BDB63634BAC03BD9DE765F197029AE4D966VENUS1inmegat_--