Received: by 10.213.65.68 with SMTP id h4csp2117425imn; Sun, 8 Apr 2018 20:08:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx48lrSSjPB07uXJz7VuzQsmv7c+AjDECvmIhzLdTJhHQfBtMl641b2JQQ3uDi0Yxl122Ijma X-Received: by 10.99.4.202 with SMTP id 193mr23769024pge.409.1523243308104; Sun, 08 Apr 2018 20:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243308; cv=none; d=google.com; s=arc-20160816; b=GXLgTSkmXuP5vSFMQXf+DI0ugvZc/yPYP1iul/o5pFpaxAiymEUW9zIUUAM4wgvOcU dmAhF1VmlEQMXEMf6Wf4LaXLW/5b0L/gL9OekmtqaBeyWoVuMdNe5pQZvPS9t71XQGMC EqPgN4Ettq/PlzqKnNnXWnku9wcvgMQlnnSUiZ/P1fbBk4M8FehzCWEfAwrBhNnqv/zA WqisJ6hpbPYKboi1tcQPCGrtfgc1IP5Sz3dDW1q9muSAoWHzsn48f0rXLQpR0rCsShne d/FSo0FMZ5PpN1QwkGnTHtZGzoKBVVZlopOOEqopPnsiZm6fM7tnc7FXxQU0qPq8V8YE tBLA== 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 :arc-authentication-results; bh=X0bJ3jAZd3WNdmj/FRtNyFYkrVvb9L8qG8svt8n6VdI=; b=bKH45IUq2vUngEWM8tBUh0137+8y1voycSOw/1jWc3gIxu6V50aJPG/se4QbTMhdkk Lb8Haj/vr2l2/pzIy45wY534J3pKe7JLrnAWediWIv2d3D7KftV5BCQw+i5wXp/vcrcB akyxp6x1J1lPUZ6rMLHSUREau1fxRUG95H9DulP+hnmgo03lNBVZ9yd/4jy2N3a9MBN9 yS23BbBf4e8cPNopL2xsRDL9OnTgE+KbhyvG+svWowrzSmP+ubFjgfJhCoiNupJ9AYLf +mftK8hwiOL13W/W0c9ScuxWUU9qgOMJ8PavqEDLhXFOEtBimPV8Dc32VknVgMQ+Fc3Q WTzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=JIeCI/TU; 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 1-v6si14166620ple.629.2018.04.08.20.07.51; Sun, 08 Apr 2018 20:08:28 -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=JIeCI/TU; 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 S1757510AbeDICAg (ORCPT + 99 others); Sun, 8 Apr 2018 22:00:36 -0400 Received: from mail-sn1nam01on0125.outbound.protection.outlook.com ([104.47.32.125]:41312 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756473AbeDIAcP (ORCPT ); Sun, 8 Apr 2018 20:32:15 -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=X0bJ3jAZd3WNdmj/FRtNyFYkrVvb9L8qG8svt8n6VdI=; b=JIeCI/TUBVkxDST/x+tKvNdQYAWEDzi8lJjQuSWfqN5JnbtKOMfp6zHfgRWU+CPWfElGl0/LdPb8gf1nD+1IZQ/0i1RSTpcGYlOD+6weDgWGG2/swU6/SUkU5NzzVApler5JskpA9IbgbLvqG6x0wj/O4aMtCYP8e04QwBLbFEA= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0806.namprd21.prod.outlook.com (10.167.107.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.3; Mon, 9 Apr 2018 00:32:13 +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:32:13 +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.9 210/293] firewire-ohci: work around oversized DMA reads on JMicron controllers Thread-Topic: [PATCH AUTOSEL for 4.9 210/293] firewire-ohci: work around oversized DMA reads on JMicron controllers Thread-Index: AQHTz5lIEqPjPjSKvEyPJ9zurZmL6g== Date: Mon, 9 Apr 2018 00:25:37 +0000 Message-ID: <20180409002239.163177-210-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-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;DM5PR2101MB0806;7:3uBFF+1GNDlRONtYFDpauAdQjcRD7N+7mjm0qHWrhDA24KhEVRFzvSyu1NTjnt/YambZY00PiGrOdHvvuTsyjqD2DvA62IeyCli+bXue1Y4j99x0e6CzKlpUhr2lmx1CdvVaiUxRdUmN5M+zTZtAAj0pbQ52m01pO6DhZjnnsnE7SnVB0jWekw+1x17MMPOrRYItOVk85NNVAAeXofABb9bmw0Gu2Y3aqrFewds1ySqTrEFWq79SDKE+Mv5VhDxt;20:EgoTJj0uXVYc5YdEpiT5od/avTgM0DZGoNRGLh38kbOoR02KqCN6GR8EqYuVNiPBRy0aSBI1D9ZsHEy+O3MX5cMBwMY+3+l34eaZ9QNGl7j8m4y1q4R/G49HT5HMs+9vHOgINvqaPjFiWt1gV4V9lQN+RuB5hP0Ct36WW26oEcQ= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: e4ff9747-643e-47c3-c9ff-08d59db156fe x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0806; x-ms-traffictypediagnostic: DM5PR2101MB0806: 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)(3231221)(944501327)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB0806;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0806; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(376002)(396003)(366004)(39380400002)(199004)(189003)(2906002)(25786009)(2501003)(10290500003)(476003)(11346002)(446003)(97736004)(5250100002)(68736007)(2616005)(102836004)(6506007)(59450400001)(3846002)(3660700001)(486006)(3280700002)(305945005)(6666003)(99286004)(5660300001)(76176011)(1076002)(186003)(26005)(7736002)(6116002)(81156014)(81166006)(86612001)(4326008)(105586002)(10090500001)(2900100001)(54906003)(22452003)(316002)(36756003)(110136005)(107886003)(8676002)(6436002)(478600001)(53936002)(66066001)(6486002)(6512007)(86362001)(14454004)(72206003)(8936002)(106356001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0806;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: HzracEh7Hb2LxS0cWb4ZcI4BT0Eocly2NwaLFdTzEEMzOVolVvAvkvsxIIPpOvB2JJh/T71EQiI5sGIi4tseprbK1Y/cjdlxu6K2k6XeQmZfHJSJR5eAOqT1Y3Xmc7yVKhJ/cGHINIha5nLPk5V7fMWoYJ2FgrPf7UQGGEKIZf8L/0s3mMv9G9SG3j7qIHoxFeP+Q6+ExclIZvU2egq+mL2t4+XjwXZbFDYMeEXvgqpmMGeZLRIajx6Tm9DZEumKtG3dEEnGPJxfCe2feGWq9ERe3BaQWqiVdUAOyanxb611E5hY0ZerK17ivljNSn0L3o7qxKTu6bHM78zZxqIHXV8pPFHkOD5mun3bwPNai7yEL+Rp/VaEmZD4fgO9+OSLxK0ivodhK07Qqu5/j4aCVQspv34NjLzgswKkd5Qx1rc= 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: e4ff9747-643e-47c3-c9ff-08d59db156fe X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:25:37.9409 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0806 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 8bf89267dc25..d731b413cb2c 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -1130,7 +1130,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