Re: FreeBSD Big Endian in a VM and VirtIO

Adrian Chadd <[email protected]> Mon, 25 May 2026 22:21:13 -0700
Newsgroups gmane.os.freebsd.devel.ppc
Message-ID <CAJ-VmomZa0+i=6pGegWwGZMS4ze-fcEorGm363JqaTjRn38DLw@mail.gmail.com>
hi!

On Sat, 23 May 2026 at 01:15, Timo V=C3=B6lker <[email protected]=
> 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 Bl=
ackbird 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=E2=80=99m investigating this bug:
>
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D294706
>
> 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=E2=80=99=
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 othe=
rs (due to another hypervisor or the endianness of the host system)?
>
> In my understanding, at the lines where virtio_pci_modern.c uses the virt=
io_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=E2=80=99=
t be done.

Thanks again for digging into it!



-a