From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=helo; client-ip=2a01:111:f400:fe51::605; helo=nam05-dm3-obe.outbound.protection.outlook.com; envelope-from=garrett.kirkendall@amd.com; receiver=edk2-devel@lists.01.org Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-dm3nam05on0605.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe51::605]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DB57B21140F4C for ; Mon, 24 Sep 2018 06:19:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gT0AeUc16tndUFwXixa5loMl1e+iFTqfq+kKFePIfHM=; b=odQbwlN6dvPyTpEZmdjAxav+pseTud12oqMn4NknSwUXtmuIyhSMrTlJJ8JygMCIGhQ7VqW8f7N1WpmSJHXk468n0dpP9/m0PrFLxfD/NLpzk114fCUNtsBM8Nt7jsJ1/+vqPVWcxC4qR4IXbBWK5ETeXwEirH8RuoYVr+n/Cb4= Received: from SN1PR12MB0158.namprd12.prod.outlook.com (10.162.3.145) by SN1PR12MB2591.namprd12.prod.outlook.com (52.132.199.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.22; Mon, 24 Sep 2018 13:19:35 +0000 Received: from SN1PR12MB0158.namprd12.prod.outlook.com ([fe80::b13a:d70a:2bb1:2fc9]) by SN1PR12MB0158.namprd12.prod.outlook.com ([fe80::b13a:d70a:2bb1:2fc9%8]) with mapi id 15.20.1143.022; Mon, 24 Sep 2018 13:19:35 +0000 From: "Kirkendall, Garrett" To: Ruiyu Ni , "edk2-devel@lists.01.org" CC: Star Zeng Thread-Topic: [PATCH 2/3] MdeModulePkg/PciHostBridge: Fix a bug that prevents PMEM access Thread-Index: AQHUUXwvIv+1pONNY0++pf9k2F6En6T/bzSA Date: Mon, 24 Sep 2018 13:19:34 +0000 Message-ID: References: <20180921072539.268068-1-ruiyu.ni@intel.com> <20180921072539.268068-3-ruiyu.ni@intel.com> In-Reply-To: <20180921072539.268068-3-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Garrett.Kirkendall@amd.com; x-originating-ip: [165.204.77.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; SN1PR12MB2591; 20:eCfEfh3lfJrQCCGMjqY/TxFcgJ8q8FWBwQcMOCYXyqkBQCfiCrFfDHRhyZUcbrx7qQ1ivCg+5erXBS+DpW7iu/zLPnt5AoQsh2ZOT/JlL4R6U9ZnDKh5WglxLEwceax4qWVFcP/c7Ps+bqkfVbIPmpgufPmqWcR1fW0+RqVjJYATDZCdAxErsEG5eNE/xgCs45Ass1HwcJDeJUxQvVKWIyM71Nf81AROr+Qy2bMPthBd364yQLWRZFOo6vfhDley x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 37e1ce78-e513-4fef-2a66-08d622205f39 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:SN1PR12MB2591; x-ms-traffictypediagnostic: SN1PR12MB2591: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(81227570615382)(767451399110)(162533806227266)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231355)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(6055026)(149066)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201708071742011)(7699051); SRVR:SN1PR12MB2591; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB2591; x-forefront-prvs: 0805EC9467 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(346002)(39860400002)(376002)(366004)(13464003)(189003)(199004)(11346002)(446003)(476003)(86362001)(186003)(81166006)(6506007)(8676002)(81156014)(5660300001)(486006)(229853002)(99286004)(7696005)(6306002)(53936002)(9686003)(305945005)(55016002)(6436002)(71200400001)(71190400001)(68736007)(74316002)(102836004)(53546011)(7736002)(97736004)(316002)(3846002)(6116002)(14444005)(256004)(110136005)(6246003)(4326008)(478600001)(5250100002)(26005)(8936002)(2906002)(2501003)(2900100001)(966005)(66066001)(72206003)(105586002)(14454004)(76176011)(25786009)(106356001)(33656002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2591; H:SN1PR12MB0158.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: PMtuSkcQ/iK48qzh7MnRVgotzjQHN642IklZVidSsU0/7Sx+tfaNDJXL1dPwqICrddNx1y1vmyfGPQK3eqFIbO9P4GLCZxjHCP+75qSGUtqmf8EWCA03bXHwbguDwBowzuajatGJuy4g1frEhXiqju0XYLLEDZOx5AhPymFov0MuVT9ZGCirx1k4KJTE4TW7wzqeeqQmjcXAh009/gkRkEzDFJu2QZF+52N1y+O40zXB7BWQI3YsBJBk+VEJtE/sAAly2ZNzo2UnBXJlQAV0ORuVlj8ccbQqtV+b/R3ADS1GF87cfI9g75itNxi65TSX5j2p7wfQVRTgoNvvxoTLEuKMKu1YV7xw7GTd64xX+XM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37e1ce78-e513-4fef-2a66-08d622205f39 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2018 13:19:35.0062 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2591 Subject: Re: [PATCH 2/3] MdeModulePkg/PciHostBridge: Fix a bug that prevents PMEM access X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2018 13:19:39 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable GARRETT KIRKENDALL SMTS Firmware Engineer | CTE 7171 Southwest Parkway, Austin, TX 78735 USA=20 AMD=A0=A0 facebook=A0 |=A0 amd.com -----Original Message----- From: Ruiyu Ni =20 Sent: Friday, September 21, 2018 2:26 AM To: edk2-devel@lists.01.org Cc: Star Zeng ; Kirkendall; Kirkendall, Garrett Subject: [PATCH 2/3] MdeModulePkg/PciHostBridge: Fix a bug that prevents PM= EM access REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1196 RootBridgeIoCheckParameter() verifies that the requested MMIO access can fi= t in any of the MEM/PMEM 32/64 ranges. But today's logic somehow only check= s the requested access against MEM 32/64 ranges. It should also check the requested access against PMEM 32/64 ranges. The patch fixes this issue. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Kirkendall, Garrett --- MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c | 14 ++++++++++---= - 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c b/MdeM= odulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c index 0b6b56f846..f6234b5d11 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c @@ -411,12 +411,18 @@ RootBridgeIoCheckParameter ( // By comparing the Address against Limit we know which range to be us= ed // for checking // - if (Address + Length <=3D RootBridge->Mem.Limit + 1) { - Base =3D RootBridge->Mem.Base; + if ((Address >=3D RootBridge->Mem.Base) && (Address + Length <=3D Root= Bridge->Mem.Limit + 1)) { + Base =3D RootBridge->Mem.Base; Limit =3D RootBridge->Mem.Limit; - } else { - Base =3D RootBridge->MemAbove4G.Base; + } else if ((Address >=3D RootBridge->PMem.Base) && (Address + Length <= =3D RootBridge->PMem.Limit + 1)) { + Base =3D RootBridge->PMem.Base; + Limit =3D RootBridge->PMem.Limit; + } else if ((Address >=3D RootBridge->MemAbove4G.Base) && (Address + Le= ngth <=3D RootBridge->MemAbove4G.Limit + 1)) { + Base =3D RootBridge->MemAbove4G.Base; Limit =3D RootBridge->MemAbove4G.Limit; + } else { + Base =3D RootBridge->PMemAbove4G.Base; + Limit =3D RootBridge->PMemAbove4G.Limit; } } else { PciRbAddr =3D (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS*) &Address; -- 2.16.1.windows.1 Reviewed-by: Garrett Kirkendall