Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1540412ybg; Thu, 11 Jun 2020 12:29:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNVoYYc9rBJR17HUzLWC9g109zcd2PQ+VOHzzlxyipzzy21Q6nhryWU/FEqnMXhE5qVPvx X-Received: by 2002:aa7:c758:: with SMTP id c24mr8204501eds.290.1591903754507; Thu, 11 Jun 2020 12:29:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591903754; cv=none; d=google.com; s=arc-20160816; b=on88O9YrDvBh6+e23ZU65H5rBZ87aWHn4X5OaI4RwaQENbqJk7gZ53mRkIKK/6scfA XJXFwo3A4OEtLm2U8oj2m0FyehSbWcOMXg4FJhjyz4auRlfDh9W+HcCBjuN1J1AcDahz 17j2897syKRMvhL21pvRKP2mOjxnOqEFBUtUoPtnya1TuX/tAzMCH+dOyvUEs6YmKXHY nS+ibtNH0tBOOvLEk04WpSWHBaURnbcbTBynhZKhNBVLmTnRUnu7wZr0irzxX0cqaXBZ 2WGfVBpl+gPOZVCPChkE8367QUekdxmsVVnymQ83S3mV5tEGxWlCPy0wDCkfDlFgrGlW TQLg== 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 :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=lhV8nqMz2laEO7u8yeQgJHEMBabnXS8HLs+yCx8wYRg=; b=SjVH2kfhHKgu4Tj0ra/TmrYKLkuPNVjH2p3RFwbMaJ5fSpvntzkeYnKSQ58j16tt/Q wkf9rxdXYCD8Zqc/RUvtYE/CXIPCMMLepQcJI5xPR5Q0sVzyJ6OO0L/x77kcom/8K1LZ 9lVwdO6vs4uymztQspwhQvCCZWkouabpv2a/NhCb3NI89SxxYfn53X6qsRi+otdemJTW B/h3Uc6Hp1dyg/hQdx99WJSKLkizwXZh7nXqGOBLwXZaAbXWsO54nVL/+c8aL7lwJTvL Xb5VP0XOgC1sFfugcBjvs7gTC0eEx323ZGUPutcru5uQeGUcR+ddoIvzXjmYnmJKZTav NEfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=acPfkpj5; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si2467144ejr.250.2020.06.11.12.28.52; Thu, 11 Jun 2020 12:29:14 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=acPfkpj5; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728130AbgFKTUk (ORCPT + 99 others); Thu, 11 Jun 2020 15:20:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727061AbgFKTUd (ORCPT ); Thu, 11 Jun 2020 15:20:33 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE557C08C5C1 for ; Thu, 11 Jun 2020 12:20:33 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id e9so2933807pgo.9 for ; Thu, 11 Jun 2020 12:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=lhV8nqMz2laEO7u8yeQgJHEMBabnXS8HLs+yCx8wYRg=; b=acPfkpj5/yf9SgDo/GgAHtc3dF88Ku0aHGKDg+7QAde4yPirke3PsVjTLGiw8CNyf5 rG2TeN3/YsFrowdQObRuyE5KZUNGYQVgTkHLC5YVK8hbZFVPU41QPkfdZek2TuIS8jYr ha+G7dTRNoOt34arFuaABOYl6byG3HiaAuYlznexIvZnxhEGlzwcKiZRIkAfeiQ90QJd XVezjcdXyBaGIsvdXilWU970/byi5P9BHFgT2xwISkH5IxvDu8aL50gDfuG5xWuMAcp9 ELWXt3Nr8CCIuG0NFyi1OsB8GLXXelexcGBOZV9WWFbayorCcW+7+9CT1EypI2M0tCut Ys+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=lhV8nqMz2laEO7u8yeQgJHEMBabnXS8HLs+yCx8wYRg=; b=kJx7RJ29zcMD1gKWO+zz/6mukb6Afj+r62Sz20RSS7KE5Wx7yR8S07/sdYY1qTSvYl DcIvUhtQxDLlgRgoogye4fWFH/ZhPsbpONM/b4Uq6wz5OlkLwDbHbm349P2JHiA77lLM qKVi97G2RAnVa7uhrPq+NuA90sdLVKP8NuCPnycLxgRs4Gz2rAi1Vx51tR2eStnp0cws 8ftEwDPqNf8PLttUyQRIZDmhANHCYArfYOvYa+54lUSorlqdHVvL2OniN8avI0qxJ1xp gz+/34kNCeEqdxqvLcl4aGXKxwgHP0F309iYbkJeVujGETHk9PovrwiidmV4KaPSa/PO 5gEg== X-Gm-Message-State: AOAM533COevcWhZKoQdIFnIph/VAdzbBzyO2rVDLUJMOEcCiermLojZi smkbDD/q2ewHfHNekKK4E+O9OQ== X-Received: by 2002:a63:8b42:: with SMTP id j63mr3450720pge.131.1591903233130; Thu, 11 Jun 2020 12:20:33 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id z24sm3714630pfk.29.2020.06.11.12.20.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2020 12:20:32 -0700 (PDT) Date: Thu, 11 Jun 2020 12:20:32 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Christoph Hellwig cc: Thomas Lendacky , Brijesh Singh , Marek Szyprowski , Robin Murphy , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [patch for-5.8 4/4] dma-direct: add missing set_memory_decrypted() for coherent mapping In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; + } memset(ret, 0, size); goto done; }