When attaching a disk as a virtio block device, the FreeBSD kernel discovers the geometry incorrectly and sees only a small portion of the available capacity. kens@freebsd-ppc64> gpart show vtbd0 =>16 48 vtbd0 MBR (8.0M) 16 48 - free - (6.0M) Here is the same disk attached to the guest as a SCSI device: kens@freebsd-ppc64> gpart show da1 => 255 4194049 da1 MBR (2.0G) 255 4194049 - free - (2.0G) In other ppc64 guest Operating Systems (Linux) I run with the same host, virtio block devices work as expected (i.e. their reported size by the OS matches what I created with qemu-img). Hypervisor: QEMU version 2.4.0.1 Operating System configuration details: ------------------------------------------------------------- kens@freebsd-ppc64> freebsd-version -ku 11.0-CURRENT 11.0-CURRENT kens@freebsd-ppc64> uname -a FreeBSD freebsd-ppc64.kpsalerno.us.ibm.com 11.0-CURRENT FreeBSD 11.0-CURRENT #3 r291616: Sat Dec 5 15:04:53 EST 2015 root@freebsd-amd64.kpsalerno.us.ibm.com:/usr/obj/powerpc.powerpc64/usr/src/sys/SALERNO powerpc kens@freebsd-ppc64> sysctl kern.conftxt kern.conftxt: options CONFIG_AUTOGENERATED ident SALERNO machine powerpc cpu AIM options SMP options INCLUDE_CONFIG_FILE options _KPOSIX_PRIORITY_SCHEDULING options SCSI_DELAY=5000 options COMPAT_FREEBSD32 options UFS_DIRHASH options INET options PREEMPTION options SCHED_ULE options FDT options PSERIES options NEW_PCIB options GEOM_PART_MBR options GEOM_PART_BSD device uart_ns8250 device pci device scbus device da device cd device pass device scc device uart device uart_z8530 device loop device random device ether device ofwd device bpf device powermac_nvram kens@freebsd-ppc64> kldstat Id Refs Address Size Name 1 25 0x100000 673ab0 kernel 2 1 0x775000 1bcb0 geom_label.ko 3 1 0x791000 b5cc0 if_em.ko 4 1 0x847000 6a578 ufs.ko 5 1 0x8b2000 13770 mem.ko 6 4 0x8c6000 16a20 virtio.ko 7 1 0x8dd000 22c60 if_vtnet.ko 8 1 0x900000 18e90 virtio_pci.ko 9 1 0x919000 18b18 virtio_blk.ko kens@freebsd-ppc64> cat make.conf MAKE_JOBS_NUMBER = 5 KPS_FLAGS = -O2 -fomit-frame-pointer -pipe CFLAGS = ${KPS_FLAGS} COPTFLAGS = ${KPS_FLAGS} WITHOUT_PROFILE = yes WITHOUT_CAPSICUM = yes WITHOUT_TESTS = yes MALLOC_PRODUCTION = yes NO_WERROR = WERROR = # temp disable these modules until Makefile fixed in 11-CURRENT # linux64 linprocfs linsysfs \ MODULES_OVERRIDE = \ geom/geom_label \ sysvipc \ ufs fdescfs tmpfs msdosfs cd9660 procfs pseudofs \ mem \ md firmware \ em \ virtio/virtio virtio/network virtio/pci virtio/block kens@freebsd-ppc64> dmesg | grep -e vt -e virtio virtio_pci0: <VirtIO PCI Block adapter> port 0x40-0x7f mem 0xc0000000-0xc0000fff irq 4100 at device 1.0 on pci0 vtblk0: <VirtIO Block Adapter> on virtio_pci0 vtblk0: 8MB (64 131072 byte sectors) kens@freebsd-ppc64> sysctl dev.vtblk dev.vtblk.0.writecache_mode: 1 dev.vtblk.0.%parent: virtio_pci0 dev.vtblk.0.%pnpinfo: dev.vtblk.0.%location: dev.vtblk.0.%driver: vtblk dev.vtblk.0.%desc: VirtIO Block Adapter dev.vtblk.%parent: Details of same disk image when attached to guest as SCSI device: ------------------------------------------------------------- kens@freebsd-ppc64> dmesg|grep da1 da1 at vscsi0 bus 0 scbus0 target 0 lun 2 da1: <QEMU QEMU HARDDISK 2.4.> Fixed Direct Access SPC-3 SCSI device da1: 150.000MB/s transfers da1: 2048MB (4194304 512 byte sectors)
This was opened a long time ago, but you can try this patch and see if works for you: https://reviews.freebsd.org/file/data/rai7ynple4urzf2uqv2h/PHID-FILE-qf4squsg737zysmalzju/D19815.diff As discussed in https://reviews.freebsd.org/D19815, it's not a final fix, but it's a workaround that makes virtio-net and virtio-scsi usable for me while final fix isn't available.
A commit references this bug: Author: alfredo Date: Wed Feb 5 20:39:18 UTC 2020 New revision: 357596 URL: https://svnweb.freebsd.org/changeset/base/357596 Log: [virtio] Fix r/w to PCI configuration area on big endian platforms In legacy VirtIO drivers, the header must be PCI endianness (little) and the device-specific region is encoded in the native endian of the guest. This patch makes the access (read/write) to VirtIO header using the little endian order. Other read and write access are native endianness. This also sets the device's IO region as big endian if on big endian machine. PR: 205178 Submitted by: Andre Silva <afscoelho@gmail.com> Reported by: Kenneth Salerno <kennethsalerno@yahoo.com> Reviewed by: bryanv, bdragon, luporl, alfredo Approved by: jhibbits (mentor) Differential Revision: https://reviews.freebsd.org/D23401 Changes: head/sys/dev/virtio/pci/virtio_pci.c