Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp758696pxj; Wed, 2 Jun 2021 10:38:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJza4bwIpON6R31lftilqdbyCP2D5cGkYWDFZT+W+9FbK8S8jxR+PVKHSKFq0iY0f3iuFfMo X-Received: by 2002:a50:8751:: with SMTP id 17mr30484542edv.340.1622655512558; Wed, 02 Jun 2021 10:38:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1622655512; cv=pass; d=google.com; s=arc-20160816; b=p+pm1ZeNuWzI9QfrRPmrvMnXCJg81LiHU9yHbnA+p0Zb2qB5K7e/MYP7xln6PY3KQo Xv0AWApxTLPO/rG/Dg3Et1bSqCYpaVdt1WIhKvV5kCmGXenInhFYdDhEejVtNYsd9Eme U+8VYZ9Ecm0QsDWAZDKFZGP9L8xx2umNcjgFMQ7cGMnmU1JUc0N2IqibIBEPrl7LZq/+ BUhu+teYC1d0VDFvoUfi6IsEeZD9nvKnrCPZONWGHkS4QBCWMGysdwWg8i+f8wJgSKiV S1B1NqgSjQRiaDqDriN6PCJC+rWRW+Bmql93QqbVPY4OEzkwzC0J2B8RSzqXM2s5awPU f+tw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7sAAQZbsxkyuTeOSdh8MO2naxa0/ImDVyUDbW7qlVAo=; b=qPZUgVS0lyPO5jJwukGL3Gg34Pg4MsP45tN2jrqyWKBrhb4yhfYwRjuZDnJEpd/SvD HQvXtrebvBwoNVxGF6CXSL7iouj5Z+sHU+FGVxs1Fs93T8P1Pt46a5gASrtSkv/mRjLg Qok2t5FKcuPJxY6AG4s9E0BHRpHg5PS0UdDfN1AJLquc0zdwDx2Bm2mzyrrYN3w0f3mB hfxYTjNKKXDdkdhV5PdeFsg8Cb301WIv3vJXMzEFqEHJJlVRsX+Mf62nab9tqmcKmWJU tNOO13bFxl+FBmLKIcJKW/ZAt/6yF9NDO/jZCFU1BR7xGwoFD3T6jTeGxPUMqfvJ6v0E 6RPA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=ojsgfsqy; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si425919edc.193.2021.06.02.10.38.09; Wed, 02 Jun 2021 10:38:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=ojsgfsqy; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230227AbhFBRg6 (ORCPT + 99 others); Wed, 2 Jun 2021 13:36:58 -0400 Received: from mail-dm3nam07on2045.outbound.protection.outlook.com ([40.107.95.45]:42849 "EHLO NAM02-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229604AbhFBRg4 (ORCPT ); Wed, 2 Jun 2021 13:36:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hdYlwEqEdZy3eptjiw9zK2h6MHOVeBsDojdPsT8Ic89pab/UFC9INH08kwtKvkTLwutEsTkNAKXXybyGIGm5M3jMlULRrjOFmpEV3lbes+uvFGbHsjqF6+yxOyw1s7120YidnwSdHBi/8AxHV5vJkSa9TJs9U6m33IkBCEhkJHV/FtfwbAS77aUaYhCn7U4qqgu7urBH2AWOAEUC6tXx/j8gdGcd+thq4TvlOiIuMZDlvjxnROYrcPz4UdFh7n/of22qFwGzUTstDixrQ/wniqfegMzqwzc1j+fdOVmHLZGQVrtYEdTD+iFFJ7rwUZb2qo0oWfAWs5jRDOdLwmZNCQ== 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-SenderADCheck; bh=7sAAQZbsxkyuTeOSdh8MO2naxa0/ImDVyUDbW7qlVAo=; b=RuVO5Vjoj6UqswwrBDd9wbxSBPbd4UCp/ygg9vnOmF3/v7L5XvfIbi3TG/6iSaJZob8WXcdYo+ImfUbSFfWwYeGzxSEFjjUNoOsV6HfDZraA5OW91T18n7LGAoICLWX7LQTINHAdBXTjz3/fmfCBeEKuBqjDFxl1csdQC2DdAJ48LvaXa8dqjF5e4qwI5Y3aNlw3Rjl7YPCMcECgfBpRqwP6SQuSK+bWzizItMVOo+OT6hibe4oCYlHeTkf2YO1cVnPuqst4igyXH7YrIPOqfl35DYou0RvcWGS5j7pYsuJkrt2hGwOsiF324s4hLQY78noS6LCVFhWAZpWBHkrM5w== 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=7sAAQZbsxkyuTeOSdh8MO2naxa0/ImDVyUDbW7qlVAo=; b=ojsgfsqyESWZmibImn+3IpF9dM4dsNXgdSDzV2dt6xzMSIIRBgEwSzpsnu2e+nIaFjjtCsyH1vyiG+XnCllOESzwgR3ENgDuYYDrwkCWlIM5xPyhsGwSCbGzBYdYjaY06VKx7eGvkONVEUjgJlpeH9l4Xd1cv9yfuvEyCCyvQUd8cJfFFJkd8XEq3JZWTcYMUkxctQqU04rOYEhI6u3B0gnLzexz08II2RQQ0eLn9tULf/kP3ZxNktV+thIl5/1MURYvqGXxa71E2WMz0vXQ9sw/LKfegwN3Xe26QHUYPvApN+W77wBNyQkwbB/EsSsjk/q7sFm53hlabiNkzsirtQ== Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=nvidia.com; Received: from BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::22) by BL1PR12MB5143.namprd12.prod.outlook.com (2603:10b6:208:31b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.21; Wed, 2 Jun 2021 17:35:12 +0000 Received: from BL0PR12MB5506.namprd12.prod.outlook.com ([fe80::3d51:a3b9:8611:684e]) by BL0PR12MB5506.namprd12.prod.outlook.com ([fe80::3d51:a3b9:8611:684e%6]) with mapi id 15.20.4195.020; Wed, 2 Jun 2021 17:35:12 +0000 Date: Wed, 2 Jun 2021 14:35:10 -0300 From: Jason Gunthorpe To: Alex Williamson Cc: "Tian, Kevin" , Jean-Philippe Brucker , "Jiang, Dave" , "Raj, Ashok" , "kvm@vger.kernel.org" , Jonathan Corbet , Robin Murphy , LKML , "iommu@lists.linux-foundation.org" , David Gibson , Kirti Wankhede , David Woodhouse , Jason Wang Subject: Re: [RFC] /dev/ioasid uAPI proposal Message-ID: <20210602173510.GE1002214@nvidia.com> References: <20210528200311.GP1002214@nvidia.com> <20210601162225.259923bc.alex.williamson@redhat.com> <20210602160140.GV1002214@nvidia.com> <20210602111117.026d4a26.alex.williamson@redhat.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210602111117.026d4a26.alex.williamson@redhat.com> X-Originating-IP: [47.55.113.94] X-ClientProxiedBy: MN2PR19CA0047.namprd19.prod.outlook.com (2603:10b6:208:19b::24) To BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (47.55.113.94) by MN2PR19CA0047.namprd19.prod.outlook.com (2603:10b6:208:19b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.21 via Frontend Transport; Wed, 2 Jun 2021 17:35:12 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1loUlq-000IeH-ND; Wed, 02 Jun 2021 14:35:10 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76f3de1d-c168-45b1-8c6e-08d925ecc68a X-MS-TrafficTypeDiagnostic: BL1PR12MB5143: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nwP+NFOdVAUqjE9GYDz/XUQYoN/i/VIRrFwDXb8Y01f1lI5xu1xhgItzEYSKTQGiU7lfN8g2Ku6Soasg9DpYMSHXBsUJX//p+M12G2kvuyW4+PyRthtGhEEF+NzZnEIw59pXiGSRRci/Fs/XV6RcY6ASe+z+gBapEmlcQ12IKGJZQfpDmsoWku00x1XiWCtx5zyGG4cqUPlVVp/GaKu2zRFGA4TXb0jVLzMt0jfmGO4yW361Ibn26ZxzQS/cJ030sSSG3pVap+lfrXP0zrVj4AepVoPvOxmcsef2ZczHRkougLasyeyXcOixkur/Txxcy5oem6bYJtSC2UoSZS6DKM8ozpBbV/EOghjx9OEIXvATtxCUwIAqVOApvwWmJA+Fuw1FQAyczp8kSsb1DA2rLFhpDWinmz9pH1BPHQDnsGsozKOAWlSzvj2bweqMSYyKbNbYH1Rqc+vVcDWbSOoi4LNklBfIDfH47JPPgLQhBrxBdPh3RO84V/4OXeusNQp/PVtRJJJn2RHH+r0vza8+KZUy68MfsIp0v0VkDj8AEPsbZChUtv3vFyaRBC+iU5jNS6Wz6gNXba7rphegwvq4OzxxSh3AO6DRKHjaVgTk/v8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL0PR12MB5506.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(376002)(136003)(39860400002)(366004)(38100700002)(6916009)(7416002)(86362001)(186003)(9746002)(9786002)(8936002)(2616005)(8676002)(66946007)(54906003)(478600001)(426003)(5660300002)(66476007)(4326008)(26005)(1076003)(36756003)(2906002)(33656002)(66556008)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?IXM5Goh5zkkowFaR1gN50BBx7zrCqwvAF4Uy4niDgaFo+3RK0KI8mg1zhubc?= =?us-ascii?Q?hHDP9GqyA7S8bRaxU22UO5FvzPoIIJq0qh0A3QI9okkuTABRXE/jSBxwa9M8?= =?us-ascii?Q?lgD+9+TayXEykUj/EMJhIHhTSpThLKJ3vOARVpMOse3sxQg5Q4MXUTxnSq/e?= =?us-ascii?Q?FtcXkY/Wjx79VCu6CJ23vXpTITSKrbDfCQHdNFLzPlXbl3eR1CCKeDeRZflj?= =?us-ascii?Q?i5LQVT/Mecom/0qEV9y3TVvRQMPdH7xSQKr1ZI5PYoQ/tlQrdWJzf+oeJA/p?= =?us-ascii?Q?Hbksb0CUb99cs3I6+Cko24Wg+tTKh97dYnuK1B/8kCZByzu+praRjootk+at?= =?us-ascii?Q?QxhUupkdM+no+XdqY1fmNB5i1eL77xz3xQcbOzFknMFlCbqehxNYZhB+lGxS?= =?us-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KlqDTpyOW?= =?us-ascii?Q?Wa1RbAwQC5DXoDgrLg0ovbIv?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76f3de1d-c168-45b1-8c6e-08d925ecc68a X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB5506.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2021 17:35:12.4129 (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: y02WsSMBe81ALIxfTcMeDRx2nKQ9xxuC5/m452P70zEzRAPhsbVj4WrdD2/G3CAl X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5143 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 02, 2021 at 11:11:17AM -0600, Alex Williamson wrote: > > > > present and be able to test if DMA for that device is cache > > > > coherent. > > > > Why is this such a strong linkage to VFIO and not just a 'hey kvm > > emulate wbinvd' flag from qemu? > > IIRC, wbinvd has host implications, a malicious user could tell KVM to > emulate wbinvd then run the op in a loop and induce a disproportionate > load on the system. We therefore wanted a way that it would only be > enabled when required. I think the non-coherentness is vfio_device specific? eg a specific device will decide if it is coherent or not? If yes I'd recast this to call kvm_arch_register_noncoherent_dma() from the VFIO_GROUP_NOTIFY_SET_KVM in the struct vfio_device implementation and not link it through the IOMMU. If userspace is telling the vfio_device to be non-coherent or not then it can call kvm_arch_register_noncoherent_dma() or not based on that signal. > > It kind of looks like the other main point is to generate the > > VFIO_GROUP_NOTIFY_SET_KVM which is being used by two VFIO drivers to > > connect back to the kvm data > > > > But that seems like it would have been better handled with some IOCTL > > on the vfio_device fd to import the KVM to the driver not this > > roundabout way? > > Then QEMU would need to know which drivers require KVM knowledge? This > allowed transparent backwards compatibility with userspace. Thanks, I'd just blindly fire a generic 'hey here is your KVM FD' into every VFIO device. The backwards compat angle is reasonable enough though. So those two don't sound so bad, don't know about PPC, but David seem optimistic A basic idea is to remove the iommu stuff from the kvm connection so that the scope of the iommu related rework is contained to vfio Jason