BAR and pci passthrough

Harry Schmalzbauer freebsd at omnilan.de
Sat Dec 10 20:44:45 UTC 2016


 In reply to
https://lists.freebsd.org/pipermail/freebsd-virtualization/2015-December/004000.html

>/>> The problem probably that the length of the bar is smaller and not
/>/>> aligned with the pagesize. Could the length of the BAR be modified in
/>/>> order to perform the pci passthrough?
/>/>
/>/> Yes, that's correct - the size of the BAR is not a multiple of the
/>/> page size which leads to the error. If this BAR is mapped into the
/>/> guest's address space then it will "leak" an additional 3K into the
/>/> guest (since the minimum nested mapping is 4KB in size).

/> The proper fix is to modify the ppt(4) driver so that
> it asks the PCI bus to allocate a full page for BARs that are smaller than a
> page.  Unfortunately the PCI bus driver doesn't currently provide a way to do
> that.  Even if it did it would not necessarily always work since the device
> may be behind a PCI-PCI bridge whose windows can't grow due to existing
> allocations of adjacent addresses.  Alternatively the hypervisor could trap
> all accesses to this page and only permit accesses to the range that contains
> the BAR, but that would be quite slow.

My stupid idea was to set in device.hints:
hint.ppt.0.msize="0x1000"

Since John (jhb@) already posted that the PCI bus driver deosn't provide the necessary capability to increase allocation, this clearly doesn't work.
But since this hint was one year ago, I wanted to ask if there are news regarding PCI passthru (ppt's) page size handling or other workarrounds.
My specific problem reads:
sh -c 'while true ; do (bhyve -u -A -H -P -s 0,hostbridge -s 6,virtio-net,vmnet0 -s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600,wait -s 31,lpc -s 1,passthru,6/0/0 -l com1,stdio -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI_CSM.fd -S -m 4G -c 4 preed); vmm_exit=$?; if [ ${vmm_exit} -ne 0 ]; then break; fi; done ; /usr/sbin/bhyvectl --destroy --vm=preed'
bhyve: passthru device 6/0/0 BAR 5: base 0xc3e10000 or size 0x200 not page aligned

Please make sure im on CC, I'm not subscribed.

Thanks,

-Harry

P.S.: Thanks to all byhve hackers, really awsome work! I'm evaluating ESXi reliever... Perhaps this obstacle is interesting for some people here (and one reason I need to passthru SATA controller)
https://lists.freebsd.org/pipermail/freebsd-stable/2016-October/086157.html



More information about the freebsd-virtualization mailing list