Received: by 10.192.165.148 with SMTP id m20csp577739imm; Wed, 25 Apr 2018 04:34:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx49s4vcPJEmVLVtqkEVQ27ow/jutO1vTWqWJuJvZh7xmJUI9b0Iq42EUcKw+pMAqNVebIFTp X-Received: by 2002:a17:902:6d0f:: with SMTP id s15-v6mr28620114plk.241.1524656093585; Wed, 25 Apr 2018 04:34:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524656093; cv=none; d=google.com; s=arc-20160816; b=u7ZBIJVm7iYhFu2aTkK3K03NJnw2yBsV4101Rg7Do+crH1Y6nfwNxhSQ4PltFn0YCK /ZhmrYDxNWJ1HSoY4qvcHbGdkaREziXbI4cy3AgPNO0TkXx4kBWYLMzKgrNdbWgJ0FwW Ar3ltFLR+2LXUcOhbx0/gf5a3Xll7tT7T2gRRvBovaWsvUrYrE+qACNuIeaFSVDZ7QJM Ax0h9C7LJOMnZl5Y1d330389edpYLd4waqV0T6cHwgBMiA3EAW1txEy8yi/A9A26hDY9 dx0bkXEY3zqY2jY7d8JB8zhHZm4aVnHwaGbMWsR4+HXL0xiTo9dO1iNPBNozZzANJ7Dd vv/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=GpY0hjbIf4QCszEal3K+9p7wjMEmqCnJmagoqZnxr/I=; b=KDYLOPIqNpq+pgwa1h3j+HtfRk9gUhDnobK3Ab2TrD0U4DQn6regswibr++0q+I8gn CKq30wLs26ldQcVlTCDQHjrxyI32bmqqTBVt3v5p0z6jI9eoynFZtaQwsX2u8cBPbGSX lbs/E8tml0lAmFhcpegLrTIx1tgUq+2MYlyBq55hV3OEZiutYzTo/4Or4WtmWksXMb1L if/wLMEwvVlu5/np4piheDxzInM65jalu11hcd9LSeRnP5QLW5VGR/LI5DxCCaCupkDS HAloEwJn+MtlMA8OXl7V+hEd2uF4hQXq8ri+4OQPg35ZbvfPSYf9x0yDZnl45Z5cFH81 bIiw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13si3777253pfc.333.2018.04.25.04.34.39; Wed, 25 Apr 2018 04:34:53 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753277AbeDYKh2 (ORCPT + 99 others); Wed, 25 Apr 2018 06:37:28 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51098 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753257AbeDYKhV (ORCPT ); Wed, 25 Apr 2018 06:37:21 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B8315480; Wed, 25 Apr 2018 10:37:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hector Martin , Clemens Ladisch , Stefan Richter , Sasha Levin Subject: [PATCH 4.14 016/183] firewire-ohci: work around oversized DMA reads on JMicron controllers Date: Wed, 25 Apr 2018 12:33:56 +0200 Message-Id: <20180425103243.263203532@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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_descriptor_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 Signed-off-by: Greg Kroah-Hartman --- drivers/firewire/ohci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -1130,7 +1130,13 @@ static int context_add_buffer(struct con return -ENOMEM; offset = (void *)&desc->buffer - (void *)desc; - desc->buffer_size = 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 = PAGE_SIZE - offset - 0x10; desc->buffer_bus = bus_addr + offset; desc->used = 0;