From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D26DCECE562 for ; Fri, 21 Sep 2018 05:25:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6588620989 for ; Fri, 21 Sep 2018 05:25:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6588620989 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389183AbeIULMs (ORCPT ); Fri, 21 Sep 2018 07:12:48 -0400 Received: from verein.lst.de ([213.95.11.211]:35883 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725887AbeIULMr (ORCPT ); Fri, 21 Sep 2018 07:12:47 -0400 Received: by newverein.lst.de (Postfix, from userid 2407) id A01FF68D80; Fri, 21 Sep 2018 07:25:37 +0200 (CEST) Date: Fri, 21 Sep 2018 07:25:37 +0200 From: Christoph Hellwig To: Stephen Boyd Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Marek Szyprowski , Robin Murphy Subject: Re: [PATCH] dma-debug: Check for drivers mapping vmalloc addresses Message-ID: <20180921052537.GB12825@lst.de> References: <20180920223559.136915-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180920223559.136915-1-swboyd@chromium.org> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 20, 2018 at 03:35:59PM -0700, Stephen Boyd wrote: > I recently debugged a DMA mapping oops where a driver was trying to map > a buffer returned from request_firmware() with dma_map_single(). Memory > returned from request_firmware() is mapped into the vmalloc region and > this isn't a valid region to map with dma_map_single() per the DMA > documentation's "What memory is DMA'able?" section. > > Unfortunately, we don't really check that in the DMA debugging code, so > enabling DMA debugging doesn't help catch this problem. Let's add a new > DMA debug function to check for a vmalloc address and print a warning if > this happens. This makes it a little easier to debug these sorts of > problems, instead of seeing odd behavior or crashes when drivers attempt > to map the vmalloc space for DMA. This looks sensible to me. I wonder if we shouldn't just throw in an unconditional WARN_ON_ONCE(is_vmalloc_addr(ptr))); into dma_map_single_attrs, though.