some QEMU success in running armv7

From: Thomas David Rivers <rivers_at_dignus.com>
Date: Fri, 19 May 2023 02:49:03 UTC
Just f.y.i. - here's the steps I was able to deduce today
to get FreeBSD armv7 running under qemu... just in case
someone goes looking for this... (I was doing this on a
FreeBSD 12.3-RELEASE x86_64 system.)


1.   Retrieve the armv7 image from:
        fetch https://download.freebsd.org/releases/arm/armv7/ISO-IMAGES/13.2/FreeBSD-13.2-RELEASE-arm-armv7-GENERICSD.img.xz
     and unzip it.   This is an actual hard-drive image of a working
     system.

2.  Assuming the qemu port has been installed - this command
    starts that system

    qemu-system-arm -M virt -m 512m -nographic \
       -bios edk2-arm-code.fd \
       -hda FreeBSD-13.2-RELEASE-arm-armv7-GENERICSD.img

    the existing terminal will be the console.  There is no
    networking.

    There root user's password is 'root'.

Unfortunately this doesn't provide networking in the guest.  This
compilation of QEMU also doesn't support the "-netdev user" mode
of networking so I can't take advantage of that.  (The FreeBSD 12.3
host is using QEMU emulator version 7.2.0 - from just the pkg 
install.)  However, I found that using this option on qemu:

    -nic tap,ifname=tap7,script=no,downscript=no

got it to use the tap interface on the host to emulate the virtio
device to the guest.

I also found this discussion regarding alignment issues in the
virtio driver in armv7:

  https://forums.freebsd.org/threads/kernel-panic-on-armv7-with-qemu.89016/#post-610281

that resulted in PR 271288.   Apparently it's because of newer versions
of QEMU doing a better job at reporting unaligned memory accesses in the 
guest for the armv7 "ldm" instruction.

When I use the tap interface, I did get the exact panic mentioned
in the forum and the PR.

I did find that specifying the rtl8139 device worked around the panic
with the QEMU option:

  -nic tap,ifname=tap7,script=no,downscript=no,model=rtl8139

by the way - tap7 happens to be a tap device I'd already configured
on the host FreeBSD 12.3 system - if you're doing this yourself,
it will likely need to be a different tap device, see this
write-up for info about how to configure a tap + bridge on your
FreeBSD host:
   http://bsdwiki.reedmedia.net/wiki/networking_qemu_virtual_bsd_systems.html

So - it seems a newer version of the armv7 kernel with the patch
applied will fix the virtio driver problem, until then, model=rtl8139
works around it and I have networking and everything!

	- Dave R. -

--
rivers@dignus.com                        Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com