Page MenuHomeFreeBSD

vmm: Rework mapping of PCI passthrough bars into guests.
Needs ReviewPublic

Authored by jhb on Aug 11 2022, 11:32 PM.
Tags
None
Referenced Files
F102707018: D36146.id109207.diff
Sat, Nov 16, 3:41 AM
Unknown Object (File)
Thu, Oct 24, 3:45 AM
Unknown Object (File)
Oct 4 2024, 11:55 AM
Unknown Object (File)
Oct 4 2024, 5:11 AM
Unknown Object (File)
Oct 3 2024, 6:16 AM
Unknown Object (File)
Oct 3 2024, 1:36 AM
Unknown Object (File)
Oct 2 2024, 9:19 PM
Unknown Object (File)
Oct 2 2024, 7:36 PM

Details

Reviewers
emaste
markj
grehan
Group Reviewers
bhyve
Summary

The existing VM_MAP_PPTDEV_MMIO ioctl permitted the userland
hypervisor to specify the host physical address of a BAR trusting the
hypervisor to only pass valid host physical addresses. Rather than
trusting the host physical address provided by userland, introduce a
new ioctl which accepts a BAR register and relative offset in place of
the host physical address. This ensures that only host physical
addresses belonging to a BAR of a passthrough device can be mapped
into the guest address space.

Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 46869
Build 43758: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Aug 11 2022, 11:32 PM
sys/amd64/vmm/io/ppt.c
455

I think this is a reasonable #ifdef to use for now, but we likely want to be more aggressive in removing this than waiting until COMPAT_FREEBSD13 naturally ages out. Or maybe we could add a sysctl to allow/disallow the old insecure ioctl. I'd be happy for that to be a followup (either by you or me).

sys/amd64/vmm/io/ppt.c
357

Will this conflict with bhyve's use of the PCIOCBARIO ioctl for mapping the MSI-X table and PBA? See the discussion about the use of RF_SHAREABLE in D31307.

sys/amd64/vmm/io/ppt.c
357

Hmm, yes it will.

Perhaps it would be best if we did something that I think I suggested against before which is to add new vmm ioctls for bhyve to use for that in place of the generic PCI ioctls. That would ensure that bhyve can only read/write BARs of ppt(4) devices and not BARs of arbitrary devices.

Where should we go with this patch?

corvink added inline comments.
sys/amd64/include/vmm_dev.h
322

Should we remove this one?

sys/amd64/vmm/io/ppt.c
191–193

Just a matter of taste here. I prefer a slightly different style because it avoids indentation.