Date: Mon, 25 May 2026 22:21:13 -0700 From: Adrian Chadd <adrian@freebsd.org> To: =?UTF-8?B?VGltbyBWw7Zsa2Vy?= <timo.voelker@fh-muenster.de> Cc: "freebsd-ppc@freebsd.org" <freebsd-ppc@freebsd.org> Subject: Re: FreeBSD Big Endian in a VM and VirtIO Message-ID: <CAJ-VmomZa0%2Bi=6pGegWwGZMS4ze-fcEorGm363JqaTjRn38DLw@mail.gmail.com> In-Reply-To: <00E9A4E2-8746-48C0-815D-B923D7AEE211@fh-muenster.de>
index | next in thread | previous in thread | raw e-mail
hi! On Sat, 23 May 2026 at 01:15, Timo Völker <timo.voelker@fh-muenster.de> wrote: > > Hi! > > How do you run FreeBSD with Big Endian in a VM? Right now I use qemu w/ full CPU emulation, as my P8/P9 hardware is running FreeBSD natively. (I am tempted to spin up Linux on one of them just to run hardware VMs, but it honestly looks like the coverage there is fine as other developers are doing this.) > Is qemu the de facto only hypervisor used for this? Well, unless you have an IBM hardware setup to run pseries VMs. :-) > To avoid CPU emulation, I installed Debian (Little Endian) on a Raptor Blackbird to run a FreeBSD (Big Endian) VM with qemu. You should be able to just setup a VM - you don't tell it the endianness - and then either boot/install a FreeBSD powerpc64 (be) or powerpc64le (le) ISO. That's it. You don't need to do anything else; the bootloader and kernel will call up to the hypervisor to set the VM endianness and then .. off you go. > > Currently, I’m investigating this bug: > > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=294706 > > I think the cause is byte swaps in sys/dev/virtio/pci/virtio_pci_modern.c (by virtio_htog*() or virtio_gtoh*() function calls) that shouldn’t be done. At least if I remove these in my setup, the bug disappears. Now, I wonder, are these byte swaps incorrect in my setup but necessary in others (due to another hypervisor or the endianness of the host system)? > > In my understanding, at the lines where virtio_pci_modern.c uses the virtio_htog*() functions, it reads a value from the PCI bus. Since the PCI bus uses little endian, it requires a byte swap in a big endian VM, but this is already done internally by the bus_space API. So, this would mean the byte swaps in virtio_pci_modern.c are incorrect in general and shouldn’t be done. Thanks again for digging into it! -ahome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-VmomZa0%2Bi=6pGegWwGZMS4ze-fcEorGm363JqaTjRn38DLw>
