Re: [PATCH V3] drivers/uio/uio_pci_generic.c: allow access for non-privileged processes

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Tom Lyon
Date: Thursday, April 29, 2010 - 12:29 pm

Michael, et al - sorry for the delay, but I've been digesting the comments and researching new approaches.

I think the plan for V4 will be to take things entirely out of the UIO framework, and instead have a driver which supports user mode use of "well-behaved" PCI devices. I would like to use read and write to support access to memory regions, IO regions,  or PCI config space. Config space is a bitch because not everything is safe to read or write, but I've come up with a table driven approach which can be run-time extended for non-compliant devices (under root control) which could then enable non-privileged users. For instance, OHCI 1394 devices use a dword in config space which is not formatted as a PCI capability, root can use sysfs to enable access:
	echo <offset> <readbits> <writebits> > /sys/dev/pci/devices/xxxx:xx:xx.x/<yyy>/config_permit


A "well-behaved" PCI device must have memory BARs >= 4K for mmaping, must have separate memory space for MSI-X that does not need mmaping
by the user driver, must support the PCI 2.3 interrupt masking, and must not go totally crazy with PCI config space (tg3 is real ugly, e1000 is fine).

Again, my primary usage model is for direct user-level access to network devices, not for virtualization, but I think both will work.

So, I will go outside UIO because:
1 - it doesn't allow reads and writes to sub-drivers, just irqcontrol
2 - it doesn't have ioctls
3 - it has its own interrupt model which doesn't use eventfds
4 - it's ugly doing the new stuff and maintaining backwards compat.

I hereby solicit comments on the name and location for the new driver.

Michael - some of your comments below imply you didn't look at the companion changes to uio.c, which had the eventfd interrupts and effectively the same iommu handling - but see my inline comments below.

On Wednesday 21 April 2010 02:38:49 am Michael S. Tsirkin wrote:
I will handle config access for well-behaved devices.

Not sure what you meant, but probably irrelevant in new scheme.
Agreed, no mmaping, just r/w.

Given that many system platforms don't have it, doesn't seem like a big deal.
But I'll look into it.

Agreed.

Yes, will "virtualize" this in the driver. User level will not be allowed to
mmap real MSI-X region (if MSI-X in use); MSI config writes will be intercepted.
The code already requires iommu protection for masters, I will make sure this
includes MSI and MSI-X devices.

As an aside, the IOMMU is supposed to be able to do interrupt translation also,
but the format for vectors changes, so it doesn't really help with virtualization.

Non-virt, just new user level drivers for special cases.

I think I can cover all these, slightly differently, in V4.
Thank for your comments.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH V3] drivers/uio/uio_pci_generic.c: allow access ..., Michael S. Tsirkin, (Wed Apr 21, 2:38 am)
Re: [PATCH V3] drivers/uio/uio_pci_generic.c: allow access ..., Michael S. Tsirkin, (Wed Apr 21, 3:30 am)
Re: [PATCH V3] drivers/uio/uio_pci_generic.c: allow access ..., Tom Lyon, (Thu Apr 29, 12:29 pm)
Re: [PATCH V3] drivers/uio/uio_pci_generic.c: allow access ..., Michael S. Tsirkin, (Thu Apr 29, 12:52 pm)
Re: [LKML] Re: [PATCH V3] drivers/uio/uio_pci_generic.c: a ..., Konrad Rzeszutek Wilk, (Mon May 3, 10:47 am)