Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3890419pxb; Mon, 1 Nov 2021 23:43:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/CZSWqnAn/4B6iEUCUJNNN+XK8C2BuJQxMNTFCRjksIWM3uJ0MrmDIPZ1WBrwz+JbctLI X-Received: by 2002:a05:6602:148b:: with SMTP id a11mr25667367iow.85.1635835387410; Mon, 01 Nov 2021 23:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635835387; cv=none; d=google.com; s=arc-20160816; b=TSZlEjdVpeHtIQtfZVzTP/5Z2zSD7LD8UpAr4ZLQnI6fq251ozulch9VSIRi3agWnm tC6QdhstkhziQRmy/0K7xEADmYnKLKf7fNnX4AC2MSo+N03SooXOou0VDC4quapiHVuV 7P6rM6EiP4wLa2Xr328VKoT6EXu55Qn0ZQMIx5zZICGP3PvsSt9v4/U+OOFwhMXQczdu fvT/vbceFDkwjA5atzNaqllWjsXECPtLV6LDT3I7i8Bb+7JXoCVVeuqk79v8lZqVy4lT artQ6o0RZD9KQfN/7v7QE/41a7fnFXIjj746lhIXE6SJ/g2JrmrF/UfkN8qC/lorTObb bTzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=NzJ0R7pj8o3rFL7X5Sfcj2Mnttk6c/nlrHtgBJvcYRM=; b=xtokKJXQSor66ajOTkCWKtiqoZ9GD8sJPCw+1CdSXola0FPB3itJrxz8sdSk2Zeoi1 IJEtUJu2AuyH6G25jXb4hSXJ6HWL/EaAAIEe1kK/Zdn6Ye0hrmQRYhkV6IUWSSVidlCo YyTkxR4lLdoRVl5ivCUDO3952769IuOPB/qAOVTQ0L4L5jXgGhu+q1Hw5R5t21EzhzIa 0mbbB+dvxIjURxxnPiF5IuWpjnmka9ZMOKc3WcFnqsr9GfIw7cQvbPMo2N+dxTKBdG58 SsbfG1hcNJ1PM3romoGRlU4C+F63nHTYhmir9hAbgsn+XY8dJc2QBu5r3ff2cIq3uk8S t6DQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g6si11257737ilf.178.2021.11.01.23.42.54; Mon, 01 Nov 2021 23:43:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbhKBGod (ORCPT + 99 others); Tue, 2 Nov 2021 02:44:33 -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.