Bug 238590

Summary: devel/libpciaccess: Missing open_device_io() method breaks some consumers (e.g., xf86-video-qxl)
Product: Ports & Packages Reporter: Conrad Meyer <cem>
Component: Individual Port(s)Assignee: freebsd-x11 (Nobody) <x11>
Status: Closed FIXED    
Severity: Affects Some People CC: zeising
Priority: --- Keywords: needs-qa, patch
Version: LatestFlags: bugzilla: maintainer-feedback? (x11)
koobs: merge-quarterly?
Hardware: Any   
OS: Any   
URL: https://gitlab.freedesktop.org/xorg/lib/libpciaccess/merge_requests/4

Description Conrad Meyer freebsd_committer freebsd_triage 2019-06-16 04:03:09 UTC
For QXL in particular, this breaks FreeBSD guests running under common Linux virt-manager for QEMU/KVM with QXL video.  (QXL is the default paravirtualized display device there.)  The symptom manifests as Xorg segfaulting at NULL+8 in pci_io_write8().

Adding the method is trivial; our existing "legacy" open method works sufficiently to implement the missing one.  See patch:

https://gitlab.freedesktop.org/xorg/lib/libpciaccess/merge_requests/4
Comment 1 Niclas Zeising freebsd_committer freebsd_triage 2019-06-16 07:28:41 UTC
Hi!
Since this is submitted upstream, together with other changes, I'd like to give upstream a day or two to respond, in case there's something we're misunderstanding.
We have a WIP branch here: https://github.com/FreeBSDDesktop/freebsd-ports/tree/feature/libpciaccess
I'll incorporate your patches there for easy testing.
Comment 2 Conrad Meyer freebsd_committer freebsd_triage 2019-06-16 15:08:29 UTC
(In reply to Niclas Zeising from comment #1)

No big hurry, it can wait a few days.  This turns an obvious segfault in qxl into a working desktop in a kvm FreeBSD guest, so I believe it’s more or less correct.
Comment 3 commit-hook freebsd_committer freebsd_triage 2019-06-30 17:04:13 UTC
A commit references this bug:

Author: zeising
Date: Sun Jun 30 17:04:05 UTC 2019
New revision: 505440
URL: https://svnweb.freebsd.org/changeset/ports/505440

Log:
  x11/libpciaccess: Update to 0.14.0

  Update x11/libpciaccess to 0.14.0.  Rework the patch to match what has
  been submitted upstream.

  Remove old code that was used before PCIOCGETBAR.  PCIOCGETBAR has been part
  of FreeBSD for a long time.
  Remove check for if pci_io.pi_sel.pc_domain exists.  This has been the case
  for quite some time.
  Add a function to detect if a driver has been attached to a PCI device
  Implement pci_device_freebsd_open_io, this fixes runtime of xf86-video-qxl
  and possibly other drivers [1]
  Reformat and try to apply upstream style.

  Side note, instead of trying to patch configure, I've elected to change
  configure.ac and add a dependency on autoreconf.  The difference between the
  previous configure and a new configure generated by the patched configure.ac
  is quite large.

  PR:		238590 [1]
  Submitted by:	cem [1]
  Obtained from:	FreeBSD Graphics Team development repo
  Sponsored by:	B3 Init (zeising)

Changes:
  head/devel/libpciaccess/Makefile
  head/devel/libpciaccess/distinfo
  head/devel/libpciaccess/files/patch-configure.ac
  head/devel/libpciaccess/files/patch-src-freebsd_pci.c
Comment 4 Niclas Zeising freebsd_committer freebsd_triage 2019-06-30 17:08:50 UTC
Committed the patch together with the libpciaccess 0.14.0.
Comment 5 Conrad Meyer freebsd_committer freebsd_triage 2019-07-12 18:22:58 UTC
FWIW, Ajax merged the proposed PR upstream, so newer versions of libpciaccess should have this bug fixed.
Comment 6 Niclas Zeising freebsd_committer freebsd_triage 2019-07-12 19:03:18 UTC
(In reply to Conrad Meyer from comment #5)
> FWIW, Ajax merged the proposed PR upstream, so newer versions of
> libpciaccess should have this bug fixed.

Yeah, he merged the other changes as well.  I've updated a test branch with the new release, but will let it sit there for a smoke test at least, before merging it.

There's also a little bit of fallout from the update to 0.14.0, that needs to be fixed.

libpciaccess 0.15.0 can be found here, in case you want to test it out.
https://github.com/FreeBSDDesktop/freebsd-ports/tree/feature/xorglibs