From patchwork Tue Sep 15 14:12:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309682 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=-15.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT 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 AC3ADC43461 for ; Tue, 15 Sep 2020 23:22:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B99020936 for ; Tue, 15 Sep 2020 23:22:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600212150; bh=KSyvzOcpC3ZDVAqUAEqom48/2QAjeD5TFMKttdGjgrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=04asTJZ8WLCUMBBFUbW1P30ydXJBkapOV/PXHFxCcuI45JnMt3I+6RtTLtYl/g6NF t5vh2wTsuq9NIHLuZW7AAuoC8C7iYErkb6wh5TOTPL6l4cdAe44tmpteOwwVleReUq Km6G2Z3kxsHjDUYEMoMMTc5CbLVzAe+DUlwQMIAQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727437AbgIOXWY (ORCPT ); Tue, 15 Sep 2020 19:22:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:48800 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727205AbgIOOiG (ORCPT ); Tue, 15 Sep 2020 10:38:06 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AFF0523BF0; Tue, 15 Sep 2020 14:28:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600180094; bh=KSyvzOcpC3ZDVAqUAEqom48/2QAjeD5TFMKttdGjgrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UL17d0/AIvFuQY11ZPVq2GS6AcT+YdAlSsUcOk9i3q/shnNvqne2vxwZutyb5Gpke I1PCRZNVCvn0xcLxj+fG9aMBSKz8ry0lwnJ5P6TyAYVpnvM1Re9nXRzTjSDzVlMrY3 PXTPOHKZFM91u1INARzg6LdlLgmi+NC3x8ts9uKY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joerg Roedel , Sasha Levin Subject: [PATCH 5.8 106/177] iommu/amd: Do not force direct mapping when SME is active Date: Tue, 15 Sep 2020 16:12:57 +0200 Message-Id: <20200915140658.731123376@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140653.610388773@linuxfoundation.org> References: <20200915140653.610388773@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Joerg Roedel [ Upstream commit 7cad554887f1c5fd77e57e6bf4be38370c2160cb ] Do not force devices supporting IOMMUv2 to be direct mapped when memory encryption is active. This might cause them to be unusable because their DMA mask does not include the encryption bit. Signed-off-by: Joerg Roedel Link: https://lore.kernel.org/r/20200824105415.21000-2-joro@8bytes.org Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/amd/iommu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 200ee948f6ec1..37c74c842f3a3 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -2650,7 +2650,12 @@ static int amd_iommu_def_domain_type(struct device *dev) if (!dev_data) return 0; - if (dev_data->iommu_v2) + /* + * Do not identity map IOMMUv2 capable devices when memory encryption is + * active, because some of those devices (AMD GPUs) don't have the + * encryption bit in their DMA-mask and require remapping. + */ + if (!mem_encrypt_active() && dev_data->iommu_v2) return IOMMU_DOMAIN_IDENTITY; return 0;