[v3,2/2] net/virtio: do not require IO permissions

Message ID 1571732503-30424-3-git-send-email-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series Using virtio ethdev ports as non-root |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/travis-robot warning Travis build: failed

Commit Message

David Marchand Oct. 22, 2019, 8:21 a.m. UTC
  On x86, iopl permissions are only available to root user (or users that
have the CAP_SYS_RAWIO capability).
But those permissions are only needed when the virtio devices accesses
are done with inb/outb instructions, which is when the device is bound
to a UIO kernel module.

So far, the virtio driver was refusing to register based on the check
on IO permissions.
This check does not make sense when binding the device to vfio.

Now that the check on IO permissions has been abstracted in the ioport
API, we can remove it on virtio side.

We still need to call rte_eal_iopl_init() in the virtio constructor so
that the interrupt thread inherits this permission in the case it could
be used with UIO later.

Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
Changelog since v1:
- remove log message in constructor (thanks Tiwei),
- reword commit log,

---
 drivers/net/virtio/virtio_ethdev.c | 5 -----
 1 file changed, 5 deletions(-)
  

Comments

Tiwei Bie Oct. 23, 2019, 4:56 a.m. UTC | #1
On Tue, Oct 22, 2019 at 10:21:43AM +0200, David Marchand wrote:
> On x86, iopl permissions are only available to root user (or users that
> have the CAP_SYS_RAWIO capability).
> But those permissions are only needed when the virtio devices accesses
> are done with inb/outb instructions, which is when the device is bound
> to a UIO kernel module.
> 
> So far, the virtio driver was refusing to register based on the check
> on IO permissions.
> This check does not make sense when binding the device to vfio.
> 
> Now that the check on IO permissions has been abstracted in the ioport
> API, we can remove it on virtio side.
> 
> We still need to call rte_eal_iopl_init() in the virtio constructor so
> that the interrupt thread inherits this permission in the case it could
> be used with UIO later.
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---

Acked-by: Tiwei Bie <tiwei.bie@intel.com>

Thanks,
Tiwei
  

Patch

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 7261109..0a2ed2e 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1995,11 +1995,6 @@  exit:
 static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	struct rte_pci_device *pci_dev)
 {
-	if (rte_eal_iopl_init() != 0) {
-		PMD_INIT_LOG(ERR, "IOPL call failed - cannot use virtio PMD");
-		return 1;
-	}
-
 	/* virtio pmd skips probe if device needs to work in vdpa mode */
 	if (vdpa_mode_selected(pci_dev->device.devargs))
 		return 1;