From patchwork Tue Sep 15 14:13:03 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: 309568 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 04DFEC433E2 for ; Wed, 16 Sep 2020 00:17:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B330420739 for ; Wed, 16 Sep 2020 00:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600215477; bh=WrnlAqu4pYVCGlc1rGq/4Sm+z4IbESJor4R40Xlh220=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=O22SsXf0ShrYwF90RTJzIsOjq+K5d/SyLJhlkStf9BwNHh06z/dcjiQ5+pOo4YGhY 4ZqG0TBDp2K4tBmwRtgReMS8WJvyfaSAL2f9UgJhujD0AMDinSTN+OL+o58Y9nkWvR +uLk+MMglMQTX4yNXNp+VV+1rjE3LLSsqgnnx0d0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727189AbgIPARx (ORCPT ); Tue, 15 Sep 2020 20:17:53 -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 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 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;