From patchwork Thu Dec 8 20:26:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13068839 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 C7F85C4167B for ; Thu, 8 Dec 2022 20:26:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229912AbiLHU0y (ORCPT ); Thu, 8 Dec 2022 15:26:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229929AbiLHU0p (ORCPT ); Thu, 8 Dec 2022 15:26:45 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2071.outbound.protection.outlook.com [40.107.92.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAE9C8427E; Thu, 8 Dec 2022 12:26:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lR1nVmP+B/M8BD/ODhw9VKzsgaVDnLml/SXrOO8EA/fgUasLgjyAQA6qFhafeXSMtXoQcx4ULwIPbf41VI4GniiTYbVSGZVKgykCwCUeZeycq/5zVrmSbqyJnu9Ra3yVk1VWJgCJ8yLKuN+jCBgxbWZ8rBUvDflbYT8O0L/xRV0/g2o4/FoXFZJa+C6Qn+14JWqirUAZnfm4pxpWydrZL1AA0g4huUcmyRWKxk63YJ+mFNQMXbjjNYnVCcnUyYWG8yOe60kADnWFIrsOspXYj+xNp9WZs4GTj/xUM+dLqNDGrHLzYLCyO5vKMIcJolV824Xb5Lob3tlctKQRYsXWjg== 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=KsBthhZkVasakyTGlPWvQQpo3fF7kAiiJxCZrQctMYY=; b=dEAv5STAnn5M2r6HKNtzEi9Me/WGhyPAoD5Iig8SH02NtplrR0KQ5olNnZHUinRZLw4HhRip7LXQJ3Dk4roF8u/5m11UHUWszeHChx1COGO6wrO0YgnEmCJtnAcVMGAs3OAx6lNWWOkT+4I3JBT7z1mwEBtK3DA+N+WhdjzJLogxAIbcZt1l3cOV9+Th05o5o9GH+rTZF9y0aiqqwdrn1F4RRlyviA2AUbux4hF6gYWpvtDUhjFU/ppK+5bwiPq1PfsZDRP+0lZBgnwaDORPeSwUcXFRJuZBVkvrb4vFYUktI4StjShqhHdBElGa58Or31EWIW1FJR+EmHtWWqpQUg== 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=KsBthhZkVasakyTGlPWvQQpo3fF7kAiiJxCZrQctMYY=; b=ju2Xm/vTKquc58luLP6eSl4xICEwZRX6RiNmEGu/7Ji8rm7k8ZJlWi3B5j7ndJeS87PlI7iMEiqxGV/4jFEw6dMdJsviNZEB0yWWE/eznjFfrrRlUGet0PMRwdwJgn6DM55Nh1TZ11mi81o+VulWQhr9RS1Lr2jMFvtAidc6BU97aihl5nQM9IC/e5VpJyw/67Qc25yuxsPsvcRH8ndtY2hxU1CdDyZDh4nUXxj7A9z/KTXdk1g9a2P/BjXu9iMDIHgDpiGXgiBAozqJdjb43A3U5bwdPJA9CBW00Z4az4Uo4+hAbKi46kdVcMONbbJR2gg/i3vRdTChC5kKWL7CNA== 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 SJ0PR12MB6966.namprd12.prod.outlook.com (2603:10b6:a03:449::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 20:26:41 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%7]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 20:26:41 +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 , Kevin Tian , 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 , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd 1/9] irq: Add msi_device_has_secure_msi() Date: Thu, 8 Dec 2022 16:26:28 -0400 Message-Id: <1-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: BL0PR0102CA0070.prod.exchangelabs.com (2603:10b6:208:25::47) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SJ0PR12MB6966:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f055923-6a3f-47cb-5a59-08dad95a8284 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7IXkjoWAadnYKK/D57Rs8oXy73GYEeq5s3TQmJazbw+cpb7Ns7vt5S68iDZ7c2IP1IKXXnOeghHB9cBEfjzPYb3bH2kI+F4VBNItEJH3hZ1r+6LeGDogyq781BIkaL6MfSuvhmJDS93BVCGHUK78jTN2FdGKwQX8GKuPFk2nmaZ+LEQjUpRRWucjlmwcIRFsBhzFUMUvy6M/vQJNHgq4MQszPN8z3yZ7A5TD3xjby/eYWtGKsG4Pt3gxnTf2oI50bAypBMUTd8VANiPXA83e6RMwajED1prRiZSIRcsz6eTXegynkVSRDu8Thkc+rdTW0A2QN3Y1AIUrhphmSwojn7qv3B6jix89Kc4lOCw2oo8qwckGE9G6gzUOqTkNWOE/zjs9Y3pqainYBCaDXxs3DWPZieYUbhg/qEkI96/JRhNf9ca2lu01T8FksnbQSIe6I/xTtRa6IQ4KjVivvBOEwIubPWMSzsWsbSyfn07RsPB3GrV7Lkm3toggX2aiuqh5OvgM8x/GjC9KF6ltGTOMm6hDJJFoZ2EtBRnFNSo2ddjQHtX+5UfwcwET2X4lg4sdb5j7MXBDlSxUzxVkvKN4KdRearrLL98M8ph684OJgxJY4cGrEZOhVMMJjzgQq4unGpUTbPd0o0PKp670H8X5tuey0a/qPrdaT+2zzmxyohVS6+TCskt1PzdCJmgAwlihV8gN+Ix4fDMND+E3gx9FIg== 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)(39860400002)(376002)(346002)(366004)(136003)(451199015)(38100700002)(36756003)(86362001)(5660300002)(921005)(41300700001)(4326008)(2906002)(8936002)(66556008)(7416002)(83380400001)(66946007)(316002)(66476007)(54906003)(6486002)(110136005)(2616005)(478600001)(8676002)(186003)(6506007)(6666004)(26005)(6512007)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ICIfgxjlT1H81q2Pl9xDDKyUIranFq6VAg20DE5t5byRMARAxkpuJmvpxdiM5aw3HrZ2UUf5ma6OcZJIcFo4CKtVEwZ6RkxSbpBNYirLM8azR7AztstG9OWqNiR4s0teKonrsIvthpqsiMuQ80npK1LPE/i5UcCAU0nkW4/cyhmDSM7/n12Pj2d6uZ3Dwh4skZFCJOEWBrOIdAQWLKu5FKu7xCUITtfM7uyLvtBdA3KFc4kjPxhu1KRrWXV6R8oBvUp9IsO63FnWcVhT83qnny6dAPIsqEStVbcAHKI0cxoVahTzIYAiF3Ll88M+m3Z1BkHjtATNesQj8GBKwFqlsRmBtpcrKFalD6kMR3tP6R4CdLLH7vbXOxiYj5N+cQJwWbqryvmj3DXC7bwBLe92pFMX4dUS6WIY2KRnY66tz90iAVeeYnoCdytXTXngVGzNQf9R7ZGmETqrvuvpXoKXtrEKu8nsLFVsGR3zRV8EPR5Zo9m0/HgSoaeAVluGJNRQSvAFJEm0YvZq3YXcf5Zgm2+cj2dSBcZGa8xWLMlFr/mdM1890TaXK4gR7gxdagGanVHTmsT0UhgPjyE6pH3gwvEz57eP4aynmtHAtvPt9DnO+87MF5sY3xl/KP1hKU6WFbp7SVdSXxqcxR+EVOSll4RabO6O79jKcsjyZyzv2qHYGFNAeS6D5zJeABhpn0K7gtgeBbP7xZk6bPTAIZMLj5zhjyUl1xE9TGGuk18AHw9p0Pdprx5Z6PQFOuUNwi7zG3GEEK9AKqO2feD9jlD9BltEu28eifZ5Kc3c9YR+uVPMe2OlR8HtRoD1dZtVJEzU6MR3OdpbXcR8UnT8zok4CNKp76JrtRN+gux8drFIYiOO5DTg8n2J7W3ai2aKLqK1GjrdnXXPN/GOFTK37h4gvhJhbM9r2mgCVlq+RMpwDwmKvf/L/fkNR2t0cfgphCHMCKSTwOuWxH3Bhi8AeE4f77qo08fqysKnOFEh994uM6R4CVY111S/X7oOK9UbbmKniUqN2Vjuw2TE1vM8P6pTV5EI7F/9dPbwklcjZSCSTrpzzHpLV4OfwZKn5zmXfKHQAQf+r7UAxCVxR3lvCImYwNBfx0+GEiyuVk5XRniYYGK9+bR2Z90fyhbOXt9d7twVomyQlHujgooVDDbHxS3P212P2+BUMmF2NurWW53TV67uqbGiylycLMX15MUNEx2N5ajYbX4xS057x2Pv6zi0X73yUq81UOXwsXfcsWQudEAug8WWjTL+msddWb9sKo9+gtoCi0sgmq9lM2xapdoBw4fkjmEol36NPA+5DHhTgKvOuV2njoHmdFJ/LM1T19Fkw6z4kWRlbQAlKrFGTS+5VrDxkGb3JesCFOu5TiiUqp9pyR1NTzWjvVmIRveznf0f7QIPgGXjA7ervM0+xOm+g3S0bjTRSl70lowg0SxGnVSM0JiZgjCRwtWmEAqDfCliSKu2SipSwKi/Tqdj80kxkGxYbGwzWeD1pszuNGGRs6M3tGKyrtNyBiO6tBGg5roqJGBbGXgledi0FmYkUQj+25r3WjUlOaRlF0/zkjlQTuw+vm7vQHI7S2LEHUopPCuL X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f055923-6a3f-47cb-5a59-08dad95a8284 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 20:26:38.8841 (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: hAE91joyHtqrdSYYmF+uNkoDOjRwOBe/AzRK3zc9NJsn+MsJPkCEX4qbJPl3QTW0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6966 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. Secure MSI means that 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 initiating device is authorized to trigger. Secure MSI 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 determination is interesting for VMs where assigning a device to VM A should not allow VM A to trigger interrupts on VM B or the host via rouge MSI operations, eg by mimicking MSI using PCI MemWr DMA. 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 Signed-off-by: Jason Gunthorpe --- include/linux/msi.h | 13 +++++++++++++ kernel/irq/msi.c | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/linux/msi.h b/include/linux/msi.h index a112b913fff949..75c2c4e71fc34c 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_secure_msi(struct device *dev); +#else /* CONFIG_GENERIC_MSI_IRQ */ +static inline bool msi_device_has_secure_msi(struct device *dev) +{ + /* + * Arguably if the platform does not enable MSI support then it has + * "secure MSI", as an interrupt controller that cannot receive MSIs is + * inherently secure 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 bd4d4dd626b4bd..7a7d9f969001c7 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1622,3 +1622,28 @@ struct msi_domain_info *msi_get_domain_info(struct irq_domain *domain) { return (struct msi_domain_info *)domain->host_data; } + +/** + * msi_device_has_secure_msi - True if the device has secure MSI + * @dev: The device to check + * + * Secure MSI means that 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 VMs where assigning device to a VM A should not allow + * VM A to trigger interrupts on VM B via rouge MSI operations, eg by mimicking + * MSI using PCI MemWr DMA. + */ +bool msi_device_has_secure_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_secure_msi); From patchwork Thu Dec 8 20:26:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13068834 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 AEA83C4332F for ; Thu, 8 Dec 2022 20:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229936AbiLHU0p (ORCPT ); Thu, 8 Dec 2022 15:26:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229784AbiLHU0l (ORCPT ); Thu, 8 Dec 2022 15:26:41 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2071.outbound.protection.outlook.com [40.107.92.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B66F07E82B; Thu, 8 Dec 2022 12:26:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TfKRmxj2Qptq/FkLQlqd87DQH90RXY078NNH6f03BkKqeOD57lglHPURObeOlszRvA5oKJeVqWAdxbM3Nhkls3w5K5/9yRnVJMo9ln1qNVDq1esTjNu7UbmhNBRDrbjIqbHdQ08PrgYU/hdLkm5J6M/rZP9txyFYByQzXDIKmKMub0HYZaaTmyP6oqdWTPIFmyzf7cpNWW7UYRKl/VlfGQONj3qTKlLSm1q5Q6e0PvAGsYna/qHstN6nn02+d2Xy9MPUbfh/jFuygEDeiQ1ZNHSKJxIO+bGGn9zPX6CZ+1qeqFsEGfZpF3E4Bjk/6bxofR1nb0/oVq5M0XJUyLIuYg== 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=E2SOl6aUd9d8UrrJwdUHbj6+FxqAlMf1+zsUj22N2pk=; b=UQUkSmT39djK7tJ2Cjz55+EEQssWfK3gTjpb/gZQ40R1LhaWfggBGJ2CpQ/p9wC+qgNvkMx1vnTgPsohmzKtkXDVJB3LHywtftlWRcwjWHillBHU6WmFzFIzIDc1U96adK2Vi8wd+GpOy9+akAaFn7ThzDT4nZ3roiJJ+nvCVZFQvZEhkUvKa5c2VKgJ5rSivlPj7y2wMgw/rXuo3kUvUn2RTjDEe5+UqqBEVmn4ne3yB+fOev6yxM4QIKGeHzGpc5YuIG05m8cappMzrSW0WTbPC0d9Ayl4T279CZiGoNKB5hupK24WBQuSoUTlZTH/nKVG1z36BIAduml3FMkmJg== 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=E2SOl6aUd9d8UrrJwdUHbj6+FxqAlMf1+zsUj22N2pk=; b=o+ji7AUD/QXq9hQra9j66Xmo9wll9kP30TBPMJZyjSO+AIRiET+jWg8xcibGkTRziDsm1durPKucTEDT2agLYr+EdEqnYKpWC72BmYYS68YimUFneANyDYMar0Vm9mYREl8lSzOXvE86t8EgLGLk+zTtJJJLAM6k6DktjIWXMWUoQZ5fK0iAG5J36qGEUUanfDZaecPL6J9XH7OPdJ4efsHQLEuqvVfNf3xBQY3nFuibQ6jgbYwX5CoEz3IqoMuo20NsyRyZ25ANuK9fb4TPOQbzlzVzysKdt1CwvF1LS7Xt4BHLE6KJFfnZ5A26o2zfaIugywY6neX4Dp0z5mfJpw== 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 SJ0PR12MB6966.namprd12.prod.outlook.com (2603:10b6:a03:449::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 20:26:38 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%7]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 20:26:38 +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 , Kevin Tian , 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 , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd 2/9] vfio/type1: Check that every device supports IOMMU_CAP_INTR_REMAP Date: Thu, 8 Dec 2022 16:26:29 -0400 Message-Id: <2-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v1-9e466539c244+47b5-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_|SJ0PR12MB6966:EE_ X-MS-Office365-Filtering-Correlation-Id: 50233802-5897-4d52-2857-08dad95a81ff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I4JLfiQ86rGTi1ryPyL/9lctyVw8CgOsQpScUEEvoSHwzhUc/b+HPTEeRc8NmjPB5m5F98mYExDY8U/XckfWD6r6AUOOyPaMwm06YugUknZUg2n+0hKVVUug7ORe+L9v4kcjRzbjG3OhdiRjuDVPmTzBwjndLu1qlUSMSpNrC869h5Q0eg/k4DCsfeaZ+Q4fQTkssKB5J4Le9Sm9oaG9BfeuqJbZLw1Qoi2GRS4ylEGaKYF9Kg4fbU8wUi3mGMyBIPvY4Wn7ybcZwRH/IuU0F0PEFMbqSy6aUSjL9Omg/me6MC5m3nZ7U0uLBJEmxm6DXu+mCc+nmG4Wmxyk2QIZjpCYayQXuK/mMMXxf+60WpKGzV+dZ0v1foqxnMBuWl598MoSyZMh1kpYr5RGoXMz4QZmo9R2r/4GmN7RG4GLITrU9KzdPhX/l+yy8MM7r/9hF4OvcUXngxbcg7fjh3eoSPZ3KQGO76YAnqGkwSXINiXNj4rscvLnsvJsKALULHAvohrefWOeUkoMQyjYzQQ4UjkHlc3NSUsR1ujzhxKJfIIS1Fl/E7NG/y3p0KEwtIs+UcCgTeXnNjv0xIuvwM3cFvvKLJiyuWV30+usB1/iuoYo/aWU5sHOGFr7rqWjK73ZEpmbjR/aUDC0rDsVwtyewMhQBij8kmqBgPq3NR/8yjWBSrwhrWNWrlAaCPtGQzXHCSBuHJLF/z+0FNyz5pB48w== 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)(39860400002)(376002)(346002)(366004)(136003)(451199015)(38100700002)(36756003)(86362001)(5660300002)(921005)(41300700001)(4326008)(2906002)(8936002)(66556008)(7416002)(83380400001)(66946007)(316002)(66476007)(54906003)(6486002)(110136005)(2616005)(478600001)(8676002)(186003)(6506007)(6666004)(26005)(6512007)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3ZXu5dkNEz4bqv6JIE+YTtpN3P9lkJSTN2ubeZ13GxSK8LXNp5HlVlYUupsRH7d2Pcp181l8hbtDasgbFckgE0japZVoQTpVGFjivIarB4QUL5z+1iiYKv6F3wkY88pwTM3VeasvpqGMDhHLBO6QsrqgKVZaT93kGSzpm6s8wj8aD9+lyPfT3AANqT0A0kGRcVpNB8cNcbTvW4PBGrK+HDPieXZEUnZ3xaCc4dlpLbRmjQM7MCEtZMQNULNJUw4rqdYcrWRC0sA7Hw/MXm31hLF3aPJ+oavRYKOlHq2g6eAel2aWHpXEORYe+EcvoyY5eqTjiW+oAOdZJ+jjqUADsOBzvIGK2potHSGquZ+a0+AcSKAyac8hBwRECUiH4yVQieE+72u9+YorUkHYalmWiemluwX5nGUj4ruhGxEt7ouPvrV08dUIU4baW4tVpokB0smN2g6Vqhz0133RkUqebZDwK99eY1PWJZLTuUR13GAGh9F9yRtPLfVHteBn7tVJ73Ymxdi3DivXvITUWq9yURCiT/I3/vvchyIXQ9yxIDhq283IXwEf/dt2+poYkyHJh93IPITOkT0uZnbCIlxxphUd6R3VSp08nbsOn/oa6yr9w0aC9TL39RwPygD12/t1NOmAJ4Nhy7W6mHGdOOHdf9Ba/sHKYZh5EismpPmZjyRvGQMhNY+F9YJB2Fw1E4NDNrgPI1ytvAryf3BVMBTaH421Y+c46O3DvNjN7OFi1qqObAxoDYojOSWJmMSIgv1axuU0Vw5LsKzAXy9/cBAptm4ENJ06BwVhCiOxSi2zNoS03iTqHmKnGfs9Et4ZyfYVuaVoVRhR5amkzmHpasXBQgyim0MaXMn0v+0ngXJ+2aSIh5L6KWvIHwLJouqKX76t+RKnC8qnK0xSLTQz3jbiZYPN+GnqSsJ8DPOMqoupymxbVnaxm/tTvY8flzVpELLo0j1r+lTZIzlvXXMogVd/YPNQYyc+LxS2P6EBN6d2wrOrQH9ZiJM3ZfWXg284Le/0fKhf8VvTGiQf8aN73FDO6ctpbBp3xzI0/WLvJNf4U2Hi6YlGU6tyUQddFv1LyVJ3cXKPSt4+6+2B5MfjcOR23tNu1uf5UcxNsX6EExi7MMLwdmFj9Ue8YQK2Z1hNdkzNUXDroI3qHcZzAzpGICSOHuoucCKNQUVEHj+A8hLi2jAchJRPivyyE+MuTUgZ9OvAWjHIQFrLAdxd2Ns9Qi49QvEU7FXUQT5tM6Q/Y9TYChuS97AGOhcfxjC535pi+KRfxeOmXKkDL6tgql2M+iMLMm6NPG+d1dHj31L58PSAOt+ACSmRsp0dybLlNLy0LJWTEHv+K4Hkq4VpY5NmUC9KGMK5N30YoFOCvlCja9RJJdHKmk3b8I13GkBAQZvCkx4KlOv3VJMMpI10SHrv4uimKlSohCB5DbqXjQLNytwY33Ps+S+p9RBowDUPHMhRzXb/UAKZq8MaKN1RO/V7QsQimG6/VANRc1vbnGlDbicrcjwDh/926k7ScohTc+fc5b+RFpsbJpBqxUbqo16AYqLizzx5rf1+V/CREboD2RJUe3Mn9rXnHaA99VYZnL9s9AJ+ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50233802-5897-4d52-2857-08dad95a81ff X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 20:26:38.0112 (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: 0/ozVdE8hbTP+56t0pm81t6KDgwWL3dE+PBsf01eFsJRCG8dz7dO2b3idHR/Zi4j X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6966 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org iommu_group_for_each_dev() exits the loop at the first callback that returns 1 - thus returning 1 fails to check the rest of the devices in the group. msi_remap (aka secure MSI) requires that all the devices in the group support it, not just any one. This is only a theoretical problem as no current drivers will have different secure MSI properties within a group. Make vfio_iommu_device_secure_msi() reduce AND across all the devices. Fixes: eed20c782aea ("vfio/type1: Simplify bus_type determination") Signed-off-by: Jason Gunthorpe --- drivers/vfio/vfio_iommu_type1.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 23c24fe98c00d4..3025b4e643c135 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -2160,10 +2160,12 @@ 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) +static int vfio_iommu_device_secure_msi(struct device *dev, void *data) { - return device_iommu_capable(dev, (enum iommu_cap)data); + bool *secure_msi = data; + + *secure_msi &= device_iommu_capable(dev, IOMMU_CAP_INTR_REMAP); + return 0; } static int vfio_iommu_domain_alloc(struct device *dev, void *data) @@ -2278,9 +2280,12 @@ 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); + msi_remap = irq_domain_check_msi_remap(); + if (!msi_remap) { + msi_remap = true; + iommu_group_for_each_dev(iommu_group, &msi_remap, + vfio_iommu_device_secure_msi); + } if (!allow_unsafe_interrupts && !msi_remap) { pr_warn("%s: No interrupt remapping support. Use the module param \"allow_unsafe_interrupts\" to enable VFIO IOMMU support on this platform\n", From patchwork Thu Dec 8 20:26:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13068840 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 ADD70C4332F for ; Thu, 8 Dec 2022 20:26:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229929AbiLHU0z (ORCPT ); Thu, 8 Dec 2022 15:26:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229784AbiLHU0q (ORCPT ); Thu, 8 Dec 2022 15:26:46 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2071.outbound.protection.outlook.com [40.107.92.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FC007E822; Thu, 8 Dec 2022 12:26:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KNYE8w7OqBoyR+m8wYgUfeKvLp6o14+BvruW0qH17CnEdAjGk2zWesuAulaMyUiM9jkdWotEGKzG+Lf+INybA4w3UqM74Ya/D9Ztb/f/1kMjhwQpTxfFrOFZxFAjSZS99DAY236U7Y0IML7R7Ablz8ypY0Ran2uoeAqk34j5q1YZRCjntpq044J/qLZDiS3QkQ+/rN25IQxF76R16Q+nauXngP7vFa5NNteP2JlEURF9H3lMDxJzv3kTa2ZIBAH+bJmIWMxyhYL8sCc5AHFPMjImMJuVGaG3fQ0+EE9x14Eif3vLSiL38QEP9hxTtnFkopz76eXN2rPGPhhUMtPL5Q== 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=omTI6TOnFBadJYpPmEgclxTrUD2dsheJKzz5Vmib0yo=; b=NKlO8shIJd5L/YsD4fCE09LlLV6ZG1YTdYrbM7s9mLOZx/f17sZF7kYPXw/io73gEIlru5lrgtm4sOmzHPaWs5SBk2LPKGvZWrKVu3VlnqUqtdwhAewp86yFuLZiUX0xmZFAF772yhw/ZbaFuH/oiHINjKBkgWRDo8OSLdFIrqsN1tyCaqG6/anGl5sG7gDBLtcG0Cd3+hCKYJkiKjtxfp6rcYLpK1OlkpJQeegru9xZUwXB9s+SK29q5sc0YwF7ztqImJeQCtBEfS7JZA1N6VhABpXDna9Z3qa1XX2gcpkDr08w7nBW5BaHyk8letfIaFlHIpzy82bZMYgIN7+toA== 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=omTI6TOnFBadJYpPmEgclxTrUD2dsheJKzz5Vmib0yo=; b=GSnsD1umisuuQGWBJhdMWjLcAwOb/WyIRt6MNVh784E9c6NsFgOpvv8g+634Mx7EMb3iHWyJArdgilUYZG+CNoR0nYnzOnVv9+OxNxescoIRHDgL4dgbu/ompBIQkXH+zD5w29nFy4cRr0t6Xg3XS/MyD5y2p6EfDKtnXatecp6Txn5qEM1u+V1Qamk8Aqyi3Njn0i+i14OK3laqqgwErygh9DRr8Ll+xo1Tny51OtQdQ06fhxHcAFmuVsZ7B3oLP548hoeEgorgIfM5s6QZDwQdu7l5nv+oCtES4Yp/i9qqp5XhIh1eye8JI79/EV1Vy0Jv0NUhnfRVeE5gketoJQ== 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 SJ0PR12MB6966.namprd12.prod.outlook.com (2603:10b6:a03:449::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 20:26:42 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%7]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 20:26:42 +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 , Kevin Tian , 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 , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd 3/9] vfio/type1: Convert to msi_device_has_secure_msi() Date: Thu, 8 Dec 2022 16:26:30 -0400 Message-Id: <3-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: BL0PR0102CA0051.prod.exchangelabs.com (2603:10b6:208:25::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_|SJ0PR12MB6966:EE_ X-MS-Office365-Filtering-Correlation-Id: 83dad2d1-e81e-412d-e343-08dad95a828d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KEO7URd870NapJ6ZUKdx54fUkAWnejnumJlwe55BEhgCtkTqW4E1yBdmIHQSKL76AtCHIvsf33ZEeilUq12GA2yoSWha6tZfpue/2dE92wYTZ4eQDx0Mty8v/q6mmCrofQzTPIM6akbJEOFY0DpmAz8GGzFpmznkOscf8/K46q/jbgYB+f387L2GmSv+MeFaXMmMmJE5V6dbo0YZq0kDJNdsrI3oakwnRtTSQlc/v3zHLh5NpBNENyJapqDG6azeNn8+/r/+SKzPTrIqiPPWHEKJvB/5SrVfo1CWTIr86Yj8LCaj8CHr2mZKUAPy6oFYGaugAhJT/fPR+YzUY3gZ4Zh6aw1l4Ub5fw5fYpqScDBgqVaO2BexBGNNX7j5C0CCat8nOLKTnZ2cxXqRwPG2Ub1L9McMgh/5MaBQYPjtHMyE7ArBYGIAG+fMtCPVFRJ+HnFNX5t8qHMBsqgCD8d7gnZPBEC+gpDPEAcc7ESISeDV0+HuQ94FE7DA5HtEoSzDQGLnebUpZpW9+Zz4TIa5VDkhzn5EcPuYVTFTPVeKuxNvfT7ECZ4h3hmjAp5tdd0pjFogaBBu/m9vixhjQzs8qDyopl+A/j5eD1w1rDqANO21uDwiLAX+LeaGyN3mlZWv9elqfK+Ltu5vgGmNS38ORvlbuSJiylKBAM7CQ5qAHjQIhx4JF/mAA2oK5fYy7cHkZQLKCWnZDPIoqXvTxRsBxg== 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)(39860400002)(376002)(346002)(366004)(136003)(451199015)(38100700002)(36756003)(86362001)(5660300002)(921005)(41300700001)(4326008)(2906002)(8936002)(66556008)(7416002)(83380400001)(66946007)(316002)(66476007)(54906003)(6486002)(110136005)(2616005)(478600001)(8676002)(186003)(6506007)(6666004)(26005)(6512007)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lpISRObjD91NR/JDeyBfV6omqOlIq6N3LGnGWVRF4Ff1qVIfsZGBs82qVH8lqJJW0KBuFtoIXowBoarXOMtibUB+QSXH+Npqa6e9ZMgSfxxf6fE66l7M16aZMF5kYLEwl6K1Iq4qKuzjF/5/fnaw9dvZqiTaXM4TVrS+KbhAqGpdw5cy873FdaDzRn77XTBpkMfDigETCZqZcaIp+IAXEmGJGaT1kceKSJIeKA977UAZSpl0/aG6Jq13uXm1qE6jrMXv0i9vjCrvH0adzFI0W5cESGUkw3M4pIG08LdncSk7gLmvyyVYYDYa3kzX4w+RtPJMcTzJVtKclaTwiwb90X6l6gdCl02q7/g85KGPeBp/0w5DeZ5d7OyhdpIqUHTxfzad7yAQf9jYyv/IBuTfGacI4zxvMD2+0TDMc2/+q6vCzU5Cnn6gB/w7UY7XXKbr0/xq4ehBf8aw2ex+HnJGBq37SBE8mYVVzgEyfJfGf2F12rr2OCwPQQ9/uuryKRvE4bA1jLf0gDOB7pq+fdr4vo3zq8qpHIbfoK5J/zSoIjopAaAQyyg8+beaFgLWNqhFh2iSqqRbJEs7xJ1obvir808UIZOwZ/oqiLprV5toUvgVD9G/2o/bLrj5Zu2yHVVvpC1zD0JxOOlkIgwq1NcRiLShjVh8iEypZae6V4XxPsTdsz+BbAjGi1EytIMUK1GZ9vxEqgZeaqSFcP5i/wGT+IHvB/MvhI0742/eADZmHojvmXdrzrzMeFUA15iyNK+DvbBKYoEQQ8UD/z4fY3ovBGVuVISGS1BD5x5YT5qf+kElZ21J3q4uTMDFPf7EDHiRxiVng20Peir1XXjZCzODR9ihNq8+LmCxhgU0kMOtj9rBO7f/0694lJBeb8L9+LwxEtc9Zs+wADGioQf2dp7yuLZh//ydE53TebP5dXgIxhJesQqAuUortwrabCbCNEZSgcbdRk28XdF0sODZl8jw0I4F9NozMOuvG72y/UCwhEBafQAL1d4ahp30rC3Op4G1lSTAOVOU9C4/n1ux8X7knRccok6ftbcKWs13znxGpAb+pWk3FVH4QzVjEgPxzmWd9CEYgvd/K5HLiEg0FAHnt8qSyT8oItb1OPogrn6aSrcuhf2vF5XHVWwSrb20WwHcT+73Ey8/CQYy08g6GVgWFzr9Ku6IeiZF1SfPIbvOfzhZcaSYBd6XJXkhWRGdk/ljRNd2aeUd5LWw8S9kC41SC8DRxzSvAebXVS0ZQtDzGw6tAuE2FZK/8qHt5WqbiQ3xkksUR9wGYZUxtnEH7kaWugaFkMt2NvHb+SE8I6ZaR96jSK8WQ2PHhbBVxSEsx5Ek4J2oKSENiZhO8T11xC77hnuhsTgadY/JcKd9aEpb5GcwRpZfvcJyLloZuCw4LJ0u0RwVfbXSX2dkn4FCe17ZJYTInjj3FDLtvjSVeVYVVt8dsJNBbD/zaxMQ72rw7JFKQKnmHi1aK6+5ZIEJnsidiWPRJszFcSWkEoGxdGzgi0KpZehH9oPAgnMy12qI/nBM+XYcoCJ++HAmtq2iIsdU9+RV3nSHQqBVmsDeP2czsGG50absGbLe31Iu2x6Bb+0Q X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 83dad2d1-e81e-412d-e343-08dad95a828d X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 20:26:38.9466 (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: Hedc6V1eeu1o/ZWlx0MKrZdyE/u6Pb8MUbz9ICRK4f4k0uEQLfbiN4mGAP/PYTQM X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6966 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Use the new API. VFIO can just slot this in the existing iteration over every device in the group. Signed-off-by: Jason Gunthorpe --- drivers/vfio/vfio_iommu_type1.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 3025b4e643c135..a954b58d606766 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include "vfio.h" #define DRIVER_VERSION "0.2" @@ -2164,6 +2164,8 @@ static int vfio_iommu_device_secure_msi(struct device *dev, void *data) { bool *secure_msi = data; + if (msi_device_has_secure_msi(dev)) + return 0; *secure_msi &= device_iommu_capable(dev, IOMMU_CAP_INTR_REMAP); return 0; } @@ -2280,12 +2282,9 @@ 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(); - if (!msi_remap) { - msi_remap = true; - iommu_group_for_each_dev(iommu_group, &msi_remap, - vfio_iommu_device_secure_msi); - } + msi_remap = true; + iommu_group_for_each_dev(iommu_group, &msi_remap, + vfio_iommu_device_secure_msi); if (!allow_unsafe_interrupts && !msi_remap) { pr_warn("%s: No interrupt remapping support. Use the module param \"allow_unsafe_interrupts\" to enable VFIO IOMMU support on this platform\n", From patchwork Thu Dec 8 20:26:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13068837 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 A4F6BC001B2 for ; Thu, 8 Dec 2022 20:26:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229956AbiLHU0u (ORCPT ); Thu, 8 Dec 2022 15:26:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229912AbiLHU0n (ORCPT ); Thu, 8 Dec 2022 15:26:43 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2071.outbound.protection.outlook.com [40.107.92.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FD3F84273; Thu, 8 Dec 2022 12:26:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j5RTCC54wSxI2ob6clQeHTFiwUuR8+/t2TOulbPGG0BF02+S4Dk6H3cvoWsXihWJEWFFbNrjqGciSp0mlzqCIKvt+zsa8nxxkuQVtzZGxTPd2hLKFZbvR/DcTrXizwoyX9+JhUDWfBp1fZSMJNsE+HESKReAw+49RwHOS/e+2Po35W5pMwfil84xaUh1zOdtMzkbNd/3doqSAHN8pTahjaQvI9/gozL1uvYg0e3pOYOxapvucOxofANPZ6qhUZk/Nr0z5UbIoxrO4DdQ62Rtt2fwqFTfeLrufNEmEnjjaiWzGUr3GWhdIpxfz+ivL7D6lQmP2TDREOmZICc5ThPWeA== 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=lVEVSu2H2ch5IjJ5JCuae7o65vB6IPfDsbdAtTujXiw=; b=h21HSidkrI4h/rx6TbX4zjgvnulOyaaw7QsefPuISOZ3gOHFyfJ3jVE8V6+MmUFL1jHj0PmsX44C10fCNL/eonjqp5rJHIzsy74sL6Zqt8fPyjw2X+e3/HCWIWOzTEkav36RaobpWe2M4k7rKHSu8FG6ZKuD07LOsF2q25de8EjBPf6znBkn5QQmRyf6qBbyNrz3Ir85Xd2Lgi3wD5PQX5tOeBTwAoQQ0gLiVPn8hlhr79THmL/5obEknYx7bpj3bZJtYqH0954VOU0bXTNpsDq9TnpDwiHjla8BroQNdDy4qK3d21xcAAAQL9DGdJqdaGg2Saf8De8er159anbMvA== 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=lVEVSu2H2ch5IjJ5JCuae7o65vB6IPfDsbdAtTujXiw=; b=l+1r8vgvWd1KwWTyggdRkR+XhvCHQ7u/cBEgmPIZQWVx7kIcYktfIXVg3kULeIof5NdD9TVu4HEPF6GEXkGR4yYJuqJkSwbQxhAOBajD97uBu7udJWdWaHBorzIUld9r0SyNinhbY0TodLR16OJjWdvX4378PRqxp8gyGi7xg5199rb71XE/0PxlOgSmhxw6fZxpJBwypgDQfs9Q8rWSnWFSHEgF5oi8/bTg/X8guAt6FxdQvq44NdBPDiu8FPuwh5/FRN45bUmYsTbU0+UAN30BC/AzWpff78S1OXaADlkgjLuROYfHhliY5hU9lMUUvcgprJAP++qHOh/Ki+532Q== 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 SJ0PR12MB6966.namprd12.prod.outlook.com (2603:10b6:a03:449::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 20:26:40 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%7]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 20:26:40 +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 , Kevin Tian , 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 , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd 4/9] iommufd: Convert to msi_device_has_secure_msi() Date: Thu, 8 Dec 2022 16:26:31 -0400 Message-Id: <4-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: BL0PR0102CA0046.prod.exchangelabs.com (2603:10b6:208:25::23) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SJ0PR12MB6966:EE_ X-MS-Office365-Filtering-Correlation-Id: eda8c252-1b9f-4871-adc4-08dad95a8254 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A0fic8T8GTI5ylUa2ML+0j12yulrOHkF/MCcvc8aB6E6WQdgYopyPuXULsWMwa1bwpHAKWL7Mex+pk9jmdxCGyUCha2cTwoai7VGIL7+zELJSFbw4UUb+WC88EZnT/PxgJ+Pg0e+IQ/21PujilJKgGe1kGSHwjZzIsBi3xygqpmaEbeN7Tx6zXJYB9x7KwnF2vqJmyzj0kARequPJ29PuDQrdzv7Cd+pFR38yUMjmM5VPlZ9824DGYO6RpDhFrGAmsvOHYBOXbB5ERWr6k1AD0qOkk+voTO1Pdku9v1sXUyUMxVcMD9wZEmlmo3GIdjLZ872OjNicPlIj1eE9KQv7btgeLnUF/+mVQFoLxq9vWUYq5dJDnr7WlSTP4v6sTHaoWLyPIAy2yn5vjjH7BED5t3Z06aMJhfT0Vt5qFqp0x2gFKdHzZdJNiNP1GGRE9qxKBBQ1glwenFzLK8YOX4pF3US6JMx3Y7AjBtrR8xqPmQzk2Bt2dekh7W86vgYMNUuSoxBqghYWoacytDkAe6+wzcLpsp6k3krue84pPXhZ/vqTiLQqMmKXtf8KF1CCCcIRd8PLtzxMAlbQVzMAWigA3Tj5At3Hd3rTVqT1RqrlbcrZcKLGgdn0oDteW1f47uhx929tps/I4epyfqnhUBtCdJ7RiNO0X7D2Fv2himoFFn4q7c/j3nNJkr7R7Iq8uQkKigO0fqCAh5wPwgrPs3P8Q== 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)(39860400002)(376002)(346002)(366004)(136003)(451199015)(38100700002)(36756003)(86362001)(5660300002)(921005)(41300700001)(4326008)(2906002)(8936002)(66556008)(7416002)(83380400001)(4744005)(66946007)(316002)(66476007)(54906003)(6486002)(110136005)(2616005)(478600001)(8676002)(186003)(6506007)(6666004)(26005)(6512007)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ci+xMP32N5DaeFErUF5Wv44llDZ9ZAYJplxdbpRBMqir5rih/qjYfSSzaZqQ2q7miR5Sl4nN99lw4Qja+YAGJA5J/1jqfj2fejNbiSJlAyMYMxGDmPxjpZkrj6djcyjh8yR1sevuGCBHcKzEh4Xw7R1aKT71CQfX7DB3Tv2U5Yd+aQg7hbFwptiS4v2KFAvZB5YNuUptAFXae+ABNS3678t4TLd8X8YW2J6/BfIElvhewNXiey6ljQvetMzNxRK6XkmArR0tFxWhdiFp2So3yhoX4cjfvYS7CmRI8UfZ5A5QEJdWsWfVBXLZjLL8FZyU19vs9ZtP4laO3cBsUJdDteqdz6Ce/8CHQ9me2mowiUJoReTQ/G7+JAaVEdKdB1uCbn6Qn0o5srpf3htMWBMKlHoB1/vsMi21jTjGcRLnpJUQcYbwi4UZ9SvhZixweOvBu7tI2qwk5rcMAoBsFql/3wQ9U3U+ZptoJsySls/cgwfXriujZxDqyOjyroyAAC2VSGXbYmPvgx9rhGIGDjUHNPaLnfbsBagCRYDKHptGhYE13pKg+N2LbNPWqR9sXP1nW6f4hYJOQybBynWN1ShMVDmTBO9foAA52p7+1VI+YpbvUxPzK2IIhI1gfjdWU29eG6+nf7nUtGvs2ZLaWrIMU5wmiJnolQ1QEQinCaNr4gqBimWYgOz5ouYbl0esdKJh91yP1OeYPP/OehABOZDmNw6Oei0hbjGMCFEADVkU+31RdtrHzm/fT1kRQt6rbaEeEnUPYqqRLK0mP884ty7VHvRWS3yUgjowXdY84mve1c06+k5BN1t8USDhZBEwarfpKAB/UIxhSFpTKM3JD02Z0HyLKQiwY9iRtuyL8xgr8Jprn0Xn+8581CNBl3I28nRG2L8295y/5xnTlJ6O8LKapIO3m7BXd9T1utT8e8e33d0T2j9oQVrdXB1bLC3euetzkdwrM0Ie+Zs0kvc4b5F3KJ9cf3sZVeWG/h6aISAKluIxUFMVla4UAwJtc7ASn4TR8dbrcvdlwBNn28uYRK4bD2nuJg4YIVnAcTl+evcforw+NmbHqKBJzr0YuTJJ0c/DazpXjwZVYHUQAs0H3hdgGWYKHQAg4LH93IuAnSf4/GygXGSTj4D6v6ySQrnbbm++hM3x8vRKPX43niSz89/MaZrVxT/Vcyz6hCGo8w9cEI83ItS2v6PzaBPGV4+t+OureUF0LJO9T3r7/cst31so1QT/fh08VkBGTpHVqYwYbHFqeRn0T0FCTFF4J2sYBFSuKDjd8LHZ12dvm634tmotyvtuOwGtOPXuR7K6pLyQe/QPm1GwZDsLD6KjCw+2OcXJLIJkD0KFqlujtkcdQIcQu/kl3xF4cuRwpOIwqXpb386udyU3FIG9CMQFP6NLfJYbwL5FWS8io5YJzzvX4aqspFAlv0eM97ZBsKxWG8e/HbVTYqimmUWWyE99/0AxhoUBbos5Jhd/rtqRzjh9aQDelLzy4XchZEGnHF2Y9ojyBhBxpR1ysUqSLr5u4ui54Lpf2jzcunFv1iLtVFMxWnfXy/vAKSK5nzTM5bavksZiNAbaujhBdMtNVmHzu+wOuu+4 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: eda8c252-1b9f-4871-adc4-08dad95a8254 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 20:26:38.5405 (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: W0IZr/U1IYK1BvdSCm3YH7uBdK/E87S7oQtP3sH9KfuNjhK2NIZ1YeVDy6tLECSx X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6966 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org iommufd already has a struct device, so trivial conversion. Signed-off-by: Jason Gunthorpe --- drivers/iommu/iommufd/device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c index 29ff97f756bc42..13ad737d50b18c 100644 --- a/drivers/iommu/iommufd/device.c +++ b/drivers/iommu/iommufd/device.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "io_pagetable.h" #include "iommufd_private.h" @@ -170,7 +170,7 @@ static int iommufd_device_setup_msi(struct iommufd_device *idev, * interrupt outside this iommufd context. */ if (!device_iommu_capable(idev->dev, IOMMU_CAP_INTR_REMAP) && - !irq_domain_check_msi_remap()) { + !msi_device_has_secure_msi(idev->dev)) { if (!allow_unsafe_interrupts) return -EPERM; From patchwork Thu Dec 8 20:26:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13068835 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 B9E70C2D0CB for ; Thu, 8 Dec 2022 20:26:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229947AbiLHU0r (ORCPT ); Thu, 8 Dec 2022 15:26:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbiLHU0n (ORCPT ); Thu, 8 Dec 2022 15:26:43 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2071.outbound.protection.outlook.com [40.107.92.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 359E17E82B; Thu, 8 Dec 2022 12:26:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RecgPm+rxkTxCehhGLLAs4iQ0IpYijpCFEo58/7LFNOr01Nell0lTQojmM2KykD4DzAFPbgHdOpvWP1+9syC1CeODE/u6RYJiQTeSX6EWmw1qrMBrKQILW/W5dxDSqg5OjZ1jx9pkglv85iBEsG3PFcXNUr+yGrsSYqIpO5aVg1+eTTeVaOxLuYDcqvT1xiQT1DS5GzenSV4m17hCDbLeY6mG8zAgilMuv08ONOLB8wdwFewxwEbWl7Ivl0GuTNMMzQRz9BRlZ2EJm8UgG8IWiSQW+gmALtJbNZRwkMQalkTg5JJKx8Z6R9yda9IuaSTEOL2gHCZ9N+DxYGoaH0L+A== 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=SCyOL545mD+Jn9BYCHsO5I6THzW7bsM87PbSEnWiaLo=; b=ANL2jDRyW2rQWOT7RdQUEOkbxretlwX+bk4vybBUAwoO03dgsaQRkqOjH8G8UeFudiwqf8Pi7bL8Dqe/t/qVCUr7iF8GOq41AoelM5NcYnYO6KUu/XoGOOeK2KAMDf/wu/lWzJgBqwdt2XQg9OpSPgGJAgf/TdAl/TAUixANtw2yzi+5gZ24VaB2AbfLaFKLdr/fEIkFK3IQen1mAaUBXH/o8GYlgIHcWta+CiMDVeIGhJLBLbGor4YV1C6uztwqtWEw5M4aPOTAiWW1uwOuq6gps17TIGlkMzqvw3YgNV8pQ+/jjUmxXCXnIbfcgpsmtCLsQjxCO2U5Y9zu+V8cjQ== 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=SCyOL545mD+Jn9BYCHsO5I6THzW7bsM87PbSEnWiaLo=; b=Jc1sSXGaS6UPqTL8Mi6gimHCT/4r6kgYzXDODZiawG6Wd7aH3/DondMuh8ZR2pidQdDyMrBKJgs01KyaXuWAgi67aMtNyKRzVvVXaxUk40k4P/KmQuNAAO7AZc2S1UJqg5kJbTw/gADhTlAZB9Qrr6Jy/UjbqR+Z2kvQMJkeuVVCMEw5e5PKSeZdI8ZKZF9j7ebVu/db7ZNp82JVfxnD+scrVoavUTD56u3i6oRH9A08UTCSDPjaB6l8fQfm9aD9gWusPBRpcO5A9FdcvYN1tsUm8cN2T81qOl4yT5dhDgUdH2n7Q2dMDpehZ8+vztgL3rxNULtaXpmcQLStIZ/4hg== 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 SJ0PR12MB6966.namprd12.prod.outlook.com (2603:10b6:a03:449::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 20:26:40 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%7]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 20:26:39 +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 , Kevin Tian , 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 , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd 5/9] irq: Remove unused irq_domain_check_msi_remap() code Date: Thu, 8 Dec 2022 16:26:32 -0400 Message-Id: <5-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: BL0PR0102CA0070.prod.exchangelabs.com (2603:10b6:208:25::47) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SJ0PR12MB6966:EE_ X-MS-Office365-Filtering-Correlation-Id: 89f6c9fd-124f-44d8-75a6-08dad95a820d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CkuwO5oWepHiQMCEzZkoYCxVCmY9mKHQPXS+mN4TgNuI028ypcxfwBUc/6xO4nrfqh4YLb8pXwk1xDwz4daeTA8kJ8J7KLLhksFmLe7uSXwv6oF2vZ1dQV10AKHz34188NpXga4Y8EUI8zA/vgw7xRhSFiU4AEyPXdfWMs/ZRGzzL44jyA8IJ79cybPdIO3bwTRAl9+Ku1/w3n6Aojd/fYLXZJ0Nt1OkOds2wmY5jcWeG24swEWxpRWOPOOG0jMSGJ6bGSV5mDdRtHtQl72UhGeOIiclkoX5zfiPiVZCJKktxDC3DClOCAJlkSDWCApVmXCW3p/JMHkB0DAhZvJQxUq9ukIzZPNe/jTxnn8fp1LsdiqcgiAiRKaZWoQO+AMFmz7OozLfQYMHz8jWMnspZ7lcYa0G/yMKK3/VUz2IRQNNezPd8YrtT8VqNV4Tg6qdoktdztyv8u01gSv/O/AieTGOqwuPKIy0hBwtId/zqTSA+FJA8YitbbUN4Pi6NJMxeokbCs919VRq1b4o8Hli3byOjpgAO6hCaepCsV+s5rEzuvCtdxRNIbWAqP9uaRgI+STLSdT/fn0PqKAlH0jl7VxF6XNDeOYrpxPHtSAZ5l6HcBKRwdhz54fgZQeT8gbRKUhsIBUWOenH+eWW+IQu5HPlL1oqSim0MGXK8I5zxnt8fus6mTro7xQ3yIjMrNllfNKt1P2ocZYkKcdvtrzILQ== 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)(39860400002)(376002)(346002)(366004)(136003)(451199015)(38100700002)(36756003)(86362001)(5660300002)(921005)(41300700001)(4326008)(2906002)(8936002)(66556008)(7416002)(83380400001)(66946007)(316002)(66476007)(54906003)(6486002)(110136005)(2616005)(478600001)(8676002)(186003)(6506007)(6666004)(26005)(6512007)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ez+sohmTH7nDvSK3cS2d6s9iMamKGGoonHROSl4eNyvGdlTWT3mSfuOUpSFOtjIkO+g1hmGhjgE+o5AM18RjEPyS/Ge3jqEQkbF8hKaZRE8bb1lXLIhpX28TL1ZN8eUST6zSeR3vOFL1cwe/JwDNFN+Tvc4yOHNkTZTdb/PXBaucviVxNMEBrTCtZrsJ0lNZP3yosbLFtPSL4toJi7FuSRpCCcvHM8YsBSryMW+y6+ccKdDwPHGydC6UFoud4LJEMQgNTgD59eJ1Tb1h6SNLhpuZK3g2h5QEm9BxmocjiCo4jyCPoG4g+LMYH5o2wBFy77XAn7YsY+HwZTpvvePZqStdn8djGNztX/PYusM7exFC7+uNlYekrMIqSHhOzRjQiRZJykCoJpy049kwXPv4eOkrKRAQIeCivQisRNWQbaSzM7XccMZENPQhjhIqpvDqnttOhLQJ/K41oOpm8YHgMRXa0un/9BIdzxeBvtYk0cJweZIuT6U1vWBPuGb7sEuNXazAF3cZwrmaqVORnrzIb/9LfzkEVjf2EqJuks4HciKQqzRlC1hLljQhLcjIhc8Flwe8gC0N8IWg/kANVLlIJzGrDli9tIdkHgJorJ9Y8WQaCaySqhL/Px56VsJEVl0jdR8PiuVfzJ3SOOeJWuorp1xgk6zfrniDdLcs+tp17QDSEvuTrQb6WxxbCKjeN/PwHw1fBmYJJOAyL25m7Ml4sJ7SD4HCIb2c0D2IlMLWzj/NZF2zmibmA2+XXRXmEEEjLztsidwmUmudZr/64r7DJ1P+m7zqYUZxusTfzqJjWlmbdqryTy5h131qs4RUb+aXoQB1cIqDBT3Y9WPISI8Ch82At1YFnmXyYoNTLBh8Sn1Uc/aPqPx1ncygIr+pA8mDV4K/VSs7CG18MmtJt2GhABaR9VTLf4p3XxVRS/guAqWtkvmu5l89PKemDPnqNmK4yiEq0t1ZP6uYaPb+W9a2LjKio5supHvY9nstkraNULay+RJLflWt7ZXQ63H66CgIHAmy9XUYMQPOTLiw1xXCzw9iMhlXwadrW0173WiqE17W4CCPfZsjozu0XqNPUqtxLW4XoqMv3YPNXmbU1RVlr8FIFBO54hvk3du2Nu4h5i7i7BhH961sf5L5MtYHRUx28lBJBpu6BF03H/MXf2oDcnU+VdrKNqgfoxoledrjRwGyftIr/3wYdXGJ2xLyh0uH/0wwPIR+XWPbuEUAOoW6IQaspDVFQydcRLyBI0C2EZmwCk4BXmIcLgI8zN8G9URnZBR0e0cZlFqeywwYJ91te4RizErK6Vgni0/hPd1BeoIc9AY68DPdwt7tyIC4uiY2kd69J1PISO5ucX53Mssvsttdws2DRaM3QxUidl//gTS16O2w7umpvXpcG3A3qutTKBju+I3n7H2JiWPpR3YQQIQWcpC/e8t7/XkWgIzuc3JX9xJ5UhrK5eT708vRWiv6u3SgE1aY+sK3ITxBiWguEX6Hp+I4ymCPGXdhVq8OYr3Il2oQRk/xpkArALg+n0DaijYpk3cfGDd5bQ0cS1YwmAFFAGcqCHcuydd3VJgwO5kg2c5OkjqVsjuXcCdOo+ko X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89f6c9fd-124f-44d8-75a6-08dad95a820d X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 20:26:38.1362 (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: EOn6klQlOA+oOMqqjr86GydbiR25JEJItRpaszv74bqxMO0pgiMJ6sSi/Ztn26Tm X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6966 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. Signed-off-by: Jason Gunthorpe --- 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 Dec 8 20:26:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13068842 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 9A530C4167B for ; Thu, 8 Dec 2022 20:27:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229993AbiLHU07 (ORCPT ); Thu, 8 Dec 2022 15:26:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229951AbiLHU0s (ORCPT ); Thu, 8 Dec 2022 15:26:48 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2071.outbound.protection.outlook.com [40.107.92.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D36F84B45; Thu, 8 Dec 2022 12:26:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qa+qSYS5B7PjrxBMqnOj4Wuo6rQGdSjuv7jsEx6vVFhMrGLhtWg2orCY/TgvUZMGq6CAUAymBje+2W22RlpxtYb9nMuqsG/QzzKwJTcSI6bw5HxhJMfrxQI0b4ihgGGJDwmBNApfNhFB8teemoMNOmSn/epIGWAABK+6FXijNGg/wuDYYX4MIjeVDR3f79slOWMusM6bQ2OAA/uOTMYDCak1dI4WGUQTG5EUuHjHLb5ep0ebLsB9lcjeSZXGkqhZfJ8pf+0FMgZ9LtAPoTwLHPxi0zeW5zrUANTmceRQ5Ek2o5DbZR4TnYF9Kjp9xktCbHlfgLI+7ob+iJmqHOqmfA== 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=qiUrLGYpRHRvTN0nQtivy752j9/niuZ54a2UFBQQNBc=; b=nIIvEU2pJhqj5hMvWXNfRDqYInSKJTxl1FdI9rnj7nC8VnV7hjvM4euC2eDVA0hrqiUqL8sckFqsouiu1I32uxVkTXHMWipovhHPSBaGG1Bl67ZTAwlzmPcB6oRFAcjhULyXkHCWKO5rdYxafdsOhRNWNHWNZbiogpeHclV0tzi22ECZz/FoL+enhmUAeAOsvli5lGrjXZcuTRQ+8+XIHwB8gHq937DbLBrcX/kkyG25UNoRvxmp4JsoJlyhUtcmpaQxecx1+zsx1Pypnm57kqdGwHjNC7aZif7mwlAZyxecxyMt3CJiShNxawFXlp70vhxRftKStKQWIyHN8cug3A== 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=qiUrLGYpRHRvTN0nQtivy752j9/niuZ54a2UFBQQNBc=; b=RYRRoL9ZvCpKRLAFlkC471Wi4nY9rRGpKIr+U7BQyuBYPQpcjCxRC6ED99Dm2k3voSAjzyT0QML92t7w70xuMKvOPuJzmF5WrisKglYAk97lDQ6Uex4Rklc24h49/ow/KLGLbWhuz2g6R4Tnaoevzqbpa+vvPUl0iw6LgeeQgpJV3nnVLutJlGHYcdI0AsEjl0hYOE5G+uf7wOFJPuyIRQ+fuoOKObqFASUfrXN2GtGOy/ZXIQ6ADLa01yYcr9JHuhhLnj7l9vNgrHRFUnnCVnRqI0vN2NERn/zt6DyLyyB/1cXTZ1fizIzjXdeY70RndRz6g8F2fD3mU4sHic6CAg== 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 SJ0PR12MB6966.namprd12.prod.outlook.com (2603:10b6:a03:449::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 20:26:43 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%7]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 20:26:43 +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 , Kevin Tian , 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 , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd 6/9] irq: Rename MSI_REMAP to SECURE_MSI Date: Thu, 8 Dec 2022 16:26:33 -0400 Message-Id: <6-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: BL1PR13CA0156.namprd13.prod.outlook.com (2603:10b6:208:2bd::11) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SJ0PR12MB6966:EE_ X-MS-Office365-Filtering-Correlation-Id: 202133c4-97d3-4c0e-a3e0-08dad95a8345 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8jI+2z6vReTtsSMwxuj49dOm+459j0lGRMAb+7oVGJkQw1SFyz9IG6+SQO1kaPDSe9ppfIUU1XbtkV9LfrcAPVNrv9LS41WXEAtlj0PxdrkJ3HKfuTWLh2fQo13FPfuHOQLXPXL1xqCYogqfuNqo86bIWT7mNK85FwSYlZ7+rIzwp8hC/+u8VOu+TCZCaGf9hsvaePu3/uej8zA6HVzqiiDRmRsHWmhOUbcc1V1Df1TVTQA9/0v6Zar0QZZ6YetM20uEMbizQ8Kt4TDS8ntM6FdRgYHly7Z+7DRiL/gBUAuExl66wmaU0l1YvSXUotRJegYJn5SvzYLEJ7rf1km4UTkIT0fGqi29FwKUgCHDLaFGZU/fW24MR+F4vTm1n+eEsPm6mnYFkaKh4sne9EA2mA4Lr7Plv/yu4hTiSAoq14ibZkmbUPqhlGxXQzT61JP9VeMloiPJlnIj3LXL2JRGgYU84QmuiqP6WRgyWR0+8A6R38FeECf2TfzJ7NOAg41HZzv7sqjhxIP2xoNUmNV7rQghhAus3HCePO/syxN+CLv2HsE5ErKqm3GaOXxCzkeo49ZF4GtlgGKfo3HuIYZ6YSsDq82+Uu6TPSqghRBjKVjBOt0it++kTCxwCrkSU0eD3kPev0yQpSNrvZsjD+72T+CnPy93MJP+W0ecz7MeUjJPHDFaqkTPn6zPDFQRvBNnQZ4CPCCJf+6fSeK4prD5BQ== 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)(39860400002)(376002)(346002)(366004)(136003)(451199015)(38100700002)(36756003)(86362001)(5660300002)(921005)(41300700001)(4326008)(2906002)(8936002)(66556008)(7416002)(83380400001)(66946007)(316002)(66476007)(54906003)(6486002)(110136005)(2616005)(478600001)(8676002)(186003)(6506007)(6666004)(26005)(6512007)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rU5+azCyF2eZXxj0Qhf1PNkpbooTAf+gD7W5Ut1xLXUJHtu3M9qKJd1eGaFqRbZZW4qJOBu+EgYgR7rAqe8ccEDjw06t3anBy+fxKeEGbfrjT5yZE+X9yE+aG/Vlib06yZlzko1MVTaVmUJs1H+2X072cFUnL5RM0c88bsQ20uMJmCNP1gDLLqT8sAzxR2XQmIhBQCtzgMMpa+FRbQkTqUgt1/VGBNyGRwECiJeFWHJjIFPFC5PKnPHWvgL9lIv5ZkNKdwVw7DW3j+4ukWlwB9yDLgCF51asC/hjYSMeXDMgxQXK4jtMzzrrO+hzJ8u2qJR4KDB1q6opYwY/Wzh8sQn8l395REDRtO9cV20KweU4TnMGhsyXI0GYUC7BYcS3CMcSi3LHPFQcIFa/R8RHAlsgxmNdTPutfDTrLiKYC/ZpeXkMnuyZUnj1FS/dP5jH2XkujhgHbetJYeqDXZiQ1ZNdZSJ59GTuYZ8dIPs+S6kMw1VA+GEajciFNIwbOMZSOp58X54dYZAQBITNAyy32kG1X8MBX8iHrSv89lRgwHzlKrAx9SQEsZB2Z75C/TROn8gUW5RK1XwTgi5/9eInOMS5M8bvVlZBVTCmcLZ+zhlfIS9vtsxYDgII56BchqOXl3EDRqF8hxC9ktt0B4/mSh9iWJCt21yVP2AuqdbXD0MbWD2N3kE2y2ty/W0hizPLRtwhrVP/wU585p7EEB1w3IASYVnA6fEBXebMMOJ8HemNXwfK9fZaw5V7kpahJX39NbMqq6Mvil5yiz0eylC204/FGfwqSK2hzeLokSIAAtacQ0mCD4Uye+qpw5BWHeEQjBZIkuRiPMeNz5N7e+IcOWNYm7y4P76Ipc+NEZNZ7S1EPe5Tafx8nbNUQgoTGgqs+Waa0qGdoiCMG9kEkMzXx7RS6Vvtefl4YBqWcvQFr+L5uazboPR+HcuHsvVx3nDqkpelRPlf0Lb8FXoDogu/cpTThsx8tLJWOhoalNMiQnqAgcal0PTCq5vpT9NGSsPHvQ/kCuAYkK2md+UE9SH1++t+PlwTTEidBCHd4Ax+jxuXwy9f6mcubcfvz1wLBDDyOTZQEJxWoWUYfiMplzGpy3rNvOocILFweyK8aNFKgu75GzxOxz/nb8L8FVm8GhI+7wabjXDE/dfWpo9BNN2YDUUzVZSjO33tTz9Z90G89/DNpdoOlsKenT319A01UKpUwsitLWjJx4EK4HLvlw6J6XPNdbyScJA5r6qRxpgJ6paiNi6T31ME3YHXdtoUVkaWJUvrLJpA87lhmL4Kz1/JSKhwldTNRl4JweM8QCPKh/WYbBQuwhlLA6mGGMBqckKB5luns3R+iw+9hHS6yjKI/NBj3/vLJU/mnsnVeqs2cxMdYnersV9jDaBoZAxS6EZcC0GL3djjKB4WwSzdKz9/D6EJeVx5OcdWUZ7Zoh4rjj+R5VTbvyN9yjQ1KtYKzCoIoln8XJCYNRAMDMv2jlRnyrz6AJM7fcNR1cTP1dFZF7Q3AZwSL3e3xdHPBeFpLlFFW+pZJQs+0agj67PjZkP5vwiiqsYMFIr5woEhT0TlrRY= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 202133c4-97d3-4c0e-a3e0-08dad95a8345 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 20:26:40.1353 (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: w19QouSlfb0hbzN8zGBO46VLZqeSCSocgJzBcle1ESyewFDj2rO+W3Ott9DsnAem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6966 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org What x86 calls "interrupt remapping" is one way to achieve secure MSI, make it clear this is talking about secure MSI, no matter how it is achieved. This matches the new driver facing API name of msi_device_has_secure_msi() No functional change. Signed-off-by: Jason Gunthorpe --- drivers/irqchip/irq-gic-v3-its.c | 4 ++-- include/linux/irqdomain.h | 4 ++-- kernel/irq/msi.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 973ede0197e36f..bb1aa5367ada6a 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_SECURE_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_SECURE_MSI; its_enable_quirks(its); diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index b04ce03d3bb69f..cc6238bfa9ed06 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -192,8 +192,8 @@ 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 secure MSI, see msi_device_has_secure_msi() */ + IRQ_DOMAIN_FLAG_SECURE_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 7a7d9f969001c7..18264bddf63b89 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1642,7 +1642,7 @@ bool msi_device_has_secure_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_SECURE_MSI) return true; return false; } From patchwork Thu Dec 8 20:26:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13068838 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 744C8C4332F for ; Thu, 8 Dec 2022 20:26:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229967AbiLHU0w (ORCPT ); Thu, 8 Dec 2022 15:26:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbiLHU0o (ORCPT ); Thu, 8 Dec 2022 15:26:44 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2071.outbound.protection.outlook.com [40.107.92.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D570B7E822; Thu, 8 Dec 2022 12:26:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WwCapo2zZwK4+wDcF2bFtucTFd3VEY4Zl8Ap/oLThAf2gF7oZ2kwqd76F+CN0/6kiuqQOZsGxh5+YcCLVHx2W1qnMAYzoBnIwL4XcJcOZwoIFHvaBDe5dDKXr9NIHQdsKi8wz5rhqTVXAMtpKzEjbF1qkX6rinkSJX5mTxED5QJZQbWuQB6m3q3YrZg+3mFtIG1vq91UpfauQRRjfcQ/bYdUJMZzY8z80PCtCUTIYQbP0wL88fXg0jYz8HyYtISgPok8bSIgE81MjQyRhwJJ+i1FP/uoYo49atA2DfRZOjO6J8cC3nzOC+PKKa4wDG/f3V5wZuP/6rnweQWF6+hh3w== 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=s17iSIHEWLvLcqni5gT0nA9zsp7aUjUx2va6NFHyS4A=; b=OfVm+Z2R8lfgvlztvrJflJ0e9OcnRipwDdxPF8hztZN8VcaRgW0nsa5jalleVhnpkwrbwTHbW059Xh9n2DDl2XdyuSsD+bR/45UJ6ZmRST31EUv8W/yBoH8QuCDATSedDkqH9CXB0LYq9euUFbZ9uMZLBbZeBrp+7rN20mn+2bSyQ0nqpXnbKrEApkvohh2kTyhM80Y7LsNh30RdHBXhJ08c98fUDDZefCbmlT8xpQdmAyVgx4Syn48Gmg6her/M8m8md/TY3zJxTGctvgdDCPpZan3J4MvkPyzKoPX9Xt9TNjYT0e2hRBo1nwu3wBFQIdjkzZYIgTKQoq8CD1L2Eg== 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=s17iSIHEWLvLcqni5gT0nA9zsp7aUjUx2va6NFHyS4A=; b=YR97Gcx0+kv8wydcd9dHSmijWq9GCRH//8MpEMWeovTLs4U9Kj1GaNIQ6AgGXPtSAj8lsW3aZ3X4yq4iz7KU32hd00PC96rhuVHBvWPKtD6miSG4yKiOTu5x7Z0m7YvsD1l2eT3eymqHJzGuUKu4S+biVJwuV/QTsVuOEamC5JeFhElD+vBUs000Hl/KmyLv7WaZ6F3WpU65AgtsC+3k6ALy2ucd+oXF7Vux3ZpCxe9O3oEPBO4piIbOoOOm5bSBnvJKPGRA+9IcQv9+LRo9fRg9auMFZsM2aN7QD7rfXCX8Ei9q/k231eh2oIBx4MqiRDBbG/VrgUv2mtt2HncD2w== 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 SJ0PR12MB6966.namprd12.prod.outlook.com (2603:10b6:a03:449::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 20:26:41 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%7]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 20:26:41 +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 , Kevin Tian , 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 , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd 7/9] iommu/x86: Replace IOMMU_CAP_INTR_REMAP with IRQ_DOMAIN_FLAG_SECURE_MSI Date: Thu, 8 Dec 2022 16:26:34 -0400 Message-Id: <7-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: BL1PR13CA0221.namprd13.prod.outlook.com (2603:10b6:208:2bf::16) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SJ0PR12MB6966:EE_ X-MS-Office365-Filtering-Correlation-Id: 8cb709ed-7f45-41a2-0fd6-08dad95a8257 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pP2Dtcfsq8+mx/bGzWG2iL7L1iYAtbsUHReh2xjfIWDvZNsfoVqCyFt3HYkUfjUDQBN9kBsvoOo/nkHFzmb5LRZJsLciZI4tdgHngo7ov8Ez83N5gVO5dY7DZi/1ddWr9K+SLXj/GoSuXG0P4SU3PsFIkq4hFLzJyWsQVeGVsQIYqF++W68PBEUKll+UAYweFXLdqIn9QdiIBgjoAUEZ4CBUqghft/fOYLbCZatukd+eRMDD/EzDWW2YU6dURYFTLpeUaEvM2l5wOZavtaRfMZbY/IUcxc56mHa3NqBVvwrn+3/+KXo56e4dLQGmHCRzlCN6wYffkrEkj0cDr0XMoReSzuh/UYgD5OA+Dmr2xkpjVbG4+u9BTMqRuYYxPoq3pbOAc5PlpXyNVDToKA72Nc8goh7JSBKLR/pEdddr9Dk+4YXkujOTgAD1OTahwbKnxeyKb1KrJoMCeENvQlGzLj5fBSK5fvOpMrWsMszHyM0upzeHKfxSh3W6v1wbWxIpooK+RVdIp3LbuAym7cVN6+hFP8ynpQuEtsHLZS07/avJ2Z40ik+bo3Npzau+30urLgDn4/ITzacz5tl+d9MtZTqxsJmLu/UE65/wS9IKn3DHiisGnbG2IKx5J0PxoNFMV+dl7W5wmRBOJzl1XlBJp+HjXUXYmnxo6r9zHX2Qn/Z25+v7HKr+SRMIMOO13lpI0Z05bwz5WzzcH3QUu+2Jag== 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)(39860400002)(376002)(346002)(366004)(136003)(451199015)(38100700002)(36756003)(86362001)(5660300002)(921005)(41300700001)(4326008)(2906002)(8936002)(66556008)(7416002)(83380400001)(66946007)(316002)(66476007)(54906003)(6486002)(110136005)(2616005)(478600001)(8676002)(186003)(6506007)(6666004)(26005)(6512007)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7V0FDcNNKPUR8uC4Iv53n2+IIln+kLFafCMKdqO2HUfIcyXqauolc2Pl+xDWjM1d/8JvjBpH2Ft+VpNPqdrGMhujQ8FdKlwS1n5FCwumMjHKnMPfdtN5p99rrzQNAqNnSlKrs1jtD4jDBilDsG+HNW0J1ZtVNYHLBZwAtBGCHP1//73zGjsw6ygwnrYvW9FEL5iUEY76DjmFkoeR/Hi3O/Iiy6VfrbY3qwGjSwpvV2PVfIjxYSlOWz9Y7+SK6bwUSHhSncEhGTBmVsQ8xFmqJjXJJwJcE6vRFUs6GeflUMEjX/aOjVoenmk0vG5XMfMikk2eYfSgejHzSWe/FmFp+qZlhfOQoVufPm/QDtnS1AuvSwYjgXEizH5lxMMtkeMOrVeiBMR9Q6OvUX+jfqzqoP4rctg8n6A/TGWKTitIte0Q0//njZgURfFkHThjgWF6ZE46yE+rjO62eE6nD/bBiW4f4nSIcp9N7tDeXgQayBbcNOL4kLVdU77fz74D42gooCfkCW0Yay1Fw16bc6E78g9tPvxgC7kdBmqTCPLh2X62ATVglpvn8/fzJHGObQHUxInvxlRJgoun/vZizSMNR7Xi1NN+kk3thWOash9s475f8fXha//2Du1uyDbXc5zGKn0Rqi+Gw0XKuwKAr/hNjab+IIhgxJ393kf4PBNAgQBPnpzVsXxhf0vIo26CYo+xnAHJBIUTaU6lR5RzNdHXtiWpQ8YJBU65vfjA5uy+i+b9l5vcSqGl3rs6MyLNZ6cnflgL5Xd5kDjdhzcGDPuXYp9CW7lWdjXcFm2GfkfgWWSdDf48f/Dt3ULr88MJeZBgLK0FfBJNAP9sUMJWT6zh+En4X3TSj5JAz4yTBpUgKA1ikskBooJ3x53j1T09qKLJLoXgQZj78KJ8VT4DpftiwvLLnIjS1pIQPWbDycC2Q2kSrhevM/9fHgjMnO2E3JCTayKVKKkUJy3UMUPdNoWwK+jEGKhhYduJM0W7/ZfKrTHVsFLPIwWgYfJEgP+IKdUiPmelGIqnREnKpOqSZBFLU/6tcWY2W4zpbe+sNRwB647WtCNgUfhWki9ikSedUYSMmMdsOYOdVHmrABjKUxkuor4J0AzUvjeADN1wJdEtQofi+W1oWUF7c+iL/pVTuRa6SqfgLKJFTc+Mm4du30VDss21kq+8Ec6iAHOAWjfUUFb1X4kCnTTog/6qKec2NyawVoscsneUa+Nd29xo56OZ+nnzzXh/+qiB01N+7LOBC+uPH2DUO/2NnZ7edHnyzqnsVUEVw+CNs4Z8owQhXO+m3MVWXhcVE1kdA3x7EIV6Bq7JOG+6pguwsCOqT6EL2Al2UpPcrHScciw/FHo+LayZkMWDm/nHQeOai4NS/mFe2cg/SES3Skd2ZFdnUO5VlvgAme5x6lVYqggDVvEzbFhEFVcuLIrAAsruwDgloy+84nIx3Kd0uxfZNVss13W33ZmcADNxqYbKKHoIQaKX8dHWKnnGx/8t5ZxfW/vAqQCoQCnmgGz584bP7MSBok9WQIYmvW9f08XstuZsgbH6YSPmcQorof+I/nyqjd8gcXE7Jiay1JLJxPuutcuje8T8WEBV X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8cb709ed-7f45-41a2-0fd6-08dad95a8257 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 20:26:38.5717 (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: 9Wxvwq4YKn2p4HCZgsL95RPUDyOOqiaRq37zkN/LG7SzvxHllinvCQW/g/v338sY X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6966 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 secure MSI property. Due to how interrupt domains work, setting IRQ_DOMAIN_FLAG_SECURE_MSI on the parent IR domain will cause all struct devices attached to it to return true from msi_device_has_secure_msi(). This replaces the IOMMU_CAP_INTR_REMAP flag as all places using IOMMU_CAP_INTR_REMAP also call msi_device_has_secure_msi() Set the flag and delete the cap. Signed-off-by: Jason Gunthorpe --- 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 8d37d9087fab28..a8ddcf42dd15c1 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -2272,8 +2272,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: @@ -3672,7 +3670,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_SECURE_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 ebe44a07c4b00e..8037a599ade0d6 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4453,8 +4453,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 a723f53ba472f9..0972f47e6ec166 100644 --- a/drivers/iommu/intel/irq_remapping.c +++ b/drivers/iommu/intel/irq_remapping.c @@ -576,7 +576,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_SECURE_MSI; if (cap_caching_mode(iommu->cap)) iommu->ir_domain->msi_parent_ops = &virt_dmar_msi_parent_ops; From patchwork Thu Dec 8 20:26:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13068841 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 78325C4332F for ; Thu, 8 Dec 2022 20:27:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229969AbiLHU05 (ORCPT ); Thu, 8 Dec 2022 15:26:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbiLHU0r (ORCPT ); Thu, 8 Dec 2022 15:26:47 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2071.outbound.protection.outlook.com [40.107.92.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6190384B50; Thu, 8 Dec 2022 12:26:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bPY/c0bjiiTO2dosHOY8ymvjDmUk6Rgf1abI96QarTqkY7N0pOvS0QObRE3Cj1geu9U8L5TNLb/oNjATRKyXePvjMfFI7UJlLry7IPf59jaMdDqnEmtAq2nIajynCevHsGRfumO6j4NVlDHwNHGtyh/ufVc8soVS3uU/kLIN3sURh3k0ntYaDPoAHDEBfGzuyzH1CHvoceHitBR94Tz2hFsNFh1pxiedfLLxDaaT6eqR5QAvWx4krqDKHxZfIo/8nX+pZ85ze+mj5y+JdLEl1HkttdiTvbgBhr2Auli2sMryYVMNxMe/4dfiNy0UQ+9bay9UyF+XGq2FA8nRtYs8SA== 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=89goVtnC6sgoworYI8ijFJgyNMrqqj1BeZ5V+Cirw+g=; b=GHK4/MmFPlsuAYTBgIbQQ4T8TS9xAecIfNzBHuAgfVUNJJDlvSe9yqUm0gP9vlJ39MKqJmNFuV5wRnWYnza11eUesjYJn0zFG+xOBbATEFyqeVdLFQagqvBjyrRN/XpaEr/nkzAaAmHwj+p2pKLxOjHzrrwBSY+21ft1zPJKatkwrV0DOfKYreYnaeseWc14Wg49S4i77vovqkyo9mJo22fe0PD2qi1QLMSZsI9CEDsl3TMhsSXX1i/pH0fTDWRuRjTDZqznyjJUuhNBOEnLrv+qDFBxbssVr+sqakiGTDb55vgvOu1TMAwfCdpSwb9nr3ARqppXlwDTC18Jr5Q7uw== 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=89goVtnC6sgoworYI8ijFJgyNMrqqj1BeZ5V+Cirw+g=; b=kqsnHW692UwhZDp+z7dNchchjz4A/IWKVSVsyj1wqOyRPruR4njB4E9vDyZ6tQQf8GUiIsCQ6nprBDicFy5PMCkwZeU26631sOmfxuht43jHRxuLM+0ePcevb4BnxK2g3CpVGHQEZk4KwVE+9Bsqnp57Uhd0Z7hUL3W/c+R4pT9Fn+Pr2Ii7JYybVpuSw4oi80jn1hurwwAEE/kIXXEqFHZEf/+52Xqk7zVPDryVS+POGo/ux8Sq9ZIhRwmSjXL9tXCY+YdkVsCUOLWvi7Djn2PHPtK/GIsxs0+8vCw5ONt8lcFxO3RCEvPicc1yrHjmhXyIwzf4L+KPjg97qnVCwQ== 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 SJ0PR12MB6966.namprd12.prod.outlook.com (2603:10b6:a03:449::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 20:26:43 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%7]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 20:26:43 +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 , Kevin Tian , 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 , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd 8/9] irq/s390: Add arch_is_secure_msi() for s390 Date: Thu, 8 Dec 2022 16:26:35 -0400 Message-Id: <8-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: BL1PR13CA0232.namprd13.prod.outlook.com (2603:10b6:208:2bf::27) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SJ0PR12MB6966:EE_ X-MS-Office365-Filtering-Correlation-Id: 39e8b42c-1c62-4168-92e2-08dad95a829e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sXS37TGQDx8YhaSmxS1AUmY0OOgyS323uohvZ8+DMA6BBuOo9Uosw274+Z8UUSnpJ7Ky0KDPzlE6LtM1aJGDS8QQmq7BxfrjawJET1f6bjDblWbtZ7hpPTwrhpZCzwBjitRDge10Laq8k0ziweqySmJbOeEf2qf1NLsUah8E8VfWqcvEVirmsajWvOiuBW+2kmRN2Jyzmd4Jz1EHuogRV07+5dm2++b33SYp2HTWUZyENpztgDHRPS3vBcQESP8iRxKEr3DHHrqaZ8B6ICw2w9XSmIRCS11cPqW23euYw43c8q5ji0vA4EbrOLSAAF4zr+XhblRnUFGW+tsv9O3s69i1fMu4ECmjbXN4hbPPW5gGvuqBLR3yMjkC0YHt9mWojF/Lww5tie0+Fg6UetSXSaP8xxM1E/Cfw+Hy5Roo2jdMv6pi9HFSgZe3H5tZLIOAIZbt7d0Wm/7KpMYrM3mcV3VP3JRoo17Lk5dADOZyxt1Xy+CPNlKHSYztmf7r6pccGOpDmfVE3o9b+qmMLLHOqZ7gU8YRwquizTZvHotOTQhUudIctzWAXLswcTKFlJuVWHiEt98dWyMvLaWVzWldpAvnTJxqOX/uhWDWTW37PUKHI3hbYKPJATa0BuF8akm2hKUOOEs82eJyUW/xYTPSeEfo7hYcfSar3ndx3++eCzQGwH5PlC6odhLcRR4eE32o45732wr0J/m6UMsn/yBJ+Q== 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)(39860400002)(376002)(346002)(366004)(136003)(451199015)(38100700002)(36756003)(86362001)(5660300002)(921005)(41300700001)(4326008)(2906002)(8936002)(66556008)(7416002)(83380400001)(66946007)(316002)(66476007)(54906003)(6486002)(110136005)(2616005)(478600001)(8676002)(186003)(6506007)(6666004)(26005)(6512007)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a2ulFypLBP1XPITmOqda/RRhh/uLqthgIViMnOKCmTdPtEV+2a14kOh5BMeZ5JUEU0pOcM8vo/RrmW87zr3rtdn94JWEYtXPDZJXJ2ctJCHS/mmIWqmgKzHBOQ9dQqNGBfA0SdWIr91U07nhdOpWaDQrckifol8L/zf0ycg5CJKXWoiKlxPHdyQ+KhcG73X412mHnNZzgf0CgQ18LjlOdcirb2sL9FEsi/jW0utNXHhju/pRFT9aSq8Ope5uxDHNoLMG09V11lKRTddbMFI7eF/OK4D4SlTsUe/T/2BGz9qyxFMgF8bldDYDJrk+bWNqZcv8IM8SYYs8ZNMAhAa7I9bESwQ0rwtCZ5pZNgPkb3cONINu8Eqt3p0NIWxn3l74OT4Ed0mOOlhDkfzSrgyN1PuhUbrN+6+fq2VPqECRaUVIXWRHVIzLIXRCiV/xuHI2TnylEt87410V1wjUEijLZGBhh3nR+yz9iyswNMUx/h9pisTUttxyXMMKEKk0F8la0IvQqmEjMT/Y4eo7KVS4U4VQkt7uKUrSUCxwxRe15vzzQ+eBMKuUvqyuwYiXfmjiEhioGuh/nDp21FWdJgw2m1FCzQ9M3gbwJ0GCe3/m5JBHNdCLrQBmz8s2759yHDs2ktKVz1BYBakkELHBENCb9zpz54oov7AVX2LESa1s2Y9jhfjF6xELpfe2rAAs9YckeLhAUzFyYoKAvK+ZpeQXB5wMM383th58MInh45Nw3tEIqSyHME8yE/oVD1P1e6VFOo06O6TJFzB08RC6FVAmmVreRANWsUZwXr3HaVvjZOOanA5ILiNUfEzqj+z8Czb9qgyXEfScnBfyX6vkICCaJ9z5Xy2h2smzqvrPzuIbwvJk1mnwlicBqwYbAdiqSGUpElUqZKPDyuWnoOcrOawUQA0h1xVwVOPqFSAJfQk8droYdWAUdBEBJT54C86BRgkFBBiQJgi/RUPt010J2GbiXG8ACG9/fLYj8Iz2j1EtRmaFXF1RicFSaAKuypgXG8SHhJuHxxUnnHCJRhxN0u50zZ2YumDFjgLjwj7HSB+Ag0XYlt1rSWyNDd7TSnSrTXRNg5gRyBdGEnYtCC4PxTZd2rj8HADdu78qXiUFZ/DE6orltOlHPlpnrqJnoUjs6SlfwuUuFXz/1D5B8iggidxQuCLSl08u3gjhj4VUgmvFt4jqYV0gu27gN8b76UonbJiVqq6VmtPaKbavZNWtDkTLRg8ZqSiJRXBaUu127q93zt1cjhfkC8i3eac7FDpZxOT2Ho+qXtBuG4mGUHjG41Vqi8WyvDNlH9de3gH2q+DByfnGDQ6U0s1KzLT8eYVrIUx8Ux4Q8SC3ssUO5RgFaQCkgy/DK/vQXft2x+h/dgNjtrTwrE+J6THjfYN8tlbQP9rX2be3C50lsD1mK17jOmanq+HzTseBL3p0XJSigwDca24nLugpUIgrbSNWInxFRLQPoEiN19SLAQt2T1PMBPGwmg9kCSn1LPqs5xe/DYTtSUKLTTmwqaiAEaQsaXL2esdGMkweT+CqNz5D8ggXi8aKpQfFb0LM52FD5/eju+h5x8Uu6P40DOx5E1c9N8QIvrh7 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 39e8b42c-1c62-4168-92e2-08dad95a829e X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 20:26:39.0716 (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: cvofKnY7HitRyS/p+8Wqo7VppZIDxh5d/oiTmUj7XQ85dPwFFd3IlbdS0s2w3QBl X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6966 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_SECURE_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 irq_device_has_secure_msi() to return true. I do not know if S390 meets the definition of "Secure MSI" if someone can explain how it works I will update the comment in the arch/msi.h to explain it. Please consider updating S390 to use the modern IRQ infrastructure. Remove IOMMU_CAP_INTR_REMAP from the s390 iommu driver. Cc: Matthew Rosato Cc: Christian Borntraeger Cc: Eric Farman Signed-off-by: Jason Gunthorpe --- arch/s390/include/asm/msi.h | 12 ++++++++++++ drivers/iommu/s390-iommu.c | 2 -- include/linux/msi.h | 6 +++++- kernel/irq/msi.c | 2 +- 4 files changed, 18 insertions(+), 4 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..e3522bde3e9c90 --- /dev/null +++ b/arch/s390/include/asm/msi.h @@ -0,0 +1,12 @@ +/* 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_SECURE_MSI + */ +#define arch_is_secure_msi() true + +#endif diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c index 3c071782f6f16d..c80f4728c0f307 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -44,8 +44,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 75c2c4e71fc34c..8efbf34a86f247 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_secure_msi +#define arch_is_secure_msi() false +#endif + /** * msi_msg - Representation of a MSI message * @address_lo: Low 32 bits of msi message address @@ -660,7 +664,7 @@ static inline bool msi_device_has_secure_msi(struct device *dev) * inherently secure by our definition. As nobody seems to needs this be * conservative and return false anyhow. */ - return false; + return arch_is_secure_msi(); } #endif /* CONFIG_GENERIC_MSI_IRQ */ diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index 18264bddf63b89..aba4f12df190b7 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1644,6 +1644,6 @@ bool msi_device_has_secure_msi(struct device *dev) for (; domain; domain = domain->parent) if (domain->flags & IRQ_DOMAIN_FLAG_SECURE_MSI) return true; - return false; + return arch_is_secure_msi(); } EXPORT_SYMBOL_GPL(msi_device_has_secure_msi); From patchwork Thu Dec 8 20:26:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13068836 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 4281BC001B2 for ; Thu, 8 Dec 2022 20:26:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229954AbiLHU0s (ORCPT ); Thu, 8 Dec 2022 15:26:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229877AbiLHU0n (ORCPT ); Thu, 8 Dec 2022 15:26:43 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2071.outbound.protection.outlook.com [40.107.92.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7267A7E822; Thu, 8 Dec 2022 12:26:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GDy7sYIGdHwQIqaWppp+I6+rjhgIkkWj3fpsTes3TV41/O82ZutdVKpOiQD8NRVnz0Pk6Vm8D0ae7HY1QzdDpgply7KU8ZMMMjGjSZINZlPSS5nOgUcPj7xu1XzGZbIJedbboRMoA14ViFsKrBJ6V9d0UhJKr71OpDu/v+9MUpY0TWHlwMXsVZQMMYuVT7mKxGuA4obyiebiugTibpNBRiDpk84UwcsSX+ynDJ95qJBUeGw62fR4asqeX+Q5n31v1bkTz9JjqNghQXcRRAABkNWYAAByAdG1oblVTYmA25NF8Ckdrv9P+un3P/iZcd1vY3pBGiMr6IKO0O9O08+Mcg== 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=xXqmnuSsu7GZSFVKHyVfR3w93jiBnlllVvlYTagL80g=; b=NpiyUfiz6/kPsO/b7SnOYYr2/vqjqGI+x6NrdEpDuW5gmQY2F/aKIxVddDwVoG5z7Wogj57RrOKA3m49rSj0pUiS6HfXFf6t3lSClzp+KFx9jEczFyxm1Kl4+cN7N7hG0oFX+0sYNXZqDYsQlzZ9TZHM4f6FFyb6VlEfUeyGVzx9XVkRJZjuvcJ0dktXKRWu4ybqX/skCZMcxbqPTY58gOKRkaQbKhySdR7xdMeC7xDFcP/RKvEWrQpelLsQU0YTPXQNwvYI4VoZ6HAbHLYcF8BMj4sQW6uhb1weIF/HcoIQeJ78QBa1NkHYlhAjnyy+tPE1m4yDELa40t8Gpbdzlg== 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=xXqmnuSsu7GZSFVKHyVfR3w93jiBnlllVvlYTagL80g=; b=ddsAiQ5eIO/3nttaXy3ZQhsiGJcK9zuYYIHuXzTDemCV3ihqWogqYQIjdN0gYo0vICPmxTWmCxpHvB2zTuNpjEc0cRF/I9lgK7zwEp/6Be4fz/gPBCvfc63Jr0K7L67WG+lXpjyawCXT+hwSM22Vz6hVhkqPnjQa1PHIJvNWOKQqK6pCadKDSphvSHnv2/IljQHbxGTXBP0VglAVPLCheoY5fDgXPElh9B9x6krj78NPE7h8nHIZvMZ59rqLna+Z7M1FRet1mdU133ROe7YQ5J0MKbVQnTJ6bPYyX9KyAlridPgL9RIiMXrzN0v/kAWlVJ+L14iRvyzMmBhVpZPKaw== 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 SJ0PR12MB6966.namprd12.prod.outlook.com (2603:10b6:a03:449::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 20:26:39 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%7]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 20:26:39 +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 , Kevin Tian , 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 , Marc Zyngier , Matthew Rosato , Tomasz Nowicki , Will Deacon Subject: [PATCH iommufd 9/9] iommu: Remove IOMMU_CAP_INTR_REMAP Date: Thu, 8 Dec 2022 16:26:36 -0400 Message-Id: <9-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> In-Reply-To: <0-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR17CA0007.namprd17.prod.outlook.com (2603:10b6:208:15e::20) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SJ0PR12MB6966:EE_ X-MS-Office365-Filtering-Correlation-Id: aa912f98-3aa6-4226-c610-08dad95a81fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tDTfeM9/AWs9EANz1jP4nTt8FkRCXpkD8FmckaaSNO1OVY2uOdWuxg+EztrOgZgTWt1sIEVS/bqkhaVGaTIzhtNxks9AIxFloEXU33cpyuhFapJ4JzKjLCvajBtBHxReDPZVK8ohh/JcdeE+Q2vNgY+ia45d9a03fllaqM8RieiFUhcXasFWwsDFG7qQagN+vtc0BYnDt7Osp74naxlLFma10R/Ipg8xC60gSUEeBaC7VxzsH6YZ3kOsN16N2jFMKTO3zABImeIjvBjjPRh3nwobGSsYBLaAZJH4e97C46LMfaDHo3K8gpRJJ5S4tG/KZaXBueC8vuevhEUAu/8RWwY/ISwHslDxAOS2KrwRneaFrFwf8UJAwfS5aFLsV3Y9qByZGoTIN9Xe6Js6lTn8fA7NtlQsQx3LElCcSmB6RqLwqhXQ+YQs28f7vuWSQhZ/QseReNXnKSaxdIXMFhQsf4ZduaL2BkxjUo5t35/cN1HFspSFo7i8mnhJGyYy7mcGt0uikfKFnkOICTIP9AFCcCd0w/RnALn9g2xTKhZCLQ71nKGldkzRz9DhdjPupZ1FWyxb7l2BW07M9e5JFQ/RkURjlYZNyZDt/Gnr/6WzCLnRO9L6CT1us6oywAMZKQcfh5RxKkpEhEU2oXXzMeAKKS5i0+DZeiINtcGIaO80KIXII9bH7n1YuVzTEJRfXBtxVtlNmDNll5iUB1E2qqGf5A== 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)(39860400002)(376002)(346002)(366004)(136003)(451199015)(38100700002)(36756003)(86362001)(5660300002)(921005)(41300700001)(4326008)(2906002)(8936002)(66556008)(7416002)(83380400001)(66946007)(316002)(66476007)(54906003)(6486002)(110136005)(2616005)(478600001)(8676002)(186003)(6506007)(6666004)(26005)(6512007)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IuZK2KKybgqkhWDXpp0FuuLOljN5m6l/abFyICJQp4KFxI2qiPtelIoYrTK2tQNLfYVIXQ+zG0StxMIn0T7eWxu4LJJBzJnCBasLGJBZeiaxLMk0+8dsYhfwKlXPEOH9yW3jyXWEDPXWvLyF0MvsKbjxzjpIYnmW3PtPXlq5gImAEPNtzfcKAyqsVx1KsF6nJHlbkEN7cEd5rlNRvYR+mpxvVgl3pidr/uKH9+Ekh5Cmdkz6MUMT9m4OBe+Bn+RdFKhX0TicX2BC7Qr8FRBnUbX+okLoPIf0sFg10sY1RrqlJ6v4QBq5UZjEiMBcaaWhwrK2P/28aOp9iFOicvnjU0BPf47PTNkDWkJR5ESekLFfmmc5eyoubuNp7hvebtI4LnSEKOj5GpS1wSlGceUl2u2N4cz1JepMNT5jHuyjg4AWH+Zh4avaO/F2lVhRk+Obkh0pw4ZYH1rEeNy8DYV+Hz91lf4+bQagRk57/q/J8TTLZEHqRGXh8zG4WlLMENADpZ+ngcP82Axf2SA5yAcckxQ+bzUGPaMlLVEOGFmuWcfpYlW52kHcpCs0hjvenoIb3ZZB+jvjM3z1qBDCfib/Xb0x0lKK55UDq5+b4i5i4AVmwxgDbNB07zagBg0ixhIxqWmePqKwN3Uye4WMpL6L709Kl5FqtXrEI1mvbyIEwEdes+Tg+H+MOZtLA+Rpij2VGjVTHhYyZB2S/7A0HD4MlBGR70Px6XnLI8ZCQ0q7l8kvVFsxjDMlWhPYL9MFEX7+QFG5tM5UL4hyriIEZpywYCsokLjlXff3ERb3EBwsg4mqHWsZo1tsMeEFDqrN1V4ZDF19HycPBv19tHZTTfn9qddI8aud0PHVyOwqPcAf0I+TaAIBnkY/CvqG7P2zwF7/B1YX0NDbVF0rBRl9McrKSgnyfc1bwn4xQzdh4GuT8HdWez0IgiV6cqGeldZRmeYaHrYgSW/C6udMExLxxtE8zJTv9V5kkNOoaLhAzqtZw3DOLB/0nfD4T1o9vUXnwcBF6KWcoRYFCfYAnbfm90qKclcGQKe+bijrEg8Ff7ld+YMacjBVST/WEvgYQ0ayGqPF+ysbRXtkOM5lPWbJyYEHBao2O6bhn5/1HjsMYb7HO6pcJutvH+bSwOlreTNj5gUR/8AX4PJG9KFPklTJDcaEeFQDLqNnX1XuHne1qqabjFjFIcMp6/LgYxAb7z8K1cIPV85w6xZkEHa0FrgsytQ0I+sAx6hJUdG6GegTrHhKEO7Cj2/IX7DxIw2DiOVqecli7HWh/bC2KUdJQnJ7+jtjLvMe7SgRLWXM/rogPxCkdWoe7zZTNFxtjmAQTfzPfKLYfyPWRPrbqlXiR6dGDIN4JCNf879B+B873epv7WA4CilQG8TQ8J77jVTLpyiPYHqvtCU5tSY2stuvKw0f/w4D6SqcZOuDfiZ3GYvoE0owiakx/SWe2BKGBSnmPd3GC4lQsIvNnPfRPBz6nTNKrSbcok1rnjFVf3P2tAaBGjNy5j2V+F0RvtRoOwKX3tVTgjEcdlC7PDanVinOb9ac6/q7/nstmz/7lmoXkDTbVH83Hx/rNFxpyDQZ7wKXYM9uQieK X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: aa912f98-3aa6-4226-c610-08dad95a81fc X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 20:26:38.0269 (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: 1ST/Okfb0rBcYsf27SVeQgb5NA8+rS1MZufAiCkamVaggInVVtd/5yUyBB3/s+TQ X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6966 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org No iommu driver implements this any more, get rid of it. Signed-off-by: Jason Gunthorpe --- drivers/iommu/iommufd/device.c | 3 +-- drivers/vfio/vfio_iommu_type1.c | 4 +--- include/linux/iommu.h | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c index 13ad737d50b18c..76a658bf9baa9c 100644 --- a/drivers/iommu/iommufd/device.c +++ b/drivers/iommu/iommufd/device.c @@ -169,8 +169,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) && - !msi_device_has_secure_msi(idev->dev)) { + if (!msi_device_has_secure_msi(idev->dev)) { if (!allow_unsafe_interrupts) return -EPERM; diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index a954b58d606766..380297334842cf 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -2164,9 +2164,7 @@ static int vfio_iommu_device_secure_msi(struct device *dev, void *data) { bool *secure_msi = data; - if (msi_device_has_secure_msi(dev)) - return 0; - *secure_msi &= device_iommu_capable(dev, IOMMU_CAP_INTR_REMAP); + *secure_msi &= msi_device_has_secure_msi(dev); return 0; } diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 1690c334e51631..0075b110d17998 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 */