Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1839127pxj; Fri, 18 Jun 2021 17:35:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRvtL6BwpibDUrfmxMeO/UUudJLEd5ou02YJEuMwSSc5nRfpLs75WmDrDga45JztCDOnIi X-Received: by 2002:a17:906:1c4e:: with SMTP id l14mr13588402ejg.172.1624062902714; Fri, 18 Jun 2021 17:35:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624062902; cv=none; d=google.com; s=arc-20160816; b=zYMpUDo/2VDIptvieRnfwdF7gOVa054EZFw5pXANNLxK+c3BS4QVu7s9JiCsJ4sCqa 9b6QOGZqusC7cvuSubLNGTmNlnb1YcJ++nU3hsybXzGZyh8KdlP9QOlDisGfLiRe2ODL XzYGiImM7Pyk+f4tLLrMikImMBzwoWzEj7Ub69J+5OnuZfU3+qAvPcDz3gVZX/Z80uN6 WGvIwHKcQ3nJdkzRZWl+1oG28nPwzX8TdR1Lx1Zfr47ieOnD7UqNWYmcttEMZfNKwb1F RwUa89YWP9YNBGejjRrd9zViaacRi068hLgQErV3AqyhXjLvl67iW4W+cjhX4eY/pqCz XU0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=2j4DFmaqTg7mJII5mjXL3wo0zAK/9f6Mm+ri23jZ0dk=; b=VZncDUr+v4nXSSGtVKbxluovjblBhdwv6/r3nW/BRwgeNB8e3jQj0luTbqSx79qBKL WTmNxh6pDsW46z/aLmWn2fh2qLQbI+U0witP2lSTAbetMzEPT8a3PhrMHhhWsrGFvHUi IVc678hZqQ2Sq5yBFIqpfAiieqM1Xh1spvfA/tIo/2aOtJbomhsHGCOWTl+8oK4PUpkr OGhlDKnUBeyV+vq8zQL8Sf/BSPkH4dFxF1cRVB1luJDbqpvce6BfxlgKPvOGty8x1M/q 4B5SOse4i9RMf3EfmKGEqgyV0yyLjOE6IZ13q0F+RbGHMbHLEIPX/LPvuQy8GiyM0tgr ObNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Uz9Z6JJQ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hx5si3064970ejc.283.2021.06.18.17.34.17; Fri, 18 Jun 2021 17:35:02 -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=@oracle.com header.s=corp-2020-01-29 header.b=Uz9Z6JJQ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233305AbhFRQJl (ORCPT + 99 others); Fri, 18 Jun 2021 12:09:41 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:52776 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231834AbhFRQJc (ORCPT ); Fri, 18 Jun 2021 12:09:32 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15IG26av010929; Fri, 18 Jun 2021 16:07:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=2j4DFmaqTg7mJII5mjXL3wo0zAK/9f6Mm+ri23jZ0dk=; b=Uz9Z6JJQ8ROB/Vco+gOwLn4gXHx/W6iZAg2KPPYebakmWrLiFNrgYj2mnFHC/4/6tYgi FyrvMEgO1WqPdJcL8+MkT7PLmw1jwAiWLhEKSHOOD7uaKIolhayMPd5n8vyuKnH60Q/l xkp2PsjOLjcVxMenCA1pllqKzZ8KyEP3kqCSXcynRnXdjBjNgxFKKPPUg3J5PMEFALD3 g6tSa/tTZnJDPdA7IlBO6H6E/9iTqu84Yz7RkahXri9mYiz7sTOx7z7ZVf1TDE6HohDZ mBTgqC+Zk3yj6LMaHYNs5k2lBjLwfLUAzsuEuQIslZ5dQ9GI7ylsq/jnajA1hXxlmK/3 gw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 398xmp00cv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 18 Jun 2021 16:06:59 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 15IG1Pvn108711; Fri, 18 Jun 2021 16:06:58 GMT Received: from pps.reinject (localhost [127.0.0.1]) by aserp3030.oracle.com with ESMTP id 396wawv2rm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 18 Jun 2021 16:06:58 +0000 Received: from aserp3030.oracle.com (aserp3030.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 15IG3fFt114314; Fri, 18 Jun 2021 16:06:58 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 396wawv2q4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 18 Jun 2021 16:06:58 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 15IG6tHa021864; Fri, 18 Jun 2021 16:06:55 GMT Received: from lateralus.us.oracle.com (/10.149.232.101) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 18 Jun 2021 16:06:55 +0000 From: Ross Philipson To: linux-kernel@vger.kernel.org, x86@kernel.org, iommu@lists.linux-foundation.org, linux-integrity@vger.kernel.org, linux-doc@vger.kernel.org Cc: ross.philipson@oracle.com, dpsmith@apertussolutions.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, luto@amacapital.net, trenchboot-devel@googlegroups.com Subject: [PATCH v2 12/12] iommu: Do not allow IOMMU passthrough with Secure Launch Date: Fri, 18 Jun 2021 12:12:57 -0400 Message-Id: <1624032777-7013-13-git-send-email-ross.philipson@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1624032777-7013-1-git-send-email-ross.philipson@oracle.com> References: <1624032777-7013-1-git-send-email-ross.philipson@oracle.com> X-Proofpoint-ORIG-GUID: 2dcc9vhgXW8othlKgr_oTBs9RkM_O--n X-Proofpoint-GUID: 2dcc9vhgXW8othlKgr_oTBs9RkM_O--n Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The IOMMU should always be set to default translated type after the PMRs are disabled to protect the MLE from DMA. Signed-off-by: Ross Philipson --- drivers/iommu/intel/iommu.c | 5 +++++ drivers/iommu/iommu.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index be35284..4f0256d 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -2877,6 +2878,10 @@ static bool device_is_rmrr_locked(struct device *dev) */ static int device_def_domain_type(struct device *dev) { + /* Do not allow identity domain when Secure Launch is configured */ + if (slaunch_get_flags() & SL_FLAG_ACTIVE) + return IOMMU_DOMAIN_DMA; + if (dev_is_pci(dev)) { struct pci_dev *pdev = to_pci_dev(dev); diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 808ab70d..d49b7dd 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -23,6 +23,7 @@ #include #include #include +#include #include static struct kset *iommu_group_kset; @@ -2761,7 +2762,10 @@ void iommu_set_default_passthrough(bool cmd_line) { if (cmd_line) iommu_cmd_line |= IOMMU_CMD_LINE_DMA_API; - iommu_def_domain_type = IOMMU_DOMAIN_IDENTITY; + + /* Do not allow identity domain when Secure Launch is configured */ + if (!(slaunch_get_flags() & SL_FLAG_ACTIVE)) + iommu_def_domain_type = IOMMU_DOMAIN_IDENTITY; } void iommu_set_default_translated(bool cmd_line) -- 1.8.3.1