Received: by 10.213.65.68 with SMTP id h4csp2175926imn; Sun, 8 Apr 2018 21:43:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx49+K6z7x01QctFKs7YuXdC/+uarZyNJksW7dQI3kKGPv4SblbzBpaxGrAEKGSeLlnWm8/9/ X-Received: by 10.99.120.74 with SMTP id t71mr24508329pgc.310.1523249037164; Sun, 08 Apr 2018 21:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523249037; cv=none; d=google.com; s=arc-20160816; b=DGrFFn9xFYS4+7ogwalfT4ap6wjRaEfrPHD5ASZsdDre88/vHEe34yLdwwIamS5Ift hT6z5TJBW5Mt/ZBEobsV3oyFzqQyxqPiCjlqdUO3KCBULL010OhVlQBfoipMYpNmnsxM +XAxN9548x6LBG+npksz9Ojf5z+mrVbSnm2Z7c3WiXy7XB9G/i+5mZIvTXqVqltuKKK/ O+esYCcnJFthaXolZETqigG0hzLrl/MRxLUTXHr5dUGqEvvEx1Uqde/MGLDEasj/IqlA um7AGIEcXPcQypr1XszQSYivLd1adSQVCg2WN6Z84t6p4eRYwZE0YIQKAHzzsokcIp/d HTdQ== 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:message-id:date:thread-index:thread-topic:subject :cc:to:from:dkim-signature:arc-authentication-results; bh=cyLyUudzxd+SYlMT9SXSmO+DFj27A80isja3MVgnOPA=; b=x+kGQfhbxIdf5ZsHZ7/JsY3EObZCQ8gtY7lnbcR0tl+dhTGEbHgVh2DpCYnrKB8Dtx j7fuhFHFfNCy+VussYh+2n0kyNj5KjdZ/4NiiQMnITl47OFy85eRsZuCe7hXgZvMHosv ojR8sKmX2d+PQkMrK9ax2akWlPaWDrUYUAXNOaS5EXOVO4Fee61rHSzZyJEV/xJpgx4Z 6bBwWcSlH8iER5lAwb7xvyBnp2JahsW5LaHvhdkbgnrr2yCyB/oQgATGKaAMPDxCmA49 JIzCNAYvMBkabfP7/6sC/kFqR3ZyUSnlEwRdIm1jrpG7BYSrmsUg97szmsFe10IqwgOl gUNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=LM+ssAqB; 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 p20-v6si14031656plo.284.2018.04.08.21.43.17; Sun, 08 Apr 2018 21:43:57 -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=LM+ssAqB; 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 S1752484AbeDIAQs (ORCPT + 99 others); Sun, 8 Apr 2018 20:16:48 -0400 Received: from mail-cys01nam02on0097.outbound.protection.outlook.com ([104.47.37.97]:28800 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751775AbeDIAQq (ORCPT ); Sun, 8 Apr 2018 20:16:46 -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; bh=cyLyUudzxd+SYlMT9SXSmO+DFj27A80isja3MVgnOPA=; b=LM+ssAqBby10rmx5rzOrSLk+CFntunce9NEFlCjS22PQ5sXFdMOXIi7zXlix20vCg31YFmwNicPIfcFPt8ZOVQmLfqU64cQkb2EzprkxgxQvL5sbtjqNS6nMkjMcGolPPbKUC0ruba1wLw8+DVwx33xKhT2bjJPjGNhai7TRjR0= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0968.namprd21.prod.outlook.com (52.132.133.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:16:44 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:16:44 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Hector Martin , Stefan Richter , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 001/189] firewire-ohci: work around oversized DMA reads on JMicron controllers Thread-Topic: [PATCH AUTOSEL for 4.15 001/189] firewire-ohci: work around oversized DMA reads on JMicron controllers Thread-Index: AQHTz5gKKJGVd7y6pUmh5HcKqg5SAQ== Date: Mon, 9 Apr 2018 00:16:44 +0000 Message-ID: <20180409001637.162453-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;DM5PR2101MB0968;7:wsALSiM65uqmmHdI8j/ywWNWM7C+4FWTeb+GKpkWLQ1wkc6J1vC91n+tygluQEtR2jRVa9GJ36yeBV5asbDg5IJk61J7ced5hGYEBGZJ7XPmXz50Q/+nqk3FIDeak/eLoitEoeOerHEwgZgtmLNmSDAbG0RAKRcuZJZiiKQ/XWxhtcEWr3ZO0kHC0wJdZkOQWRvLPxLSmHbJIU81PPovit6ZiC290+vuzgzTmSgcqSSBnjt9o/2kIfPXbr2MnJHf;20:sBm1NaGIqoG6mfxPhE4ptFGlMWZ05nvBxJA9uz/KRKWOyQhfVZ84Ca0To+ufIi87zFuimVwLCL67wTViMFgfWK/PEXEViYUNltsIF7tuCBgFvez4J3QXxqGQBJLg4PmaARaff84uvK5+1V4+GHh7ckstk7fUeg1etb77kN6/Jl8= x-ms-exchange-antispam-srfa-diagnostics: SOS; X-MS-Office365-Filtering-Correlation-Id: 1b3532cb-8f05-40e9-5d7e-08d59daf2cf4 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7193020);SRVR:DM5PR2101MB0968; x-ms-traffictypediagnostic: DM5PR2101MB0968: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0968;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0968; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(376002)(366004)(346002)(39380400002)(396003)(189003)(199004)(6486002)(53936002)(107886003)(81156014)(36756003)(10290500003)(6436002)(81166006)(5660300001)(478600001)(8936002)(8676002)(6512007)(106356001)(105586002)(5250100002)(2900100001)(7736002)(305945005)(2501003)(10090500001)(66066001)(25786009)(476003)(3846002)(6116002)(186003)(2616005)(59450400001)(68736007)(6506007)(486006)(14454004)(86362001)(99286004)(26005)(102836004)(22452003)(2906002)(316002)(3660700001)(110136005)(97736004)(86612001)(3280700002)(1076002)(4326008)(54906003)(72206003)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0968;H:DM5PR2101MB1032.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: hrSH55N6QBor+eaTVjCGvX0AOTQwN4V8QPxChCRtwqQFDLS/NL8GxTtK//5t4igMnebX06sLugfBGlR0WwqR3VWcPD+NNthYYH2Sm6K0AlMYpp8OsbJsRmJPMv0otLouxUL31Q+t+YcioalbR7usmqaPi83pQGNhFwRzXT82ffcH3H1jjS5uKsI202E1nk3opXTjqyU7fLJ5HfG5Zqm7V3qbKQL0mLLrcEgZM14zWDU/fOK8MvnA3y/eR0c9nlW8eq/6NH/oYcr/9J4/5iaFeGRjaoqB/RXumu5TIS3L/kQ9dgbgsWV3vAQTEd79Os/qW2ERK+ED1Y0t00uFeI8CvHLecqZ5R4VMNKSHEg6tVHaj9koXjxM+ybt6VNFOS5mv+EYbSsiPc+PEZGB5l18P6KVwU+90rDIGXFZwLnC2Sbc= 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: 1b3532cb-8f05-40e9-5d7e-08d59daf2cf4 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:16:44.0593 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0968 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hector Martin [ Upstream commit 188775181bc05f29372b305ef96485840e351fde ] At least some JMicron controllers issue buggy oversized DMA reads when fetching context descriptors, always fetching 0x20 bytes at once for descriptors which are only 0x10 bytes long. This is often harmless, but can cause page faults on modern systems with IOMMUs: DMAR: [DMA Read] Request device [05:00.0] fault addr fff56000 [fault reason= 06] PTE Read access is not set firewire_ohci 0000:05:00.0: DMA context IT0 has stopped, error code: evt_de= scriptor_read This works around the problem by always leaving 0x10 padding bytes at the end of descriptor buffer pages, which should be harmless to do unconditionally for controllers in case others have the same behavior. Signed-off-by: Hector Martin Reviewed-by: Clemens Ladisch Signed-off-by: Stefan Richter Signed-off-by: Sasha Levin --- drivers/firewire/ohci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index ccf52368a073..45c048751f3b 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -1128,7 +1128,13 @@ static int context_add_buffer(struct context *ctx) return -ENOMEM; =20 offset =3D (void *)&desc->buffer - (void *)desc; - desc->buffer_size =3D PAGE_SIZE - offset; + /* + * Some controllers, like JMicron ones, always issue 0x20-byte DMA reads + * for descriptors, even 0x10-byte ones. This can cause page faults when + * an IOMMU is in use and the oversized read crosses a page boundary. + * Work around this by always leaving at least 0x10 bytes of padding. + */ + desc->buffer_size =3D PAGE_SIZE - offset - 0x10; desc->buffer_bus =3D bus_addr + offset; desc->used =3D 0; =20 --=20 2.15.1