Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2175480imm; Mon, 28 May 2018 03:15:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpLXGnh+/d0Tsbf6XPC9Y0yOgkUFLd+KVbmnI3vNw42mcdsWezeqNGfuFD2nOlR2dJMl+kO X-Received: by 2002:a17:902:8a87:: with SMTP id p7-v6mr12876824plo.278.1527502520236; Mon, 28 May 2018 03:15:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527502520; cv=none; d=google.com; s=arc-20160816; b=XIa1MkDIGWe9Veq2RF/RiCUdPu+dmiwswc9hSgdvL8S97sFm5JHMgECQgtPlT7EAEA leA/aIYmJzbkEyyqEXz55Shx121e29S5khhn4Tw8xwCg4cK30gq1NOamM2X8wD7GfqH5 N5qpSoVFUs1eNoR0TGyNWeRRoD+oBMRzMZYraMitg7CkbiTm4cUGvAkUAH2A4bJJv93k Tp4+JhQt8gbzGqnpS5cFsE9tdVFXrAe8L5/qmvuCEEV4Gouz4pQrbZrn95tW/u4mVmtf ArhMVM1J57GVlN9hf8jm70+899YxtjxifCDmTkK0fO9MmJrRYuEG0xfJg6njpWxRc7wo lYZQ== 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=bPvS82pM8FBQUU3bhlEBH3a4VqIBWY2nbMNWR5xPAqY=; b=tKoUp1tlx2/dtLZ3QtCiGEjAntG1qRYfNIEmtl3hm7jZBpE7Nykxleh7sx/qpJICOn xZ1W42NxmDJFIpTSXFbZ9yFLQZwysZY/vaJ3eaSTd1H7E830suowP7RJtf2CerptwdoC 3/qcr3RUhjo3NCKzIDmUOcVK0Avo3/7PavQFUsJHWETHhOpkD54CKwLA6xhHJtNkmOoX fhqDOE0OWenbpFP8SfwQTlLNktEKwtAwAHuPI9TF6TvxRuyEz0Ok2WoJmMJ1NVAxOaY2 WJpt6iJOH3PUBsXUJJtZQKyP7V3rHlA9s4OkNNu1KHnlD5USxqsHOFaNzswq7Yna7JcD xqHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SnGIn5TM; 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 8-v6si30477297plc.444.2018.05.28.03.15.05; Mon, 28 May 2018 03:15:20 -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=SnGIn5TM; 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 S936908AbeE1KOv (ORCPT + 99 others); Mon, 28 May 2018 06:14:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:34822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936897AbeE1KOo (ORCPT ); Mon, 28 May 2018 06:14:44 -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 C6E1420843; Mon, 28 May 2018 10:14:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502484; bh=64ADagSWkZ6+j0hP/SJNOEUamiGEaZqxKeNH0j9wTRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SnGIn5TMrwcneNJeabV8ujlfqqyWZiVbJLQIsdzsOfB+DbrChr0Y8U4dfEqILQt+i w+0f5FTUlWGm6X+QD0Z37ApFYrjRbe0Q7f2mbuz0wmgjfMTFPqt+fIccJEpE53IfVw DUVOx0qWq5vfhN719JSvPdAjLULLLUwxBq0prVPY= 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.4 018/268] firewire-ohci: work around oversized DMA reads on JMicron controllers Date: Mon, 28 May 2018 11:59:52 +0200 Message-Id: <20180528100204.086394334@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100202.045206534@linuxfoundation.org> References: <20180528100202.045206534@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.4-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;