From patchwork Thu Jan 5 19:33:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13090392 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C5A0C54EF0 for ; Thu, 5 Jan 2023 19:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235984AbjAETg4 (ORCPT ); Thu, 5 Jan 2023 14:36:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235954AbjAETf0 (ORCPT ); Thu, 5 Jan 2023 14:35:26 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2072.outbound.protection.outlook.com [40.107.93.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D97917E15; Thu, 5 Jan 2023 11:34:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K1oc5+DGyqh55BY62wIiRCnoll5nvAbV0BT3sk26gk1qAR5MwHv/L/24JpYf9qOxfQVxT4OfOwAubuPeXmt7pAZMnrAdKxufeI3XfTpA8PInfvL95n5BRPY4Lppdo+NNSj7lSqkQOyhu/iBf+e+VSGYTL6685iubWYH9Jq+tcExZa+43AqiaeZnOk6uRm4T3jdXarIFUNf2hwJfHJeJg0L1s1rxN4428jWhqTm3m6AUjcQ2kWeR4O6N92EDyPtIaa0OvPyWeZQ0lsBANREj19co1XR+syMQESQN1CppuDBWfIGNfNnwHuEBn8cq9BwKUgXhKR/if0vaiBNV1Q/A/wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sosBjdYNTrjBhynMWFRWg8lUNZPX9K16eP56km3TEM4=; b=BuA2Bb68AXXz7N6JIfsVPGSX/R/NaUcMGhxlA6sQ8oag9r7hhjshGfH1Et8lnUNIJ5Pe0oO2xq/+wC5kW1pTUW7hoKuUao7Ot9ixhMGKfKb9cYrtit1PPFSopnlYZJw6lwlR9cmEixxmCSt3+PSSFSPvmbQp2YFd1zz/kbL6ocZq9Z0ZQVXoboSZEzKIUhmhJ5Ylb6GvLKHciUhaieqX/otVN6J6jjumLaLhlpQoCM4DIAe6hYZmRLzBPkmkOETtCbvYZiA6OxXEKLHfrAaEygWy/L5DgmXFyIZqIGXhpS40lOI01NPzpTBxWT7kNz929gGDcfI/7v0+1OfEDftQsg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sosBjdYNTrjBhynMWFRWg8lUNZPX9K16eP56km3TEM4=; b=b2Zb6H85AdsF0/RBk5q964DDMWmAnclnjdB9+rbIWkiVnpjY45PYNOcCHeAQUfEFdKnsN7u0cKVtRgu6NX/x0vue0NpHu2/EkBR7zeeYK/jBPJPF//hENXY33RF57jpvb3ms5pCPdQ+j9Xyx5xOdTDPcRJ3wOHA3M8nTnXQsho+8SoiiBiNpS8UQqPOXIsz6RpHE3ekWTaOzXFtPELoB9RLxT3sthCuEDFx5+wzuWR5/nspjBzKM1XZ1YRKHyxuJTPHmdnTAvEQiBO/U7z22YOWaqYMKm2dSty41vOVBlL18lNIP6WK3vTuV9qvPe+x9tp94xTjjzwjTA6Odqj7mcw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SA3PR12MB7950.namprd12.prod.outlook.com (2603:10b6:806:31c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 19:34:02 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 19:34:02 +0000 From: Jason Gunthorpe To: Alexander Gordeev , Alex Williamson , Lu Baolu , Christian Borntraeger , Cornelia Huck , David Woodhouse , Gerald Schaefer , Vasily Gorbik , Heiko Carstens , iommu@lists.linux.dev, Joerg Roedel , kvm@vger.kernel.org, linux-s390@vger.kernel.org, Marc Zyngier , Robin Murphy , Suravee Suthikulpanit , Sven Schnelle , Thomas Gleixner , Will Deacon Cc: Bharat Bhushan , Christian Borntraeger , Eric Auger , Eric Farman , Kevin Tian , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd v3 1/9] irq: Add msi_device_has_isolated_msi() Date: Thu, 5 Jan 2023 15:33:49 -0400 Message-Id: <1-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR02CA0031.namprd02.prod.outlook.com (2603:10b6:208:fc::44) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA3PR12MB7950:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f796dec-9ea9-4cf9-857f-08daef53cb35 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O3DFHfClBJyIa1wUHRZIfCoGvwn8UkRt7RJo3ybWNB+qoHqldDNoYp3UkL9VjMG1dDOfzWjH7mgpDu7GTaFB0SLiN5MqmhJvP9zx4N1AdPYEWYG6cIf+afwRoK7sTiuJg+IRATIZ9QGIve9HjvDnkh4JexDwTNypkjmG0WyCuQOredybUVRg3VbqoPM85LuxP9EaHYBSJcqNSZxJFfRSsjE3INfclcXhQbpX3J8aozUWCG8hx0CayQb7cVd7zrsOGS1HhAm6A4pYR1y7s5I3bdgOJZxNTTkgx2ZJ6gvBgavQQp0Wxi/oCpWeuUrUFUbYClyyNrM6QWl2/4sQOFGnFRgo67YQJTtP4sYdgRjGw47CCxvBEWA8131gdNfDlU137FxJzN1JkK6ek1rnKte9TlREf04WyIGT7jpoJOaaRBFZlfw+vqHH4NYICMgDKsjCS/g/KUp0E+CZQglCcuW/mmiks0gCPeZ+sXJXrnzBaxbbVibkcix1TYQPNHBSweWDqsjWutLjvmK4mrSkiHIS18UAD0/nr5JC0mJTsuofxzqg9Cow8SWwm06Pa9DB/FjBJOLkqnBAE9MzFxpiL/9S5xG4ppL8tslA9mcSu7WdEt+A/oqGhAiwqgxyXld/KBftOXVaQYRKCJmX7vf0mpht56WLmljb/2IrcUkRqiqxrq4XGs2lZARN0PucRYspVb7zQhLPJ2uYyZ0H8J2VVtIVmQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(376002)(366004)(346002)(39860400002)(451199015)(66556008)(7416002)(41300700001)(4326008)(66946007)(5660300002)(66476007)(8936002)(8676002)(110136005)(54906003)(2906002)(316002)(6506007)(478600001)(6512007)(6666004)(26005)(186003)(6486002)(86362001)(2616005)(83380400001)(38100700002)(921005)(36756003)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YEDquqSFBRbOBA7GEisZZfAXarWgx3eaKmAuOlTOaF0C85Np3HvRcheWRZGFss0cDHnHKDW9LhI4KVbW0sOWWc7LNe/QUOmHxGxRx6eqaqSqVvk8edm4MSISwYp0gPLWZFwQ4p2TZ9hRlRpsWwmjK2nXfWq0mbKmpulRXg6nTRbaqFQKL6CmJU01RsJ7fVvYehHwrVAXPhNfSYq3jhweEbBfOkatH0xQCAoPfzT324Pq5/RJ2Pf40pWBvCjLlb5wKZ/0CvgRAWZ4tUdIj9Uutvg5+1n+fLclsT5DGDwiI5RF/YKp0awuYY3D6uCRYqZykLrHl9DK58562UyHcY3hoEIJ38bocuRHQdmEn9PdWfWE0+ow5KXAu2ct5vZPXAWBuPK3i3DgXO4vcQv/QkfjZKXayhVIe2WaHhpaiQr5mTE5sVt1tWBL+VH6aSBd/bVX/22u36iGJSx4/UAqofDJoBSDpBqLLWmmBK6R7nyz3NuFz3p/udTbvmZI7klVE6/XO4M8ChJmTDUI8aU12GK5c8Ipx4LruOmRCv7BqEQTLHioqAslWOywA67/7BfIGCfXBB8swdkfmPqvEmdxtA/9Yc8NCKlGlFBJPv1owTsL+kJEAvJCnQVSwnx5MycZaMCMsSt0nRCk2b1PeW1Yd1dsacz1ldFJJ6qFbQlVYQG5+ICyPra0ZNDdBgln4YZdMSnlvLdDEEW0t1ynofLfjX1L8UGESQ8aW5Ov/rQXQG32QSlt8kqjM+OyqtURK3H/0yanWUL4c0REvrm6CYu6/iDlk6ZDRAPCQZrGvqVFGhVTRIES1nEZed45xJOWfWsu/vwhVCureO9rkWlhPLE4HNkZVbZ4ZjtdKjn5fA0E78j4zhcqrngwGiDlAg6Rrv07wca4ryxn2/GhT0EvCfuEvfhfea9Nn4BScyltbYBoSCgTC9WfOxXIeQf2XH80s4usnrQwfJR/MtE6N7MJW/gZ8SJJOotlUdJuUW+CgXk6M7QrhgYdXQ8KmbEOahItYKcoxSHggTw0fu7bXJkl2YQ7cvfTS4Nl6VQCc79rRzKPTnL8lb9CYI3ejZHBJPQTl9aizBkdVFJtmXbqcgZYC1McKBUn8O1Ei6pR6K4Z22ax5pd9W9j2bV6zNobwwBl+tJKe9qhUGLqawKK9uPWOuy5Gl8cmv64wrZMdbZ9+k724XWOPpQUzWKEUy7Z21NOYFuhoc0A/Fd2gRXz/QDhi+G8NG4z6dzM8cmD5yU3VKBgLzqZ1GgJ3HMPVSjv0SbFA1O/a2j8n/MYUHDN6xSfOYWGeIc82uZf0bcIrN/KftdYkgEa/XLHGEO4KowH7IDQ9zdCOrq7x+mR6L+elxJo0W+7eMrX1jTP6bw34Ac4OXd+iVJRGva4bpWnyCvmMq0HDz/L02d+uafcRoNJjLMxT4M/6uawtqjL4+gGltgQ9bQSaFi+kdupAJhMomo60Cc74dP8TaqDB3v4JUglyBQsEL+s5D3Aeap6qdfkF8Y7xbWVeNGcB6M3KghgqkGubu6N8Yqt1kJD6RYMjxqMz06keTNm9Lu7c9zXgJtCIR0wteMUXmTECdztR+TeYequ7y5O1GEnTxRcp X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f796dec-9ea9-4cf9-857f-08daef53cb35 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 19:33:59.8670 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fb69ybEkF1h/SUwY43NSSFow6oqyuHCAKvBhKuvwbUE+gEoczxMSmv81jN3kA5SZ X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7950 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This will replace irq_domain_check_msi_remap() in following patches. The new API makes it more clear what "msi_remap" actually means from a functional perspective instead of identifying an implementation specific HW feature. Isolated MSI means that HW modeled by an irq_domain on the path from the initiating device to the CPU will validate that the MSI message specifies an interrupt number that the device is authorized to trigger. This must block devices from triggering interrupts they are not authorized to trigger. Currently authorization means the MSI vector is one assigned to the device. This is interesting for securing VFIO use cases where a rouge MSI (eg created by abusing a normal PCI MemWr DMA) must not allow the VFIO userspace to impact outside its security domain, eg userspace triggering interrupts on kernel drivers, a VM triggering interrupts on the hypervisor, or a VM triggering interrupts on another VM. As this is actually modeled as a per-irq_domain property, not a global platform property, correct the interface to accept the device parameter and scan through only the part of the irq_domains hierarchy originating from the source device. Locate the new code in msi.c as it naturally only works with CONFIG_GENERIC_MSI_IRQ, which also requires CONFIG_IRQ_DOMAIN and IRQ_DOMAIN_HIERARCHY. Cc: Eric Auger Cc: Marc Zyngier Cc: Tomasz Nowicki Cc: Bharat Bhushan Cc: Will Deacon Tested-by: Matthew Rosato Reviewed-by: Kevin Tian Signed-off-by: Jason Gunthorpe Reviewed-by: Thomas Gleixner --- include/linux/msi.h | 13 +++++++++++++ kernel/irq/msi.c | 27 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/linux/msi.h b/include/linux/msi.h index a112b913fff949..e8a3f3a8a7f427 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -649,6 +649,19 @@ int platform_msi_device_domain_alloc(struct irq_domain *domain, unsigned int vir void platform_msi_device_domain_free(struct irq_domain *domain, unsigned int virq, unsigned int nvec); void *platform_msi_get_host_data(struct irq_domain *domain); + +bool msi_device_has_isolated_msi(struct device *dev); +#else /* CONFIG_GENERIC_MSI_IRQ */ +static inline bool msi_device_has_isolated_msi(struct device *dev) +{ + /* + * Arguably if the platform does not enable MSI support then it has + * "isolated MSI", as an interrupt controller that cannot receive MSIs + * is inherently isolated by our definition. As nobody seems to needs + * this be conservative and return false anyhow. + */ + return false; +} #endif /* CONFIG_GENERIC_MSI_IRQ */ /* PCI specific interfaces */ diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index 955267bbc2be63..dfb5d40abac9e8 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1623,3 +1623,30 @@ struct msi_domain_info *msi_get_domain_info(struct irq_domain *domain) { return (struct msi_domain_info *)domain->host_data; } + +/** + * msi_device_has_isolated_msi - True if the device has isolated MSI + * @dev: The device to check + * + * Isolated MSI means that HW modeled by an irq_domain on the path from the + * initiating device to the CPU will validate that the MSI message specifies an + * interrupt number that the device is authorized to trigger. This must block + * devices from triggering interrupts they are not authorized to trigger. + * Currently authorization means the MSI vector is one assigned to the device. + * + * This is interesting for securing VFIO use cases where a rouge MSI (eg created + * by abusing a normal PCI MemWr DMA) must not allow the VFIO userspace to + * impact outside its security domain, eg userspace triggering interrupts on + * kernel drivers, a VM triggering interrupts on the hypervisor, or a VM + * triggering interrupts on another VM. + */ +bool msi_device_has_isolated_msi(struct device *dev) +{ + struct irq_domain *domain = dev_get_msi_domain(dev); + + for (; domain; domain = domain->parent) + if (domain->flags & IRQ_DOMAIN_FLAG_MSI_REMAP) + return true; + return false; +} +EXPORT_SYMBOL_GPL(msi_device_has_isolated_msi); From patchwork Thu Jan 5 19:33:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13090394 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C8ABC63707 for ; Thu, 5 Jan 2023 19:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236060AbjAEThA (ORCPT ); Thu, 5 Jan 2023 14:37:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235962AbjAETfe (ORCPT ); Thu, 5 Jan 2023 14:35:34 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2084.outbound.protection.outlook.com [40.107.92.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A731417E25; Thu, 5 Jan 2023 11:34:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EWbWMxiaRBdPwhiW74kqliRwV4+vs2KvSUlERYEhe3/aIsp4JmjfZWZbDKGlEbTibUPFhkULU25ry/hmS3mP3hCtis1lg4nVw3yIYaA2oJBz90piUB+xkL4eS95yUQIO0bKDmq+3c6FwlwuR15H01JUYi08kwjaZlS3vQVbUXmmp9tOezaiw0ar9a9VjYdHbpJqHmInTv/0gqD2kyQzoU1t2UE9f+neSvyEtd9iSMBtqq+wK12igSGY01NeW2UcedJi6NggEAf4HQNhYaBiexWcMCTFvzBsnI6SrvL302gjgBTRXqzBjSZ/x2WA0Md2WlitnqbSdM9iNyfXPM11W1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Hl7XhSH9iz91PAHAZaxI8XUWKANy2bz24h1oI8ozYO8=; b=g9KNvDOQ5pTyZXkydgsAq0DTpH0sybr5ERECqw5gfzTk+bD/33eebG599TvGR8qWl8oervkiree5KgwtlT38904pm9PVrf6gkBjjt+RDCbGEjNdCI0P75StuE1ZzTRDc2qBsv8+W4avyAX7G3ceW7JnliaVX3iyZM7mnH0rSbC4bbQXGVNMmhOZXf03uPOju3kjbGiy1KksEkM8hipAtdHgOVC5AM+oPEsywNTcWqjo0aTZWh7fI9KEBu3CIZ9Ik+G5Y/5CMkga6PNwM5VGDLOjzPnIZ/qwsi77wlHQB8aaSpKrO36kwNMIIcJVTN7cSyE+Or9vyFUnnpV3nNqqGAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Hl7XhSH9iz91PAHAZaxI8XUWKANy2bz24h1oI8ozYO8=; b=S7UFyImZPnUSbv4UxZ6mtfUnqUqVoc2qd0D1Kfa9o5cHoqoMNSJ9gAfBePyh0N63mAQ9WSFTSFztFc8uE5zqCt4rIamtFyxfLPukvle1yckzllHYb1Htt3kySIslIX2TysW5EHQJs1S9mj2N5IyUVn5ikJaxBQfSIAjK/7KXtMzmql/9nejGYb+59B9LV5Knl8Tp/RgOCOi3Cq73V+YvJh1dnLhOeIsaj2GSF4uVnXgfjLgYUtlkBQOYOVVrxNdFu3KCHq29PggAlSu9vZtolI/Ne/7jimPUwpxTF++EHwfnxH59l0jzSoOKP2zlFii9/OCB3vO8P/kevfUnOmwJug== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SA1PR12MB6776.namprd12.prod.outlook.com (2603:10b6:806:25b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 19:33:58 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 19:33:58 +0000 From: Jason Gunthorpe To: Alexander Gordeev , Alex Williamson , Lu Baolu , Christian Borntraeger , Cornelia Huck , David Woodhouse , Gerald Schaefer , Vasily Gorbik , Heiko Carstens , iommu@lists.linux.dev, Joerg Roedel , kvm@vger.kernel.org, linux-s390@vger.kernel.org, Marc Zyngier , Robin Murphy , Suravee Suthikulpanit , Sven Schnelle , Thomas Gleixner , Will Deacon Cc: Bharat Bhushan , Christian Borntraeger , Eric Auger , Eric Farman , Kevin Tian , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd v3 2/9] iommu: Add iommu_group_has_isolated_msi() Date: Thu, 5 Jan 2023 15:33:50 -0400 Message-Id: <2-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: BL1PR13CA0153.namprd13.prod.outlook.com (2603:10b6:208:2bd::8) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA1PR12MB6776:EE_ X-MS-Office365-Filtering-Correlation-Id: 570b892d-6798-4ee5-7fc4-08daef53ca82 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CYsNRxYso3BJkE4NmMpT7tgNYGV2foZenWofQXyhN4ghXnJe92kaNcyL0M5xVid39izBe/LrgnfllFCqpYKIMDgRtEQL4f0qYr2GR0jzQ4Lz/0/PpbFYeztcf6y6UFinR91+/luinGTpcobk9kCGaGTliyA4uBXTkWTXpJKToBoGrou0nykH1LIK0mSx9fBxV3tJ4x0VZj/0JeDu7Pe2Ggsf4fJkp40NGNVh749qAx2Bu3IcraAZb/MiltXOtDDcPC0tkK3yQ/bhhEpdrO8nzxaXs5KB2fOLgKbDXHVu6bz4fmym4tS+Mo/tdyx7zjz5IlOLyEDDht4q/9MJM48AfL7ibQ+iGP5acCYXkYJ0fJ/PnLCz+kyTshRpFZ/Ni48JDk816qeRRYhpehJZMOPEw+2hJuZR41CM9o9RoO8scSQizpPM6/UdpJetesbU/d+kLT1h5XngWN0Dy6TNydVyi+xX0JtyHjZCQQb8LOO4gwo24QVBPQTgRUZE3fcI4HxT6C+9y8rt1WBN7zLacVFOECp/DuWnPRXamDta1gbJjr8WTsb5YGylBPz2xBlEtDsFznk2DOmtFd3tx2MsLUmyRhq/o5VnaHg0R5HHO+nlap8ZiSapjqI3lbQ1agKjvWKFACg7jdwL1vmM95q99M2dOvHQE4ktFQojGM1Z+U4TbokGIj+w4dL0OYeohnFGKOQLYUlFzRUlLZat91HhO1DAqg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(396003)(346002)(366004)(39860400002)(451199015)(6486002)(6512007)(26005)(186003)(6506007)(7416002)(8936002)(83380400001)(478600001)(54906003)(4326008)(316002)(2616005)(66476007)(8676002)(36756003)(66556008)(6666004)(66946007)(41300700001)(38100700002)(5660300002)(2906002)(110136005)(921005)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PgeeihRmc+JVsqWcYHyKOXJf+EvzFk7NWyBzIZ2YNxXF7i3koFFnS9w/QrQWsvkOHtejFGsXyq1ENhsFbGJpIsRxu565VWrZCnMA2i+Totb5gpNiANrs038PSZpUIB68XQIWN4l0A9CqBexks6iC9jDbZgrhtT4wkwAib7zoWPA/nNVlfeSfDiVxuug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W0Enrt/rB69EmZvzFUCaiexts8kWiBF1m2IsQdGVs60ahKB1i2zmXDy9QiyOQRUGucoiuJWB44Q2BXFfUHK+r5Sg69B0iRqxoz6pTZtEqCramJANHUB+AMW3H9a6SOAaJgAwsk8+SplPWWpwxRWerqqwnj1ordCWKYLJR2vbwvURL8emTgxONJCLLdjHNLw9mPz/oy+oFfoJjdlIfLbcfxzBnFL8jwCjGZ0D3IzQ6+GkUpRCNbTthW1uYaPIU6s84b8D+C3trUzpy5sWkJ36knZPwjUvxxiBGL6RlrvuS7SmQsFkiWvALJCzzY4bRNuNFfqYsoGdlpt X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 570b892d-6798-4ee5-7fc4-08daef53ca82 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 19:33:58.6782 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Nitzb4mXnqOtla20wp+bCah4BFaQqJFpxiMd7wEDjrErqthv6OrCon0QddncpqbW X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6776 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Compute the isolated_msi over all the devices in the IOMMU group because iommufd and vfio both need to know that the entire group is isolated before granting access to it. Tested-by: Matthew Rosato Reviewed-by: Kevin Tian Signed-off-by: Jason Gunthorpe Reviewed-by: Lu Baolu --- drivers/iommu/iommu.c | 26 ++++++++++++++++++++++++++ include/linux/iommu.h | 1 + 2 files changed, 27 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index de91dd88705bd3..7f744904e02f4d 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "dma-iommu.h" @@ -1897,6 +1898,31 @@ bool device_iommu_capable(struct device *dev, enum iommu_cap cap) } EXPORT_SYMBOL_GPL(device_iommu_capable); +/** + * iommu_group_has_isolated_msi() - Compute msi_device_has_isolated_msi() + * for a group + * @group: Group to query + * + * IOMMU groups should not have differing values of + * msi_device_has_isolated_msi() for devices in a group. However nothing + * directly prevents this, so ensure mistakes don't result in isolation failures + * by checking that all the devices are the same. + */ +bool iommu_group_has_isolated_msi(struct iommu_group *group) +{ + struct group_device *group_dev; + bool ret = true; + + mutex_lock(&group->mutex); + list_for_each_entry(group_dev, &group->devices, list) + ret &= msi_device_has_isolated_msi(group_dev->dev) || + device_iommu_capable(group_dev->dev, + IOMMU_CAP_INTR_REMAP); + mutex_unlock(&group->mutex); + return ret; +} +EXPORT_SYMBOL_GPL(iommu_group_has_isolated_msi); + /** * iommu_set_fault_handler() - set a fault handler for an iommu domain * @domain: iommu domain diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 46e1347bfa2286..9b7a9fa5ad28d3 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -455,6 +455,7 @@ static inline const struct iommu_ops *dev_iommu_ops(struct device *dev) extern int bus_iommu_probe(struct bus_type *bus); extern bool iommu_present(struct bus_type *bus); extern bool device_iommu_capable(struct device *dev, enum iommu_cap cap); +extern bool iommu_group_has_isolated_msi(struct iommu_group *group); extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus); extern struct iommu_group *iommu_group_get_by_id(int id); extern void iommu_domain_free(struct iommu_domain *domain); From patchwork Thu Jan 5 19:33:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13090395 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBA7EC64981 for ; Thu, 5 Jan 2023 19:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236157AbjAEThO (ORCPT ); Thu, 5 Jan 2023 14:37:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235766AbjAETgB (ORCPT ); Thu, 5 Jan 2023 14:36:01 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2084.outbound.protection.outlook.com [40.107.92.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BD111A39E; Thu, 5 Jan 2023 11:34:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QtdxJ9yIRSqtdfgB7d3yw0IWkGWL53NAU0aBDgIkYfObjYNSpmMSDOn2KDiUVKj6kdFNTlBnhO7q1BDejYaZ+TsrOCXM2iyNxkXMiagPBX5gLDjzVgnxUfsPw8aO97q+p9XIXGznSjj0wzNvVmwTwQkNC66nm+CDgmuQGFO5r6bVRXBTdxj8s+blN+C6DKWlEwMRVHa5vbGgh3gMNZAh8F2GYDqdZItzthAd6tfXGBFjzARQq/h6MLWX4VaXAGhKOCUMw+0HISgAkJiOEITbgyM5NcYutlRzzinGaq3Z9znz7YGGWo7qDvA7+p03n7guP7Baz2QzmdrG1mlGlTJAig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GrCuHObzvLnzWtfGMBKcR0aBdQFymdGSL2skEgBgidk=; b=S3dwKF+7/QNFgQzuQibQCqwgGlF49BbGDPpwcBiJPs4Tb2A6413UWD47KAYWN5ZuS91UA634AMMV6FwifVjUhZt2fJ0D+jT9A4b2RhCOdxVvAu+NKcsjrpGCLn05165O+DTCijtLomRyZ/eH/uviH2SGjHUJIHsmOGDTbuQe6InojP7wOjhJ0j5Cwl3cu+WUBh7btAWVjZoDcJbg6mlUNxzGAQa6+Sh0VO/fORSUGWHcPu9BcMBQ6EWd41rHKGoeWvWS4+4dBmCOdf7WQyoWrdIDE9w5teg21hfsOgcIEOvaTPIHF1sBsjKgMRNIKlnQKn5/abaAdA757sylFs/vsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GrCuHObzvLnzWtfGMBKcR0aBdQFymdGSL2skEgBgidk=; b=YEA5jyudbJ53pPcUCrYGWNMCDP4Uq/sM5Li0Ms7Cuh7kH31Qa98esLSIuxftIAhQWbROStNrucaNIH6HZtKne3AE3Iy7kNq/gfipDQ9kusVvcezr0zQTVMNs/rbwcSsMRCW6qdwLlEjilV4zxv4fWJ1oIzdldOfaaYlzTID3e4PHtuvMEVYAp+e09VaoFEGdfr//pm455B6xf+nzeJaFxxPtVTkBKxElA6iBipCRjoMBsmGQg8otl9tDLye3Jx1wv0+py7SyxpliZl77qFd8kV/11q0F13nM4cP/xUe3OL8e8q1M2iaUgdlug1QCMQCAWDZovCdoyZsXQ2C7FT33Jw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SA1PR12MB6776.namprd12.prod.outlook.com (2603:10b6:806:25b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 19:34:00 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 19:34:00 +0000 From: Jason Gunthorpe To: Alexander Gordeev , Alex Williamson , Lu Baolu , Christian Borntraeger , Cornelia Huck , David Woodhouse , Gerald Schaefer , Vasily Gorbik , Heiko Carstens , iommu@lists.linux.dev, Joerg Roedel , kvm@vger.kernel.org, linux-s390@vger.kernel.org, Marc Zyngier , Robin Murphy , Suravee Suthikulpanit , Sven Schnelle , Thomas Gleixner , Will Deacon Cc: Bharat Bhushan , Christian Borntraeger , Eric Auger , Eric Farman , Kevin Tian , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd v3 3/9] vfio/type1: Convert to iommu_group_has_isolated_msi() Date: Thu, 5 Jan 2023 15:33:51 -0400 Message-Id: <3-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: BL1PR13CA0323.namprd13.prod.outlook.com (2603:10b6:208:2c1::28) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA1PR12MB6776:EE_ X-MS-Office365-Filtering-Correlation-Id: 0309e0e2-d173-4d03-ad45-08daef53cb1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZtCwkxVvBf9qARP6y/RLFDDpVgvcjb0LEJF3gv88KUV+TA3EYMXFq56PVjeLYNRw6s+vTGvv6Uf218QDEsMgohxQ5Qd8+OjBwr7Z6WiwXbkdRGH3Hn0AR6RHswKibQJnMtHmRtidGSTqG/EFPM/8OAxdvpFrILuLGevbgx1SunpcFS2spkxT+Xo1uWNIlAk0ysgHVa1aQhvkH0nl5cjV5q+V8E/ohCfyaObxoMwDAbxsF6cwFA1qfGRmcyWsaxojiM+yELA33QfAAwyglOtISaJONWtvBRRpHk2s2TtQAzmNjiVnuceN1BXECNC5vcRzJxhSDiUCKNVD/G3Esw0VEchKlucx9A0fg+iasBUreWE4W/wxT52J5nQRW3KZ1wnEIt6eZTHQY6D4JxxYcn8S6CO3CQRmaIY9V4JYHWUXLrUUwCbsseITaSajvSifG8kpJYtIDQqHWyJhviwTMw8q21gOSpiDWwyKE8rEuOT1bw/TT69bVqEAnupZ0ocu4qVFaOKhpAjSgUHgaNMLkB03nTezHh1cEmuG76p/XwBE8ipN+uGeWq1Ur406/Sz8LrMhtpGsSkhsPX2/UWhyshc9epyon6Xxy4MVyTx1WAYf5EscxtvGnGqSvlb8UmX1EPxeuoY4HSk5smVeEDsouPW4hsc7jlPjgjz1OuNP07Qp1VCjIlsiEr2PTUlpjcvE/D/AElpPAm46m5sBnavoKEaMmw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(396003)(346002)(366004)(39860400002)(451199015)(6486002)(6512007)(26005)(186003)(6506007)(7416002)(8936002)(83380400001)(478600001)(54906003)(4326008)(316002)(2616005)(66476007)(8676002)(36756003)(66556008)(6666004)(66946007)(41300700001)(38100700002)(5660300002)(2906002)(110136005)(921005)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1/y11guwduQpFjVHaXfJqdLtOrINwJOZdnxq4utOJnHvfsELP35lPbcRM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28PevzLl1WpgjX+ufqmgXP4fm9j3bvKhM/TlyberZslQE0IMmbH1eMGOqWSv39/TrBMB4Vo+OuB3L9zibLyqKwf/U/fY7zE9gipP1/yns1FbQeeCv3pC0J+/gAeKW9LmjlgXUMoxX58UTcCgnotJB3UQ8BfJTNft+0lj3GWS6zFP/3ONHth0PuGykBDtMPeFySJFMcfaznEB6MwYo4Kb/QFZljjfEvcEYRKdJFQXkT1OqUcpJkkU6Ji7RbmfXX7Ua2ZW3fhXxvgqou/WLIktoR4ErxUooy61o2RKOhzzh2OZTsswmmHNqb8logLeSoPaOPn5YVCPQZN3C/zrDJJJFX/0xtbLDWfa+1ld0A+9zLOZQKWpNlTzH6fW7M+iG3+RmDcRXrvY3ROc6MKkpT82zg+dxQXJ2oXidWksX0Zx+Z5iUdVb1KrOPJsvCwJFJAOtSJ++QE//yFPXUao4p77wNzum X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0309e0e2-d173-4d03-ad45-08daef53cb1d X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 19:33:59.7264 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8uyMZX2xOmsKx02pKGwCOLCv8vKlw4c1Qbq2iC/07na8H1rb1k1Lcb6wtMPuJ6LG X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6776 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Trivially use the new API. Tested-by: Matthew Rosato Reviewed-by: Kevin Tian Signed-off-by: Jason Gunthorpe Reviewed-by: Lu Baolu --- drivers/vfio/vfio_iommu_type1.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 23c24fe98c00d4..393b27a3bd87ee 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -37,7 +37,6 @@ #include #include #include -#include #include "vfio.h" #define DRIVER_VERSION "0.2" @@ -2160,12 +2159,6 @@ static void vfio_iommu_iova_insert_copy(struct vfio_iommu *iommu, list_splice_tail(iova_copy, iova); } -/* Redundantly walks non-present capabilities to simplify caller */ -static int vfio_iommu_device_capable(struct device *dev, void *data) -{ - return device_iommu_capable(dev, (enum iommu_cap)data); -} - static int vfio_iommu_domain_alloc(struct device *dev, void *data) { struct iommu_domain **domain = data; @@ -2180,7 +2173,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, struct vfio_iommu *iommu = iommu_data; struct vfio_iommu_group *group; struct vfio_domain *domain, *d; - bool resv_msi, msi_remap; + bool resv_msi; phys_addr_t resv_msi_base = 0; struct iommu_domain_geometry *geo; LIST_HEAD(iova_copy); @@ -2278,11 +2271,8 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, INIT_LIST_HEAD(&domain->group_list); list_add(&group->next, &domain->group_list); - msi_remap = irq_domain_check_msi_remap() || - iommu_group_for_each_dev(iommu_group, (void *)IOMMU_CAP_INTR_REMAP, - vfio_iommu_device_capable); - - if (!allow_unsafe_interrupts && !msi_remap) { + if (!allow_unsafe_interrupts && + !iommu_group_has_isolated_msi(iommu_group)) { pr_warn("%s: No interrupt remapping support. Use the module param \"allow_unsafe_interrupts\" to enable VFIO IOMMU support on this platform\n", __func__); ret = -EPERM; From patchwork Thu Jan 5 19:33:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13090389 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 456F5C5479D for ; Thu, 5 Jan 2023 19:36:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235762AbjAETgP (ORCPT ); Thu, 5 Jan 2023 14:36:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235928AbjAETfL (ORCPT ); Thu, 5 Jan 2023 14:35:11 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2063.outbound.protection.outlook.com [40.107.92.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 181B0EE25; Thu, 5 Jan 2023 11:34:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hbls8eYJ9Sn+cYwfukoJ4czWQG0laskXfXp2Qs2q+2ECFBqxCQd9RaEZEhksteksslcd0xZaizFRCwg+QZxDeyTvGpEsoR0qAoYCuY4uH3+FwYvln8x5BehX9IDNHGNUmu/zQo1/tzn4JXSGZNSQ22Kp1+vnXoaJd6eizX9zLg7BliprX/9HrVn537qkYW3R3n3Khr62D1qkd3VbCeLpBNdciuK0BeBPnLk/5tjxADZ2M/NftyXPw5Brma3ETxYG+eVgASxP+qDWWISoDz8s3e773AN+Zu1TtQ2CamskiuPNwKOejpOUdBtRX2eHSHbNrZ0KkggsNVSRm3SBkNR/iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VVZI6MAJ6Q7no8ep2bQlh0Nl9Ee+c9c5pp/n8uIBW78=; b=bH7mFa5oQNKhFMV+OOTP2y828qGgq1yJ107tk5N0ZgJaDsHn79BS5V2MEqVMUv1KSFHLb79dQpL6ZOTiaEN4uEJ8G38Pz2QTfV8gdzhhdXfxQx/vtKeEeI3me/WjNsU/C/VAoQY3mc2LhzIZgCYun3deStrxHbRrVoeJbrbh6DhKQyZJs2KJ6kS2yNgRPdRU2CTFnhCLQ15/EDeN3ubjt6I6QDRV7EdHkkXWgAWyp54JFt8kHD8LHER64HJNnQmVvItVTrxOx/212SDFxxFAfRTM5Fa5iYNlb/SUajOJLbMPWR8YLeWuzDP0tpIY5Gx9tVL5Uu/pS55BhLbZ/A7xGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VVZI6MAJ6Q7no8ep2bQlh0Nl9Ee+c9c5pp/n8uIBW78=; b=U/Z8uJkCxKVyDSUpdBkJimtHIyoPsJrsxsWEWAgIVsFOC0BfiPGtZKT8CdnANORxthXT5gmPESAnR65TMf5O/z2OhWmce80enpiR5mIhD+knRXCWLWUxe1N6m6ZtXfuOyQyqWqH2l2k6CjAmEnEcYBGWGh2lFREsVBqV2vJ+UiOOLvxdcyev1CmginqVVnwz9OTpnwIQQ3MjnsOCmBMFY2vSZc7vgPEB4DnSdUdy0Mwz0Ym+BzQa8VrhxHzRYIPooxCqP82mOjcyIhlrKiBm/P/JCJU1vZr2vJMIrEM1C6+SWrMda9u6XpgqoItuBnsmaopAgYBbydtEnoYY0z9NBw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SA1PR12MB6776.namprd12.prod.outlook.com (2603:10b6:806:25b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 19:34:00 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 19:33:59 +0000 From: Jason Gunthorpe To: Alexander Gordeev , Alex Williamson , Lu Baolu , Christian Borntraeger , Cornelia Huck , David Woodhouse , Gerald Schaefer , Vasily Gorbik , Heiko Carstens , iommu@lists.linux.dev, Joerg Roedel , kvm@vger.kernel.org, linux-s390@vger.kernel.org, Marc Zyngier , Robin Murphy , Suravee Suthikulpanit , Sven Schnelle , Thomas Gleixner , Will Deacon Cc: Bharat Bhushan , Christian Borntraeger , Eric Auger , Eric Farman , Kevin Tian , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd v3 4/9] iommufd: Convert to msi_device_has_isolated_msi() Date: Thu, 5 Jan 2023 15:33:52 -0400 Message-Id: <4-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: BL1PR13CA0152.namprd13.prod.outlook.com (2603:10b6:208:2bd::7) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA1PR12MB6776:EE_ X-MS-Office365-Filtering-Correlation-Id: 693e5836-432d-4c70-2d47-08daef53cab7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7CATumuBUFZ9fs2CBPkpX3dcNp9m+3fpijmmy1fEoycuPlTQ99piY1Z2bxPOLj7WKWLt8WUQ7iexuFmRiNvmEdnxCmIsOuaH0izbwgu/xee2HxtKC08Pdw95loBJP5Xj07ZWYUH4p0vf8ZD21SHTJ3e8NPf/jmA/wCSN3Zc/YtiTS5pUF0xkXdUD0ChVkJmxdeo/icMMpRlfR+KlIzot14mRgG6RxYfHSV3gETwZzmJWbePsaDujjUjVjy6nXMBkpStcZ06LdN6VD6cVfx47xxCOIRcoRUH72/qkDJFOtkT1itD5/byM5K+lke8QiKt5ljN7hMFFKF4eEXHH244RyH9AAaY5KrtVEhfFCnMAI+XtNErN0YiCu6GbBERZJAHkGf4KxVFU/KWP5Urha2oG7CBB/n5ZvFJeRQ4y5f9KT9c9uZ79Lb32GGG/PWSgtKLHkIfSOf6+dT1h8rAkv/T1aBiM136KYc4Rr1k8HHTX25Og5ySLzlJ3fxLJj05lK2ANYJrrzxJDHkSCWUxYHySb4t8sTm0sz38kNrx9lN+Yje/RWVVR/kDnMPaQ/2soKXz0fU6abMPJOfXasvfx8Wj19sqvgO4Yb3o+FZVGfZQ6vlyRt29DkEfNxriABuvh7aLLiDpwBEdUfq73SstPpl6ZDMO9khUp5js7x1SYfGr36j2cEMeJ48E9B3h0gPBJ965gKU+2cgRHq2P0Wl+nR1RhVw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(396003)(346002)(366004)(39860400002)(451199015)(6486002)(6512007)(26005)(186003)(6506007)(7416002)(8936002)(83380400001)(478600001)(54906003)(4326008)(316002)(2616005)(66476007)(8676002)(36756003)(66556008)(6666004)(66946007)(41300700001)(38100700002)(5660300002)(2906002)(110136005)(921005)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: j4mCNIe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ih6YtY8n5TUfEzF8x0KWDoduRYB/S+twSNQwAnkWAX1ikjadcnVvlICQgnDyhjrUWvXNVT69Y33LR1QIe4BweFZ+NOOYZXcOIwP0vyBtRYG431lL/g2c2KwlVjUvEH4YorgKtJ+L4exhbF7r0rHUhyi93t1ottjtAzLsYKXttVo49PTdqEVpVh8A08E7mZYM1VJt365Y12I9jxtVIyMJeFYTYirDZQ7iNt8i1Iy8t7nuvaPdKswTeEZbmfS1G2rk85DKiH660YIKi59p/EPnmt43Ot/nw4K0UfkFX798AIRZIzzibIIPPZb5ntVVWZWIctG1/Z9Klndj2EChX4WWoHu+uc/6g2WLKHFeahnAZLC23UoDzgqrXSN7F/TUveSw6dD2f+r24b7GXigHy5ANxjUhTvWBSWNVvySvucKO0ygVOYfDiNwNeO98qwqI76hHWTghTB/LykBaM/jjQDXFEnICZ4m24x6qV8OlB9KC6d1roSZnEaddA+slc+QScj6vQSrOhPChuy09 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 693e5836-432d-4c70-2d47-08daef53cab7 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 19:33:59.0079 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jfCW5t+ocA42iTntVtEogR7oePxLr1vD085wCtEnzfZtyJfyw3xWIfpOQ4kH+5f1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6776 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Trivially use the new API. Tested-by: Matthew Rosato Reviewed-by: Kevin Tian Signed-off-by: Jason Gunthorpe Reviewed-by: Lu Baolu --- drivers/iommu/iommufd/device.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c index d81f93a321afcb..9f3b9674d72e81 100644 --- a/drivers/iommu/iommufd/device.c +++ b/drivers/iommu/iommufd/device.c @@ -4,7 +4,6 @@ #include #include #include -#include #include "io_pagetable.h" #include "iommufd_private.h" @@ -169,8 +168,7 @@ static int iommufd_device_setup_msi(struct iommufd_device *idev, * operation from the device (eg a simple DMA) cannot trigger an * interrupt outside this iommufd context. */ - if (!device_iommu_capable(idev->dev, IOMMU_CAP_INTR_REMAP) && - !irq_domain_check_msi_remap()) { + if (!iommu_group_has_isolated_msi(idev->group)) { if (!allow_unsafe_interrupts) return -EPERM; From patchwork Thu Jan 5 19:33:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13090397 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B974BC63797 for ; Thu, 5 Jan 2023 19:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236109AbjAEThF (ORCPT ); Thu, 5 Jan 2023 14:37:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235944AbjAETfN (ORCPT ); Thu, 5 Jan 2023 14:35:13 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2063.outbound.protection.outlook.com [40.107.92.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45E5417894; Thu, 5 Jan 2023 11:34:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EZIJNGNTsleZTnhBIgKZZZ7eMTG2xUF32mEfbRUJJMd/TvlN3/XX/YboVrgv4oMvRH4/eSC3QksKmHqFWlHcXyRcRfS55D380YyiC39ZoV7w3FseTVS5oBn+pHtiDU79kQ2QdwDRN5trrdyBV6YNE3Aivug/dvCkB0U5wWyf5rIbPbFWNhCNPZG+nbu8R4Iapa7oT7oyEFlu0RQ4oPcnzyoaB48DkRSzLG+bGOzCpMiOs/x+GMgE8noi1bOBmozY8yjEu0nSuRwuLlN4Ngh5zzH4yMM2jdn37B0ebh0RDwU0uEmCDqXUSHKyvplXUmFV+rsssl39iaTaNwPaSy5dig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZvEIS91FyxOHJlA7slRdWkbc8+lsRvHRgU+kOfTr3Hc=; b=JX5JErh6TJuYnGAcCU494EqoN9EvfJa8wQ7yZopnwg8gqCYK9E3E4jbjptyNvsKBO333AVQTLtCKQA0euAHGgkmvfnkUTOXU3bc19jYLKhiSdGGQi38dlClS04HFsZI5hbb7EZau0CeWMjEnJS9Vcddaf50hNTaojQa5HQ6AH1LgARhYNXor3Z5YpRdMnsj42GBLFTXkNF8yMNpPGe4Xq4344KBZXHs+j6hJ7LLUhGMxGlMlC9+LnGsNEgqnfBrr5jh+tFG/4HHmOHFkPlGYJVaGk4x5dC33h5yRp3qFRfda8c+tH+Sh702kov07xM60Hpuwp2lSt7ih8PWOxXqJow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZvEIS91FyxOHJlA7slRdWkbc8+lsRvHRgU+kOfTr3Hc=; b=Djx+UUVE+TpW/0Cw3tOr6ez8vb8ySpVxP0s8gb4XkYX3/aMVGqPD+akIx5dhA6UMkAHi6h4dG78h4DFKAxfLRzPSK1hRcov0c2iK72mxr2RwfrXdh4zJQGb/ddsj3Emo+v30oAkcmqzzs2CAreyS/Wt0YyJRFnSDa3VJt3H+2/cEX9yG8OnAPXT0u4gHU+QDzNyql3T4eOKhJsYAhPNZu77JyNvNt+38FXONazomvv4yP+HGUYpL4NLhYgmt769TWHsMiTKUoZw7NguLtOHZLGRvBv3JhG/YHhmQ1RoJxNwTZWLG2zAEeILtwJqol2QyPyBX9LP5lBxTHwQBwdwrJw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SA1PR12MB6776.namprd12.prod.outlook.com (2603:10b6:806:25b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 19:33:59 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 19:33:59 +0000 From: Jason Gunthorpe To: Alexander Gordeev , Alex Williamson , Lu Baolu , Christian Borntraeger , Cornelia Huck , David Woodhouse , Gerald Schaefer , Vasily Gorbik , Heiko Carstens , iommu@lists.linux.dev, Joerg Roedel , kvm@vger.kernel.org, linux-s390@vger.kernel.org, Marc Zyngier , Robin Murphy , Suravee Suthikulpanit , Sven Schnelle , Thomas Gleixner , Will Deacon Cc: Bharat Bhushan , Christian Borntraeger , Eric Auger , Eric Farman , Kevin Tian , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd v3 5/9] irq: Remove unused irq_domain_check_msi_remap() code Date: Thu, 5 Jan 2023 15:33:53 -0400 Message-Id: <5-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR13CA0009.namprd13.prod.outlook.com (2603:10b6:208:160::22) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA1PR12MB6776:EE_ X-MS-Office365-Filtering-Correlation-Id: e887f276-5cd4-4701-bb5c-08daef53ca7d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iEwrayhJeo/zuUKSpY27I0s7wN/5ZVITrEkY0zNkyOmiRRMrAjU/lCFTOMt7lKYfqKDsnqLo+S2cxrmCRvnPTQeVSPn+vWA3ObyoORW2rso9HujTyWc3hElDGhCy7qpcr44VhB42jPTfqMl0y1ytS2mQqKm0BMW6ZdhRwzdkSBTJcUb5uD7dlGyORFhEFKj1FcC9Zy8XlPX6dwz37RIAxeeZ2UYa2Jrb7FRUY89uLl+t9cMZCPP+SLYmVOKo6M0ipclmfnIdQ8yvJU5NyclD2Z+EmAiCc2ZETYLiHQigAKEL8MC6GH+CKNuKfca1AeLlgHy3UHkSDhIOnwS1eqEyZK8CE47pdGPVIiygH1o9qIU64TZiX3QwYkUMP2MPVmW9+w12r0ai4boAmoCzzIevKjI9lGC4bEi1NHRIvAiDKroQFHaZN2GIrt4e0a1hPzjkRsD2B8SDdMWHuDuxazdUtvUKo5XC1z4tyDMTN2Pv91JHrb0AaMYmHIMJKmtTTZr2OsQBW8CVjOzan45nk154KHuHvNvipBl/ZKlT1rYzgnZqVfP2/5HqwF78YU8ky0+DveT3ATSPIIKaXx2dls+nB3R+iRwnGCXqqipJN2AaLij2ehLDXO/o6cEKF4ydI6/BO4Q1GXOWHyyLGXhGAZfO4NxjqlL7B5CKGy3ClLtQLF5rN0ZXmvLOYikqsx7WoW9dNnR0/0ihZpyFrcjIwvDVKQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(396003)(346002)(366004)(39860400002)(451199015)(6486002)(6512007)(26005)(186003)(6506007)(7416002)(8936002)(83380400001)(478600001)(54906003)(4326008)(316002)(2616005)(66476007)(8676002)(36756003)(66556008)(6666004)(66946007)(41300700001)(38100700002)(5660300002)(2906002)(110136005)(921005)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: d0j2pCTDAzyAbQiWfVdMvLSjjKv4lhCNiWFhd0FN/RzrrayFi4YzgTcgRpvWAJaLzIhSSHL4biL+Al90R0UVVaZi7olrFZpGQim1SgJ0bNc9SrZrU6Gnr/im9+nATkI3QUFuWYoF+Sfi0gNdOkLaQq/4TlyFBhIaus/tW9rFqULtVBvAvWpkqVbovG3yy0Xn6YVoxji0Rhrm8NBnSOBYxk9BRP5eHe/rSICLVX+BFi3KEtKHvUnbAVOTwWtF4Y2bpaZn3eBLPZU+XqjzhRky5bX2yTA6yx0X9+/3UcCI4TDo136lc4e+hfFWGoJUrmqU9fmS3qkanYfpTZNrautCmHUN+M9DglDMUYPrZ6CpJhqeBhRdmZdNMvEB7o7LE8KiJwj6E+mOMw7ZIPUl/v0XVlM9hIny4ucShHIBO2QVIA5zMnlR9M4xqPxB3zj/OLUHo6Ole9K51zi1yM/sBEX2DzNVexSeK4Sjv+oXIiLqtEJnrr17PvQisiyocaPN4j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DlF8Uw4t2nCa5MXYAhOwrgN X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e887f276-5cd4-4701-bb5c-08daef53ca7d X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 19:33:58.6939 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CBXShzvSLetb8ELJ/OxxFu67nliH8URecn5DQS3ZFT6kjc55U3Z/KTj5N4TbXbxj X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6776 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org After converting the users of irq_domain_check_msi_remap() it and the helpers are no longer needed. The new version does not require all the #ifdef helpers and inlines because CONFIG_GENERIC_MSI_IRQ always requires CONFIG_IRQ_DOMAIN and IRQ_DOMAIN_HIERARCHY. Tested-by: Matthew Rosato Reviewed-by: Kevin Tian Signed-off-by: Jason Gunthorpe Reviewed-by: Thomas Gleixner --- include/linux/irqdomain.h | 23 ----------------------- kernel/irq/irqdomain.c | 39 --------------------------------------- 2 files changed, 62 deletions(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index a372086750ca55..b04ce03d3bb69f 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -276,7 +276,6 @@ struct irq_domain *irq_domain_create_legacy(struct fwnode_handle *fwnode, void *host_data); extern struct irq_domain *irq_find_matching_fwspec(struct irq_fwspec *fwspec, enum irq_domain_bus_token bus_token); -extern bool irq_domain_check_msi_remap(void); extern void irq_set_default_host(struct irq_domain *host); extern struct irq_domain *irq_get_default_host(void); extern int irq_domain_alloc_descs(int virq, unsigned int nr_irqs, @@ -559,13 +558,6 @@ static inline bool irq_domain_is_msi(struct irq_domain *domain) return domain->flags & IRQ_DOMAIN_FLAG_MSI; } -static inline bool irq_domain_is_msi_remap(struct irq_domain *domain) -{ - return domain->flags & IRQ_DOMAIN_FLAG_MSI_REMAP; -} - -extern bool irq_domain_hierarchical_is_msi_remap(struct irq_domain *domain); - static inline bool irq_domain_is_msi_parent(struct irq_domain *domain) { return domain->flags & IRQ_DOMAIN_FLAG_MSI_PARENT; @@ -611,17 +603,6 @@ static inline bool irq_domain_is_msi(struct irq_domain *domain) return false; } -static inline bool irq_domain_is_msi_remap(struct irq_domain *domain) -{ - return false; -} - -static inline bool -irq_domain_hierarchical_is_msi_remap(struct irq_domain *domain) -{ - return false; -} - static inline bool irq_domain_is_msi_parent(struct irq_domain *domain) { return false; @@ -641,10 +622,6 @@ static inline struct irq_domain *irq_find_matching_fwnode( { return NULL; } -static inline bool irq_domain_check_msi_remap(void) -{ - return false; -} #endif /* !CONFIG_IRQ_DOMAIN */ #endif /* _LINUX_IRQDOMAIN_H */ diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 8fe1da9614ee8d..10495495158210 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -436,31 +436,6 @@ struct irq_domain *irq_find_matching_fwspec(struct irq_fwspec *fwspec, } EXPORT_SYMBOL_GPL(irq_find_matching_fwspec); -/** - * irq_domain_check_msi_remap - Check whether all MSI irq domains implement - * IRQ remapping - * - * Return: false if any MSI irq domain does not support IRQ remapping, - * true otherwise (including if there is no MSI irq domain) - */ -bool irq_domain_check_msi_remap(void) -{ - struct irq_domain *h; - bool ret = true; - - mutex_lock(&irq_domain_mutex); - list_for_each_entry(h, &irq_domain_list, link) { - if (irq_domain_is_msi(h) && - !irq_domain_hierarchical_is_msi_remap(h)) { - ret = false; - break; - } - } - mutex_unlock(&irq_domain_mutex); - return ret; -} -EXPORT_SYMBOL_GPL(irq_domain_check_msi_remap); - /** * irq_set_default_host() - Set a "default" irq domain * @domain: default domain pointer @@ -1815,20 +1790,6 @@ static void irq_domain_check_hierarchy(struct irq_domain *domain) if (domain->ops->alloc) domain->flags |= IRQ_DOMAIN_FLAG_HIERARCHY; } - -/** - * irq_domain_hierarchical_is_msi_remap - Check if the domain or any - * parent has MSI remapping support - * @domain: domain pointer - */ -bool irq_domain_hierarchical_is_msi_remap(struct irq_domain *domain) -{ - for (; domain; domain = domain->parent) { - if (irq_domain_is_msi_remap(domain)) - return true; - } - return false; -} #else /* CONFIG_IRQ_DOMAIN_HIERARCHY */ /** * irq_domain_get_irq_data - Get irq_data associated with @virq and @domain From patchwork Thu Jan 5 19:33:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13090393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA775C6379F for ; Thu, 5 Jan 2023 19:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236087AbjAEThD (ORCPT ); Thu, 5 Jan 2023 14:37:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235941AbjAETfN (ORCPT ); Thu, 5 Jan 2023 14:35:13 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2084.outbound.protection.outlook.com [40.107.92.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27615178B4; Thu, 5 Jan 2023 11:34:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iDRSCUu33YB4KhlXWr3z52n4mg/gkm/76UT8Vsvvmls7O9ENt8u+yyHecJVyiTrUfWKCtP20sMRUS8j0bXmCgU9sGaAJrFzXEJEZpcTy+jQMTIAf1NXBbrBJv7KVND8XpXWHSA8X6jx0LvqauamdLK9ykoYMA/aGJi6MhQQL2KaKcYENUEpGxRymSy719g0jCy8RNPUP06AIcC4mK48NZPGB0IdqkGRT4Jxbu1bmMRqKmVbMif43eVBLmrByuDNy9FD+HcPrjIm4aYw2fj2to+GUXbKOn9g+EaZlPXegHarrhPa6ppMAQNdLjCn3hYqFvT/++SxevIypZEvqDfXc1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Rsr/lhBcuVU1xrYn8NOic0gYBZ2p5nfAYZZXHfwOpic=; b=FdzCnHFunTJkoLhlCXRkcan18ffmoiviemhtJ3CDxOJVRBZxbusWVeI2AVBVejI+d0GxC9SgrcJQ0XmeCCpaxCEovIn9NH56Pik1ACNe8Q1+nh2kkJeJYUGT/Mbqc2S3O8eFNxdS2PuxMQcIQ1A5TLq5AaMZXibbDRR0yJ5WPr1khiD/mKbYMyPrS3p67w18OAVpySazhTl/0IVWB6JO57LDcNy7Wtpe3vWQVqnB4s+RxGXKb7ijAAqTWQtYfnKhnvRHzdE7Wnl+jaX2bxy8x/CUycYEWUOVlqM0T5cz73wgsgB8G/NosMwa1hLDEytLIjJXNnljjkqIgYMElGQbJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Rsr/lhBcuVU1xrYn8NOic0gYBZ2p5nfAYZZXHfwOpic=; b=LJFdR8kjGWYy4pFTODcGZAXQBfW4X/kuaCCxPIF5iWGrs92mLf8fskrAadP8jDDVWsMLerkGGXTEyouYxQA5GOOorfuDFj6H2PKEreK4CV26KTFmSJ8neze56VBp8ZHGXuu8/OaDryJLsdY1Ylk+duYRoFr2vKEeI2VviS0PC5WOEHZAOqR4AaQEJI1eC3DrbRzA2EbbhG82UQC4D2Tqg4QZU3//A3Fwj4zmfHG9maktMB3v8yXd1sn1ruehZGYc+wtwR26AR3fixZ3DLMkhvH/Z09yXxPCKYnpEGVAtNb3fHEo9g5v8RmVIHIHLV8GjHbHeSF2qxyAj/AJ63KDwiA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SA1PR12MB6776.namprd12.prod.outlook.com (2603:10b6:806:25b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 19:33:59 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 19:33:59 +0000 From: Jason Gunthorpe To: Alexander Gordeev , Alex Williamson , Lu Baolu , Christian Borntraeger , Cornelia Huck , David Woodhouse , Gerald Schaefer , Vasily Gorbik , Heiko Carstens , iommu@lists.linux.dev, Joerg Roedel , kvm@vger.kernel.org, linux-s390@vger.kernel.org, Marc Zyngier , Robin Murphy , Suravee Suthikulpanit , Sven Schnelle , Thomas Gleixner , Will Deacon Cc: Bharat Bhushan , Christian Borntraeger , Eric Auger , Eric Farman , Kevin Tian , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd v3 6/9] irq: Rename IRQ_DOMAIN_MSI_REMAP to IRQ_DOMAIN_ISOLATED_MSI Date: Thu, 5 Jan 2023 15:33:54 -0400 Message-Id: <6-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR02CA0019.namprd02.prod.outlook.com (2603:10b6:208:fc::32) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA1PR12MB6776:EE_ X-MS-Office365-Filtering-Correlation-Id: fab7249e-502b-4868-08c2-08daef53ca8c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9VP5BoSG7MJK6t0/1qojK/Q23BvoDSDLs6VFd9er1mFvC33YN7M9+5K1DklrvnjXWXAGlpo14cXc/dsx/j/oZLJ4k9XGnan4f3oMrWl86YrEJ54xhHr1gwKsLgFDty3R1XpaUypyNIbVAq9sybewd8G8gzyvA6JfDOCDa2qdupbUEqr7TzlQrXHTzktyQAJJECfixfKvCphIYo6NpMJN7rezHY76JrPK/et8lTx4mXBF11IbB/qYPzCK8caQtREse+oycxGNB8mMarj4TuB7xgQi4wTEKdiU+IM7gjDXy01rN/b32yiM7jTS7eBbb+k2dyZMedaOBT83RRw27nqr0qJn88PJdrhQPSFIQ9VCWf52UgG4HsQ4aXse086Ud3VwcxW8jeQwIGZsayp8ZGDWOPpij6ohigYdiEIMCWbm2Nj65sFnmT96hqJ1hYmgOGyGyB8NPv3GLgp1XxDWl1oflKQhHILdkuBjFyGEWhTltePOyqIN0Q1K+WF3IXOHbf45ovIUbNU2xWHVtODyazidJHT37tqed8klstdZ9rBc7rNnz0C4L390JnNWJcZsEABngOUatpOlNXyaahAHOrGen6WTFm+sOQJasqe/+FvurE6CrqeoukHuQXLcdFKCL3sZM62GSzYIW/m7vq6Pp7cycSyPbRGNKPyEPa23QTNukAQ5fAswQNJ3RrU+nvZsQVm5g79dmr5QkfIKsHJI22xsxw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(396003)(346002)(366004)(39860400002)(451199015)(6486002)(6512007)(26005)(186003)(6506007)(7416002)(8936002)(83380400001)(478600001)(54906003)(4326008)(316002)(2616005)(66476007)(8676002)(36756003)(66556008)(6666004)(66946007)(41300700001)(38100700002)(5660300002)(2906002)(110136005)(921005)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PJX7y66W1Jw8B6ngp7d6VEiS8lgIvs2hG55M2WwewYMTeZJDHAGf9LpRYkRRSxO/AfS87W/Oxi65XYzl2xcmFaMzhOKEr1Z+DbQI+KRJQ9e4Q9XhlhHBoweksoN2Gmiij68DK61iBCGc05y6IYxoZz4Ll5NGJ8xbNI7DUVw8oMgLXVcob2cKOp2JBQNNiPUQcxwtbMyUFt3sjVvWQB9NwIPeFhI/MkCH3jTEoyghg6zUKyGkcSSYAhoDndUZs3fgFPP28lRyXWVdfS9Bik0aQWpkeZi5G2c1PJBObvBR1SgEw7/0bEbSGydTcbNa5tL5PrgooADe3PNleKc2/CGnGIkCW31Kv3lHJp4bkCR3q87d8ojWE7mjiGc6MbA6lKCy3ennMUXHtwd+wQZBBWrWH70TRYN1ROAL7Z+PBglIiqYtz9h3glwg4VPBJRx2XvhnXKHGp2JVHq3x9UvYBMPfNDiMQTg1fM+m7gA64mfSgTZGh6VjlUhZKfcHhuVtHUDUdvhagO/FX85N6J6C42b6fHVrc0ImOCnrXaeTX5sIIJXXyhpdyEFqNjV9GBqVl7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-502b-4868-08c2-08daef53ca8c X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 19:33:58.8047 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rrGJxPSyJKEFv56YEavm/K4Bnl6UWRWN/Wy208Me9ZhOO6+lbxCQEvZIKnm/MPI+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6776 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org What x86 calls "interrupt remapping" is one way to achieve isolated MSI, make it clear this is talking about isolated MSI, no matter how it is achieved. This matches the new driver facing API name of msi_device_has_isolated_msi() No functional change. Tested-by: Matthew Rosato Reviewed-by: Kevin Tian Signed-off-by: Jason Gunthorpe Reviewed-by: Thomas Gleixner --- drivers/irqchip/irq-gic-v3-its.c | 4 ++-- include/linux/irqdomain.h | 6 ++++-- kernel/irq/msi.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 973ede0197e36f..b4069f825a9b73 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -4692,7 +4692,7 @@ static bool __maybe_unused its_enable_quirk_socionext_synquacer(void *data) } /* the pre-ITS breaks isolation, so disable MSI remapping */ - its->msi_domain_flags &= ~IRQ_DOMAIN_FLAG_MSI_REMAP; + its->msi_domain_flags &= ~IRQ_DOMAIN_FLAG_ISOLATED_MSI; return true; } return false; @@ -5074,7 +5074,7 @@ static int __init its_probe_one(struct resource *res, its->cmd_write = its->cmd_base; its->fwnode_handle = handle; its->get_msi_base = its_irq_get_msi_base; - its->msi_domain_flags = IRQ_DOMAIN_FLAG_MSI_REMAP; + its->msi_domain_flags = IRQ_DOMAIN_FLAG_ISOLATED_MSI; its_enable_quirks(its); diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index b04ce03d3bb69f..0a3e974b7288d0 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -192,8 +192,10 @@ enum { /* Irq domain implements MSIs */ IRQ_DOMAIN_FLAG_MSI = (1 << 4), - /* Irq domain implements MSI remapping */ - IRQ_DOMAIN_FLAG_MSI_REMAP = (1 << 5), + /* + * Irq domain implements isolated MSI, see msi_device_has_isolated_msi() + */ + IRQ_DOMAIN_FLAG_ISOLATED_MSI = (1 << 5), /* Irq domain doesn't translate anything */ IRQ_DOMAIN_FLAG_NO_MAP = (1 << 6), diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index dfb5d40abac9e8..ac5e224a11b9aa 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1645,7 +1645,7 @@ bool msi_device_has_isolated_msi(struct device *dev) struct irq_domain *domain = dev_get_msi_domain(dev); for (; domain; domain = domain->parent) - if (domain->flags & IRQ_DOMAIN_FLAG_MSI_REMAP) + if (domain->flags & IRQ_DOMAIN_FLAG_ISOLATED_MSI) return true; return false; } From patchwork Thu Jan 5 19:33:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13090396 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD083C677F0 for ; Thu, 5 Jan 2023 19:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235631AbjAEThI (ORCPT ); Thu, 5 Jan 2023 14:37:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235746AbjAETgA (ORCPT ); Thu, 5 Jan 2023 14:36:00 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2072.outbound.protection.outlook.com [40.107.93.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C1741A232; Thu, 5 Jan 2023 11:34:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RiogZ6mFyXs9o/Y7vLyDjhiw6SZz4IuEuEXG6kmB8JwFIK57YR4Zf2M9W57bcFsqGYQ35kisrDwOHu442INvc0iOiBazhETNQxa8kGZa9dgo9r+WEnCCHFnIgQsNI7Xf2mlitOPl2vIBGfuRuGq56G+zuvxFB+bbgPY3BqJKzxtYO7KZB+HszuxDOu7PLnArirSp8wI/2eiBo8/Ng6IWBb+18fGizRfsLi0H9QByquqeZEyyIJ33D8fxTdA0oZ1BrMmTYFaMd6iOZK56KEMVNvkShUU4rz2MCXqVYRcGab5Q+5TkYi+Eca2pDvTW1L+UqeXAR1XeGwjSD85qPfqMSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EyuibPUEpGMeh7uiH6zC5yEoYdpeP8pvOhMxcgnITi8=; b=lFun/mjLL32No36AQxk63u/kIP6+otb4pW/SrTbnzpzWjkTljyi1QDpr+oH6bmRUHLFDod9rSOgoODMmXLpgPZFGMQgsJl5iHMjq7mMQlysn9rlaoGxLKHiMEhORsxuPXfeZhGbgeL4vQXc1D46PCnIgLslSkMmiHqosWYdYf3z/3ibGHm+8l1YWmDQ2gfvH35cpXQJTA4WaFBwVsLvMy4k+bt2MEBu4xsvNPppXXNhzGSzFTbPbTHC0oxIXjjbvbp4loxkmBGZoN6xhIV+ohLtKdZcxrihHazfbgvf3+6RJVIVPVrbaPdWGJattXCt72aO2Aa9n0/+hw45tLltfVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EyuibPUEpGMeh7uiH6zC5yEoYdpeP8pvOhMxcgnITi8=; b=fjo9bO6F5Jq4A6W9Xov5yKeb2owz0RTmzqmLLdI6sESQ6HAN/9lP1gwHhOo18DSIoRP6UTu96wzUkQtKL7ZPlCPtUjnzCFVccV0xmU9zf1xPzRXF/pyfYy9uDrNs1wI3s5ULLQ19/3ByzX6achCm2XmqbNJeH6L492wsTkhEgKVSU3WyFFZeSDNI5rxGog3o193UETxZ7XYlpABwwx013nvDJc12vjK898O8y2Gzl3RBUv1rOLmfzK/WDYxs1S/xdnTdSQv73fdDpVxNM/lSwAMJFiL2FCsqO3RpwGGbH5RvFZpCvpD/ktSvsNLV7IWk5B36e7+8rbM2DAdob4pxOw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SA3PR12MB7950.namprd12.prod.outlook.com (2603:10b6:806:31c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 19:34:02 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 19:34:02 +0000 From: Jason Gunthorpe To: Alexander Gordeev , Alex Williamson , Lu Baolu , Christian Borntraeger , Cornelia Huck , David Woodhouse , Gerald Schaefer , Vasily Gorbik , Heiko Carstens , iommu@lists.linux.dev, Joerg Roedel , kvm@vger.kernel.org, linux-s390@vger.kernel.org, Marc Zyngier , Robin Murphy , Suravee Suthikulpanit , Sven Schnelle , Thomas Gleixner , Will Deacon Cc: Bharat Bhushan , Christian Borntraeger , Eric Auger , Eric Farman , Kevin Tian , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd v3 7/9] iommu/x86: Replace IOMMU_CAP_INTR_REMAP with IRQ_DOMAIN_FLAG_ISOLATED_MSI Date: Thu, 5 Jan 2023 15:33:55 -0400 Message-Id: <7-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: BL1PR13CA0327.namprd13.prod.outlook.com (2603:10b6:208:2c1::32) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA3PR12MB7950:EE_ X-MS-Office365-Filtering-Correlation-Id: 1fee1d6b-26bf-4197-5d18-08daef53cbd0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3FxwUIso3hOuisGQHT46yPLC5z+5UNpkmf2PCMRnasSHAISvGmku62N+iZBOcNgIZAGseusk921bSKuj5Ar1WfX5XMIKG7BqowV9SveK+sC4FkGWsIXJivBAYvQU8NskPneMWRnDlTjCvQnHsyjs9Pz5wG8+k2UBQd8y/XJ2xhqTRfgxWSzG5QnEiQ8gqHNgv3jDaVIMmKTJnz5i48Oz8EYbQXyczQRAvAodmrF/XzKHFW+4SQ4Haf+QFSFN0qHmNrD2N1VR4X7FAnH/nnqh8ZFOaiPD+ZIbs1ljxWKj5jo5D+cmMoIkGiZDVayakboVeOxQvBlLGsWXceV2GdtdCdaMMPMUlmyCTmEZIYXRYbobLdHT9bAoetEfJQZ3xLucM49ik/O6b2MuLiOsOHvbCH3E8KGg+RUJ5WDp8oQHvutLkmNvBxf5Pk/Ihc8ArKi7h1beoo4XVTAzAn3d9TV0L3dfClrJtbH+JwIAhqnjt3S4FyV6zgTa+SJ+VGMnOLZyuGLaGHYyn/0/RvApaoj/e6YtsQ+0Z7YZxKMeD3DFsIPKfQsRS+UYoROm7d/tYRzH5O8o73i7O6C7o7UoTdL1HSk3nti5pMmQPQJj/GjdiMmo6zxm6v2L/bCun1gqMPEUX1dDWxMACI+U4SBIeAvJgqWdVuPU9g7FKNCNiAjEwupsK20fSQIkFotVE3y4r8cuUNifV9YSG2KTN0xTQZ42ow== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(376002)(366004)(346002)(39860400002)(451199015)(66556008)(7416002)(41300700001)(4326008)(66946007)(5660300002)(66476007)(8936002)(8676002)(110136005)(54906003)(2906002)(316002)(6506007)(478600001)(6512007)(6666004)(26005)(186003)(6486002)(86362001)(2616005)(83380400001)(38100700002)(921005)(36756003)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lJ4xBGX9XLkRMQXRzIr5zOuugfVCbeSw9HlpHaxM5a3e1VZfDXgudfBr+NCDFriJn0bwMy+0nwaQmF7ZTWj3fgq8ocqJqnqcUleiF8kp8t0HbudqD8g9jYoFaPdx3gI1I/B4g9sSxaRN7DOWRGTondp7O5gVsJOb7GcmRuMMD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edr1qXz4F/Hj3bQUwKTlhkBjPGxoHLkP7Sy3V8Yq2CTnkou5/kUEfKlR/EhIN28YoSbdRkDta6qQQapGmpHePJ9Wphx+Ceec7LT8RjlNoPDX1s3yNQr+DZaHXQqa4S6wDIywg3cKb+eoIi2q0UYhxoPHwoVmSEEEHr8odNzF+YcnjUpjU12uv+w4DlFvuHGBzhvGJctyHwnXFaKy+COFW5kDKeYYfaCpu7nOCC4nRIaHx242hcZmchIYCSGD2HJXRYkBwi+DPGPmnRowcHcyxhVT3hn/nmfI3H6WS+QwQAgH85DWZ9grhg32ugyuEYUfN1AODaferU1VsjcfDWilb9p7 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1fee1d6b-26bf-4197-5d18-08daef53cbd0 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 19:34:00.8990 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vvKCmykmZswlK0fmiiHpWiBxdTxGIZFm+sgoeaP4iQO0NDqOqEsUxuuDe14+ht83 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7950 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On x86 platforms when the HW can support interrupt remapping the iommu driver creates an irq_domain for the IR hardware and creates a child MSI irq_domain. When the global irq_remapping_enabled is set, the IR MSI domain is assigned to the PCI devices (by intel_irq_remap_add_device(), or amd_iommu_set_pci_msi_domain()) making those devices have the isolated MSI property. Due to how interrupt domains work, setting IRQ_DOMAIN_FLAG_ISOLATED_MSI on the parent IR domain will cause all struct devices attached to it to return true from msi_device_has_isolated_msi(). This replaces the IOMMU_CAP_INTR_REMAP flag as all places using IOMMU_CAP_INTR_REMAP also call msi_device_has_isolated_msi() Set the flag and delete the cap. Tested-by: Matthew Rosato Reviewed-by: Kevin Tian Signed-off-by: Jason Gunthorpe Reviewed-by: Lu Baolu Acked-by: Thomas Gleixner --- drivers/iommu/amd/iommu.c | 5 ++--- drivers/iommu/intel/iommu.c | 2 -- drivers/iommu/intel/irq_remapping.c | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index cbeaab55c0dbcc..321d50e9df5b4a 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -2271,8 +2271,6 @@ static bool amd_iommu_capable(struct device *dev, enum iommu_cap cap) switch (cap) { case IOMMU_CAP_CACHE_COHERENCY: return true; - case IOMMU_CAP_INTR_REMAP: - return (irq_remapping_enabled == 1); case IOMMU_CAP_NOEXEC: return false; case IOMMU_CAP_PRE_BOOT_PROTECTION: @@ -3671,7 +3669,8 @@ int amd_iommu_create_irq_domain(struct amd_iommu *iommu) } irq_domain_update_bus_token(iommu->ir_domain, DOMAIN_BUS_AMDVI); - iommu->ir_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT; + iommu->ir_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT | + IRQ_DOMAIN_FLAG_ISOLATED_MSI; if (amd_iommu_np_cache) iommu->ir_domain->msi_parent_ops = &virt_amdvi_msi_parent_ops; diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 59df7e42fd533c..7cfab5fd5e5964 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4464,8 +4464,6 @@ static bool intel_iommu_capable(struct device *dev, enum iommu_cap cap) switch (cap) { case IOMMU_CAP_CACHE_COHERENCY: return true; - case IOMMU_CAP_INTR_REMAP: - return irq_remapping_enabled == 1; case IOMMU_CAP_PRE_BOOT_PROTECTION: return dmar_platform_optin(); case IOMMU_CAP_ENFORCE_CACHE_COHERENCY: diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c index f58f5f57af782b..6d01fa078c36fc 100644 --- a/drivers/iommu/intel/irq_remapping.c +++ b/drivers/iommu/intel/irq_remapping.c @@ -573,7 +573,8 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu) } irq_domain_update_bus_token(iommu->ir_domain, DOMAIN_BUS_DMAR); - iommu->ir_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT; + iommu->ir_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT | + IRQ_DOMAIN_FLAG_ISOLATED_MSI; if (cap_caching_mode(iommu->cap)) iommu->ir_domain->msi_parent_ops = &virt_dmar_msi_parent_ops; From patchwork Thu Jan 5 19:33:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13090390 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7378C3DA7A for ; Thu, 5 Jan 2023 19:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235623AbjAETgr (ORCPT ); Thu, 5 Jan 2023 14:36:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235963AbjAETfg (ORCPT ); Thu, 5 Jan 2023 14:35:36 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2063.outbound.protection.outlook.com [40.107.92.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A73AF18380; Thu, 5 Jan 2023 11:34:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NIjgmZTZnbyhzv5RE7nMd+Px8wo59ZI0yGEAgfeYexiF7B4wPBVTW2xokh9qrSL6k0ZpEIlk9MD2NqVYyuL+mYv8Y7hUg3H7GMwuNHISFULbaww/rrLbnaKFPBoQI/u3G/yduRioWk+F7SJgOUN96+/5/N2zCmku2QKdGdbe28uFKXEiWlzrr1BY55t3A+sVhydwm+WgVk3t5gzZtgkBM4rH4rfiU1Bm7+ZhdlWSftI/Uj3QjEC0wEXItAUgYeqFRFQLFWQOJQ1qrDnZnmvWNKpIXmCDRMcAteiK1qGWJTDzw1ne8e1JhuensIGq4AE58sBmK48dsQ1sdUoYu2DAog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zy+THkEzs3vZnFUTuqqQXlIcXMufDEl0Vr09ikq85SU=; b=htGlWdx/CzVcNxGmUV3lVb3nmv79VI+Ed9z3VhRRhsSAlFkB6XX6zEN+I/XMcDEK3mYdZSEe95USFkYJbXnPXiJ0+dwD8lURIQHwiqrMznTr553gb0lzCkT4F+z3t2FrTYzdt8zgCadTgmV5l7QHmJ43wLN4F3fZ9+t72PAWvURScXLxcAmLaLx4h4Ew7iY72WJTTfxGhCeVKV5sYHEtNIPn0rwZxIoyhdCd36lfiuRobdMt/n2Zh4DtTwMUOV3edrToJizvuR47gh+WtK2fNo2i/bpDyVWi/utYtV4DuiO3fvwMe2aO0UHbZjebYNtabOvzZHENBnhtmoY0KkZfRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zy+THkEzs3vZnFUTuqqQXlIcXMufDEl0Vr09ikq85SU=; b=HIxXvSlcKKGkN6uCehPrBagqcmyrQQORxpttyE3Ij8vnQjTbbdTNzuaJtIBlY46F8uGr+yNjyYbu4TeOcsXOFBBfkRdVhtDJgRzd2EGlD56QCe8on65KDZ0siRR6om1cE4oPhRC7FFN0O6NkfsPUR51eudLatipnRm9a0+G68YzoC9zuklyoblHvojf26Z0KvO8hnatt3vfZ8nCsTWCwU3hi8xQ6PaZuZr4bocLXWCctrS03HSNjXFAGg1dN5/EczRNAM9vlyXknzcKWI4lghrF1CsnrTWstZK3W9YUKqscYnBbkTuWDRB6BJMbm9PWAApDwZrwyMVj4gCNxyO7vuA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SA1PR12MB6776.namprd12.prod.outlook.com (2603:10b6:806:25b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 19:34:00 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 19:34:00 +0000 From: Jason Gunthorpe To: Alexander Gordeev , Alex Williamson , Lu Baolu , Christian Borntraeger , Cornelia Huck , David Woodhouse , Gerald Schaefer , Vasily Gorbik , Heiko Carstens , iommu@lists.linux.dev, Joerg Roedel , kvm@vger.kernel.org, linux-s390@vger.kernel.org, Marc Zyngier , Robin Murphy , Suravee Suthikulpanit , Sven Schnelle , Thomas Gleixner , Will Deacon Cc: Bharat Bhushan , Christian Borntraeger , Eric Auger , Eric Farman , Kevin Tian , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd v3 8/9] irq/s390: Add arch_is_isolated_msi() for s390 Date: Thu, 5 Jan 2023 15:33:56 -0400 Message-Id: <8-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR13CA0026.namprd13.prod.outlook.com (2603:10b6:208:160::39) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA1PR12MB6776:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c259066-4865-46cb-1d1a-08daef53cac3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a7EAof3v4OInOdAR+C0Qn8v3a5fOAJSlro2/wpUHi8503D3jFLIq3HFyTINVmAtTSrYxG93if74aVXq7HbaGLsz+kGbwVqY4svmff+zRRvqtPVEyrRsLlbzF3GWAAwg4wPsDfAu+hbcP+lxW5YO0dJOZfcUu1bhcfSRcw3JlsxXatCQRPNosRWiN9MvY9Lz3qfvgIPtADsGEJrz0LW7zPlzT0xoXV8tA9bGTAsDPd0xCBt+Tt3O+FXnniTBq6K1o5CSrthULq5dJAEn5oj8UoZcMltwFJeMDxtjT33UwDAVkzxzTQH4OZ3rN3a4kKCP5r2aOUIxHjW7jVYPr7rEvIKCQ4FsLSD642MUlFzAB/g7XESvkjKqRUPP/ZoHfyp5l9phQtIwnNk/aoDRFKTLwuiX/JPfCFTRyaf0yJri1AnzUn+pCbp3RMJEyZePP8AkijgE5K2w6T704mVl0avogHgHoXqEQskvNTYgcGS8B86VgGJmAmtxmRTtM2RoiZLffFXYtCrV5gZvbyStmj2Tm3+9xvAiPWEyxp+Z+CYOpBKW/Ys0pKo6dxvU4UFARAOzI1dbiSCaaMfmLPhc1kGy5C7y1vNYs0+st0ko8GO9LFn4rxFAboiXOJHFr/G8mxLLG9MYiDMqDggH5O3qdkbW8d1Xe4DW2+I862gOg80hQVkhoAUDvct0YPHpg3SV6xwlXgAq6A6+G8M4WLIxwPmO0/FLj+9B30kN/HMvQ3P0/kZmXI+Vjj7pEyJnRhe2spcfOq5NBbZYU5A5hYD7vRAoncMPSAe0mZ4+0vZmt2VDI3dQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(396003)(346002)(366004)(39860400002)(451199015)(6486002)(6512007)(26005)(186003)(6506007)(7416002)(966005)(8936002)(83380400001)(478600001)(54906003)(4326008)(316002)(2616005)(66476007)(8676002)(36756003)(66556008)(6666004)(66946007)(41300700001)(38100700002)(5660300002)(2906002)(110136005)(921005)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E9/2aSRMG71erA8S4QPDhSuJ7SBKkT7A2xyblRFfIk9xlaYuQipomg0gdztJXbPIom3hcqQHugnwhLaCV3oANxDQCIb0GWYwGZRjLNP4RP1qA8r4phBekENlnDbh6LBAmb+mAc+apmzPd6AyvKMorsllznQO/v3ud2sU4ham8yOJ13TgqA1YOvimtfun9ogj1qDr1tuzodVaYGypOxzMA9KHJkMtezKez8Gdv9s8ri2xA4XgC6d6fmP8c2hN4YJbUCbj8rNOktfVCx7NtnWhLKTndHmXeZp6jj5AXW2UnH0iOWBWzbocaltS5RwuBELVbMwAQlSVswgEe07yyLaX3YoGuMlWtSazi4mumcu7nVAl+tKyQywoow7amR5I56OkaGyD4R/pdLMxcjFtKlzSx3iceVrIebzenEkOXtmdPco44/c8s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2SXFj8y4gQgT5uu62sZcRLnZXUzAxfDQpbmpCdiymfTlDCr4SwvjCffSUwipscmLxZhP/BIkiQRnMd0iVisAUjS/10+uH8LnBGjc7mxNH0kH X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c259066-4865-46cb-1d1a-08daef53cac3 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 19:33:59.0704 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RpPNutKEC7UcQrbbL6yKzkhymJoxyT8Sv+0nSYQSobXTi1NZlBmDD3L6gefym9ij X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6776 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org s390 doesn't use irq_domains, so it has no place to set IRQ_DOMAIN_FLAG_ISOLATED_MSI. Instead of continuing to abuse the iommu subsystem to convey this information add a simple define which s390 can make statically true. The define will cause msi_device_has_isolated() to return true. Remove IOMMU_CAP_INTR_REMAP from the s390 iommu driver. Cc: Christian Borntraeger Cc: Eric Farman Reviewed-by: Matthew Rosato Tested-by: Matthew Rosato Reviewed-by: Kevin Tian Signed-off-by: Jason Gunthorpe --- arch/s390/include/asm/msi.h | 17 +++++++++++++++++ drivers/iommu/s390-iommu.c | 2 -- include/linux/msi.h | 10 +++++++--- kernel/irq/msi.c | 2 +- 4 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 arch/s390/include/asm/msi.h diff --git a/arch/s390/include/asm/msi.h b/arch/s390/include/asm/msi.h new file mode 100644 index 00000000000000..399343ed9ffbc6 --- /dev/null +++ b/arch/s390/include/asm/msi.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_S390_MSI_H +#define _ASM_S390_MSI_H +#include + +/* + * Work around S390 not using irq_domain at all so we can't set + * IRQ_DOMAIN_FLAG_ISOLATED_MSI. See for an explanation how it works: + * + * https://lore.kernel.org/r/31af8174-35e9-ebeb-b9ef-74c90d4bfd93@linux.ibm.com/ + * + * Note this is less isolated than the ARM/x86 versions as userspace can trigger + * MSI belonging to kernel devices within the same gisa. + */ +#define arch_is_isolated_msi() true + +#endif diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c index ed33c6cce08362..bb00580a30d84d 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -34,8 +34,6 @@ static bool s390_iommu_capable(struct device *dev, enum iommu_cap cap) switch (cap) { case IOMMU_CAP_CACHE_COHERENCY: return true; - case IOMMU_CAP_INTR_REMAP: - return true; default: return false; } diff --git a/include/linux/msi.h b/include/linux/msi.h index e8a3f3a8a7f427..13c9b74a4575aa 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -48,6 +48,10 @@ typedef struct arch_msi_msg_data { } __attribute__ ((packed)) arch_msi_msg_data_t; #endif +#ifndef arch_is_isolated_msi +#define arch_is_isolated_msi() false +#endif + /** * msi_msg - Representation of a MSI message * @address_lo: Low 32 bits of msi message address @@ -657,10 +661,10 @@ static inline bool msi_device_has_isolated_msi(struct device *dev) /* * Arguably if the platform does not enable MSI support then it has * "isolated MSI", as an interrupt controller that cannot receive MSIs - * is inherently isolated by our definition. As nobody seems to needs - * this be conservative and return false anyhow. + * is inherently isolated by our definition. The default definition for + * arch_is_isolated_msi() is conservative and returns false anyhow. */ - return false; + return arch_is_isolated_msi(); } #endif /* CONFIG_GENERIC_MSI_IRQ */ diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index ac5e224a11b9aa..4dec57fc4ea639 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1647,6 +1647,6 @@ bool msi_device_has_isolated_msi(struct device *dev) for (; domain; domain = domain->parent) if (domain->flags & IRQ_DOMAIN_FLAG_ISOLATED_MSI) return true; - return false; + return arch_is_isolated_msi(); } EXPORT_SYMBOL_GPL(msi_device_has_isolated_msi); From patchwork Thu Jan 5 19:33:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13090391 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0001CC54EBC for ; Thu, 5 Jan 2023 19:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235909AbjAETgw (ORCPT ); Thu, 5 Jan 2023 14:36:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235943AbjAETfN (ORCPT ); Thu, 5 Jan 2023 14:35:13 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2072.outbound.protection.outlook.com [40.107.93.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C8C117890; Thu, 5 Jan 2023 11:34:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RgInahvDA/g74xa0Qw2Af6Ul78WPJGeBPqY28CehO7PwVn2oqGn9/dPNHIJhhCFiawakVeDycauXO8ajPIJS//7caVUCKb+aIRUKXYuu4QHMsY3y8xP2zXtve/C2MkTK0JJBkM2IKjxxtg4hH06Mh4fZy3jreFLYWBeLTfo3OvaytFkQhBBZcVm8WXfyVkXSxopcvGLn1lU1NPXokfX63JkQuYBJJ+41tGBzscNm5o9AUrwpjfbmebYNvCGx4nZH0731Kbx/6SM73NRh1FrZyv9XU4LXdAbHI1Ae2x/j2N4Un7niYRi5SaGBPqFIfRn+dtTNWh6QXq1kTvMApq/E/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kZ+ZVwve1nnZe95+ZC0zjQXYD+Q1A6RwLMLYEtdXT+c=; b=BYq2ZfMGkyiV0zqrthA4R+pC/bw0PROV0vDcHDRc5HuLMgfgPaQVTDhAwxX9fg3O5Q1JN14RaJTm0xrKenDk2hCctZeH33A+BAlAHCboRaXMvrICfp4LyDK7aS52b6sVBhT2hauA8298cQKPRdC36v28NmnqnThM625tf8xv8mTHa99twPA/NP5c1HIoAathQUtwocDsgHxb/aYmNN49lyRlmTk3M6gubvP1XhFG7lg+iwSjca08mvWpKgKHiMH6C0Io4G9rMM4E/er3WazfKRtikY0aW0f9ci24zfISvMhtLmsx6tolK1jk1hyzMYalvPcYCiycEAoMrYGa7QlwIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kZ+ZVwve1nnZe95+ZC0zjQXYD+Q1A6RwLMLYEtdXT+c=; b=SjD36juiujqYyp9LUqsRn2LgneuonInJf2yreXuiQV23lD5rWRUEd41Ey29lbfWkM54EHtNMPVFAfPkZ/ggrzxwi4CYaukPUHk5FwGsVRlO9cntYvO6H67pIXYntjUdwIui4oMF0uZdfZmEQfyUwh0xYmUnjiO2P4xFDdfKsMoPhoYPEjPJDsN/+/rN5CBfvdryID376zJAB7mCw2EuKUg6+lhXqQglqC0KptR+F/2ROGsz3aope+6diuPqnXJZeT+iDXY4H5cRHeqqz1Ecvxfta6z/R3HnFSKm6dYL7d9Gvgc2CKB74Zh3v2O+CO/X4GT2lwt+hyVkoJ73tKc/JWg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SA3PR12MB7950.namprd12.prod.outlook.com (2603:10b6:806:31c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 19:34:01 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 19:34:01 +0000 From: Jason Gunthorpe To: Alexander Gordeev , Alex Williamson , Lu Baolu , Christian Borntraeger , Cornelia Huck , David Woodhouse , Gerald Schaefer , Vasily Gorbik , Heiko Carstens , iommu@lists.linux.dev, Joerg Roedel , kvm@vger.kernel.org, linux-s390@vger.kernel.org, Marc Zyngier , Robin Murphy , Suravee Suthikulpanit , Sven Schnelle , Thomas Gleixner , Will Deacon Cc: Bharat Bhushan , Christian Borntraeger , Eric Auger , Eric Farman , Kevin Tian , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd v3 9/9] iommu: Remove IOMMU_CAP_INTR_REMAP Date: Thu, 5 Jan 2023 15:33:57 -0400 Message-Id: <9-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v3-3313bb5dd3a3+10f11-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR02CA0002.namprd02.prod.outlook.com (2603:10b6:208:fc::15) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA3PR12MB7950:EE_ X-MS-Office365-Filtering-Correlation-Id: cda4bbc9-9b68-421f-d3fb-08daef53cb24 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vT2QNUgdNar6WYvaRfIE+RiPgoPfrJ8h2YiJy3ualIAdQag5XLoKdZN5Q1NXYaVlK9kDOZu8f9dJc9COw94qnGEYGWTwlVute+gr6wYWjs3zL9N1pVm2FTEPBbwCUnPKJTdczUkipfmZR8CziAtxyCiCZH1WK7GObV9Cld29/VaeaKbQQBEu9PptPyUnor41MCSLxpZMBWIfzGW0QcOEx30Wi+t/4TpYAGM8wUiQbMQBqbOBCkWTAzAHy6sht8FDIzeUmNKI/5e6X8scMj4F582kw7WB7s8UZSZOqAvzygCObNPRYUVz8onpiwD9vmdFjKc0fPLQnD4gZKt8PfcWQf2zIovDXgG2ipPiCNvRRdMpdFWWrN++N9uw1PMCGX6uR4Vf9w2e7KeDdixl9wW12aa6No8XezjNyv/6Eg0kB+6J56xkWxkrFyWNhhMpsYd+jMTarcR0E63c19d0CWzbvkm+FgWHfBkUiY1rGGBReO/4DdKl8aL3zxZ99ifU3718iun+YNEiB6QN6Px23VuGoT7JDplKx79Afc+KcyfxZWfrhzUCJsGQONb/hrzueyqhks3+aFJBbr/4tjJGZAMc1j36F6ofKCo+NXeqEK63jZEkgKJdewWqVfl7ajMUWt8Xv5rMVTAt3+C/9QRwkNQtHyWr1OppIdM7TDCIq/mN1tJBIiPY7Pzx/t+umEuXSxlpzijb4JbmKPFWKiNfh1YKaA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(376002)(366004)(346002)(39860400002)(451199015)(66556008)(7416002)(41300700001)(4326008)(66946007)(5660300002)(66476007)(8936002)(8676002)(110136005)(54906003)(2906002)(316002)(6506007)(478600001)(6512007)(6666004)(26005)(186003)(6486002)(86362001)(2616005)(83380400001)(38100700002)(921005)(36756003)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QsgrkMXry//xfSjSbJOB5rTyEZw68wxNTXUEGxLgE9fAPspPFKZTEx1hJeAVFqSHwt3GVly045DOXcjbSEN+J222NQ/r0QG37DkGsUuScTKpvnbsoQiA2xesyZUVWEJLxuUXAuE/jR+v1jsDQ/8HU8vjYBxHvyM1U9orjRLjqT8xHzgE/qypE3DOdziLBjl6cFGvININL1nYSJpJxZjQarmMGaYWz1XQPMpyDwB/2Za5xRsJhAGx3mubQh25N2e4uhnFKwWPT09u7SxHN55/CwSSocxw7SvjE1Vvhy5bom9pZxAM2uoOSx/RPD2l1Fp7YDAIlGzFJuAiX7RrvT0MXiRGGGno1Bw62Wnj0K31znfth83Ca56q6idPHAvY7RQVFxtNHxnxh58cpL6lVVntiJBklwVYfCd4uYpnVa2uzzYZAN/25Da9I1zJcpSQFT37uzDABrw/GSohOo9Ht1zdHvb91WrTbyzcSzEvOU4xb32zNljE2gLAl9U64RTNXCGxHRMIQVHk/DB5pR8NFqzTDxcTC6YCzAbdJnd1YRC5XLO5rOrfinyDGgXdvJg0qX/mM0ASmKJ5RqD7mUSHoxE6O7zCie6FN5DDLCgXGPh0PyamcNDhubDgIZUj27hGZoBATYiqcZZy4IjEyfNWxfqZWW+V8gIfm+2WmIxgVwZBjYbBTxX3w5njIZOTesN0lnL6gAbUtCs9b6HW67zjoVIO79cckGZJTgvIJuY1Izb2Y7ie/MAXJ1qZV96ZPpDEAM95r57YGFVXrg9u6Elo6UGpjbJ42+20LCvL3xvl5UJ8tkelIZskXT+sBnXy7w1HgYriuahQVji9HDe1jXWhgTV1cOVgFMERNzi0c0vBLfPU/5TeYj5FNo6hCxe7ASI5kyDix5xpvTOv8pY5/YADW4uOezvFnR0ETZPFcx9MeALgx3yATni/X1/lfkhhE8SKt06RXoXoYMBf1QhjYvGauv1MoBvwUliglxEljGN31bTT6QgTjHOm6Yd/tVwpYkCXm9JZFr208e6GPu7/IYqqx9NY6KKmloSf+whdZ88AUzkbDWbxl2p4MS2JeGaRreBH4ITl98aOlIZr1ZDs/31+4umc/JT0CURqLGXxTf+cDjFAqAUTt6iGZBWJU5nXHHNTDC0pFrBek0JR7KJQ7XJDD4ocOa7lUGiR3/gGJXaHO6ZIL9uODKPlb7oOdXNCw4X0hQiy/VqZjsOJblqihuu7YP9ToUysbjPFIBmBdm4N5FHuMXWWGtDfjeI53dzRINZAvz6Z81q7Y5KpGx/9nbcN6IkwfsOSVVQbnHBunpkNvIw9rgWRPwT3MAA2y3PgRpMu2xUpZrFjjXbUkWl+Ehzd1WDlAx3Kv/rCBqIfEm07Osb76WIwr4Ove2YegmnEaDQX3ZJnwSH+nwitzcuT7JRBxwI9xDcHtM597G7HV+y1qMZq6PEGFV9FH4dirtRzBGdrByBJffrmKKadoVNvjMa0KPFHC2rMh9HUUU7RQ86JrEa88JY4VJJ9GzPVsE89PkTidUgarFE/LKdrAqoJM1+Y030mIJE9SzZn6QGTvPUpWenEDr31LZYDujZ7B/ButC4FrXqN X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: cda4bbc9-9b68-421f-d3fb-08daef53cb24 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 19:33:59.7577 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LmVgf2tKUSiECJFMcJW83dOlwiwBMMtAb99LjF9wI+3lV+S8HCX0IGoasK8cRLoE X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7950 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org No iommu driver implements this any more, get rid of it. Tested-by: Matthew Rosato Reviewed-by: Kevin Tian Signed-off-by: Jason Gunthorpe Reviewed-by: Lu Baolu --- drivers/iommu/iommu.c | 4 +--- include/linux/iommu.h | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 7f744904e02f4d..834e6ecf3e5197 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1915,9 +1915,7 @@ bool iommu_group_has_isolated_msi(struct iommu_group *group) mutex_lock(&group->mutex); list_for_each_entry(group_dev, &group->devices, list) - ret &= msi_device_has_isolated_msi(group_dev->dev) || - device_iommu_capable(group_dev->dev, - IOMMU_CAP_INTR_REMAP); + ret &= msi_device_has_isolated_msi(group_dev->dev); mutex_unlock(&group->mutex); return ret; } diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 9b7a9fa5ad28d3..933cc57bfc4818 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -120,7 +120,6 @@ static inline bool iommu_is_dma_domain(struct iommu_domain *domain) enum iommu_cap { IOMMU_CAP_CACHE_COHERENCY, /* IOMMU_CACHE is supported */ - IOMMU_CAP_INTR_REMAP, /* IOMMU supports interrupt isolation */ IOMMU_CAP_NOEXEC, /* IOMMU_NOEXEC flag */ IOMMU_CAP_PRE_BOOT_PROTECTION, /* Firmware says it used the IOMMU for DMA protection and we should too */