Page MenuHomeFreeBSD

bhyve: Open /dev/pci read-only when possible
Needs ReviewPublic

Authored by markj on Fri, Jan 16, 4:29 PM.
Tags
None
Referenced Files
F142197482: D54739.id.diff
Sat, Jan 17, 2:55 AM
Unknown Object (File)
Sat, Jan 17, 1:06 AM
Unknown Object (File)
Fri, Jan 16, 11:58 PM
Unknown Object (File)
Fri, Jan 16, 9:51 PM
Unknown Object (File)
Fri, Jan 16, 7:47 PM
Unknown Object (File)
Fri, Jan 16, 6:50 PM

Details

Reviewers
bnovkov
Group Reviewers
bhyve
Summary

When running as an unprivileged user, we can't open /dev/pci for writing,
but pci_host_read_config() doesn't require that.

Make pcifd_open()'s callers declare their access flags. Don't log a
warning if open() failed due to a permissions issue.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 69924
Build 66807: arc lint + arc unit

Event Timeline

I did an initial smoke test for this phab stack and it worked for me..got a couple questions though

usr.sbin/bhyve/pci_passthru.c
198–201

hmm..wonder if this will break the gpu passthru bits?

host_read_config() proxies through ioctl(PCIOCREAD)..and PCIOCREAD requires a writable descriptor...

it appears the the existing gpu passthru bits rely on pci_host_read_config()

curious if the gpu bits should leverage passthru_read_config() using the global pcifd descriptor instead?

for what its worth i haven't experimented with gpu passthru yet

usr.sbin/bhyve/pci_passthru.c
198–201

Thanks for testing... you're right, for some reason I had convinced myself that PCIOCREAD was in the list of ioctls that pci_ioctl() explicitly lists as not requiring FWRITE. I'll retest and update the revision.