Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2526372imm; Mon, 28 May 2018 09:45:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI5AeEi/+fen/DeplWrACunNzIKuPvyisVlJV1HR9p+RyepSJXv7MZI9Yc7nsX4vn3CGgal X-Received: by 2002:a63:9e19:: with SMTP id s25-v6mr7100917pgd.371.1527525949758; Mon, 28 May 2018 09:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527525949; cv=none; d=google.com; s=arc-20160816; b=ekxvUZL0LfOaXf4ZHHgMX22ebOayrikj/fufjjwlyDdFtbePiX9pUtJPhf7MlR4SGk ijdRpzTqf5Lmpo843CIkL7xh0LJ5IJeStSWkGG7d4cfDO4+ggvgluyA5Id1gt7WGTZT4 juZozZLvPPlOJqrlQDNlO9N1yrFblTQLowsZlIDglmFBo6LzZTTiolh6WJON244YWlm5 2SY3HLLNET6iCxI2LRHpF/FqaJANiEk9tKgp8zJSeunvCVWrPATMVPs6IU5Ue4oqp2lz 6jMnBQsbu8+fW7Wico15+S4KZcxNpNo3cv7GHZrL3NB6qA4ewLdpWSi35FCKg2kEqChK 6pOw== 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:dkim-signature :arc-authentication-results; bh=XAXeKecpzSxLclgjD4AUlISjzAgtKG4QPOrWiqKlCXg=; b=m4qU6sSA/0RjbKLzV5oieVYuSlwA0k7t2cxnpZj0viOf9Svn0xWl2lXhFNE5UTxdhX wDpXXYPbp9mv86yFMRYnkDAFmFv+J8Dj9rYYGsT/+jZNOcYwSVKJGX9ZbFGDVjU5yJ8R 5sfenu+VVDl7lTlNo/6CLLFlue5NEnAgvA0sgJ+F8EPYlb1LfiRPSM2infnS3CMu38xM ROD7jT0LzKEUsx+PcBXkT/VminZ12tJfyt6+u2t1suYhybRRcRkt0hGL/yZtqe5jYq4K 0djDK86KwzVxMJ4mnXOav/1ur070Rt2QiRK/D+2HfWhHHS6cD3X6V0qGehU7ePILEODE 1rHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Xf9bcz3G; 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 k3-v6si11695717pld.21.2018.05.28.09.45.35; Mon, 28 May 2018 09:45:49 -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=@kernel.org header.s=default header.b=Xf9bcz3G; 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 S940358AbeE1QoL (ORCPT + 99 others); Mon, 28 May 2018 12:44:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:55490 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754331AbeE1KH0 (ORCPT ); Mon, 28 May 2018 06:07:26 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C0FA420843; Mon, 28 May 2018 10:07:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502046; bh=ftCJ1osJDVbT1nVlBSwZPVvjPnh7bcjh2MqTIpyNgZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xf9bcz3GNNCkjHX6Gtp3KC+cuuo6umMye5JwcmZiLWnPUTeZNnjHAoCe6SLXf8BUs UFXIcXQ3HYLcGQL0w1ldohRQ24hVLaoz9DQwGvg9OPZ0Q2DVYAtwKsyJx9lnhBnA6U zFrS3FB9x8DG1Y3myaXwkSVWey6QpzO/LaN5fhjQ= 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 3.18 010/185] firewire-ohci: work around oversized DMA reads on JMicron controllers Date: Mon, 28 May 2018 12:00:51 +0200 Message-Id: <20180528100051.293224595@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@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 3.18-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 @@ -1137,7 +1137,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;