Skip to content

Introduce new vmapple machine type

Alexander Graf qemu-arm qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest12 patches 16 repliesIn review
  2. v112 patches 20 repliesSuperseded

Changes in v2 from the cover letter

- Adapt to system_ss meson.build target
- Add documentation
- Rework virtio-blk patch to make all vmapple virtio-blk logic subclasses
- Add log message on write
- Move max slot number to define
- Use SPDX header
- Remove useless includes

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12build: Only define OS_OBJECT_USE_OBJC with gccmeson.build+3 -14 replies
2/12hw/misc/pvpanic: Add MMIO interfacehw/misc/Kconfig hw/misc/meson.build hw/misc/pvpanic-mmio.c +1 more+67 -01 reply
3/12hvf: Increase number of possible memory slotsaccel/hvf/hvf-accel-ops.c include/sysemu/hvf_int.h+4 -20 replies
4/12hvf: arm: Ignore writes to CNTP_CTL_EL0target/arm/hvf/hvf.c+9 -01 reply
5/12hw: Add vmapple subdirMAINTAINERS hw/Kconfig hw/meson.build +5 more+13 -00 replies
6/12gpex: Allow more than 4 legacy IRQshw/arm/sbsa-ref.c hw/arm/virt.c hw/i386/microvm.c +7 more+52 -270 replies
7/12hw/vmapple/aes: Introduce aes enginehw/vmapple/Kconfig hw/vmapple/aes.c hw/vmapple/meson.build +1 more+604 -01 reply
8/12hw/vmapple/bdif: Introduce vmapple backdoor interfacehw/vmapple/Kconfig hw/vmapple/bdif.c hw/vmapple/meson.build +2 more+284 -02 replies
9/12hw/vmapple/cfg: Introduce vmapple cfg regionhw/vmapple/Kconfig hw/vmapple/cfg.c hw/vmapple/meson.build +1 more+177 -01 reply
10/12hw/vmapple/apple-gfx: Introduce ParavirtualizedGraphics.Framework supporthw/vmapple/Kconfig hw/vmapple/apple-gfx.m hw/vmapple/meson.build +2 more+608 -01 reply
11/12hw/vmapple/virtio-blk: Add support for apple virtio-blkhw/block/virtio-blk.c hw/vmapple/Kconfig hw/vmapple/meson.build +4 more+282 -53 replies
12/12hw/vmapple/vmapple: Add vmapple machine typeMAINTAINERS docs/system/arm/vmapple.rst docs/system/target-arm.rst +3 more+746 -02 replies

Reviews trailers per patch

5 of 12 patches have a Reviewed-by or Acked-by.

PatchPhilippe Mathieu-DaudéAkihiko OdakiStefan HajnocziPhil Dennis-Jordan
1/12R-b R-b
2/12R-b T-b
3/12
4/12R-b
5/12
6/12
7/12
8/12R-b
9/12
10/12T-b
11/12R-b
12/12

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v2 thread

Cover letter [PATCH v2 00/12] Introduce new vmapple machine type

This patch set introduces a new ARM and HVF specific machine type called "vmapple". It mimicks the device model that Apple's proprietary Virtualization.Framework exposes, but implements it in QEMU.

