Received: by 10.213.65.68 with SMTP id h4csp2135618imn; Sun, 8 Apr 2018 20:36:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx49UNvDTW/fILDGjAhZw3lqhY4XO4h09WywDVbns8U3zBj2scGep4sIKVg1IEpVwb/svs9B/ X-Received: by 10.99.37.71 with SMTP id l68mr23859901pgl.440.1523244993287; Sun, 08 Apr 2018 20:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523244993; cv=none; d=google.com; s=arc-20160816; b=MVDwodOxXiWsbQl1Ym8S5kyAqb9JTAbfw4zEsxPr/jPLHt2LaB55TLRERx52Twm5v7 00N3E5U8ngVmyYL0wznXBPqtIWYtqxWjOjgGCheb+E3IbRSJfcMKlOXBkXfpgdi2LYtc MkHdgeoZpmJvug4akrk+c6klFRS8b9N6wKoUvHen9P13188vz2GkJTBhylhEm/O0GKl5 OCXasooJIsIbNIjM4m+qiiDUWeFfFM2B0K42enU9sc+5J3VXnsaFPGvq5h9pfVLtKcRt eeHISqg1kDcS17THdgILZE0/EuXeWzwC6aAO2lfb/giRtvFkLrvO8xGNuKbhPUvJPIu3 I6iQ== 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=X0bJ3jAZd3WNdmj/FRtNyFYkrVvb9L8qG8svt8n6VdI=; b=H2iMRqmMktp7LgDkYxbQb1tclTwGgRovpf7iPRNqMv50ZmQ8wmyWpWlTyLs/Oa7JVs dRYzTsFegrfxqMDXY8KKTyR+XImKEB609+EM7NWbXBVLZ5RJ6c5SjtJb9nGSJAo3+W5W 29B5mbJgQ7FoV+jTYrNyMQHqK0heJK2Cm3sW5iqatCgR6He3M+xBpCtRBslc0q6RcPUC RkXtcKgay6n/TrxeEdmzNp5w5nlSLGNCkYPKtvxLvQ7ssAJqJ1nRt5/CO8ZV3jbPARKW XaO130ju93LiwyDtSPxU/UGM9LA4O22L8247wAPnZzpInmleyFBRNHXNs1amq9Zu/Ai/ L4vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=mxE9mbHM; 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 f1-v6si16240912pld.168.2018.04.08.20.35.55; Sun, 08 Apr 2018 20:36:33 -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=mxE9mbHM; 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 S1753522AbeDIDaw (ORCPT + 99 others); Sun, 8 Apr 2018 23:30:52 -0400 Received: from mail-sn1nam02on0123.outbound.protection.outlook.com ([104.47.36.123]:35872 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754556AbeDIAV5 (ORCPT ); Sun, 8 Apr 2018 20:21:57 -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=mxE9mbHMoBhPi5jbJRo6WiisaVkbfu/NtUvr2z+Q8NmJ4lTfneR6Pot6gdZV1+AlcRWp8aGROyr3Ms+Gb0bjp6MfQ7K68f/5hWYKqnR4xylcQDB6Yt9xzEZIDBwnnr+oL3Fc2U2vprBjKoHlv+Rv2NfFNKxJUG68ImiN0ekobk0= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0936.namprd21.prod.outlook.com (52.132.131.166) 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:21:54 +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:21:54 +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.14 001/161] firewire-ohci: work around oversized DMA reads on JMicron controllers Thread-Topic: [PATCH AUTOSEL for 4.14 001/161] firewire-ohci: work around oversized DMA reads on JMicron controllers Thread-Index: AQHTz5h0/9hJy9Ln8UKcvf5gNagYOw== Date: Mon, 9 Apr 2018 00:19:41 +0000 Message-ID: <20180409001936.162706-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;DM5PR2101MB0936;7:zoYXnpW2/X+v+7gU1Lk3efF9H6e3bzzMIrUnbAh/6+rsO2FvHd/dZncMgE93mdqA7rpaQO0gyhK3CcDIvqvJYqC1M5HEhys2bw5QsKu11uYBgXAoEzYKLVx+P/h1pBOiBd5T6xmbBWW5XNbl5q2bqKr8AYiDLS9Fjqmywh8BFBUhQ7mY8CW6j0nGzfss+Hz1/Xjgk3WbY0e/LJudyHVFs8mhWoDkeBzCyoxm93HB3Gkpdln/mvl1ZnmJewUiLrr/;20:2yFp3TDz6TGdYsD90QDVtWeE8pt+p9ouCGFhP2/hizClF7UCkbDm8R/uuRWmmhEG2dJTgHzAOY2xUd7wnwdfdMhFwR5VO4f50Yu4ASjXNxSLaHQmjILyjesr7kaisC21Rci7H1k3bThrI7R6SB/0mRpKsXKR05Uw/Xuj7Wx+nYo= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 2d7a36ec-7b5c-4995-c5d1-08d59dafe5f4 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0936; x-ms-traffictypediagnostic: DM5PR2101MB0936: 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)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB0936;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0936; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39380400002)(39860400002)(396003)(376002)(366004)(199004)(189003)(3660700001)(36756003)(2501003)(10290500003)(2616005)(5250100002)(3280700002)(478600001)(1076002)(72206003)(6436002)(53936002)(486006)(476003)(4326008)(6486002)(107886003)(5660300001)(54906003)(110136005)(102836004)(2906002)(6116002)(3846002)(86612001)(81156014)(81166006)(6666003)(8936002)(305945005)(8676002)(2900100001)(6506007)(68736007)(14454004)(106356001)(105586002)(25786009)(6512007)(86362001)(99286004)(59450400001)(10090500001)(316002)(26005)(7736002)(66066001)(186003)(22452003)(97736004)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0936;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: mcEa9G9Nok/W6jvskukBeAD4xZzpZtAtR8sRUUwpa1MApUMiJsf91X2Y3VWe0IUkhfSGOARIED0Iqnf3aeEegetDOqHyJNGdLm9XMBkKpIsk/5v9krV3PqLIFq5NmrFXoXPFmQYhhlu5f353PwOLH6DCUiDxnZJGd7KMl6fh2e1CfBxJVzLbqI+XUtw0KDdoS4iCxCQ0jcSIu4AlzqReh9ho4waclGdVO6BsJBB/cEzCfDyXKBKxLPb4vmahlM4rreqc/YS8SUoP1mVTVtqhVTn1yf6MKO9ZLjTr7VwV7HdLZPrQi4BT8o4GTkGc2t57JwiGWhDiIeAWwBWp4OsZVuVAf4t9UrsNdF02c+1t85g/LG846duHuYdYjP0PEcSUPwhmwzkUdiuTCe1nZSe8zUuS+6ZvGQBk0Fm/l+y4ELY= 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: 2d7a36ec-7b5c-4995-c5d1-08d59dafe5f4 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:19:41.7666 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0936 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