public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Re: [edk2-devel] [PATCH 1/1] MdeModulePkg/Pci: Fixed SCT Issues in NonDiscoverablePciDevice.
  2020-02-14 12:04 [PATCH 1/1] MdeModulePkg/Pci: Fixed SCT Issues in NonDiscoverablePciDevice Gaurav Jain
@ 2020-02-14 12:00 ` Ard Biesheuvel
  0 siblings, 0 replies; 2+ messages in thread
From: Ard Biesheuvel @ 2020-02-14 12:00 UTC (permalink / raw)
  To: edk2-devel-groups-io, Gaurav Jain
  Cc: Jian J Wang, Hao A Wu, Ray Ni, Pankaj Bansal

On Fri, 14 Feb 2020 at 07:44, Gaurav Jain <gaurav.jain@nxp.com> wrote:
>
> GetBarAttributes, MemRead, MemWrite consistency test failed
> with Invalid BarIndex.
> Added check for BarIndex and return Invalid Parameter.
>
> PCI Controller Attribute operation with Unsupported Attributes
> is failing.
> Added check to return Unsupported when wrong attributed are set.
>
> Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com>

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>

> ---
>  .../NonDiscoverablePciDeviceIo.c              | 21 +++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
> index 76cb000602fc..804e7e6cc834 100644
> --- a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
> +++ b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
> @@ -243,6 +243,10 @@ PciIoMemRead (
>    EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR   *Desc;
>    EFI_STATUS                          Status;
>
> +  if (BarIndex >= PCI_MAX_BAR) {
> +    return EFI_UNSUPPORTED;
> +  }
> +
>    if (Buffer == NULL) {
>      return EFI_INVALID_PARAMETER;
>    }
> @@ -330,6 +334,10 @@ PciIoMemWrite (
>    EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR   *Desc;
>    EFI_STATUS                          Status;
>
> +  if (BarIndex >= PCI_MAX_BAR) {
> +    return EFI_UNSUPPORTED;
> +  }
> +
>    if (Buffer == NULL) {
>      return EFI_INVALID_PARAMETER;
>    }
> @@ -1302,13 +1310,22 @@ PciIoAttributes (
>      break;
>
>    case EfiPciIoAttributeOperationEnable:
> +    if ((Attributes & (~DEV_SUPPORTED_ATTRIBUTES)) != 0) {
> +      return EFI_UNSUPPORTED;
> +    }
>      Attributes |= Dev->Attributes;
>    case EfiPciIoAttributeOperationSet:
> +    if ((Attributes & (~DEV_SUPPORTED_ATTRIBUTES)) != 0) {
> +      return EFI_UNSUPPORTED;
> +    }
>      Enable = ((~Dev->Attributes & Attributes) & EFI_PCI_DEVICE_ENABLE) != 0;
>      Dev->Attributes = Attributes;
>      break;
>
>    case EfiPciIoAttributeOperationDisable:
> +    if ((Attributes & (~DEV_SUPPORTED_ATTRIBUTES)) != 0) {
> +      return EFI_UNSUPPORTED;
> +    }
>      Dev->Attributes &= ~Attributes;
>      break;
>
> @@ -1369,6 +1386,10 @@ PciIoGetBarAttributes (
>      return EFI_INVALID_PARAMETER;
>    }
>
> +  if (BarIndex >= PCI_MAX_BAR) {
> +    return EFI_UNSUPPORTED;
> +  }
> +
>    Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
>
>    Status = GetBarResource (Dev, BarIndex, &BarDesc);
> --
> 2.17.1
>
>
> 
>

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

* [PATCH 1/1] MdeModulePkg/Pci: Fixed SCT Issues in NonDiscoverablePciDevice.
@ 2020-02-14 12:04 Gaurav Jain
  2020-02-14 12:00 ` [edk2-devel] " Ard Biesheuvel
  0 siblings, 1 reply; 2+ messages in thread
From: Gaurav Jain @ 2020-02-14 12:04 UTC (permalink / raw)
  To: devel; +Cc: Jian J Wang, Hao A Wu, Ray Ni, Pankaj Bansal, Gaurav Jain

GetBarAttributes, MemRead, MemWrite consistency test failed
with Invalid BarIndex.
Added check for BarIndex and return Invalid Parameter.

PCI Controller Attribute operation with Unsupported Attributes
is failing.
Added check to return Unsupported when wrong attributed are set.

Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com>
---
 .../NonDiscoverablePciDeviceIo.c              | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
index 76cb000602fc..804e7e6cc834 100644
--- a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
+++ b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
@@ -243,6 +243,10 @@ PciIoMemRead (
   EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR   *Desc;
   EFI_STATUS                          Status;
 
+  if (BarIndex >= PCI_MAX_BAR) {
+    return EFI_UNSUPPORTED;
+  }
+
   if (Buffer == NULL) {
     return EFI_INVALID_PARAMETER;
   }
@@ -330,6 +334,10 @@ PciIoMemWrite (
   EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR   *Desc;
   EFI_STATUS                          Status;
 
+  if (BarIndex >= PCI_MAX_BAR) {
+    return EFI_UNSUPPORTED;
+  }
+
   if (Buffer == NULL) {
     return EFI_INVALID_PARAMETER;
   }
@@ -1302,13 +1310,22 @@ PciIoAttributes (
     break;
 
   case EfiPciIoAttributeOperationEnable:
+    if ((Attributes & (~DEV_SUPPORTED_ATTRIBUTES)) != 0) {
+      return EFI_UNSUPPORTED;
+    }
     Attributes |= Dev->Attributes;
   case EfiPciIoAttributeOperationSet:
+    if ((Attributes & (~DEV_SUPPORTED_ATTRIBUTES)) != 0) {
+      return EFI_UNSUPPORTED;
+    }
     Enable = ((~Dev->Attributes & Attributes) & EFI_PCI_DEVICE_ENABLE) != 0;
     Dev->Attributes = Attributes;
     break;
 
   case EfiPciIoAttributeOperationDisable:
+    if ((Attributes & (~DEV_SUPPORTED_ATTRIBUTES)) != 0) {
+      return EFI_UNSUPPORTED;
+    }
     Dev->Attributes &= ~Attributes;
     break;
 
@@ -1369,6 +1386,10 @@ PciIoGetBarAttributes (
     return EFI_INVALID_PARAMETER;
   }
 
+  if (BarIndex >= PCI_MAX_BAR) {
+    return EFI_UNSUPPORTED;
+  }
+
   Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
 
   Status = GetBarResource (Dev, BarIndex, &BarDesc);
-- 
2.17.1


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

end of thread, other threads:[~2020-02-14 12:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-14 12:04 [PATCH 1/1] MdeModulePkg/Pci: Fixed SCT Issues in NonDiscoverablePciDevice Gaurav Jain
2020-02-14 12:00 ` [edk2-devel] " Ard Biesheuvel

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