Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2721848imj; Mon, 11 Feb 2019 07:30:38 -0800 (PST) X-Google-Smtp-Source: AHgI3IZz4i5d4I1oC5GyfYmHkgjuVfQSUNmo9DFV63pwZ3iOP9XU1P851BqTi9HU0aZEbQXGi8U+ X-Received: by 2002:a63:6e8c:: with SMTP id j134mr16817635pgc.230.1549899038164; Mon, 11 Feb 2019 07:30:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549899038; cv=none; d=google.com; s=arc-20160816; b=bttMs6LjBL843ED+IhZ1rKJL4KOcPcAmp2Qc79x+NNfn0/JSqa8OckDWeCZ2538COc 6Umls28xWHgK2uTAD9lA2EQxTZ506gnNd3eCy8v7shew48YgOjxCyJfcdWps95ORfjfb hXWV6axrTSRv2JHFIY/z0V6fZvnuTJyDEVbbDvjzsgfYMlCKdMvlLqkQH11TLq3kHP43 NoJmTdBJD8bpNBGnziWm7q7BjFu7rHbqnvF9QFFJc83Lo4/Xs5V+UCO3U8U+kWmTMWf/ admANwApeYyGt8A9K9Gh2bCoZGiKdmIaE1EhvKmKZMvHxn6FML2NiIiAwtJCCoeKpWC2 D2Ow== 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=y1CAktEVF4k0aaV8XJ9gx0TIYbUlshkKBE9E8WOce2g=; b=aHDC6olxF5bo/lTTldy4sTWDf+1agnJ4EpXhmk1N0wIrTJ1e26iNO3XdnbdddVKWlp K7RqBBoT6UhN0aXwrNONBZT64OtK+dRWSYUZi/evPgMBpDfaQyRDzFg39ayXw6WAR+B+ g/nCmYAtza/GuNouT7prZTYoRDd7Oi+8F2gJ6Ar7CPXcGfZZP/1qy5XcgRR9ZCoXwH3E Qu2p8kd2nCztZb7+8EaDtoIQzC+3TITo9WFjroR7MTrT3ThAxRExku8XBfC/YZlw8EkG n+YvAG56kkkWmtpDKFsq8JwXPk5d9mpNeT5j7xyKqJ2p+81DITD4EhpGAA4j5ZR5d2R+ LjAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gUm0+G7+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31si10623150plj.244.2019.02.11.07.30.21; Mon, 11 Feb 2019 07:30:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gUm0+G7+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389650AbfBKP3h (ORCPT + 99 others); Mon, 11 Feb 2019 10:29:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:44812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389348AbfBKO5Z (ORCPT ); Mon, 11 Feb 2019 09:57:25 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 07DE1222A6; Mon, 11 Feb 2019 14:57:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897044; bh=DErTnLU0kcCUey6hUM5BBX9jcG6De/nceOOufX9VJC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gUm0+G7+YxEd4+tdMiJWl3eIp+ejS+Z/aS31nlLOQOjU8lUBL2SrPgcfa6gGhCDHs 9ONBttizRpBcXVrG622/d3ZHUxmOchx60nwgUXUaDfaHvQLjfjqJsrhzAoT4zs0cNn 5eKdFAEZt238Ua6uqC9w5M+Y2xeJqWbkdLapD0+0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yu Zhao , Joerg Roedel , Sasha Levin Subject: [PATCH 4.14 072/205] iommu/amd: Fix amd_iommu=force_isolation Date: Mon, 11 Feb 2019 15:17:50 +0100 Message-Id: <20190211141833.443087975@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit c12b08ebbe16f0d3a96a116d86709b04c1ee8e74 ] The parameter is still there but it's ignored. We need to check its value before deciding to go into passthrough mode for AMD IOMMU v2 capable device. We occasionally use this parameter to force v2 capable device into translation mode to debug memory corruption that we suspect is caused by DMA writes. To address the following comment from Joerg Roedel on the first version, v2 capability of device is completely ignored. > This breaks the iommu_v2 use-case, as it needs a direct mapping for the > devices that support it. And from Documentation/admin-guide/kernel-parameters.txt: This option does not override iommu=pt Fixes: aafd8ba0ca74 ("iommu/amd: Implement add_device and remove_device") Signed-off-by: Yu Zhao Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/amd_iommu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index efa6cd2500b9..766103ea237e 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -442,7 +442,14 @@ static int iommu_init_device(struct device *dev) dev_data->alias = get_alias(dev); - if (dev_is_pci(dev) && pci_iommuv2_capable(to_pci_dev(dev))) { + /* + * By default we use passthrough mode for IOMMUv2 capable device. + * But if amd_iommu=force_isolation is set (e.g. to debug DMA to + * invalid address), we ignore the capability for the device so + * it'll be forced to go into translation mode. + */ + if ((iommu_pass_through || !amd_iommu_force_isolation) && + dev_is_pci(dev) && pci_iommuv2_capable(to_pci_dev(dev))) { struct amd_iommu *iommu; iommu = amd_iommu_rlookup_table[dev_data->devid]; -- 2.19.1