On Fri, 14 Feb 2020 at 07:44, Gaurav Jain <gaurav.j...@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.j...@nxp.com>
Reviewed-by: Ard Biesheuvel <ard.biesheu...@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 > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#54440): https://edk2.groups.io/g/devel/message/54440 Mute This Topic: https://groups.io/mt/71264395/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-