libpciaccess porting problems

Mark Kettenis mark.kettenis at xs4all.nl
Sun Feb 24 09:00:16 PST 2008


I'm trying to port libpciaccess to OpenBSD and I'm running into a
nasty problem.

On OpenBSD one can map device memory using /dev/xf86.  This device has
exclusive open semantics to prevent conflicting access from multiple
processes.  This means that the device can be opened only once.
Because the mapping of PCI BARs has been moved into libpciaccess, the
libpciaccess code has to open /dev/xf86.  But the xserver code itself
also has to open /dev/xf86 to map VGA resources that are not mapped by
PCI BARs.  This doesn't work, because libpciaccess gets there first
and the xserver code loses.

I need to find a way to get libpciaccess and xserver to share the file
descriptor for /dev/xf86.  I see a couple of possibilities:

* Modify the pci_system_init() interface to make it possible to pass
  OS-specific arguments.

* Add an OpenBSD-specific interface to libpciaccess to set the
  /dev/xf86 file descriptor.

* Turn libpciaccess into a Xorg module such that it can access xserver
  internal symbols.

Having xserver pass the file descriptor to libpciaccess is also
necessary for another reason.  On OpenBSD the X server uses privilige
seperation where the X server starts as root, opens /dev/xf86, forks,
and then drops root priviliges.  If we do that before initializing
libpciaccess, it won't be possible to for the library to open
/dev/xf86.

What solution would people prefer?  Alternative solutions are also
welcome.

Mark



More information about the xorg mailing list