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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6117C433EF for ; Tue, 2 Nov 2021 06:42:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A39160F02 for ; Tue, 2 Nov 2021 06:42:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbhKBGoe (ORCPT ); Tue, 2 Nov 2021 02:44:34 -0400 Received: from verein.lst.de ([213.95.11.211]:54601 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbhKBGoc (ORCPT ); Tue, 2 Nov 2021 02:44:32 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 7487768AA6; Tue, 2 Nov 2021 07:41:55 +0100 (CET) Date: Tue, 2 Nov 2021 07:41:55 +0100 From: Christoph Hellwig To: Walter Wu Cc: Christoph Hellwig , Marek Szyprowski , Robin Murphy , Matthias Brugger , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, wsd_upstream , linux-mediatek@lists.infradead.org, Andrew Morton Subject: Re: [PATCH] dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING Message-ID: <20211102064155.GA27749@lst.de> References: <20211101031558.7184-1-walter-zh.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211101031558.7184-1-walter-zh.wu@mediatek.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As others pointed out, DMA_ATTR_NO_KERNEL_MAPPING just means the caller can't rely on a kernel mapping. So the "fix" here is wrong. That being said for cases where we can easily remove a page from the kernel mapping it would be nice to do to: a) improve security b) as a debug check to see that no one actually tries to access it > + /* remove kernel mapping for pages */ > + set_memory_valid((unsigned long)phys_to_virt(dma_to_phys(dev, *dma_handle)), Please avoid overly long lines. Also this function only exists for arm64 also and others pointed out won't work for all cases.