Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp46215pxk; Tue, 15 Sep 2020 17:20:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEaAJEZvdO6huFbgBaBVbqGg8EHyyPGgsXzUms836+s8Y2QxNnEPKCeHQluekpAiVl66ly X-Received: by 2002:a05:6402:1697:: with SMTP id a23mr25175731edv.195.1600215634512; Tue, 15 Sep 2020 17:20:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600215634; cv=none; d=google.com; s=arc-20160816; b=SBLSGDZlf+Dy5JcjmaZABJbX3Hd5q8ZFvWQoNwmSEZeRZmWql1YjPAX+Ta0K9h+Y9J DkoPsUs3JoJOT3k+N+3hULiRjN13vXQSeoXQyHf9K51OLRADZHkgMJgkf3pPi9yyu0da PxqMIQlhXXSSjL3C4wXGBHIVWm1FlnytvMMNMSAvs9Zrqxo4wVzaI/FNchqgrpnSURMt zj/++Mcuas+/NE7cST8bhUvR8rYZ188+oL/DGgZuL+p/hZ6PMPnzvT6oxxuGV1Ss6Yz7 IPm1AZP1A7SGnCroeLBuOGyvPC1FnBlQMFgEMWH5vlqd15UlVnZIsOfuJzR68NnUhV64 6EhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ISIMMusJmNw5YYqYj+aWI4gg6Q9hbZa3RM8KoAWxveM=; b=K9D+ic7g8XVR697D/cnlnHTvdvKV2a+/0Xk38lesMB88846VHiTIEcQtW8HF1BkVBh yC26XmbT/mZ2dy47wfJQLO6SDr+exrWXm9B3wjEqN2JMZg9rjn0SN2EWYG5nJLzA7BCr gRvvKiVz0rdzhjKZrdba0CWbhIDj1Yb2C4XrL9P2qantcBSHmXL/eJi74D+SH3I3ML3S LyJaD6Dp4D02H0x9VEl/9VTfVaZn9e4DonwhmVSj+KHUZr6tPLyqNmZIEN887BKXl9HY vqk1lmpzrvl255Bd+bIoPNksjrjiiiQIPLoesAQa1+qwRgckE/y2by7Ll8CXwQgAHquB /5NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Z2IPMIHU; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r22si10637447edv.388.2020.09.15.17.20.11; Tue, 15 Sep 2020 17:20:34 -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=@kernel.org header.s=default header.b=Z2IPMIHU; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726909AbgIPASM (ORCPT + 99 others); Tue, 15 Sep 2020 20:18:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:38172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726885AbgIOOWr (ORCPT ); Tue, 15 Sep 2020 10:22:47 -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 0EC4A22275; Tue, 15 Sep 2020 14:17:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179458; bh=WrnlAqu4pYVCGlc1rGq/4Sm+z4IbESJor4R40Xlh220=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z2IPMIHUrSa14G7F4u/NK0PR2/MWSpSoRM/Dd5ebu0qvebfKsTwad7Sm+8SPE3tjh hJqlhYurbI0su8r+DhnJFpWPuh5qWMO4njXy/BM6B4umIMEspazF8GP4AB27nIeRHh GT8AZtR/RCdmCGCyV8HBwWTywwpWTi6BD0DdmfUQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joerg Roedel , Sasha Levin Subject: [PATCH 4.19 38/78] iommu/amd: Do not use IOMMUv2 functionality when SME is active Date: Tue, 15 Sep 2020 16:13:03 +0200 Message-Id: <20200915140635.495652007@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140633.552502750@linuxfoundation.org> References: <20200915140633.552502750@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel [ Upstream commit 2822e582501b65707089b097e773e6fd70774841 ] When memory encryption is active the device is likely not in a direct mapped domain. Forbid using IOMMUv2 functionality for now until finer grained checks for this have been implemented. Signed-off-by: Joerg Roedel Link: https://lore.kernel.org/r/20200824105415.21000-3-joro@8bytes.org Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/amd_iommu_v2.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c index 58da65df03f5e..7a59a8ebac108 100644 --- a/drivers/iommu/amd_iommu_v2.c +++ b/drivers/iommu/amd_iommu_v2.c @@ -776,6 +776,13 @@ int amd_iommu_init_device(struct pci_dev *pdev, int pasids) might_sleep(); + /* + * When memory encryption is active the device is likely not in a + * direct-mapped domain. Forbid using IOMMUv2 functionality for now. + */ + if (mem_encrypt_active()) + return -ENODEV; + if (!amd_iommu_v2_supported()) return -ENODEV; -- 2.25.1