With this new machine type, you can run macOS guests on Apple Silicon systems via HVF. To do so, you need to first install macOS using Virtualization.Framework onto a virtual disk image using a tool like macosvm (https://github.com/s-u/macosvm)

  $ macosvm --disk disk.img,size=32g --aux aux.img \
            --restore UniversalMac_12.0.1_21A559_Restore.ipsw vm.json

Then, extract the ECID from the installed VM:

  $ cat "$DIR/macosvm.json" | python3 -c                                 \
  'import json,sys;obj=json.load(sys.stdin);print(obj["machineId"]) |    \
  base64 -d | plutil -extract ECID raw -

In addition, cut off the first 16kb of the aux.img:

  $ dd if=aux.img of=aux.img.trimmed bs=$(( 0x4000 )) skip=1

Now, you can just launch QEMU with the bits generated above:

  $ qemu-system-aarch64 -serial mon:stdio                                \
  -m 4G                                                                  \
  -M vmapple,uuid=6240349656165161789                                    \
  -bios /Sys*/Lib*/Fra*/Virtualization.f*/R*/AVPBooter.vmapple2.bin      \
  -pflash aux.img.trimmed                                                \
  -pflash disk.img                                                       \
  -drive file=disk.img,if=none,id=root                                   \
  -device vmapple-virtio-root,drive=root                                 \
  -drive file=aux.img.trimmed,if=none,id=aux                             \
  -device vmapple-virtio-aix,drive=aux                                   \
  -accel hvf

There are a few limitations with this implementation:

- Only runs on macOS because it relies on ParavirtualizesGraphics.Framework
- Something is not fully correct on interrupt delivery or similar - the keyboard does not work
- No Rosetta in the guest because we lack the private entitlement to enable TSO

Over time, I hope that some of the limitations above could cease to exist. This device model would enable very nice use cases with KVM on an Asahi Linux device.

Please beware that the vmapple device model only works with macOS 12 guests for now. Newer guests run into Hypervisor.Framework incompatibilities.

---

v1 -> v2:

- Adapt to system_ss meson.build target
- Add documentation
- Rework virtio-blk patch to make all vmapple virtio-blk logic subclasses
- Add log message on write
- Move max slot number to define
- Use SPDX header
- Remove useless includes

Alexander Graf (12):
build: Only define OS_OBJECT_USE_OBJC with gcc hw/misc/pvpanic: Add MMIO interface
hvf: Increase number of possible memory slots
hvf: arm: Ignore writes to CNTP_CTL_EL0
hw: Add vmapple subdir
gpex: Allow more than 4 legacy IRQs
hw/vmapple/aes: Introduce aes engine
hw/vmapple/bdif: Introduce vmapple backdoor interface hw/vmapple/cfg: Introduce vmapple cfg region hw/vmapple/apple-gfx: Introduce ParavirtualizedGraphics.Framework
support
hw/vmapple/virtio-blk: Add support for apple virtio-blk hw/vmapple/vmapple: Add vmapple machine type

 MAINTAINERS                     |   7 +
 docs/system/arm/vmapple.rst     |  68 ++++
 docs/system/target-arm.rst      |   1 +
 meson.build                     |   9 +-
 hw/vmapple/trace.h              |   1 +
 include/hw/misc/pvpanic.h       |   1 +
 include/hw/pci-host/gpex.h      |   7 +-
 include/hw/pci/pci_ids.h        |   1 +
 include/hw/virtio/virtio-blk.h  |  11 +-
 include/hw/vmapple/bdif.h       |  31 ++
 include/hw/vmapple/cfg.h        |  68 ++++
 include/hw/vmapple/virtio-blk.h |  39 ++
 include/sysemu/hvf_int.h        |   4 +-
 accel/hvf/hvf-accel-ops.c       |   2 +-
 hw/arm/sbsa-ref.c               |   2 +-
 hw/arm/virt.c                   |   2 +-
 hw/block/virtio-blk.c           |  18 +-
 hw/i386/microvm.c               |   2 +-
 hw/loongarch/virt.c             |   2 +-
 hw/mips/loongson3_virt.c        |   2 +-
 hw/misc/pvpanic-mmio.c          |  61 +++
 hw/openrisc/virt.c              |  12 +-
 hw/pci-host/gpex.c              |  36 +-
 hw/riscv/virt.c                 |  12 +-
 hw/vmapple/aes.c                | 583 ++++++++++++++++++++++++++++
 hw/vmapple/bdif.c               | 245 ++++++++++++
 hw/vmapple/cfg.c                | 105 +++++
 hw/vmapple/virtio-blk.c         | 212 ++++++++++
 hw/vmapple/vmapple.c            | 661 ++++++++++++++++++++++++++++++++
 hw/xtensa/virt.c                |   2 +-
 target/arm/hvf/hvf.c            |   9 +
 hw/Kconfig                      |   1 +
 hw/meson.build                  |   1 +
 hw/misc/Kconfig                 |   4 +
 hw/misc/meson.build             |   1 +
 hw/vmapple/Kconfig              |  33 ++
 hw/vmapple/apple-gfx.m          | 578 ++++++++++++++++++++++++++++
 hw/vmapple/meson.build          |   6 +
 hw/vmapple/trace-events         |  47 +++
 39 files changed, 2852 insertions(+), 35 deletions(-)
 create mode 100644 docs/system/arm/vmapple.rst
 create mode 100644 hw/vmapple/trace.h
 create mode 100644 include/hw/vmapple/bdif.h
 create mode 100644 include/hw/vmapple/cfg.h
 create mode 100644 include/hw/vmapple/virtio-blk.h
 create mode 100644 hw/misc/pvpanic-mmio.c
 create mode 100644 hw/vmapple/aes.c
 create mode 100644 hw/vmapple/bdif.c
 create mode 100644 hw/vmapple/cfg.c
 create mode 100644 hw/vmapple/virtio-blk.c
 create mode 100644 hw/vmapple/vmapple.c
 create mode 100644 hw/vmapple/Kconfig
 create mode 100644 hw/vmapple/apple-gfx.m
 create mode 100644 hw/vmapple/meson.build
 create mode 100644 hw/vmapple/trace-events
Signature · 12 lines
2.39.2 (Apple Git-143)




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879