Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1452598ybt; Mon, 15 Jun 2020 00:05:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlqylostlU96MxV4tiVdT4kxknYfrOscLrTluGJgF1qL9YKjjozjgia954tmKyi7nUr82k X-Received: by 2002:a50:fe07:: with SMTP id f7mr22994611edt.315.1592204726717; Mon, 15 Jun 2020 00:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592204726; cv=none; d=google.com; s=arc-20160816; b=CRal7VNGd2j6nM6drp45J6iTmg88etmHrBHup/eAdItpx6Ni/ET9l1iZGUU5ybg1Ys YM6YBK3mLAb8Y0SrxLGrHGTbsCP7d1g5kzmDQT5t9YID/F9Tg5m0cyywrQrxq+wNDQoN pGJ4iLV1BifvVuQsvhgo2G1EtiRG374XKpeLo1aQJ5TWqQ5LdlOJO+AdEVoONT2DdKFJ iZ6jSBxLeUj9NpwsExYHgIV16v4yBrHMYJrBUX0jHPvAj7E7ZX/TzSzFT1KH+83ckKuF M3sUt+CAjhWdlnoo8BWhhD1Qgaq6FDoEV8piAad8vq6CTrwk89QLLCG+y457dnKC1IIg +kzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=JunFmmuiHqsHdAPTiTPNgbjPJ3SW5bI0sHF9D+3lv28=; b=eNgtbm34LI+06dk1TEcW3OLOWk+m0ibXjfxwe8gXejddkQe71JdmrQD+zNKPjQZmRC bIAouDbaKJKcnTwaIgMkzLZLUtSVcZ5SqmqTOi1Ku2h5VuOrmZ9+Ryndz2lQqsF7UhaC wnUil5Cz/xrVaapcbXQT7Y7JxREN9/43oeUuKGd3aCLi8Of+WJ60pHLIEj+vhQJ4Yq0z IRALep/IdLKG+Cj6zAd4l7J+j8rBFEbNxVAGPDwB4ry0nwVJBWfrXa7+RvF8gSIoucnT gL7k2VEMZAHGRrUotH8uv80WYX8yd4HnltAcH3OjW49cPfJykxBiobQQ3lGqW6DgVwrw 3OZg== 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 np7si8396517ejb.377.2020.06.15.00.05.03; Mon, 15 Jun 2020 00:05:26 -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 S1728320AbgFOHBI (ORCPT + 99 others); Mon, 15 Jun 2020 03:01:08 -0400 Received: from verein.lst.de ([213.95.11.211]:59869 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728605AbgFOHBG (ORCPT ); Mon, 15 Jun 2020 03:01:06 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 010A568B05; Mon, 15 Jun 2020 09:00:14 +0200 (CEST) Date: Mon, 15 Jun 2020 09:00:14 +0200 From: Christoph Hellwig To: David Rientjes Cc: Christoph Hellwig , Thomas Lendacky , Brijesh Singh , Marek Szyprowski , Robin Murphy , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [patch for-5.8 4/4] dma-direct: add missing set_memory_decrypted() for coherent mapping Message-ID: <20200615070014.GC21248@lst.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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, Jun 11, 2020 at 12:20:32PM -0700, David Rientjes wrote: > When a coherent mapping is created in dma_direct_alloc_pages(), it needs > to be decrypted if the device requires unencrypted DMA before returning. > > Fixes: 3acac065508f ("dma-mapping: merge the generic remapping helpers > into dma-direct") > Cc: stable@vger.kernel.org # 5.5+ > Signed-off-by: David Rientjes > --- > kernel/dma/direct.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > --- a/kernel/dma/direct.c > +++ b/kernel/dma/direct.c > @@ -195,6 +195,12 @@ void *dma_direct_alloc_pages(struct device *dev, size_t size, > __builtin_return_address(0)); > if (!ret) > goto out_free_pages; > + if (force_dma_unencrypted(dev)) { > + err = set_memory_decrypted((unsigned long)ret, > + 1 << get_order(size)); > + if (err) > + goto out_free_pages; > + } Note that ret is a vmalloc address here. Does set_memory_decrypted work for that case? Again this should be mostly theoretical, so I'm not too worried for now.