Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3324813imm; Sun, 30 Sep 2018 17:51:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV623vSDFY/YFmH/2fenZJvTBMCKPUf0sloLHOwhENt72QXqt5g/v9VI6Xt0Vo6Kcw5aiKUnf X-Received: by 2002:a63:5c10:: with SMTP id q16-v6mr8012898pgb.452.1538355112701; Sun, 30 Sep 2018 17:51:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538355112; cv=none; d=google.com; s=arc-20160816; b=snFaqfPyLu31+b6QJ45JKj0JHCtLTnMHTWO4U6PXNQrVjb+8k6NxKToRsPo6huSEt7 VejsnZZ+7xxQ3K4qBqTMcHXTwP2soXFxai4XEhXQ/X6BYX3avFLmO31Uaz3o8laAcgnV ytsFJSfN5+L6u8O9R5t/9ok/nI5UsEiYNf7AC1o08GpfvbMyHu9XdwI81JYrmJJAcfww 4TggUBiDYz+PP3QmjGqXIRdc4jYfpc/K2bfrfRMV6KMu9vwjX2tdr3BBwqCMabel2aEb O8Obmrwhp9M7SxgiDZ40T/lwBNJrqrbkL6Nrv5RkpNCwrANdk9Z/uHYu8O30U5wRoUpo N7CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=yfdcYUvoZBsH8wfFZ9yUYk+IR5ZtjJIeTaHXCw8Hzww=; b=zIqBc6fsYSC4bKWF+mwvh+zyusGYUzA4K2D/63LxCz7pmcv+y6WsYR59OVxeJZDjhn W5Kl6FyVxRccrWzhnl4KwAmc6Nv54wi7B/Oyg3h/N7cOtwpSpu2dX/7GkLn4SP77C9r2 0ATL9kq2G6qLDdGnTL/y6uXgs6sSJcEZAwB18pRm6hQxLu8NIcl/aXAv+suNFkVC2QXY Dal0+1SGKM5VQaqlRbO19hVTAV0EqndTKT3XPGqbzGPOuRMGAgHT5mA085M9Z7nBpyRu 0q9g4FutUr1Gi4oh3q8MQWwNi08k9GacYVc495gETXV0+o71VSp3HV/5WfLt2MDzBcNW ysag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=SqLZ4WeB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 60-v6si11309277pla.487.2018.09.30.17.51.38; Sun, 30 Sep 2018 17:51:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=SqLZ4WeB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729379AbeJAHOp (ORCPT + 99 others); Mon, 1 Oct 2018 03:14:45 -0400 Received: from mail-by2nam03on0120.outbound.protection.outlook.com ([104.47.42.120]:46043 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728345AbeJAHOp (ORCPT ); Mon, 1 Oct 2018 03:14:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yfdcYUvoZBsH8wfFZ9yUYk+IR5ZtjJIeTaHXCw8Hzww=; b=SqLZ4WeB2sUxF9YVGcDGAcXuBCFbZF+MrCLyGJlYIU8JHZYcp1TFW/YhiDH1nmtb3NfWdXCvcfJg6k402UYQnRX5nFNg/LINSBzQ6kHtOe+OvqngFPadOCCS8g+4B5XAMIb3CG+Ws0md5lV+ZxoZouSWt7Lm1e1cWj48qL8INVM= Received: from CY4PR21MB0776.namprd21.prod.outlook.com (10.173.192.22) by CY4PR21MB0696.namprd21.prod.outlook.com (10.175.121.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.6; Mon, 1 Oct 2018 00:39:36 +0000 Received: from CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::54e2:88e0:b622:b36]) by CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::54e2:88e0:b622:b36%5]) with mapi id 15.20.1228.006; Mon, 1 Oct 2018 00:39:36 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Andrew Murray , Will Deacon , Sasha Levin Subject: [PATCH AUTOSEL 4.18 61/65] asm-generic: io: Fix ioport_map() for !CONFIG_GENERIC_IOMAP && CONFIG_INDIRECT_PIO Thread-Topic: [PATCH AUTOSEL 4.18 61/65] asm-generic: io: Fix ioport_map() for !CONFIG_GENERIC_IOMAP && CONFIG_INDIRECT_PIO Thread-Index: AQHUWR8ZrTRycVXQA0Sgs3xjR1fIQg== Date: Mon, 1 Oct 2018 00:38:40 +0000 Message-ID: <20181001003754.146961-61-alexander.levin@microsoft.com> References: <20181001003754.146961-1-alexander.levin@microsoft.com> In-Reply-To: <20181001003754.146961-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY4PR21MB0696;6:qr4UkH5whdr12/RXsufcFSQTZLKaDhuPps0yPmJPWlKJN4gB/S5kpUTRQbircHIkpTWjinPimaijS8dNI2k2OP+1mioHroTqRQ2xc9ZDxnFUU1gU2zaOFAnN/jWiKf/iBh8EuS7KwVPw23Xjm0ZDKOX1ViQH+6O+0wDG1sWIEQef5SjmT/GLkN0A6N6K5lvxGYujC9gBHXKj/MosT19vpc834JZZ87d66CPvQjfFbKG7nYdsq/auHZnp8RDeUpfo6mqfv3lG26Nu1CEWGUlasmPyJxy4piUnF42XOSYbleoofIuyXGpfPRJurpUwbdnzf75EVi/v+lrpWUkz3JZQb5MUdjnvi3wlZTX5te8Acd54jdyXUCVgwYJL+CJXG+lVvg6nZtJMhE7vQdiTL/DHzV4WOwy2S4EQ0o6P+cgbtuyYBpr1BtgyXM3irNGVjjbOivjHy/pKoMGVKA70FjELPg==;5:8Ss/RmmgsAWO+ZtNdY5KvrLTKF1TkH+KDDiftpDvWiAMHKf6Tfm6tp0UM+eH5wpWkdoZeBHnc79utykEGomcl3zYkVcxD3fh/NyFfoFGmbx+AsterDajKy14t3jYIhU5q/lyunRgq3OoTCBwyWj7wMcOTirtFvUnTQGlF0hWlqo=;7:flWf6h730gUKcrKGG7Ld4yRgmUn+fHIecjzKP8OPyM9Qs8lWMtx52q9N+afNHMYguMcRuBFbJ+q0pyCyAeJUzxo2EdqUqzrKtM1+R1J0HiWSJVuXMGPk/Mj3gdDQlfSXl3kDLyqK5VisTs+ZGBwFrFHLzx/O+VxKtQAJ7F5agMkmZqWjMxjf0iFv+LQkl8qXseBsiOXsnbjRSklKaAhSHbiTCpl55Tdn57jnMqSmVD+5bG2fMyQcmGJR+Wsx+F74 x-ms-office365-filtering-correlation-id: a00f7903-875c-4c42-55cc-08d627365d29 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)(7193020);SRVR:CY4PR21MB0696; x-ms-traffictypediagnostic: CY4PR21MB0696: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(28532068793085)(89211679590171); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231355)(944501410)(52105095)(2018427008)(93006095)(93001095)(10201501046)(6055026)(149066)(150057)(6041310)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991041);SRVR:CY4PR21MB0696;BCL:0;PCL:0;RULEID:;SRVR:CY4PR21MB0696; x-forefront-prvs: 0812095267 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(39860400002)(396003)(346002)(136003)(366004)(189003)(199004)(3846002)(6116002)(5250100002)(71200400001)(97736004)(217873002)(71190400001)(1076002)(76176011)(6506007)(99286004)(11346002)(26005)(86362001)(575784001)(36756003)(2501003)(446003)(2906002)(86612001)(102836004)(2616005)(476003)(14454004)(107886003)(10090500001)(14444005)(4326008)(34290500001)(316002)(486006)(22452003)(256004)(186003)(66066001)(53936002)(305945005)(25786009)(2900100001)(106356001)(6486002)(105586002)(7736002)(6512007)(81156014)(81166006)(6666003)(8936002)(8676002)(5660300001)(68736007)(54906003)(110136005)(6436002)(10290500003)(72206003)(478600001)(41533002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR21MB0696;H:CY4PR21MB0776.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 56e91YG9BNwICcwcjftP5jJUIDQ9yRK8oO/EZseSmCsGxxX7VAnwRGrZi7Of1155DsevcyGtMzYOqSXZwHFm6BXP+qHWUJoNayUxMPFLpTqKytCMUI/GWkAHl41spoh8frz7hOlKLsHnasXWdKnHGUQ+VndAY5IynQbH/yVXyh4lDMOdOX037xWZtt6HXeEDmrmLL2gm8LdeEyWyEw071T7VEq+cL0gWlDDB4v18mdVGv+vJYvJRFJ5qBRduOHchiDuyJAHk31ckgqtn19qFrSkRekb7GbWtodkBsrxXuoHy48x0TOzYO6mktdJV1qHPOMoNBGBxtInKWqJkWcA1NZIuZs2rh6NVFkJ3IvbX7u4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: a00f7903-875c-4c42-55cc-08d627365d29 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Oct 2018 00:38:40.9001 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0696 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Murray [ Upstream commit 500dd232449e7c07500e713dc6970aa713f8e4f1 ] The !CONFIG_GENERIC_IOMAP version of ioport_map uses MMIO_UPPER_LIMIT to prevent users from making I/O accesses outside the expected I/O range - however it erroneously treats MMIO_UPPER_LIMIT as a mask which is contradictory to its other users. The introduction of CONFIG_INDIRECT_PIO, which subtracts an arbitrary amount from IO_SPACE_LIMIT to form MMIO_UPPER_LIMIT, results in ioport_map mangling the given port rather than capping it. We address this by aligning more closely with the CONFIG_GENERIC_IOMAP implementation of ioport_map by using the comparison operator and returning NULL where the port exceeds MMIO_UPPER_LIMIT. Though note that we preserve the existing behavior of masking with IO_SPACE_LIMIT such that we don't break existing buggy drivers that somehow rely on this masking. Fixes: 5745392e0c2b ("PCI: Apply the new generic I/O management on PCI IO h= osts") Reported-by: Will Deacon Reviewed-by: Arnd Bergmann Signed-off-by: Andrew Murray Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- include/asm-generic/io.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 66d1d45fa2e1..d356f802945a 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1026,7 +1026,8 @@ static inline void __iomem *ioremap_wt(phys_addr_t of= fset, size_t size) #define ioport_map ioport_map static inline void __iomem *ioport_map(unsigned long port, unsigned int nr= ) { - return PCI_IOBASE + (port & MMIO_UPPER_LIMIT); + port &=3D IO_SPACE_LIMIT; + return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port; } #endif =20 --=20 2.17.1