From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.77]) by mx.groups.io with SMTP id smtpd.web09.3047.1581662690725505688 for ; Thu, 13 Feb 2020 22:44:51 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nxp.com header.s=selector2 header.b=rOLYpQzN; spf=pass (domain: nxp.com, ip: 40.107.22.77, mailfrom: gaurav.jain@nxp.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UtNiTSoG0vNUK6uZTdUjgg9mddoa8ngewlNMDE9Zd0J5c2kkUNZz11rA8KfEudzLIe9Evm29kpr6HFr56ziNTgpUymiV/DrE0mNNTLOSw9mi8rqUEcCryhB5v7kGdgQop0c9iReGJ7e0wKKG8gPwpxmRaQFSU8dSltCOji6WiwCQk6w1SUT7LVwjAm8NVOwCj+MDEemdw2KgN4bEevHyk/ZtOqFMo7SMwZ7C/wCy8Td7m6HOIB2v1MT6b5WS+u67dUOqKyrmYgDj8Duut00/4Uada3L7azPiwWI6XilLTwM7lCfabPKkkjajjrtEMD2Nzu5Toad8UYFqKAw4qNTtQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o7O9LHHNBfBo5CRchorMpHEyV+cxFQuGharMXT4pFQw=; b=cMzKJB8aK44w+Q4R//uBhYoeGaQOvH05llCWxCLb4oBweqj+v+FOZJFcVx8m0KUcI6ZxyvjEF4PUEuGK+6B70h3QJCw8elpzIZRvuNfVMy5vbpnCZDpBOu6pA7HV3ndWjVpAPRCBFC8nd3215j2CMXXz0IcseOqjR5oYpSg0cl0uekRVtszgf8O6tg5caeXKkRzZZ5hJAngPoPMFQkmlq5oOXeLpJEx2cdnsYJoJ3RWebjilFQ59CjgKVDiMVbd+DeziqJyBOmzHeGhH5hbDGCgIGKut8l3K8/cyZGhoJz87iTEFNHUJPSbkh85KNt29rJiAXhk6ZmDXlDskKxHDaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o7O9LHHNBfBo5CRchorMpHEyV+cxFQuGharMXT4pFQw=; b=rOLYpQzNnKz9ivM1BkCIGOJDh8p8QIaTnEOFD9SlGfPpTm8LDAhHT+Xw7hyny7g6aDuTL72QX7Z1ks6jElMVZhMVg4rkq7/3EPKx02q5eBd6jXuA9ndECm/96kaCY+zPVjuqdOWsCkL7DgJltMNypZO3C/WGUhK6a1AICJFOQZo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=gaurav.jain@nxp.com; Received: from DB7PR04MB4091.eurprd04.prod.outlook.com (52.134.110.144) by DB7PR04MB4988.eurprd04.prod.outlook.com (20.176.234.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.23; Fri, 14 Feb 2020 06:44:48 +0000 Received: from DB7PR04MB4091.eurprd04.prod.outlook.com ([fe80::811d:4963:2158:c3f7]) by DB7PR04MB4091.eurprd04.prod.outlook.com ([fe80::811d:4963:2158:c3f7%5]) with mapi id 15.20.2707.031; Fri, 14 Feb 2020 06:44:48 +0000 From: "Gaurav Jain" To: devel@edk2.groups.io CC: Jian J Wang , Hao A Wu , Ray Ni , Pankaj Bansal , Gaurav Jain Subject: [PATCH 1/1] MdeModulePkg/Pci: Fixed SCT Issues in NonDiscoverablePciDevice. Date: Fri, 14 Feb 2020 17:34:23 +0530 Message-ID: <20200214120423.9615-1-gaurav.jain@nxp.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: BM1PR01CA0130.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:40::24) To DB7PR04MB4091.eurprd04.prod.outlook.com (2603:10a6:5:1e::16) Return-Path: gaurav.jain@nxp.com MIME-Version: 1.0 Received: from uefi-workstation.ap.freescale.net (92.120.1.69) by BM1PR01CA0130.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:40::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.24 via Frontend Transport; Fri, 14 Feb 2020 06:44:46 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [92.120.1.69] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: eaa3f9ff-e13a-4153-66d0-08d7b119623d X-MS-TrafficTypeDiagnostic: DB7PR04MB4988:|DB7PR04MB4988: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1186; X-Forefront-PRVS: 03137AC81E X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(396003)(366004)(376002)(346002)(136003)(189003)(199004)(6506007)(8936002)(66946007)(66556008)(8676002)(86362001)(6486002)(66476007)(2906002)(4326008)(6666004)(81166006)(81156014)(6916009)(186003)(478600001)(44832011)(2616005)(52116002)(16526019)(5660300002)(26005)(36756003)(6512007)(956004)(1076003)(54906003)(316002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB7PR04MB4988;H:DB7PR04MB4091.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kdGAjc0DMK6AXvCyravDZTYih35En6p0Lz/qVf5BIRbuYWQg7JW4Jary4H9Qntlg7uYG3InVcu6ZtLTclvFX8nG/X9fiFVdrQIXm/eXW2C3y+98CLDAfHPeZb1uKBgCXz1hvvSysRWpDgo0p7P8USWDeY7KfAXgefzQWSOuZHZgl9i5As4KsFRYBfQfyW1tLNGqetdHL6FioNj9wBVfCsaQprYURJmKKW39NHQtbB9+fToiHTaZ7BGb0VMX77IBvSvENFlVKlWhyDHqEmy3DdguRYRkgGARCCWMZoi3lK4/AzAV9VcVB2Slq9Foalr0Ti8N6Sx9KVrl/cVLsgn5dnd71qDFjB+3BRG0VA3zIiSdWK0dQ117zuTMAAuCPMvZMHSUz9Hajc6gQYbSITR4C1MN+broQHGxltJLoO4iwAcTVTwSwsNUAsh+MG/Hkcvrc X-MS-Exchange-AntiSpam-MessageData: meotX8/vznikO6F5MffrdB/Q/wudCqcNF7hTe/GNGztxDjJY7Qx5M95dwGavM3OVqVyZFU3MykHxdLB1dqNQFx2YwKUf5FHPO1ETiOD9tSuz1h6QTpF8R8TT8/bdgblMC5aNf8rWhRhyjMFJDPXvGg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: eaa3f9ff-e13a-4153-66d0-08d7b119623d X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2020 06:44:47.8863 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FZgAIgK+/Cm/P04nAm3b5+KSkh8DwczxF+mJh7tkbGS89HyMDVyo+qbQf+bxtnddDgnLe16i9H0RPaGlIUjX4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4988 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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 --- .../NonDiscoverablePciDeviceIo.c | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverab= lePciDeviceIo.c b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDisco= verablePciDeviceIo.c index 76cb000602fc..804e7e6cc834 100644 --- a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDe= viceIo.c +++ b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDe= viceIo.c @@ -243,6 +243,10 @@ PciIoMemRead ( EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Desc; EFI_STATUS Status; =20 + if (BarIndex >=3D PCI_MAX_BAR) { + return EFI_UNSUPPORTED; + } + if (Buffer =3D=3D NULL) { return EFI_INVALID_PARAMETER; } @@ -330,6 +334,10 @@ PciIoMemWrite ( EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Desc; EFI_STATUS Status; =20 + if (BarIndex >=3D PCI_MAX_BAR) { + return EFI_UNSUPPORTED; + } + if (Buffer =3D=3D NULL) { return EFI_INVALID_PARAMETER; } @@ -1302,13 +1310,22 @@ PciIoAttributes ( break; =20 case EfiPciIoAttributeOperationEnable: + if ((Attributes & (~DEV_SUPPORTED_ATTRIBUTES)) !=3D 0) { + return EFI_UNSUPPORTED; + } Attributes |=3D Dev->Attributes; case EfiPciIoAttributeOperationSet: + if ((Attributes & (~DEV_SUPPORTED_ATTRIBUTES)) !=3D 0) { + return EFI_UNSUPPORTED; + } Enable =3D ((~Dev->Attributes & Attributes) & EFI_PCI_DEVICE_ENABLE) != =3D 0; Dev->Attributes =3D Attributes; break; =20 case EfiPciIoAttributeOperationDisable: + if ((Attributes & (~DEV_SUPPORTED_ATTRIBUTES)) !=3D 0) { + return EFI_UNSUPPORTED; + } Dev->Attributes &=3D ~Attributes; break; =20 @@ -1369,6 +1386,10 @@ PciIoGetBarAttributes ( return EFI_INVALID_PARAMETER; } =20 + if (BarIndex >=3D PCI_MAX_BAR) { + return EFI_UNSUPPORTED; + } + Dev =3D NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This); =20 Status =3D GetBarResource (Dev, BarIndex, &BarDesc); --=20 2.17.1