All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pci-stub: enable SR-IOV configuration through sysfs
@ 2017-12-13 13:05 Maximilian Heyne
  2018-01-10 23:35 ` Bjorn Helgaas
  0 siblings, 1 reply; 3+ messages in thread
From: Maximilian Heyne @ 2017-12-13 13:05 UTC (permalink / raw)
  To: linux-pci; +Cc: Maximilian Heyne

Currently, SR-IOV VFs can only be configured through sysfs, if a driver
is loaded for the device. Sometimes we don't care about the PF, but only
want to assign VFs to guests, which is now possible with this patch.

Signed-off-by: Maximilian Heyne <mheyne@amazon.de>
---
 drivers/pci/pci-stub.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pci-stub.c b/drivers/pci/pci-stub.c
index 886fb35..aa007c3 100644
--- a/drivers/pci/pci-stub.c
+++ b/drivers/pci/pci-stub.c
@@ -32,10 +32,27 @@ static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	return 0;
 }
 
+static void pci_stub_remove(struct pci_dev *dev)
+{
+	pci_disable_sriov(dev);
+}
+
+static int pci_stub_sriov_configure(struct pci_dev *dev, int num_vfs)
+{
+	if (!num_vfs) {
+		pci_disable_sriov(dev);
+		return 0;
+	}
+
+	return pci_enable_sriov(dev, num_vfs);
+}
+
 static struct pci_driver stub_driver = {
-	.name		= "pci-stub",
-	.id_table	= NULL,	/* only dynamic id's */
-	.probe		= pci_stub_probe,
+	.name			= "pci-stub",
+	.id_table		= NULL,	/* only dynamic IDs */
+	.probe			= pci_stub_probe,
+	.remove			= pci_stub_remove,
+	.sriov_configure	= pci_stub_sriov_configure,
 };
 
 static int __init pci_stub_init(void)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] pci-stub: enable SR-IOV configuration through sysfs
  2017-12-13 13:05 [PATCH] pci-stub: enable SR-IOV configuration through sysfs Maximilian Heyne
@ 2018-01-10 23:35 ` Bjorn Helgaas
  2018-01-11  0:05   ` Alexander Duyck
  0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2018-01-10 23:35 UTC (permalink / raw)
  To: Maximilian Heyne
  Cc: linux-pci, Alexander Duyck, Alex Williamson, Jeff Kirsher,
	Liang-Min Wang, kvm, linux-kernel

[+cc Alex, Alex, Jeff, Liang-Min, kvm, LKML]

Anybody else have any thoughts on this?

On Wed, Dec 13, 2017 at 02:05:33PM +0100, Maximilian Heyne wrote:
> Currently, SR-IOV VFs can only be configured through sysfs, if a driver
> is loaded for the device. Sometimes we don't care about the PF, but only
> want to assign VFs to guests, which is now possible with this patch.
> 
> Signed-off-by: Maximilian Heyne <mheyne@amazon.de>
> ---
>  drivers/pci/pci-stub.c | 23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/pci-stub.c b/drivers/pci/pci-stub.c
> index 886fb35..aa007c3 100644
> --- a/drivers/pci/pci-stub.c
> +++ b/drivers/pci/pci-stub.c
> @@ -32,10 +32,27 @@ static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  	return 0;
>  }
>  
> +static void pci_stub_remove(struct pci_dev *dev)
> +{
> +	pci_disable_sriov(dev);
> +}
> +
> +static int pci_stub_sriov_configure(struct pci_dev *dev, int num_vfs)
> +{
> +	if (!num_vfs) {
> +		pci_disable_sriov(dev);
> +		return 0;
> +	}
> +
> +	return pci_enable_sriov(dev, num_vfs);
> +}
> +
>  static struct pci_driver stub_driver = {
> -	.name		= "pci-stub",
> -	.id_table	= NULL,	/* only dynamic id's */
> -	.probe		= pci_stub_probe,
> +	.name			= "pci-stub",
> +	.id_table		= NULL,	/* only dynamic IDs */
> +	.probe			= pci_stub_probe,
> +	.remove			= pci_stub_remove,
> +	.sriov_configure	= pci_stub_sriov_configure,
>  };
>  
>  static int __init pci_stub_init(void)
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pci-stub: enable SR-IOV configuration through sysfs
  2018-01-10 23:35 ` Bjorn Helgaas
@ 2018-01-11  0:05   ` Alexander Duyck
  0 siblings, 0 replies; 3+ messages in thread
From: Alexander Duyck @ 2018-01-11  0:05 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Maximilian Heyne, linux-pci, Alex Williamson, Jeff Kirsher,
	Liang-Min Wang, kvm, linux-kernel

Sorry for top-posting but I am just going to throw a recap of the
discussions as I recall them on top of this since the code itself
isn't so much the subject of review.

I would imagine this has the same issues that we were talking about
for the VFIO or UIO solutions for this. Basically the discussion all
came down to the fact that doing this potentially exposes the kernel
to a possible security issue since the PF might be managed by an
untrusted source. I believe the last discussion we had about the VFIO
based solution ended in us needing to have a way to make it so that
the auto-probe value could be changed and be restored after the
user-space managed PF driver was unloaded and/or SR-IOV was disabled.
Basically we can't risk tainting the kernel by auto-loading the VF
drivers on the kernel when the PF is managed by an unknown entity or
user space.

- Alexander

On Wed, Jan 10, 2018 at 3:35 PM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> [+cc Alex, Alex, Jeff, Liang-Min, kvm, LKML]
>
> Anybody else have any thoughts on this?
>
> On Wed, Dec 13, 2017 at 02:05:33PM +0100, Maximilian Heyne wrote:
>> Currently, SR-IOV VFs can only be configured through sysfs, if a driver
>> is loaded for the device. Sometimes we don't care about the PF, but only
>> want to assign VFs to guests, which is now possible with this patch.
>>
>> Signed-off-by: Maximilian Heyne <mheyne@amazon.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-11  0:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-13 13:05 [PATCH] pci-stub: enable SR-IOV configuration through sysfs Maximilian Heyne
2018-01-10 23:35 ` Bjorn Helgaas
2018-01-11  0:05   ` Alexander Duyck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.