From patchwork Tue Sep 15 14:12:58 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: 309683 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 00436C43461 for ; Tue, 15 Sep 2020 23:22:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A59D520936 for ; Tue, 15 Sep 2020 23:22:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600212142; bh=MfRNgySIkpHHnYNgad/82iP6adXIbt8e2kLzPLxy684=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=kGQGXpNUlxBCljEZT1v1cRMLfJTaduLROwy5ZYnlR+7nWx4QJQnY5sv3mdc5ffYHt cinBS8ioNDsbIonatckEigPlZJLAhCLbFvhbSsf2D5FXEQxFQ4BBmMzwpUgqI8yPxG DTUXJHS7dOxAzMv3DQbZhnvJ8DRrSWwgwXMjXWj4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727266AbgIOXWV (ORCPT ); Tue, 15 Sep 2020 19:22:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:48796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726379AbgIOOiG (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 2F67823C81; Tue, 15 Sep 2020 14:28:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600180096; bh=MfRNgySIkpHHnYNgad/82iP6adXIbt8e2kLzPLxy684=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F5bOq9/P0LL7H9JsGpOo91Pf5faverKht5lHSylJcEjqesFpE9o5F4RAqOSPgS16G JNIgVGHrRS1hd3nVgqudBYvd6c8NIG8l39CNOCpBmrE35kPARuJpzM0uLCKEsEN5bJ vhc8ur9V2PjGKlUqMZnHgkNfdGhxk9y08s9b5Tv8= 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 107/177] iommu/amd: Do not use IOMMUv2 functionality when SME is active Date: Tue, 15 Sep 2020 16:12:58 +0200 Message-Id: <20200915140658.773079964@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 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 e4b025c5637c4..5a188cac7a0f1 100644 --- a/drivers/iommu/amd/iommu_v2.c +++ b/drivers/iommu/amd/iommu_v2.c @@ -737,6 +737,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;