From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.79]) by mx.groups.io with SMTP id smtpd.web11.3832.1587638637335172195 for ; Thu, 23 Apr 2020 03:43:58 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nxp.com header.s=selector2 header.b=Oe8QuWw5; spf=pass (domain: nxp.com, ip: 40.107.8.79, mailfrom: wasim.khan@nxp.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MyDcNk6eYljXz1Pp6nOdpmQX/TkNJMIoigN4LPkfuKFQ2PkbkX2BnJ7n3Wz1ax87bZNca1vdOuGMWna80GEeH+PaMXmtWxEaNee+RVGecZinGB6rWSh/2sqiy1lanp/XHdKo1p16uE9Xc3eO0g/TtcsL+dL9jm35Lk6ggH/TTYaHVhKgJm4AUkvWAzRJ/FOt9y6zHPA5wwXlrw7w5PM4vSOjwGHAC1r2B1tmopPgdS3occhtcnmn5sPXp1S5oeRLooZqRbklO6VlEUvyvUGIcNV/ck8m/s9G4WwGx0dtmWOQrocQP7pU27Wt7brjBvuHUAxOoiDAkMWCuY6ZUOOtTA== 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=kw4/9bF7ADNzi5xZArZ13UN1KOFRK/h2zgGXrbXPuIE=; b=MbeeSo9rrS3AGpvs2druOAv96+coPd1lvWYFdkCQp3fErpjbMmmu23vrAqM3oT9LMkzpgXI8vGF/RpLnNsIPLjPrthZVEVWJrjxBLzLdkwdJX9A8TG5aLlwp6FQ0RjoJT+VTEFHK8tWkpsBqOnpRaLVesjqUA8+x3JW02PPLlMwKRBiyXrvKWvI82vQTSECts8XPo2N6QZRet2evCUAljmhC5uc6tnBfcxyCopktLfwEH4XNyZHItM2pCMlmOjbh26oN5Px9L2rt2naPmd/ZvcIl7/Llx92dQ4QqC23G1nCwdhdFGzhOEshaHJyxxdGzYac9kw4sIJEUkMTFV26u9Q== 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=kw4/9bF7ADNzi5xZArZ13UN1KOFRK/h2zgGXrbXPuIE=; b=Oe8QuWw5Z4Mcwptm9+VWXHLObOJNRsuQS401nzSukGkrSODuKYnHQg6FIkV26BR+2/s+tplff8oKfVv1WGZ0u7VAsJFruCE5vjoMYN7YJ4XKGJMjNBk4pARfsrv9Q2ii6pr7m7iPfS9Ce+Xmqh4cmr05pP67WVo148ex4H2L500= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=wasim.khan@nxp.com; Received: from VE1PR04MB6702.eurprd04.prod.outlook.com (2603:10a6:803:123::13) by VE1PR04MB6686.eurprd04.prod.outlook.com (2603:10a6:803:125::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.13; Thu, 23 Apr 2020 10:43:55 +0000 Received: from VE1PR04MB6702.eurprd04.prod.outlook.com ([fe80::c092:8f65:8b04:dd28]) by VE1PR04MB6702.eurprd04.prod.outlook.com ([fe80::c092:8f65:8b04:dd28%5]) with mapi id 15.20.2937.012; Thu, 23 Apr 2020 10:43:55 +0000 From: "Wasim Khan" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, v.sethi@nxp.com, hao.a.wu@intel.com, ray.ni@intel.com, Wasim Khan Subject: [PATCH] MdeModulePkg/PciHostBridge: Update Mem and PMem Limit Checks Date: Thu, 23 Apr 2020 16:13:32 +0530 Message-Id: <1587638612-13056-1-git-send-email-wasim.khan@nxp.com> X-Mailer: git-send-email 2.7.4 X-ClientProxiedBy: PN1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:c::34) To VE1PR04MB6702.eurprd04.prod.outlook.com (2603:10a6:803:123::13) Return-Path: wasim.khan@nxp.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (157.37.82.244) by PN1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:c::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2937.13 via Frontend Transport; Thu, 23 Apr 2020 10:43:52 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [157.37.82.244] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4746c75d-07a6-462d-2707-08d7e773383f X-MS-TrafficTypeDiagnostic: VE1PR04MB6686:|VE1PR04MB6686: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1850; X-Forefront-PRVS: 03827AF76E X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6702.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(376002)(396003)(39860400002)(346002)(366004)(26005)(956004)(16526019)(2616005)(186003)(6512007)(5660300002)(2906002)(316002)(66476007)(6666004)(86362001)(81156014)(8936002)(66946007)(66556008)(8676002)(15650500001)(52116002)(4326008)(6506007)(69590400007)(6486002)(478600001)(44832011)(6916009)(36756003);DIR:OUT;SFP:1101; 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: Nknkt3M2+jm1HSCbVoic7s95L3/n2eOBdy+D4bSBfJVKM1nq8bWJoJ12PuYvBmQq5I8jxR+AbpBJJFENvDGEvmZkA0xhF02IqTJ1eXqjMwfLP94eRc+UuCFIpPvjptE3tzylziVrJy9J/n3gZDnjWD4DFYOJNc9z9tMxbk0VeYldfJwK22bFyXFTloBSBnEyj5Fis4iqJ12uzyemywzslAeQHmzleSNtcAO/Gkz9OiX1PCCQ0W79qoLXC8FlUvJ570y3gwjhC2LPYTu+DSmKH7Kw0I5Kf4AxJJ8Bf1vMdK/5eilIC413nM1EhRfUsSQ7It5u/XtGdRj2J4mQGlAZb5ckpt0Zsy+sRCW+0pJKq+wGClKRrfwFd/TAveaU8eCd+4P53vu7H/c5XBwEIAyKclHkQ1UDz8PBhJmTZBhJblYPZnlP+asfEkTUTKZN/xe15tLmv7GrOZpZq62d2XBRVDQSLf9yv6jvQYh9RRa+pZvlcznN0EbqAMS8VDYg0JeP X-MS-Exchange-AntiSpam-MessageData: 4xcwsXHF4BFHipQwy0JZj4h86E/H600YJpJHCzaKwUYi/u4Zkb7we+cb9W79g3BovHSyJJbA8a7JGl0v5eYEuOyXUVAINVPHq73/GsWS8XNxBZwDWSUAKpEerg9Qn1lRhrpRm6oyJTK6EM+sTwfCew== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4746c75d-07a6-462d-2707-08d7e773383f X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2020 10:43:54.9231 (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: NUnwkq9QGThYuWTDUskRWeyFkAaqiA/O0gtS+SqQlc3tsEaHO7SMoSetl7LEyR+rCBCtvA89wD0rUzEnzDhJ4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6686 Content-Type: text/plain With Address Translation Support, it is possible and also correct that Mem and Pmem Limit cross the 4GB boundary. Update the checks so that Mem/PMem Limit should not cross 4GB from the Mem/PMem Base address. Signed-off-by: Wasim Khan --- MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c index d304fae..9cf7e98 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c @@ -117,8 +117,8 @@ CreateRootBridge ( // Make sure Mem and MemAbove4G apertures are valid // if (RESOURCE_VALID (&Bridge->Mem)) { - ASSERT (Bridge->Mem.Limit < SIZE_4GB); - if (Bridge->Mem.Limit >= SIZE_4GB) { + ASSERT (Bridge->Mem.Limit < (Bridge->Mem.Base + SIZE_4GB)); + if (Bridge->Mem.Limit >= (Bridge->Mem.Base + SIZE_4GB)) { return NULL; } } @@ -129,8 +129,8 @@ CreateRootBridge ( } } if (RESOURCE_VALID (&Bridge->PMem)) { - ASSERT (Bridge->PMem.Limit < SIZE_4GB); - if (Bridge->PMem.Limit >= SIZE_4GB) { + ASSERT (Bridge->PMem.Limit < (Bridge->PMem.Base + SIZE_4GB)); + if (Bridge->PMem.Limit >= (Bridge->PMem.Base + SIZE_4GB)) { return NULL; } } -- 2.7.4