From patchwork Tue Sep 15 14:12:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "gregkh@linuxfoundation.org" X-Patchwork-Id: 309601 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=unavailable 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 2ADA3C433E2 for ; Wed, 16 Sep 2020 00:05:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC3D520739 for ; Wed, 16 Sep 2020 00:05:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600214739; bh=BKVFiFzMUYAQUVaxQkM6bp25DCi8Pz65MYI1WSJoPFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=v5VEzmLhWlb2dpFbqJx6acIuHlJfuRlX1xijVaEL4g74+e8T8mpdvM+0GclmmOWkF Y/vw3nT5U/O9Exhl3LFmaqsuXSvmNwnDkvghRCnO4iuUDJ76E9QxlgVMIzefd1nfb7 856JhZ/XLaBwSSRUVgkXRheZrwFxWs3xTv8Aaino= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727003AbgIPAFJ (ORCPT ); Tue, 15 Sep 2020 20:05:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:43016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726977AbgIOO3B (ORCPT ); Tue, 15 Sep 2020 10:29:01 -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 778DD229C6; Tue, 15 Sep 2020 14:21:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179669; bh=BKVFiFzMUYAQUVaxQkM6bp25DCi8Pz65MYI1WSJoPFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WiROntfquB/p9OTaPQX1kGQjoPjV2Odn0n69zSGhfX/uYKaP7HPDXloYpi9c18M7n PldpvbZwn0XtwBNs4XMXBZ/ppZgOxzxuzenqekILfd8DcPRz7CMWI58I9dQfhYYntQ G4X/AzjAtHg0rxoq0dkYUQm17ImN0Jy5ryGVbNoo= 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.4 072/132] iommu/amd: Do not use IOMMUv2 functionality when SME is active Date: Tue, 15 Sep 2020 16:12:54 +0200 Message-Id: <20200915140647.715245510@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140644.037604909@linuxfoundation.org> References: <20200915140644.037604909@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 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 d6d85debd01b0..05f3d93cf480c 100644 --- a/drivers/iommu/amd_iommu_v2.c +++ b/drivers/iommu/amd_iommu_v2.c @@ -741,6 +741,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;