Re: Emulated macppc with qemu

Mark Cave-Ayland <[email protected]> Mon, 5 Apr 2021 12:00:15 +0100
Newsgroups gmane.os.netbsd.ports.macppc
Message-ID <[email protected]>
On 04/04/2021 20:58, Havard Eidnes wrote:

> Hi,
> 
> after a bit of trial and error, I now have an emulated macppc
> host up and running with qemu.  This appears to require qemu
> 5.2.0 (latest from pkgsrc).

Fantastic!

> The script I've used to start and run the installer with is
> 
> ---
> #!/bin/sh
> 
> MEM=2g
> qemu-system-ppc \
>          -M mac99,via=pmu \
>          -m $MEM  \
>          -nographic \
>          -drive id=hda,format=raw,file=disk.img \
>          -L pc-bios \
>          -netdev user,id=net0,hostfwd=tcp::2223-:22,ipv6=off \
>          -net nic,model=rtl8139,netdev=net0 \
>          -boot d \
>          -cdrom NetBSD-8.2-macppc.iso
> ---
> 
> The installer is booted up with "boot cd:\ofwboot.xcf".

Is there any reason that you're overriding the default sungem NIC for QEMU's macppc 
machines? You should be able to drop the model=rtl8139 here and end up with a more 
realistic hardware configuration.

> There appears to be something finicky about the amount of memory:
> 1G fails with a trap early on, 3G fails as described in
> 
>    https://bugs.launchpad.net/bugs/1922391
> 
> quite a bit into the installation, but with 2G I've managed to
> install and it appears to run stably as well.

Hmmm that's odd - it looks like something has unmapped the DMA memory used for the 
macio IDE request before the QEMU host IO callback has completed?

> I recently built a pared-down kernel for one of my G4 Mac Minis,
> and that system has 1G physical memory and runs fine, while if I
> try the same 5.2MB-sized kernel in qemu, it still fails when only
> configured with 1G memory.  There's something spooky going on
> here, I think...
> 
> It also appears that the ppc qemu doesn't support SMP, at least
> not in this version.

In theory it shouldn't be too difficult, but no-one has really looked at this yet. 
The main thing that is missing is the interface for controlling the CPUs from OpenBIOS.

> Speed-wise it's nothing to write home about, but it's not
> entirely unusable either: a 1.5GHz G4 Mac Mini gives this with
> "openssl speed sha1":
> 
> type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
> sha1              5365.74k    19695.50k    64076.54k   146566.70k   235167.74k
> 
> while the emulated system on a i7-4790 host gives
> 
> type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
> sha1              1123.70k     4264.97k    15203.62k    40735.26k    86124.15k

If you are looking for more IO speed, you can always use virtio-blk-pci and 
virtio-net devices after the install has completed which should help considerably. My 
TODO list does include adding virtio-scsi support for OpenBIOS one day...


ATB,

Mark.