From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5950C3F2D1 for ; Thu, 5 Mar 2020 18:22:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B072C208C3 for ; Thu, 5 Mar 2020 18:22:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="X6lJoe//" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726004AbgCESWj (ORCPT ); Thu, 5 Mar 2020 13:22:39 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:45761 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725948AbgCESWj (ORCPT ); Thu, 5 Mar 2020 13:22:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583432557; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=90RLHPqVNEZEMrWwkgjpPMMkSbZ9eZRo8m2gr4E/ffQ=; b=X6lJoe//wIbzEpTbF5V9izN51b9RMXNH8T9JVh+2zWsb0W4rLbwpAaKq9hJ2oiCdlBhP5k OUNrdmWcHkimtLhOIAuY/srrG+j5MJELRRzCoZ7T3H8iE+JTUgV/W0VfVW/gvmPNYZvsmk 8RLPocprFVhx5c2yaIw1jBdaU25aFWQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-140-FZVPSvRgM1yuOakSm6mTpA-1; Thu, 05 Mar 2020 13:22:35 -0500 X-MC-Unique: FZVPSvRgM1yuOakSm6mTpA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23DBB13F6; Thu, 5 Mar 2020 18:22:34 +0000 (UTC) Received: from w520.home (ovpn-116-28.phx2.redhat.com [10.3.116.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B5AB8F34E; Thu, 5 Mar 2020 18:22:31 +0000 (UTC) Date: Thu, 5 Mar 2020 11:22:30 -0700 From: Alex Williamson To: "Tian, Kevin" Cc: "kvm@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "dev@dpdk.org" , "mtosatti@redhat.com" , "thomas@monjalon.net" , "bluca@debian.org" , "jerinjacobk@gmail.com" , "Richardson, Bruce" , "cohuck@redhat.com" Subject: Re: [PATCH v2 5/7] vfio/pci: Add sriov_configure support Message-ID: <20200305112230.0dd77712@w520.home> In-Reply-To: References: <158213716959.17090.8399427017403507114.stgit@gimli.home> <158213846731.17090.37693075723046377.stgit@gimli.home> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Tue, 25 Feb 2020 03:08:00 +0000 "Tian, Kevin" wrote: > > From: Alex Williamson > > Sent: Thursday, February 20, 2020 2:54 AM > > > > With the VF Token interface we can now expect that a vfio userspace > > driver must be in collaboration with the PF driver, an unwitting > > userspace driver will not be able to get past the GET_DEVICE_FD step > > in accessing the device. We can now move on to actually allowing > > SR-IOV to be enabled by vfio-pci on the PF. Support for this is not > > enabled by default in this commit, but it does provide a module option > > for this to be enabled (enable_sriov=1). Enabling VFs is rather > > straightforward, except we don't want to risk that a VF might get > > autoprobed and bound to other drivers, so a bus notifier is used to > > "capture" VFs to vfio-pci using the driver_override support. We > > assume any later action to bind the device to other drivers is > > condoned by the system admin and allow it with a log warning. > > > > vfio-pci will disable SR-IOV on a PF before releasing the device, > > allowing a VF driver to be assured other drivers cannot take over the > > PF and that any other userspace driver must know the shared VF token. > > This support also does not provide a mechanism for the PF userspace > > driver itself to manipulate SR-IOV through the vfio API. With this > > patch SR-IOV can only be enabled via the host sysfs interface and the > > PF driver user cannot create or remove VFs. > > I'm not sure how many devices can be properly configured simply > with pci_enable_sriov. It is not unusual to require PF driver prepare > something before turning PCI SR-IOV capability. If you look kernel > PF drivers, there are only two using generic pci_sriov_configure_ > simple (simple wrapper like pci_enable_sriov), while most others > implementing their own callback. However vfio itself has no idea > thus I'm not sure how an user knows whether using this option can > actually meet his purpose. I may miss something here, possibly > using DPDK as an example will make it clearer. There is still the entire vfio userspace driver interface. Imagine for example that QEMU emulates the SR-IOV capability and makes a call out to libvirt (or maybe runs with privs for the PF SR-IOV sysfs attribs) when the guest enables SR-IOV. Can't we assume that any PF specific support can still be performed in the userspace/guest driver, leaving us with a very simple and generic sriov_configure callback in vfio-pci? Thanks, Alex