New vmapple machine type and xhci fixes
v17 cover New vmapple machine type and xhci fixes
This patch set introduces a new ARM and macOS HVF specific machine type called "vmapple". There are also some patches for fixing XHCI spec compliance issues and adding a workaround to a quirk in the macOS guest's XHCI driver.
The vmapple machine type approximates the configuration in macOS's own Virtualization.framework when running arm64 macOS guests. In addition to generic components such as a GICv3 and an XHCI USB controller, it includes nonstandard extensions to the virtio block device, a special "hardware" aes engine, a configuration device, a pvpanic variant, a "backdoor" interface, and of course the apple-gfx paravirtualised display adapter.
The macOS guest initially did not work well with QEMU's XHCI controller, which required some investigation, bug fixing, and a work-around.
Essentially, the macOS driver attempts to use XHCI event rings 1 and 2 even when there is only a single pin-based interrupt available. The interrupts for rings 1 and 2 are dropped, and so events are only handled after a timeout. The driver appears to expect the device to act as if interrupter mapping was not supported - the spec only mentions that interrupter mapping should be disabled if only one interrupter is enabled, not one interrupt, although there is potential ambiguity in the spec's wording around enabling and disabling interrupters.
In any case, this investigation has led to 3 changes:
* The spec requires that modulo arithmetic be used for selecting the MSI vector to notify from the interrupter/event ring index. (Patch 1)
* The spec requires that all events be directed at ring 0 if interrupter mapping is not available; the condition for this mentioned in the spec is when there is only 1 interrupter available. (Patch 2)
* A property is added to the PCI XHCI controller classes to disable interrupter mapping when using pin-based interrupts. This makes the macOS guest drivers work. (Patch 9) This is enabled in the vmapple machine type, which does not offer MSI(-X) support.
There are currently a few limitations to the vmapple machine. These aren't intrinsic, just imperfect emulation of the VZF, but it's good enough to be just about usable for some purposes:
* macOS 12 guests only. Versions 13+ currently fail during early boot.
* macOS 11+ arm64 hosts only, with hvf accel. (Perhaps some differences between Apple M series CPUs and TCG's aarch64 implementation? macOS hosts only because ParavirtualizedGraphics.framework is a black box implementing most of the logic behind the apple-gfx device.)
* The guest OS must first be provisioned using Virtualization.framework; the disk images can subsequently be used in Qemu. (See docs.)
Previous versions of this series also included the macOS PV graphics device ("apple-gfx"); those patches have already been merged, so the title has been changed. Previous iteration:
https://patchew.org/QEMU/[email protected]/
Furthermore, the XHCI fixes and workaround were previously submitted as a separate patch set, of which a few patches have also been merged. "hw/usb/hcd-xhci: Fixes, improvements and macOS workaround"
https://patchew.org/QEMU/[email protected]/
Finally, I've included one of Philippe Mathieu-Daudé's GICv3 patches which arose out of the discovery that the software GICv3 dependency was missing when building v16 and earlier versions of this series in a HVF-only configuration.
https://patchew.org/QEMU/[email protected]/
---
v2 -> v3:
* Merged the apple-gfx and vmapple patchsets.
* Squashed a bunch of later apple-gfx patches into the main one. (dGPU support, queried MMIO area size, host GPU picking logic.)
* Rebased on latest upstream, fixing any breakages due to internal Qemu API changes.
* apple-gfx: Switched to re-entrant MMIO. This is supported by the underlying framework and simplifies the MMIO forwarding code which was previously different on x86-64 vs aarch64.
* vmapple: Fixes for minor bugs and comments from the last round of review.
* vmapple aes, conf, apple-gfx: Switched reset methods to implement the ResettableClass base's interface.
* vmapple: switched from virtio-hid to an XHCI USB controller and USB mouse and tablet devices. macOS does not provide drivers for virtio HID devices, at least not in version 12's vmapple kernel. So input now sort of works (interrupt issues) rather than not at all. Use network-based remote access to the guest OS as a work-around.
v3 -> v4:
* Complete rework of the mechanism for handling runloop/libdispatch events on the main thread. PV graphics now work with the SDL UI.
* Renamed 'apple-gfx-vmapple' device to 'apple-gfx-mmio'
* hw/display/apple-gfx: threading model overhaul to be more consistent, safer, and more QEMU-idiomatic.
* display-modes property on the apple-gfx devices now uses the native array property mechanism and works on both device variants.
* hw/vmapple/aes: Improvements to logging and error handling.
* hw/vmapple/cfg: Bug fixes around device property default values.
* hw/vmapple/{aes,cfg,virtio-blk/vmapple}: Most header code moved into .c files, only a single vmapple.h now contains the #defines for the vmapple machine model-specific device type names.
* hw/block/virtio-blk: New patch for replacing virtio_blk_free_request with g_free. (Optional)
* Various smaller changes following comments in v3 code review in apple-gfx, aes, cfg, bdif, virtio-blk-vmapple, and the vmapple machine type itself. See patch-specific v4 change notes for details.
v4 -> v5:
* Simplified the main thread runloop mechanism. Back to setting qemu_main directly, but narrowing the scope of what it needs to do, and it can now be NULL. (Meaning run the QEMU main event loop on the main thread as is traditional.)
* hw/display/apple-gfx: Further improvements to the BH based job code bridging the libdispatch & QEMU thread synchronisation impedance mismatch.
* hw/display/apple-gfx: Thread safety and object lifetime improvements.
* hw/display/apple-gfx-*: Better buffer and error handling in display mode property setters and getters.
* hw/vmapple/aes: More consistent and safer logging/tracing
* hw/vmapple/cfg: Better error reporting on overlong property strings.
* hw/vmapple/virtio-blk: Fixed theoretically-unaligned write to config buffer.
* vmapple machine type: Moved ecam region into machine state, improved device property setting error handling, improved ECID/UUID extraction script and docs.
* Various smaller fixes in apple-gfx/-mmio, apple-gfx-pci, vmapple/aes, vmapple/cfg, vmapple/virtio-blk, and vmapple machine type.
* Added SPDX license identifiers where they were missing.
v5 -> v6:
* 01/15 (main/Cocoa/runloop): Combined functions, fixed whitespace
* 02/15 (apple-gfx): Further refinement of PVG threading: reduced some callback tasks from BHs to merely acquiring RCU read lock; replaced some libdispatch tasks with BHs; last remaining synchronous BH now uses emphemeral QemuSemaphore.
* 02/15 (apple-gfx): Readability improvements and other smaller tweaks (see patch change notes for details)
* 04/15 (display modes): Replaced use of alloca() with NSMutableArray.
v6 -> v7:
* 02/15 (apple-gfx): Use g_ptr_array_find() helper function, coding style tweak
* 03/15 (apple-gfx-pci): Removed an unused function parameter
* 04/15 (apple-gfx display mode property): Simplified error handling in property parsing.
* 10/15 (vmapple/aes): Coding style tweaks.
* 12/15 (vmapple/cfg): Changed error messages for overrun of properties with fixed-length strings to be more useful to users than developers.
* 15/15 (vmapple machine type): Tiny error handling fix, un-inlined function
v7 -> v8:
* 02/15 (apple-gfx): Naming and type use improvements, fixes for a bug and a leak.
* 04/15 (apple-gfx display mode property): Type use improvement
* 10/15 (vmapple/aes): Guest error logging tweaks.
* 11/15 (vmapple/bdif): Replaced uses of cpu_physical_memory_read with dma_memory_read, and a g_free call with g_autofree.
* 12/15 (vmapple/cfg): Macro hygiene fix: consistently enclosing arguments in parens.
* 15/15 (vmapple machine type): Use less verbose pattern for defining uuid property.
v8 -> v9:
* 01/16 (ui & main loop): Set qemu_main to NULL for GTK UI as well.
* 02/16 (apple-gfx): Pass device pointer to graphic_console_init(), various non-functional changes.
* 03/16 (apple-gfx-pci): Fixup of changed common call, whitespace and comment formatting tweaks.
* 04/16 (apple-gfx display modes): Re-ordered type definitions so we can drop a 'struct' keyword.
* 10/16 (vmapple/aes): Replaced a use of cpu_physical_memory_write with dma_memory_write, minor style tweak.
* 11/16 (vmapple/bdif): Replaced uses of cpu_physical_memory_write with dma_memory_write.
* 13/16 (vmapple/virtio-blk): Correctly specify class_size for VMAppleVirtIOBlkClass.
* 15/16 (vmapple machine type): Documentation improvements, fixed variable name and struct field used during pvpanic device creation.
* 16/16 (NEW/RFC vmapple/virtio-blk): Proposed change to replace type hierarchy with a variant property. This seems cleaner and less confusing than the original approach to me, but I'm not sure if it warrants creation of a new QAPI enum and property type definition.
v9 -> v10:
* 01/15 (ui & main loop): Added comments to qemu_main declaration and GTK.
* 02/15 (apple-gfx): Reworked the way frame rendering code is threaded to use BHs for sections requiring BQL.
* 02/15 (apple-gfx): Fixed ./configure error on non-macOS platforms.
* 10/15 (vmapple/aes): Code style and comment improvements.
* 12/15 (vmapple/cfg): Slightly tidier error reporting for overlong property values.
* 13/15 (vmapple/virtio-blk): Folded v9 patch 16/16 into this one, changing the device type design to provide a single device type with a variant property instead of 2 different subtypes for aux and root volumes.
* 15/15 (vmapple machine type): Documentation fixup for changed virtio-blk device type; small improvements to shell commands in documentation; improved propagation of errors during cfg device instantiation.
v10 -> v11:
* 01/15 (ui & main loop): Simplified main.c, better comments & commit message
* 02/15 (apple-gfx): Give each PV display instance a unique serial number.
* 02 & 03/15 (apple-gfx, -pci): Formatting/style tweaks
* 15/15 (vmapple machine type): Improvements to shell code in docs
v11 -> v12:
* 01/15 (ui & main loop): More precise wording of code comments.
* 02/15 (apple-gfx): Fixed memory management regressions introduced in v10; improved error handling; various more conmetic code adjustments
* 09/15 (GPEX): Fixed uses of deleted GPEX_NUM_IRQS constant that have been added to QEMU since this patch was originally written.
v12 -> v13:
* 15/15 (vmapple machine type): Bumped the machine type version from 9.2 to 10.0.
* All patches in the series now have been positively reviewed and received corresponding reviewed-by tags.
v13 -> v14:
* 6/15 (hw/vmapple directory): Changed myself from reviewer to maintainer, as that seemed appropriate at this point.
* 15/15 (vmapple machine type): Gate creation of XHCI and USB HID devices behind if (defaults_enabled()).
v14 -> v15
* Constified property tables to match Richard Henderson's recent project- wide convention change. (patches 4/15, 7/15, 11/15, 12/15, & 13/15)
v15 -> v16
* 14 patches now, as patch 8 has already been pulled. (Thanks Philippe!)
* Fixed a bunch of conflicts with upstream code motion:
- DEFINE_PROP_END_OF_LIST removal (4/14 - apple-gfx mode list, 7/14 -
pvpanic-mmio, 10/14 - bdif, 11/14 - cfg device, and
12/14 - vmapple-virtio-blk)
- sysemu->system move/rename: (1/14 - ui/qemu-main, 2/14 - apple-gfx,
9/14 - aes, 10/14 - bdif, 14/14 - vmapple machine type) * 14/14 (vmapple machine type):
- Moved compatibility setting for removing legacy mode from virtio-pci to proper global property table rather than (ab)using sugar property.
- Removed a few superfluous #includes during sysemu rename cleanup.
- Removed machine type versioning as it's not necessary (yet?)
- Made memory map array const
XHCI RFC -> v1:
* Gated conditional interrupter mapping support behind a property, enabled that property in the VMApple machine type.
* Added patch to fix the MSI vector assertion failure.
* Moved msi and msix properties from NEC XHCI controller to generic xhci-pci superclass as that also seems useful.
* Broke the workaround up into 2 patches, one for mapping disabling required by the standard, and one for the conditional disabling workaround.
XHCI v1 -> v2:
* 1/6: Switch to modulo arithmetic for MSI vector number, as per spec.
* 6/6: Set the "conditional-intr-mapping" property via compat_props.
* Commit message tweaks
XHCI v2 -> v3:
* 2/6: In line with recent upstream changes, the property table is now const and no longer carries an end-of-list marker.
* The indentation fix (previously 5/6) has already been merged, so is no longer included.
* Added patch fixing up logging of certain unhandled MMIO cases. (4/6)
* 6/6: Moved the compat global property table into vmapple patch set -v16; we now just add the conditional-intr-mapping property to it in this patch. We also set the property on any device implementing the abstract TYPE_XHCI_PCI rather than only the TYPE_QEMU_XHCI device specifically.
v16 -> v17
* Rebased on latest upstream (with minor conflict fixes)
* apple-gfx, GPEX, and ui/cocoa patches dropped as they have been merged.
* Unmerged patches from xhci series v3 combined into this series.
* vmapple machine type: Explicitly depend on software GICv3.
* vmapple machine type: Enable the new XHCI PCI conditional-intr-mapping property via the machine type's global compat property table.
* Integrated Philippe's patch on renaming the GICv3's confusing config name, and removing its TCG dependency. (It's needed with HVF too.)
* vmapple machine type: Dropped Tested-by tag because of above changes
Alexander Graf (7):
hw: Add vmapple subdir
hw/misc/pvpanic: Add MMIO interface hw/vmapple/aes: Introduce aes engine hw/vmapple/bdif: Introduce vmapple backdoor interface hw/vmapple/cfg: Introduce vmapple cfg region hw/vmapple/virtio-blk: Add support for apple virtio-blk hw/vmapple/vmapple: Add vmapple machine type
Phil Dennis-Jordan (3):
hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported hw/usb/hcd-xhci-pci: Adds property for disabling mapping in IRQ mode
Philippe Mathieu-Daudé (1):
hw/intc: Remove TCG dependency on ARM_GICV3
MAINTAINERS | 8 + contrib/vmapple/uuid.sh | 9 + docs/system/arm/vmapple.rst | 63 +++ docs/system/target-arm.rst | 1 + hw/Kconfig | 1 + hw/block/virtio-blk.c | 19 +- hw/core/qdev-properties-system.c | 8 + hw/intc/Kconfig | 6 +- hw/intc/meson.build | 4 +- hw/meson.build | 1 + hw/misc/Kconfig | 4 + hw/misc/meson.build | 1 + hw/misc/pvpanic-mmio.c | 60 +++ hw/usb/hcd-xhci-pci.c | 25 ++ hw/usb/hcd-xhci-pci.h | 1 + hw/usb/hcd-xhci.c | 5 + hw/usb/hcd-xhci.h | 5 + hw/vmapple/Kconfig | 32 ++ hw/vmapple/aes.c | 581 ++++++++++++++++++++++++++ hw/vmapple/bdif.c | 274 ++++++++++++ hw/vmapple/cfg.c | 195 +++++++++ hw/vmapple/meson.build | 5 + hw/vmapple/trace-events | 21 + hw/vmapple/trace.h | 1 + hw/vmapple/virtio-blk.c | 204 +++++++++ hw/vmapple/vmapple.c | 618 ++++++++++++++++++++++++++++ include/hw/misc/pvpanic.h | 1 + include/hw/pci/pci_ids.h | 1 + include/hw/qdev-properties-system.h | 5 + include/hw/virtio/virtio-blk.h | 11 +- include/hw/vmapple/vmapple.h | 23 ++ include/qemu/cutils.h | 15 + meson.build | 1 + qapi/virtio.json | 14 + util/hexdump.c | 18 + 35 files changed, 2231 insertions(+), 10 deletions(-) create mode 100755 contrib/vmapple/uuid.sh create mode 100644 docs/system/arm/vmapple.rst create mode 100644 hw/misc/pvpanic-mmio.c create mode 100644 hw/vmapple/Kconfig 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/meson.build create mode 100644 hw/vmapple/trace-events create mode 100644 hw/vmapple/trace.h create mode 100644 hw/vmapple/virtio-blk.c create mode 100644 hw/vmapple/vmapple.c create mode 100644 include/hw/vmapple/vmapple.h
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH v17 1/11 hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec
QEMU would crash with a failed assertion if the XHCI controller attempted to raise the interrupt on an interrupter corresponding to a MSI vector with a higher index than the highest configured for the device by the guest driver.
This behaviour is correct on the MSI/PCI side: per PCI 3.0 spec, devices must ensure they do not send MSI notifications for vectors beyond the range of those allocated by the system/driver software. Unlike MSI-X, there is no generic way for handling aliasing in the case of fewer allocated vectors than requested, so the specifics are up to device implementors. (Section 6.8.3.4. "Sending Messages")
It turns out the XHCI spec (Implementation Note in section 4.17, "Interrupters") requires that the host controller signal the MSI vector with the number computed by taking the interrupter number modulo the number of enabled MSI vectors.
This change introduces that modulo calculation, fixing the failed assertion. This makes the device work correctly in MSI mode with macOS's XHCI driver, which only allocates a single vector.
---
v2:
* Switch to modulo arithmetic for MSI vector number rather than dropping, as per spec.
hw/usb/hcd-xhci-pci.c | 1 + 1 file changed, 1 insertion(+)
hw/usb/hcd-xhci-pci.c +1 -0
@@ -74,6 +74,7 @@ static bool xhci_pci_intr_raise(XHCIState *xhci, int n, bool level) }if (msi_enabled (pci_dev) && level) { + n %=msi_nr_vectors_allocated (pci_dev);msi_notify (pci_dev, n);return true; }
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH v17 2/11 hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported
In reply to Phil Dennis-JordanThe XHCI specification, section 4.17.1 specifies that "If the Number of Interrupters (MaxIntrs) field is greater than 1, then Interrupter Mapping shall be supported." and "If Interrupter Mapping is not supported, the Interrupter Target field shall be ignored by the xHC and all Events targeted at Interrupter 0."
QEMU's XHCI device has so far not specially addressed this case, so we add a check to xhci_event() to redirect to event ring and interrupt 0 if mapping is disabled.
--- hw/usb/hcd-xhci.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/usb/hcd-xhci.c +4 -0
@@ -644,6 +644,10 @@ static void xhci_event(XHCIState *xhci, XHCIEvent *event, int v)dma_addr_t erdp;unsigned int dp_idx; +if (xhci->numintrs ==1 ) { + v =0 ; + } +if (v >= xhci->numintrs) {DPRINTF ("intr nr out of range (%d >= %d)\n" , v, xhci->numintrs);return ;
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH v17 3/11 hw: Add vmapple subdir
In reply to Phil Dennis-JordanFrom: Alexander Graf <[email protected]>
We will introduce a number of devices that are specific to the vmapple target machine. To keep them all tidily together, let's put them into a single target directory.
--- MAINTAINERS | 7 +++++++ hw/Kconfig | 1 + hw/meson.build | 1 + hw/vmapple/Kconfig | 1 + hw/vmapple/meson.build | 0 hw/vmapple/trace-events | 2 ++ hw/vmapple/trace.h | 1 + meson.build | 1 + 8 files changed, 14 insertions(+) create mode 100644 hw/vmapple/Kconfig create mode 100644 hw/vmapple/meson.build create mode 100644 hw/vmapple/trace-events create mode 100644 hw/vmapple/trace.h
MAINTAINERS +7 -0
@@ -2785,6 +2785,13 @@ F: hw/hyperv/hv-balloon*.h F: include/hw/hyperv/dynmem-proto.h F: include/hw/hyperv/hv-balloon.h +VMapple +M: Alexander Graf <[email protected]> +M: Phil Dennis-Jordan <[email protected]> +S: Maintained +F: hw/vmapple/* +F: include/hw/vmapple/* + Subsystems ---------- Overall Audio backends
hw/Kconfig +1 -0
@@ -41,6 +41,7 @@ source ufs/Kconfig source usb/Kconfig source virtio/Kconfig source vfio/Kconfig +source vmapple/Kconfig source xen/Kconfig source watchdog/Kconfig
hw/meson.build +1 -0
@@ -39,6 +39,7 @@ subdir('ufs') subdir('usb') subdir('vfio') subdir('virtio') +subdir('vmapple') subdir('watchdog') subdir('xen') subdir('xenpv')
hw/vmapple/Kconfig new file +1 -0
@@ -0,0 +1 @@ +
hw/vmapple/meson.build new file +0 -0
hw/vmapple/trace-events new file +2 -0
@@ -0,0 +1,2 @@ +# See docs/devel/tracing.rst for syntax documentation. +
hw/vmapple/trace.h new file +1 -0
@@ -0,0 +1 @@ +#include "trace/trace-hw_vmapple.h"
meson.build +1 -0
@@ -3588,6 +3588,7 @@ if have_system 'hw/usb', 'hw/vfio', 'hw/virtio', + 'hw/vmapple', 'hw/watchdog', 'hw/xen', 'hw/gpio',
Signature · 1 line
2.39.5 (Apple Git-154)
Re: [PATCH v17 03/11] hw: Add vmapple subdir
Quoted 56 lines · Phil Dennis-Jordan
From: Alexander Graf <[email protected]>
We will introduce a number of devices that are specific to the vmapple target machine. To keep them all tidily together, let's put them into a single target directory.
Signed-off-by Alexander Graf <[email protected]>Signed-off-by Phil Dennis-Jordan <[email protected]>Reviewed-by Akihiko Odaki <[email protected]>Tested-by Akihiko Odaki <[email protected]>--- MAINTAINERS | 7 +++++++ hw/Kconfig | 1 + hw/meson.build | 1 + hw/vmapple/Kconfig | 1 + hw/vmapple/meson.build | 0 hw/vmapple/trace-events | 2 ++ hw/vmapple/trace.h | 1 + meson.build | 1 + 8 files changed, 14 insertions(+)create mode 100644 hw/vmapple/Kconfig
create mode 100644 hw/vmapple/meson.build
create mode 100644 hw/vmapple/trace-events
create mode 100644hw/vmapple/trace.hhw/vmapple/Kconfig new file +1
-0@@ -0,0 +1 @@ +hw/vmapple/meson.build new file +0
-0hw/vmapple/trace-events new file +2
-0@@ -0,0 +1,2 @@ +# See docs/devel/tracing.rst for syntax documentation. +hw/vmapple/trace.h new file +1
-0@@ -0,0 +1 @@ +#include "trace/trace-hw_vmapple.h" meson.build +0
-0
meson.build if have_system · line 3594
Quoted 7 lines
meson.build +1
-0@@ -3588,6 +3588,7 @@ if have_system 'hw/usb', 'hw/vfio', 'hw/virtio', + 'hw/vmapple', 'hw/watchdog', 'hw/xen', 'hw/gpio',
Alex, Phil, we now mandate a SPDX tag. Due to the license used in vmapple.c in this patch, are you OK with me squashing here:
-- >8 --
hw/vmapple/trace.h +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
hw/vmapple/Kconfig +1 -1
@@ -1 +1 @@ - +# SPDX-License-Identifier: GPL-2.0-or-later
hw/vmapple/meson.build +1 -0
@@ -0,0 +1 @@ +# SPDX-License-Identifier: GPL-2.0-or-later
hw/vmapple/trace-events +1 -1
@@ -2 +2 @@ - +# SPDX-License-Identifier: GPL-2.0-or-later
---
?
PATCH v17 4/11 hw/misc/pvpanic: Add MMIO interface
In reply to Phil Dennis-JordanFrom: Alexander Graf <[email protected]>
In addition to the ISA and PCI variants of pvpanic, let's add an MMIO platform device that we can use in embedded arm environments.
---
v3:
* Rebased on upstream, updated a header path
v15:
* Constified the property table.
v16:
* Removed the DEFINE_PROP_END_OF_LIST marker to match recent upstream changes.
hw/misc/Kconfig | 4 +++ hw/misc/meson.build | 1 + hw/misc/pvpanic-mmio.c | 60 +++++++++++++++++++++++++++++++++++++++ include/hw/misc/pvpanic.h | 1 + 4 files changed, 66 insertions(+) create mode 100644 hw/misc/pvpanic-mmio.c
hw/misc/Kconfig +4 -0
@@ -150,6 +150,10 @@ config PVPANIC_ISA depends on ISA_BUS select PVPANIC_COMMON +config PVPANIC_MMIO + bool + select PVPANIC_COMMON + config AUX bool select I2C
hw/misc/meson.build +1 -0
@@ -124,6 +124,7 @@ system_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c')) system_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c')) system_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c')) +system_ss.add(when: 'CONFIG_PVPANIC_MMIO', if_true: files('pvpanic-mmio.c')) system_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c')) system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files( 'aspeed_hace.c',
hw/misc/pvpanic-mmio.c new file +60 -0
60 lines not on this page · raw message
include/hw/misc/pvpanic.h +1 -0
@@ -26,6 +26,7 @@#define TYPE_PVPANIC_ISA_DEVICE "pvpanic"#define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci" +#define TYPE_PVPANIC_MMIO_DEVICE "pvpanic-mmio"#define PVPANIC_IOPORT_PROP "ioport"
Signature · 1 line
2.39.5 (Apple Git-154)
Re: [PATCH v17 04/11] hw/misc/pvpanic: Add MMIO interface
Quoted 19 lines · Phil Dennis-Jordan
From: Alexander Graf <[email protected]>
In addition to the ISA and PCI variants of pvpanic, let's add an MMIO platform device that we can use in embedded arm environments.
Signed-off-by Alexander Graf <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Phil Dennis-Jordan <[email protected]>Reviewed-by Akihiko Odaki <[email protected]>Tested-by Akihiko Odaki <[email protected]>---
v3:
* Rebased on upstream, updated a header pathv15:
* Constified the property table.
Quoted 7 lines
v16:
* Removed theDEFINE_PROP_END_OF_LISTmarker to match recent upstream changes.hw/misc/Kconfig | 4 +++ hw/misc/meson.build | 1 + hw/misc/pvpanic-mmio.c | 60 +++++++++++++++++++++++++++++++++++++++
Missing MAINTAINERS update, who is going to maintain this file?
I could add it within the vmapple section in the next patch, but I'd rather pvpanic have its own entry covering all variants.
Quoted 3 lines
include/hw/misc/pvpanic.h | 1 + 4 files changed, 66 insertions(+)create mode 100644
hw/misc/pvpanic-mmio.c
Re: [PATCH v17 04/11] hw/misc/pvpanic: Add MMIO interface
Quoted 24 lines · Philippe Mathieu-Daudé
Quoted 23 lines · Phil Dennis-Jordan
From: Alexander Graf <[email protected]>
In addition to the ISA and PCI variants of pvpanic, let's add an MMIO platform device that we can use in embedded arm environments.
Signed-off-by Alexander Graf <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Phil Dennis-Jordan <[email protected]>Reviewed-by Akihiko Odaki <[email protected]>Tested-by Akihiko Odaki <[email protected]>---
v3:
* Rebased on upstream, updated a header pathv15:
* Constified the property table.v16:
* Removed theDEFINE_PROP_END_OF_LISTmarker to match recent upstream changes.
Quoted 5 lines
Quoted 3 lines
hw/misc/Kconfig | 4 +++ hw/misc/meson.build | 1 + hw/misc/pvpanic-mmio.c | 60 +++++++++++++++++++++++++++++++++++++++Missing
MAINTAINERSupdate, who is going to maintain this file?
Good spot!
Quoted 2 lines
I could add it within the vmapple section in the next patch, but I'd rather pvpanic have its own entry covering all variants.
You're welcome to put me down as a maintainer on this.
Thanks for taking another look at this series and helping to get it merged!
Quoted 5 lines
Quoted 3 lines
include/hw/misc/pvpanic.h | 1 + 4 files changed, 66 insertions(+)create mode 100644
hw/misc/pvpanic-mmio.c
PATCH v17 5/11 hw/vmapple/aes: Introduce aes engine
In reply to Phil Dennis-JordanFrom: Alexander Graf <[email protected]>
VMApple contains an "aes" engine device that it uses to encrypt and decrypt its nvram. It has trivial hard coded keys it uses for that purpose.
Add device emulation for this device model.
---
v3:
* Rebased on latest upstream and fixed minor breakages.
* Replaced legacy device reset method with Resettable method
v4:
* Improved logging of unimplemented functions and guest errors.
* Better adherence to naming and coding conventions.
* Cleaner error handling and recovery, including using g_autoptr
v5:
* More logging improvements
* Use xxx64_overflow() functions for hexdump buffer size calculations.
v7:
* Coding style tweaks.
v8:
* Further improved logging of guest errors.
v9:
* Replaced a use of cpu_physical_memory_write with dma_memory_write.
* Dropped unnecessary use of ternary operator for bool -> 0/1.
v10:
* Code style and comment improvements.
v16:
* Fixed #include path breakage from recent sysemu->system path rename.
hw/vmapple/Kconfig | 2 + hw/vmapple/aes.c | 581 +++++++++++++++++++++++++++++++++++ hw/vmapple/meson.build | 1 + hw/vmapple/trace-events | 14 + include/hw/vmapple/vmapple.h | 17 + include/qemu/cutils.h | 15 + util/hexdump.c | 18 ++ 7 files changed, 648 insertions(+) create mode 100644 hw/vmapple/aes.c create mode 100644 include/hw/vmapple/vmapple.h
hw/vmapple/Kconfig +2 -0
@@ -1 +1,3 @@ +config VMAPPLE_AES + bool
hw/vmapple/aes.c new file +581 -0
581 lines not on this page · raw message
hw/vmapple/meson.build +1 -0
@@ -0,0 +1 @@ +system_ss.add(when: 'CONFIG_VMAPPLE_AES', if_true: files('aes.c'))
hw/vmapple/trace-events +14 -0
@@ -1,2 +1,16 @@ # See docs/devel/tracing.rst for syntax documentation. +# aes.c +aes_read(uint64_t offset, uint64_t res) "offset=0x%"PRIx64" res=0x%"PRIx64 +aes_cmd_key_select_builtin(uint32_t ctx, uint32_t key_id, const char *direction, const char *cipher) "[%d] Selecting builtin key %d to %scrypt with %s" +aes_cmd_key_select_new(uint32_t ctx, uint32_t key_len, const char *direction, const char *cipher) "[%d] Selecting new key size=%d to %scrypt with %s" +aes_cmd_iv(uint32_t ctx, uint32_t iv0, uint32_t iv1, uint32_t iv2, uint32_t iv3) "[%d] 0x%08x 0x%08x 0x%08x 0x%08x" +aes_cmd_data(uint32_t key, uint32_t iv, uint64_t src, uint64_t dst, uint32_t len) "[key=%d iv=%d] src=0x%"PRIx64" dst=0x%"PRIx64" len=0x%x" +aes_cmd_store_iv(uint32_t ctx, uint64_t addr, uint32_t iv0, uint32_t iv1, uint32_t iv2, uint32_t iv3) "[%d] addr=0x%"PRIx64"x -> 0x%08x 0x%08x 0x%08x 0x%08x" +aes_cmd_flag(uint32_t raise, uint32_t flag_info) "raise=%d flag_info=0x%x" +aes_fifo_process(uint32_t cmd, bool success) "cmd=%d success=%d" +aes_write(uint64_t offset, uint64_t val) "offset=0x%"PRIx64" val=0x%"PRIx64 +aes_2_read(uint64_t offset, uint64_t res) "offset=0x%"PRIx64" res=0x%"PRIx64 +aes_2_write(uint64_t offset, uint64_t val) "offset=0x%"PRIx64" val=0x%"PRIx64 +aes_dump_data(const char *desc, const char *hex) "%s%s" +
include/hw/vmapple/vmapple.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* Devices specific to the VMApple machine type +* +* Copyright © 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_VMAPPLE_VMAPPLE_H +#define HW_VMAPPLE_VMAPPLE_H + +#define TYPE_APPLE_AES "apple-aes" + +#endif /* HW_VMAPPLE_VMAPPLE_H */
include/qemu/cutils.h +15 -0
@@ -302,4 +302,19 @@ GString *qemu_hexdump_line(GString *str, const void *buf, size_t len,void qemu_hexdump (FILE *fp,const char *prefix,const void *bufptr,size_t size); +/** +* qemu_hexdump_to_buffer: +* @buffer: output string buffer +* @buffer_size: amount of available space in buffer. Must be at least +* data_size*2+1. +* @data: input bytes +* @data_size: number of bytes in data +* +* Converts the @data_size bytes in @data into hex digit pairs, writing them to +* @buffer. Finally, a nul terminating character is written; @buffer therefore +* needs space for (data_size*2+1) chars. +*/ +void qemu_hexdump_to_buffer (char *restrict buffer,size_t buffer_size, +const uint8_t *restrict data,size_t data_size); +#endif
util/hexdump.c +18 -0
@@ -15,6 +15,7 @@#include "qemu/osdep.h" #include "qemu/cutils.h" +#include "qemu/host-utils.h" static inline char hexdump_nibble (unsigned x) {
@@ -97,3 +98,20 @@ void qemu_hexdump(FILE *fp, const char *prefix, } } + +void qemu_hexdump_to_buffer (char *restrict buffer,size_t buffer_size, +const uint8_t *restrict data,size_t data_size) +{ +size_t i; +uint64_t required_buffer_size; +bool overflow =umul64_overflow (data_size,2 , &required_buffer_size); + overflow |=uadd64_overflow (required_buffer_size,1 , &required_buffer_size); +assert (!overflow && buffer_size >= required_buffer_size); + +for (i =0 ; i < data_size; i++) { +uint8_t val = data[i]; + *(buffer++) =hexdump_nibble (val >>4 ); + *(buffer++) =hexdump_nibble (val &0xf ); + } + *buffer ='\0' ; +}
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH v17 6/11 hw/vmapple/bdif: Introduce vmapple backdoor interface
In reply to Phil Dennis-JordanFrom: Alexander Graf <[email protected]>
The VMApple machine exposes AUX and ROOT block devices (as well as USB OTG emulation) via virtio-pci as well as a special, simple backdoor platform device.
This patch implements this backdoor platform device to the best of my understanding. I left out any USB OTG parts; they're only needed for guest recovery and I don't understand the protocol yet.
---
v4:
* Moved most header code to .c, rest to vmapple.h
* Better compliance with coding, naming, and formatting conventions.
v8:
* Replaced uses of cpu_physical_memory_read with dma_memory_read.
* Replaced an instance of g_free with g_autofree.
v9:
* Replaced uses of cpu_physical_memory_write with dma_memory_write.
v15:
* Constified the property table.
v16:
* Fixed #include path breakage from recent sysemu->system path rename.
* Removed the DEFINE_PROP_END_OF_LIST marker to match recent upstream changes.
hw/vmapple/Kconfig | 3 + hw/vmapple/bdif.c | 274 +++++++++++++++++++++++++++++++++++ hw/vmapple/meson.build | 1 + hw/vmapple/trace-events | 5 + include/hw/vmapple/vmapple.h | 2 + 5 files changed, 285 insertions(+) create mode 100644 hw/vmapple/bdif.c
hw/vmapple/Kconfig +3 -0
@@ -1,3 +1,6 @@ config VMAPPLE_AES bool +config VMAPPLE_BDIF + bool +
hw/vmapple/bdif.c new file +274 -0
274 lines not on this page · raw message
hw/vmapple/meson.build +1 -0
@@ -1 +1,2 @@ system_ss.add(when: 'CONFIG_VMAPPLE_AES', if_true: files('aes.c')) +system_ss.add(when: 'CONFIG_VMAPPLE_BDIF', if_true: files('bdif.c'))
hw/vmapple/trace-events +5 -0
@@ -14,3 +14,8 @@ aes_2_read(uint64_t offset, uint64_t res) "offset=0x%"PRIx64" res=0x%"PRIx64 aes_2_write(uint64_t offset, uint64_t val) "offset=0x%"PRIx64" val=0x%"PRIx64 aes_dump_data(const char *desc, const char *hex) "%s%s" +# bdif.c +bdif_read(uint64_t offset, uint32_t size, uint64_t value) "offset=0x%"PRIx64" size=0x%x value=0x%"PRIx64 +bdif_write(uint64_t offset, uint32_t size, uint64_t value) "offset=0x%"PRIx64" size=0x%x value=0x%"PRIx64 +bdif_vblk_read(const char *dev, uint64_t addr, uint64_t offset, uint32_t len, int r) "dev=%s addr=0x%"PRIx64" off=0x%"PRIx64" size=0x%x r=%d" +
include/hw/vmapple/vmapple.h +2 -0
@@ -14,4 +14,6 @@#define TYPE_APPLE_AES "apple-aes" +#define TYPE_VMAPPLE_BDIF "vmapple-bdif" +#endif /* HW_VMAPPLE_VMAPPLE_H */
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH v17 7/11 hw/vmapple/cfg: Introduce vmapple cfg region
In reply to Phil Dennis-JordanFrom: Alexander Graf <[email protected]>
Instead of device tree or other more standardized means, VMApple passes platform configuration to the first stage boot loader in a binary encoded format that resides at a dedicated RAM region in physical address space.
This patch models this configuration space as a qdev device which we can then map at the fixed location in the address space. That way, we can influence and annotate all configuration fields easily.
---
v3:
* Replaced legacy device reset method with Resettable method
v4:
* Fixed initialisation of default values for properties
* Dropped superfluous endianness conversions
* Moved most header code to .c, device name #define goes in vmapple.h
v5:
* Improved error reporting in case of string property buffer overflow.
v7:
* Changed error messages for overrun of properties with fixed-length strings to be more useful to users than developers.
v8:
* Consistent parenthesising of macro arguments for better safety.
v10:
* Slightly tidier error reporting for overlong property values.
v15:
* Constified the property table.
v16:
* Removed the DEFINE_PROP_END_OF_LIST marker to match recent upstream changes.
hw/vmapple/Kconfig | 3 + hw/vmapple/cfg.c | 195 +++++++++++++++++++++++++++++++++++ hw/vmapple/meson.build | 1 + include/hw/vmapple/vmapple.h | 2 + 4 files changed, 201 insertions(+) create mode 100644 hw/vmapple/cfg.c
hw/vmapple/Kconfig +3 -0
@@ -4,3 +4,6 @@ config VMAPPLE_AES config VMAPPLE_BDIF bool +config VMAPPLE_CFG + bool +
hw/vmapple/cfg.c new file +195 -0
195 lines not on this page · raw message
hw/vmapple/meson.build +1 -0
@@ -1,2 +1,3 @@ system_ss.add(when: 'CONFIG_VMAPPLE_AES', if_true: files('aes.c')) system_ss.add(when: 'CONFIG_VMAPPLE_BDIF', if_true: files('bdif.c')) +system_ss.add(when: 'CONFIG_VMAPPLE_CFG', if_true: files('cfg.c'))
include/hw/vmapple/vmapple.h +2 -0
@@ -16,4 +16,6 @@#define TYPE_VMAPPLE_BDIF "vmapple-bdif" +#define TYPE_VMAPPLE_CFG "vmapple-cfg" +#endif /* HW_VMAPPLE_VMAPPLE_H */
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH v17 8/11 hw/vmapple/virtio-blk: Add support for apple virtio-blk
In reply to Phil Dennis-JordanFrom: Alexander Graf <[email protected]>
Apple has its own virtio-blk PCI device ID where it deviates from the official virtio-pci spec slightly: It puts a new "apple type" field at a static offset in config space and introduces a new barrier command.
This patch first creates a mechanism for virtio-blk downstream classes to handle unknown commands. It then creates such a downstream class and a new vmapple-virtio-blk-pci class which support the additional apple type config identifier as well as the barrier command.
The 'aux' or 'root' device type are selected using the 'variant' property.
v4:
* Use recommended object type declaration pattern.
* Correctly log unimplemented code paths.
* Most header code moved to .c, type name #defines moved to vmapple.h
v5:
* Corrected handling of potentially unaligned writes to virtio config area.
* Simplified passing through device variant type to subobject.
v9:
* Correctly specify class_size for VMAppleVirtIOBlkClass
v10:
* Folded v9 patch 16/16 into this one, changing the device type design to provide a single device type with a variant property instead of 2 different subtypes for aux and root volumes.
* Tidied up error reporting for the variant property.
v15:
* Constified the property table.
v16:
* Removed the DEFINE_PROP_END_OF_LIST marker to match recent upstream changes.
--- hw/block/virtio-blk.c | 19 ++- hw/core/qdev-properties-system.c | 8 ++ hw/vmapple/Kconfig | 3 + hw/vmapple/meson.build | 1 + hw/vmapple/virtio-blk.c | 204 ++++++++++++++++++++++++++++ include/hw/pci/pci_ids.h | 1 + include/hw/qdev-properties-system.h | 5 + include/hw/virtio/virtio-blk.h | 11 +- include/hw/vmapple/vmapple.h | 2 + qapi/virtio.json | 14 ++ 10 files changed, 263 insertions(+), 5 deletions(-) create mode 100644 hw/vmapple/virtio-blk.c
hw/block/virtio-blk.c +15 -4
@@ -50,7 +50,7 @@ static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq, req->mr_next =NULL ; } -static void virtio_blk_req_complete (VirtIOBlockReq *req,unsigned char status) +void virtio_blk_req_complete (VirtIOBlockReq *req,unsigned char status) {VirtIOBlock *s = req->dev;VirtIODevice *vdev =VIRTIO_DEVICE (s);
@@ -71,7 +71,7 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)static int virtio_blk_handle_rw_error (VirtIOBlockReq *req,int error,bool is_read,bool acct_failed) { -VirtIOBlock *s = req->dev; +VirtIOBlock *s = req->dev;BlockErrorAction action =blk_get_error_action (s->blk, is_read, error);if (action ==BLOCK_ERROR_ACTION_STOP ) {
@@ -961,8 +961,18 @@ static int virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)break ; }default : -virtio_blk_req_complete (req,VIRTIO_BLK_S_UNSUPP ); -g_free (req); + { +/* +* Give subclasses a chance to handle unknown requests. This way the +* class lookup is not in the hot path. +*/ +VirtIOBlkClass *vbk =VIRTIO_BLK_GET_CLASS (s); +if (!vbk->handle_unknown_request || + !vbk->handle_unknown_request (req, mrb, type)) { +virtio_blk_req_complete (req,VIRTIO_BLK_S_UNSUPP ); +g_free (req); + } + } }return 0 ; }
@@ -2038,6 +2048,7 @@ static const TypeInfo virtio_blk_info = { .instance_size = sizeof(VirtIOBlock), .instance_init = virtio_blk_instance_init, .class_init = virtio_blk_class_init, + .class_size = sizeof(VirtIOBlkClass), };static void virtio_register_types (void )
hw/core/qdev-properties-system.c +8 -0
@@ -1283,3 +1283,11 @@ const PropertyInfo qdev_prop_iothread_vq_mapping_list = { .set = set_iothread_vq_mapping_list, .release = release_iothread_vq_mapping_list, }; + +const PropertyInfo qdev_prop_vmapple_virtio_blk_variant = { + .name ="VMAppleVirtioBlkVariant" , + .enum_table = &VMAppleVirtioBlkVariant_lookup, + .get = qdev_propinfo_get_enum, + .set = qdev_propinfo_set_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, +};
hw/vmapple/Kconfig +3 -0
@@ -7,3 +7,6 @@ config VMAPPLE_BDIF config VMAPPLE_CFG bool +config VMAPPLE_VIRTIO_BLK + bool +
hw/vmapple/meson.build +1 -0
@@ -1,3 +1,4 @@ system_ss.add(when: 'CONFIG_VMAPPLE_AES', if_true: files('aes.c')) system_ss.add(when: 'CONFIG_VMAPPLE_BDIF', if_true: files('bdif.c')) system_ss.add(when: 'CONFIG_VMAPPLE_CFG', if_true: files('cfg.c')) +system_ss.add(when: 'CONFIG_VMAPPLE_VIRTIO_BLK', if_true: files('virtio-blk.c'))
hw/vmapple/virtio-blk.c new file +204 -0
204 lines not on this page · raw message
include/hw/pci/pci_ids.h +1 -0
@@ -191,6 +191,7 @@#define PCI_DEVICE_ID_APPLE_UNI_N_AGP 0x0020#define PCI_DEVICE_ID_APPLE_U3_AGP 0x004b#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC 0x0021 +#define PCI_DEVICE_ID_APPLE_VIRTIO_BLK 0x1a00#define PCI_VENDOR_ID_SUN 0x108e#define PCI_DEVICE_ID_SUN_EBUS 0x1000
include/hw/qdev-properties-system.h +5 -0
@@ -30,6 +30,7 @@ extern const PropertyInfo qdev_prop_pcie_link_speed;extern const PropertyInfo qdev_prop_pcie_link_width;extern const PropertyInfo qdev_prop_cpus390entitlement;extern const PropertyInfo qdev_prop_iothread_vq_mapping_list; +extern const PropertyInfo qdev_prop_vmapple_virtio_blk_variant;#define DEFINE_PROP_PCI_DEVFN (_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
@@ -97,4 +98,8 @@ extern const PropertyInfo qdev_prop_iothread_vq_mapping_list; DEFINE_PROP(_name, _state, _field, qdev_prop_iothread_vq_mapping_list, \ IOThreadVirtQueueMappingList *) +#define DEFINE_PROP_VMAPPLE_VIRTIO_BLK_VARIANT(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_vmapple_virtio_blk_variant, \ + VMAppleVirtioBlkVariant) +#endif
include/hw/virtio/virtio-blk.h +10 -1
@@ -24,7 +24,7 @@#include "qapi/qapi-types-virtio.h" #define TYPE_VIRTIO_BLK "virtio-blk-device" -OBJECT_DECLARE_SIMPLE_TYPE (VirtIOBlock,VIRTIO_BLK ) +OBJECT_DECLARE_TYPE (VirtIOBlock, VirtIOBlkClass,VIRTIO_BLK ) /* This is the last element of the write scatter-gather list */struct virtio_blk_inhdr
@@ -100,6 +100,15 @@ typedef struct MultiReqBuffer { bool is_write; } MultiReqBuffer; +typedef struct VirtIOBlkClass { +/*< private >*/ +VirtioDeviceClass parent; +/*< public >*/ +bool (*handle_unknown_request)(VirtIOBlockReq *req,MultiReqBuffer *mrb, +uint32_t type); +}VirtIOBlkClass ; +void virtio_blk_handle_vq (VirtIOBlock *s,VirtQueue *vq); +void virtio_blk_req_complete (VirtIOBlockReq *req,unsigned char status);#endif
include/hw/vmapple/vmapple.h +2 -0
@@ -18,4 +18,6 @@#define TYPE_VMAPPLE_CFG "vmapple-cfg" +#define TYPE_VMAPPLE_VIRTIO_BLK_PCI "vmapple-virtio-blk-pci" +#endif /* HW_VMAPPLE_VMAPPLE_H */
qapi/virtio.json +14 -0
@@ -992,3 +992,17 @@ ## { 'enum': 'GranuleMode', 'data': [ '4k', '8k', '16k', '64k', 'host' ] } + +## +# @VMAppleVirtioBlkVariant: +# +# @unspecified: The default, not a valid setting. +# +# @root: Block device holding the root volume +# +# @aux: Block device holding auxiliary data required for boot +# +# Since: 9.2 +## +{ 'enum': 'VMAppleVirtioBlkVariant', + 'data': [ 'unspecified', 'root', 'aux' ] }
Signature · 1 line
2.39.5 (Apple Git-154)
Re: [PATCH v17 08/11] hw/vmapple/virtio-blk: Add support for apple virtio-blk
Quoted 78 lines · Phil Dennis-Jordan
From: Alexander Graf <[email protected]>
Apple has its own virtio-blk PCI device ID where it deviates from the official virtio-pci spec slightly: It puts a new "apple type" field at a static offset in config space and introduces a new barrier command.
This patch first creates a mechanism for virtio-blk downstream classes to handle unknown commands. It then creates such a downstream class and a new vmapple-virtio-blk-pci class which support the additional apple type config identifier as well as the barrier command.
The 'aux' or 'root' device type are selected using the 'variant' property.
Signed-off-by Alexander Graf <[email protected]>Signed-off-by Phil Dennis-Jordan <[email protected]>Reviewed-by Akihiko Odaki <[email protected]>Tested-by Akihiko Odaki <[email protected]>v4:
* Use recommended object type declaration pattern.
* Correctly log unimplemented code paths.
* Most header code moved to .c, type name #defines moved tovmapple.hv5:
* Corrected handling of potentially unaligned writes to virtio config area.
* Simplified passing through device variant type to subobject.v9:
* Correctly specify
class_sizefor VMAppleVirtIOBlkClassv10:
* Folded v9 patch 16/16 into this one, changing the device type design to provide a single device type with a variant property instead of 2 different subtypes for aux and root volumes.
* Tidied up error reporting for the variant property.v15:
* Constified the property table.
v16:
* Removed the
DEFINE_PROP_END_OF_LISTmarker to match recent upstream changes.--- hw/block/virtio-blk.c | 19 ++- hw/core/qdev-properties-system.c | 8 ++ hw/vmapple/Kconfig | 3 + hw/vmapple/meson.build | 1 + hw/vmapple/virtio-blk.c | 204 ++++++++++++++++++++++++++++ include/hw/pci/pci_ids.h | 1 + include/hw/qdev-properties-system.h | 5 + include/hw/virtio/virtio-blk.h | 11 +- include/hw/vmapple/vmapple.h | 2 + qapi/virtio.json | 14 ++ 10 files changed, 263 insertions(+), 5 deletions(-)create mode 100644
hw/vmapple/virtio-blk.chw/block/virtio-blk.c +1
-1@@ -50,7 +50,7 @@ static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq, req->mr_next =NULL ; } -static void virtio_blk_req_complete (VirtIOBlockReq *req,unsigned char status) +void virtio_blk_req_complete (VirtIOBlockReq *req,unsigned char status) {VirtIOBlock *s = req->dev;VirtIODevice *vdev =VIRTIO_DEVICE (s);
hw/block/virtio-blk.c static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status) · line 74
Quoted 5 lines
hw/block/virtio-blk.c +1
-1@@ -71,7 +71,7 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)static int virtio_blk_handle_rw_error (VirtIOBlockReq *req,int error,bool is_read,bool acct_failed) { -VirtIOBlock *s = req->dev; +VirtIOBlock *s = req->dev;
It seems you broke the indention here while rebasing.
Quoted 373 lines
hw/block/virtio-blk.c +13
-2BlockErrorAction action =blk_get_error_action (s->blk, is_read, error);if (action ==BLOCK_ERROR_ACTION_STOP ) {@@ -961,8 +961,18 @@ static int virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)break ; }default : -virtio_blk_req_complete (req,VIRTIO_BLK_S_UNSUPP ); -g_free (req); + { +/* +* Give subclasses a chance to handle unknown requests. This way the +* class lookup is not in the hot path. +*/ +VirtIOBlkClass *vbk =VIRTIO_BLK_GET_CLASS (s); +if (!vbk->handle_unknown_request || + !vbk->handle_unknown_request (req, mrb, type)) { +virtio_blk_req_complete (req,VIRTIO_BLK_S_UNSUPP ); +g_free (req); + } + } }return 0 ; }@@ -2038,6 +2048,7 @@ static const TypeInfo virtio_blk_info = { .instance_size = sizeof(VirtIOBlock), .instance_init = virtio_blk_instance_init, .class_init = virtio_blk_class_init, + .class_size = sizeof(VirtIOBlkClass), };static void virtio_register_types (void )hw/core/qdev-properties-system.c +8
-0@@ -1283,3 +1283,11 @@ const PropertyInfo qdev_prop_iothread_vq_mapping_list = { .set = set_iothread_vq_mapping_list, .release = release_iothread_vq_mapping_list, }; + +const PropertyInfo qdev_prop_vmapple_virtio_blk_variant = { + .name ="VMAppleVirtioBlkVariant" , + .enum_table = &VMAppleVirtioBlkVariant_lookup, + .get = qdev_propinfo_get_enum, + .set = qdev_propinfo_set_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, +};hw/vmapple/Kconfig +3
-0@@ -7,3 +7,6 @@ config VMAPPLE_BDIF config VMAPPLE_CFG bool +config VMAPPLE_VIRTIO_BLK + bool +hw/vmapple/meson.build +1
-0@@ -1,3 +1,4 @@ system_ss.add(when: 'CONFIG_VMAPPLE_AES', if_true: files('aes.c')) system_ss.add(when: 'CONFIG_VMAPPLE_BDIF', if_true: files('bdif.c')) system_ss.add(when: 'CONFIG_VMAPPLE_CFG', if_true: files('cfg.c')) +system_ss.add(when: 'CONFIG_VMAPPLE_VIRTIO_BLK', if_true: files('virtio-blk.c'))hw/vmapple/virtio-blk.c new file +204
-0@@ -0,0 +1,204 @@ +/* +* VMApple specific VirtIO Block implementation +* +* Copyright © 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* VMApple uses almost standard VirtIO Block, but with a few key differences: +* +* - Different PCI device/vendor ID +* - An additional "type" identifier to differentiate AUX and Root volumes +* - An additional BARRIER command +*/ + +#include "qemu/osdep.h" +#include "hw/vmapple/vmapple.h" +#include "hw/virtio/virtio-blk.h" +#include "hw/virtio/virtio-pci.h" +#include "qemu/bswap.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qapi/error.h" + +#define TYPE_VMAPPLE_VIRTIO_BLK "vmapple-virtio-blk" +OBJECT_DECLARE_TYPE(VMAppleVirtIOBlk, VMAppleVirtIOBlkClass, VMAPPLE_VIRTIO_BLK) + +typedef struct VMAppleVirtIOBlkClass { +VirtIOBlkClass parent; + +void (*get_config)(VirtIODevice *vdev,uint8_t *config); +}VMAppleVirtIOBlkClass ; + +typedef struct VMAppleVirtIOBlk { +VirtIOBlock parent_obj; + +uint32_t apple_type; +}VMAppleVirtIOBlk ; + +/* +* vmapple-virtio-blk-pci: This extends VirtioPCIProxy. +*/ +OBJECT_DECLARE_SIMPLE_TYPE(VMAppleVirtIOBlkPCI, VMAPPLE_VIRTIO_BLK_PCI) + +#define VIRTIO_BLK_T_APPLE_BARRIER 0x10000 + +static bool vmapple_virtio_blk_handle_unknown_request (VirtIOBlockReq *req, +MultiReqBuffer *mrb, +uint32_t type) +{ +switch (type) { +case VIRTIO_BLK_T_APPLE_BARRIER : +qemu_log_mask (LOG_UNIMP ,"%s: Barrier requests are currently no-ops\n" , + __func__); +virtio_blk_req_complete (req,VIRTIO_BLK_S_OK ); +g_free (req); +return true; +default : +return false; + } +} + +/* +* VMApple virtio-blk uses the same config format as normal virtio, with one +* exception: It adds an "apple type" specififer at the same location that +* the spec reserves for max_secure_erase_sectors. Let's hook into the +* get_config code path here, run it as usual and then patch in the apple type. +*/ +static void vmapple_virtio_blk_get_config (VirtIODevice *vdev,uint8_t *config) +{ +VMAppleVirtIOBlk *dev =VMAPPLE_VIRTIO_BLK (vdev); +VMAppleVirtIOBlkClass *vvbk =VMAPPLE_VIRTIO_BLK_GET_CLASS (dev); +struct virtio_blk_config *blkcfg = (struct virtio_blk_config *)config; + + vvbk->get_config (vdev, config); + + g_assert(dev->parent_obj.config_size >= endof(struct virtio_blk_config, zoned)); + +/* Apple abuses the field for max_secure_erase_sectors as type id */ +stl_he_p (&blkcfg->max_secure_erase_sectors, dev->apple_type); +} + +static void vmapple_virtio_blk_class_init (ObjectClass *klass,void *data) +{ +VirtIOBlkClass *vbk =VIRTIO_BLK_CLASS (klass); +VirtioDeviceClass *vdc =VIRTIO_DEVICE_CLASS (klass); +VMAppleVirtIOBlkClass *vvbk =VMAPPLE_VIRTIO_BLK_CLASS (klass); + + vbk->handle_unknown_request = vmapple_virtio_blk_handle_unknown_request; + vvbk->get_config = vdc->get_config; + vdc->get_config = vmapple_virtio_blk_get_config; +} + +static const TypeInfo vmapple_virtio_blk_info = { + .name =TYPE_VMAPPLE_VIRTIO_BLK , + .parent =TYPE_VIRTIO_BLK , + .instance_size =sizeof (VMAppleVirtIOBlk), + .class_size =sizeof (VMAppleVirtIOBlkClass), + .class_init = vmapple_virtio_blk_class_init, +}; + +/* PCI Devices */ + +struct VMAppleVirtIOBlkPCI { +VirtIOPCIProxy parent_obj; +VMAppleVirtIOBlk vdev; +VMAppleVirtioBlkVariant variant; +}; + + +static const Property vmapple_virtio_blk_pci_properties[] = { +DEFINE_PROP_UINT32 ("class" , VirtIOPCIProxy, class_code,0 ), +DEFINE_PROP_BIT ("ioeventfd" , VirtIOPCIProxy, flags, +VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT , true), +DEFINE_PROP_UINT32 ("vectors" , VirtIOPCIProxy, nvectors, +DEV_NVECTORS_UNSPECIFIED ), +DEFINE_PROP_VMAPPLE_VIRTIO_BLK_VARIANT ("variant" , VMAppleVirtIOBlkPCI, variant, +VM_APPLE_VIRTIO_BLK_VARIANT_UNSPECIFIED ), +}; + +static void vmapple_virtio_blk_pci_realize (VirtIOPCIProxy *vpci_dev,Error **errp) +{ +ERRP_GUARD (); +VMAppleVirtIOBlkPCI *dev =VMAPPLE_VIRTIO_BLK_PCI (vpci_dev); +DeviceState *vdev =DEVICE (&dev->vdev); +VirtIOBlkConf *conf = &dev->vdev.parent_obj.conf; + +if (dev->variant ==VM_APPLE_VIRTIO_BLK_VARIANT_UNSPECIFIED ) { +error_setg (errp,"vmapple virtio block device variant unspecified" ); +error_append_hint (errp, +"Variant property must be set to 'aux' or 'root'.\n" +"Use a regular virtio-blk-pci device instead when " +"neither is applicaple.\n" ); +return ; + } + +if (conf->num_queues ==VIRTIO_BLK_AUTO_NUM_QUEUES ) { + conf->num_queues =virtio_pci_optimal_num_queues (0 ); + } + +if (vpci_dev->nvectors ==DEV_NVECTORS_UNSPECIFIED ) { + vpci_dev->nvectors = conf->num_queues +1 ; + } + +/* +* We don't support zones, but we need the additional config space size. +* Let's just expose the feature so the rest of the virtio-blk logic +* allocates enough space for us. The guest will ignore zones anyway. +*/ +virtio_add_feature (&dev->vdev.parent_obj.host_features,VIRTIO_BLK_F_ZONED ); +/* Propagate the apple type down to the virtio-blk device */ + dev->vdev.apple_type = dev->variant; +/* and spawn the virtio-blk device */ +qdev_realize (vdev,BUS (&vpci_dev->bus), errp); + +/* +* The virtio-pci machinery adjusts its vendor/device ID based on whether +* we support modern or legacy virtio. Let's patch it back to the Apple +* identifiers here. +*/ +pci_config_set_vendor_id (vpci_dev->pci_dev.config,PCI_VENDOR_ID_APPLE ); +pci_config_set_device_id (vpci_dev->pci_dev.config, +PCI_DEVICE_ID_APPLE_VIRTIO_BLK ); +} + +static void vmapple_virtio_blk_pci_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +VirtioPCIClass *k =VIRTIO_PCI_CLASS (klass); +PCIDeviceClass *pcidev_k =PCI_DEVICE_CLASS (klass); + +set_bit (DEVICE_CATEGORY_STORAGE , dc->categories); +device_class_set_props (dc, vmapple_virtio_blk_pci_properties); + k->realize = vmapple_virtio_blk_pci_realize; + pcidev_k->vendor_id =PCI_VENDOR_ID_APPLE ; + pcidev_k->device_id =PCI_DEVICE_ID_APPLE_VIRTIO_BLK ; + pcidev_k->revision =VIRTIO_PCI_ABI_VERSION ; + pcidev_k->class_id =PCI_CLASS_STORAGE_SCSI ; +} + +static void vmapple_virtio_blk_pci_instance_init (Object *obj) +{ +VMAppleVirtIOBlkPCI *dev =VMAPPLE_VIRTIO_BLK_PCI (obj); + +virtio_instance_init_common (obj, &dev->vdev,sizeof (dev->vdev), +TYPE_VMAPPLE_VIRTIO_BLK ); +} + +static const VirtioPCIDeviceTypeInfo vmapple_virtio_blk_pci_info = { + .generic_name =TYPE_VMAPPLE_VIRTIO_BLK_PCI , + .instance_size =sizeof (VMAppleVirtIOBlkPCI), + .instance_init = vmapple_virtio_blk_pci_instance_init, + .class_init = vmapple_virtio_blk_pci_class_init, +}; + +static void vmapple_virtio_blk_register_types (void ) +{ +type_register_static (&vmapple_virtio_blk_info); +virtio_pci_types_register (&vmapple_virtio_blk_pci_info); +} + +type_init (vmapple_virtio_blk_register_types)include/hw/pci/pci_ids.h +1
-0@@ -191,6 +191,7 @@#define PCI_DEVICE_ID_APPLE_UNI_N_AGP 0x0020#define PCI_DEVICE_ID_APPLE_U3_AGP 0x004b#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC 0x0021 +#define PCI_DEVICE_ID_APPLE_VIRTIO_BLK 0x1a00#define PCI_VENDOR_ID_SUN 0x108e#define PCI_DEVICE_ID_SUN_EBUS 0x1000include/hw/qdev-properties-system.h +5
-0@@ -30,6 +30,7 @@ extern const PropertyInfo qdev_prop_pcie_link_speed;extern const PropertyInfo qdev_prop_pcie_link_width;extern const PropertyInfo qdev_prop_cpus390entitlement;extern const PropertyInfo qdev_prop_iothread_vq_mapping_list; +extern const PropertyInfo qdev_prop_vmapple_virtio_blk_variant;#define DEFINE_PROP_PCI_DEVFN (_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)@@ -97,4 +98,8 @@ extern const PropertyInfo qdev_prop_iothread_vq_mapping_list; DEFINE_PROP(_name, _state, _field, qdev_prop_iothread_vq_mapping_list, \ IOThreadVirtQueueMappingList *) +#define DEFINE_PROP_VMAPPLE_VIRTIO_BLK_VARIANT(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_vmapple_virtio_blk_variant, \ + VMAppleVirtioBlkVariant) +#endif include/hw/virtio/virtio-blk.h +10
-1@@ -24,7 +24,7 @@#include "qapi/qapi-types-virtio.h" #define TYPE_VIRTIO_BLK "virtio-blk-device" -OBJECT_DECLARE_SIMPLE_TYPE (VirtIOBlock,VIRTIO_BLK ) +OBJECT_DECLARE_TYPE (VirtIOBlock, VirtIOBlkClass,VIRTIO_BLK ) /* This is the last element of the write scatter-gather list */struct virtio_blk_inhdr @@ -100,6 +100,15 @@ typedef struct MultiReqBuffer { bool is_write; } MultiReqBuffer; +typedef struct VirtIOBlkClass { +/*< private >*/ +VirtioDeviceClass parent; +/*< public >*/ +bool (*handle_unknown_request)(VirtIOBlockReq *req,MultiReqBuffer *mrb, +uint32_t type); +}VirtIOBlkClass ; +void virtio_blk_handle_vq (VirtIOBlock *s,VirtQueue *vq); +void virtio_blk_req_complete (VirtIOBlockReq *req,unsigned char status);#endif include/hw/vmapple/vmapple.h +2
-0@@ -18,4 +18,6 @@#define TYPE_VMAPPLE_CFG "vmapple-cfg" +#define TYPE_VMAPPLE_VIRTIO_BLK_PCI "vmapple-virtio-blk-pci" +#endif /* HW_VMAPPLE_VMAPPLE_H */ qapi/virtio.json +14
-0@@ -992,3 +992,17 @@ ## { 'enum': 'GranuleMode', 'data': [ '4k', '8k', '16k', '64k', 'host' ] } + +## +# @VMAppleVirtioBlkVariant: +# +# @unspecified: The default, not a valid setting. +# +# @root: Block device holding the root volume +# +# @aux: Block device holding auxiliary data required for boot +# +# Since: 9.2 +## +{ 'enum': 'VMAppleVirtioBlkVariant', + 'data': [ 'unspecified', 'root', 'aux' ] }
PATCH v17 9/11 hw/usb/hcd-xhci-pci: Adds property for disabling mapping in IRQ mode
In reply to Phil Dennis-JordanThis change addresses an edge case that trips up macOS guest drivers for PCI based XHCI controllers. The guest driver would attempt to schedule events to XHCI event rings 1 and 2 even when using PCI pin-based interrupts. Interrupts would therefore be dropped, and events only handled on timeout.
So, in addition to disabling interrupter mapping if numintrs is 1, a callback is added to xhci to check whether interrupter mapping should be enabled. The PCI XHCI device type now provides an implementation of this callback if the new "conditional-intr-mapping" property is enabled. (default: disabled) When enabled, interrupter mapping is only enabled when MSI-X or MSI is active.
This means that when using pin-based interrupts, events are only submitted to interrupter 0 regardless of selected target. This allows the macOS guest drivers to work with the device in those configurations.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2705
--- hw/usb/hcd-xhci-pci.c | 24 ++++++++++++++++++++++++ hw/usb/hcd-xhci-pci.h | 1 + hw/usb/hcd-xhci.c | 3 ++- hw/usb/hcd-xhci.h | 5 +++++ 4 files changed, 32 insertions(+), 1 deletion(-)
hw/usb/hcd-xhci-pci.c +24 -0
@@ -82,6 +82,21 @@ static bool xhci_pci_intr_raise(XHCIState *xhci, int n, bool level)return false; } +static bool xhci_pci_intr_mapping_conditional (XHCIState *xhci) +{ +XHCIPciState *s =container_of (xhci, XHCIPciState, xhci); +PCIDevice *pci_dev =PCI_DEVICE (s); + +/* +* Implementation of the "conditional-intr-mapping" property, which only +* enables interrupter mapping if MSI or MSI-X is available and active. +* Forces all events onto interrupter/event ring 0 in pin-based IRQ mode. +* Provides compatibility with macOS guests on machine types where MSI(-X) +* is not available. +*/ +return msix_enabled (pci_dev) ||msi_enabled (pci_dev); +} +static void xhci_pci_reset (DeviceState *dev) {XHCIPciState *s =XHCI_PCI (dev);
@@ -119,6 +134,9 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp)object_property_set_link (OBJECT (&s->xhci),"host" ,OBJECT (s),NULL ); s->xhci.intr_update = xhci_pci_intr_update; s->xhci.intr_raise = xhci_pci_intr_raise; +if (s->conditional_intr_mapping) { + s->xhci.intr_mapping_supported = xhci_pci_intr_mapping_conditional; + }if (!qdev_realize (DEVICE (&s->xhci),NULL , errp)) {return ; }
@@ -201,6 +219,8 @@ static void xhci_instance_init(Object *obj)static const Property xhci_pci_properties[] = {DEFINE_PROP_ON_OFF_AUTO ("msi" , XHCIPciState, msi,ON_OFF_AUTO_AUTO ),DEFINE_PROP_ON_OFF_AUTO ("msix" , XHCIPciState, msix,ON_OFF_AUTO_AUTO ), +DEFINE_PROP_BOOL ("conditional-intr-mapping" , XHCIPciState, + conditional_intr_mapping, false), };static void xhci_class_init (ObjectClass *klass,void *data)
@@ -215,6 +235,10 @@ static void xhci_class_init(ObjectClass *klass, void *data) k->exit = usb_xhci_pci_exit; k->class_id =PCI_CLASS_SERIAL_USB ;device_class_set_props (dc, xhci_pci_properties); +object_class_property_set_description (klass,"conditional-intr-mapping" , +"When true, disables interrupter mapping for pin-based IRQ mode. " +"Intended to be used with guest drivers with questionable behaviour, " +"such as macOS's." ); }static const TypeInfo xhci_pci_info = {
hw/usb/hcd-xhci-pci.h +1 -0
@@ -40,6 +40,7 @@ typedef struct XHCIPciState {XHCIState xhci;OnOffAuto msi;OnOffAuto msix; + bool conditional_intr_mapping; } XHCIPciState;#endif
hw/usb/hcd-xhci.c +2 -1
@@ -644,7 +644,8 @@ static void xhci_event(XHCIState *xhci, XHCIEvent *event, int v)dma_addr_t erdp;unsigned int dp_idx; -if (xhci->numintrs ==1 ) { +if (xhci->numintrs ==1 || + (xhci->intr_mapping_supported && !xhci->intr_mapping_supported (xhci))) { v =0 ; }
hw/usb/hcd-xhci.h +5 -0
@@ -193,6 +193,11 @@ typedef struct XHCIState {uint32_t max_pstreams_mask;void (*intr_update)(XHCIState *s,int n,bool enable);bool (*intr_raise)(XHCIState *s,int n,bool level); +/* +* Callback for special-casing interrupter mapping support. NULL for most +* implementations, for defaulting to enabled mapping unless numintrs == 1. +*/ +bool (*intr_mapping_supported)(XHCIState *s);DeviceState *hostOpaque;/* Operational Registers */
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH v17 10/11 hw/intc: Remove TCG dependency on ARM_GICV3
In reply to Phil Dennis-JordanFrom: Philippe Mathieu-Daudé <[email protected]>
The TYPE_ARM_GICV3 model doesn't have any particular dependency on TCG, remove it. Rename the Kconfig selector ARM_GICV3_TCG -> ARM_GICV3.
--- hw/intc/Kconfig | 6 +++--- hw/intc/meson.build | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
hw/intc/Kconfig +3 -3
@@ -23,13 +23,13 @@ config APIC config ARM_GIC bool - select ARM_GICV3_TCG if TCG + select ARM_GICV3 if TCG select ARM_GIC_KVM if KVM select MSI_NONBROKEN -config ARM_GICV3_TCG +config ARM_GICV3 bool - depends on ARM_GIC && TCG + depends on ARM_GIC config ARM_GIC_KVM bool
hw/intc/meson.build +2 -2
@@ -6,7 +6,7 @@ system_ss.add(when: 'CONFIG_ARM_GIC', if_true: files( 'arm_gicv3_common.c', 'arm_gicv3_its_common.c', )) -system_ss.add(when: 'CONFIG_ARM_GICV3_TCG', if_true: files( +system_ss.add(when: 'CONFIG_ARM_GICV3', if_true: files( 'arm_gicv3.c', 'arm_gicv3_dist.c', 'arm_gicv3_its.c',
@@ -39,7 +39,7 @@ endif specific_ss.add(when: 'CONFIG_APIC', if_true: files('apic.c', 'apic_common.c')) specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif_common.c')) -specific_ss.add(when: 'CONFIG_ARM_GICV3_TCG', if_true: files('arm_gicv3_cpuif.c')) +specific_ss.add(when: 'CONFIG_ARM_GICV3', if_true: files('arm_gicv3_cpuif.c')) specific_ss.add(when: 'CONFIG_ARM_GIC_KVM', if_true: files('arm_gic_kvm.c')) specific_ss.add(when: ['CONFIG_ARM_GIC_KVM', 'TARGET_AARCH64'], if_true: files('arm_gicv3_kvm.c', 'arm_gicv3_its_kvm.c')) specific_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_nvic.c'))
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH v17 11/11 hw/vmapple/vmapple: Add vmapple machine type
In reply to Phil Dennis-JordanFrom: Alexander Graf <[email protected]>
Apple defines a new "vmapple" machine type as part of its proprietary macOS Virtualization.Framework vmm. This machine type is similar to the virt one, but with subtle differences in base devices, a few special vmapple device additions and a vastly different boot chain.
This patch reimplements this machine type in QEMU. To use it, you have to have a readily installed version of macOS for VMApple, run on macOS with -accel hvf, pass the Virtualization.Framework boot rom (AVPBooter) in via -bios, pass the aux and root volume as pflash and pass aux and root volume as virtio drives. In addition, you also need to find the machine UUID and pass that as -M vmapple,uuid= parameter:
$ qemu-system-aarch64 -accel hvf -M vmapple,uuid=0x1234 -m 4G \
-bios /System/Library/Frameworks/Virtualization.framework/Versions/A/Resources/AVPBooter.vmapple2.bin
-drive file=aux,if=pflash,format=raw \
-drive file=root,if=pflash,format=raw \
-drive file=aux,if=none,id=aux,format=raw \
-device vmapple-virtio-blk-pci,variant=aux,drive=aux \
-drive file=root,if=none,id=root,format=raw \
-device vmapple-virtio-blk-pci,variant=root,drive=rootWith all these in place, you should be able to see macOS booting successfully.
Known issues:
- Currently only macOS 12 guests are supported. The boot process for 13+ will need further investigation and adjustment.
---
v3:
* Rebased on latest upstream, updated affinity and NIC creation
API usage
* Included Apple-variant virtio-blk in build dependency
* Updated API usage for setting 'redist-region-count' array-typed property on GIC.
* Switched from virtio HID devices (for which macOS 12 does not contain drivers) to an XHCI USB controller and USB HID devices.
v4:
* Fixups for v4 changes to the other patches in the set.
* Corrected the assert macro to use
* Removed superfluous endian conversions corresponding to cfg's.
* Init error handling improvement.
* No need to select CPU type on TCG, as only HVF is supported.
* Machine type version bumped to 9.2
* #include order improved
v5:
* Fixed memory reservation for ecam alias region.
* Better error handling setting properties on devices.
* Simplified the machine ECID/UUID extraction script and actually created a file for it rather than quoting its code in documentation.
v7:
* Tiny error handling fix, un-inlined function.
v8:
* Use object_property_add_uint64_ptr rather than defining custom UUID property get/set functions.
v9:
* Documentation improvements
* Fixed variable name and struct field used during pvpanic device creation.
v10:
* Documentation fixup for changed virtio-blk device type.
* Small improvements to shell commands in documentation.
* Improved propagation of errors during cfg device instantiation.
v11:
* Quoted more strings in the documentation's shell script code.
v13:
* Bumped the machine type version from 9.2 to 10.0.
v16:
* Fixed #include path breakage from recent sysemu->system path rename.
* Removed a few superfluous #includes during sysemu rename cleanup.
* Moved compatibility setting for disabling legacy mode in virtio-pci to proper global property table rather than (ab)using sugar property.
* Removed machine type versioning as it's not necessary (yet?)
* Made memory map array const
v17:
* Explicitly depend on software GICv3
* Enable the new XHCI PCI conditional-intr-mapping property via the global compat property table, fixing vmapple's USB/HID issues.
MAINTAINERS | 1 + contrib/vmapple/uuid.sh | 9 + docs/system/arm/vmapple.rst | 63 ++++ docs/system/target-arm.rst | 1 + hw/vmapple/Kconfig | 20 ++ hw/vmapple/meson.build | 1 + hw/vmapple/vmapple.c | 618 ++++++++++++++++++++++++++++++++++++ 7 files changed, 713 insertions(+) create mode 100755 contrib/vmapple/uuid.sh create mode 100644 docs/system/arm/vmapple.rst create mode 100644 hw/vmapple/vmapple.c
MAINTAINERS +1 -0
@@ -2791,6 +2791,7 @@ M: Phil Dennis-Jordan <[email protected]> S: Maintained F: hw/vmapple/* F: include/hw/vmapple/* +F: docs/system/arm/vmapple.rst Subsystems ----------
contrib/vmapple/uuid.sh new file +9 -0
@@ -0,0 +1,9 @@ +#!/bin/sh +# Used for converting a guest provisioned using Virtualization.framework +# for use with the QEMU 'vmapple' aarch64 machine type. +# +# Extracts the Machine UUID from Virtualization.framework VM JSON file. +# (as produced by 'macosvm', passed as command line argument) + +plutil -extract machineId raw "$1" | base64 -d | plutil -extract ECID raw - +
docs/system/arm/vmapple.rst new file +63 -0
63 lines not on this page · raw message
docs/system/target-arm.rst +1 -0
@@ -102,6 +102,7 @@ Board-specific documentation arm/stellaris arm/stm32 arm/virt + arm/vmapple arm/xenpvh arm/xlnx-versal-virt arm/xlnx-zynq
hw/vmapple/Kconfig +20 -0
@@ -10,3 +10,23 @@ config VMAPPLE_CFG config VMAPPLE_VIRTIO_BLK bool +config VMAPPLE + bool + depends on ARM + depends on HVF + default y if ARM + imply PCI_DEVICES + select ARM_GICV3 + select PLATFORM_BUS + select PCI_EXPRESS + select PCI_EXPRESS_GENERIC_BRIDGE + select PL011 # UART + select PL031 # RTC + select PL061 # GPIO + select GPIO_PWR + select PVPANIC_MMIO + select VMAPPLE_AES + select VMAPPLE_BDIF + select VMAPPLE_CFG + select MAC_PVG_MMIO + select VMAPPLE_VIRTIO_BLK
hw/vmapple/meson.build +1 -0
@@ -2,3 +2,4 @@ system_ss.add(when: 'CONFIG_VMAPPLE_AES', if_true: files('aes.c')) system_ss.add(when: 'CONFIG_VMAPPLE_BDIF', if_true: files('bdif.c')) system_ss.add(when: 'CONFIG_VMAPPLE_CFG', if_true: files('cfg.c')) system_ss.add(when: 'CONFIG_VMAPPLE_VIRTIO_BLK', if_true: files('virtio-blk.c')) +specific_ss.add(when: 'CONFIG_VMAPPLE', if_true: files('vmapple.c'))
hw/vmapple/vmapple.c new file +618 -0
618 lines not on this page · raw message
Signature · 1 line
2.39.5 (Apple Git-154)
Re: [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type
docs/system/arm/vmapple.rst
Quoted 82 lines · Phil Dennis-Jordan
From: Alexander Graf <[email protected]>
Apple defines a new "vmapple" machine type as part of its proprietary macOS Virtualization.Framework vmm. This machine type is similar to the virt one, but with subtle differences in base devices, a few special vmapple device additions and a vastly different boot chain.
This patch reimplements this machine type in QEMU. To use it, you have to have a readily installed version of macOS for VMApple, run on macOS with -accel hvf, pass the Virtualization.Framework boot rom (AVPBooter) in via -bios, pass the aux and root volume as pflash and pass aux and root volume as virtio drives. In addition, you also need to find the machine UUID and pass that as -M vmapple,uuid= parameter:
$ qemu-system-aarch64 -accel hvf -M vmapple,uuid=0x1234 -m 4G \ -bios /System/Library/Frameworks/Virtualization.framework/Versions/A/Resources/AVPBooter.vmapple2.bin -drive file=aux,if=pflash,format=raw \ -drive file=root,if=pflash,format=raw \ -drive file=aux,if=none,id=aux,format=raw \ -device vmapple-virtio-blk-pci,variant=aux,drive=aux \ -drive file=root,if=none,id=root,format=raw \ -device vmapple-virtio-blk-pci,variant=root,drive=rootWith all these in place, you should be able to see macOS booting successfully.
Known issues:
- Currently only macOS 12 guests are supported. The boot process for 13+ will need further investigation and adjustment.Signed-off-by Alexander Graf <[email protected]>Co-authored-by Phil Dennis-Jordan <[email protected]>Signed-off-by Phil Dennis-Jordan <[email protected]>Reviewed-by Akihiko Odaki <[email protected]>---
MAINTAINERS | 1 + contrib/vmapple/uuid.sh | 9 + docs/system/arm/vmapple.rst | 63 ++++ docs/system/target-arm.rst | 1 + hw/vmapple/Kconfig | 20 ++ hw/vmapple/meson.build | 1 + hw/vmapple/vmapple.c | 618 ++++++++++++++++++++++++++++++++++++ 7 files changed, 713 insertions(+)create mode 100755
contrib/vmapple/uuid.sh
create mode 100644docs/system/arm/vmapple.rst
create mode 100644hw/vmapple/vmapple.cMAINTAINERS +1
-0@@ -2791,6 +2791,7 @@ M: Phil Dennis-Jordan <[email protected]> S: Maintained F: hw/vmapple/* F: include/hw/vmapple/* +F: docs/system/arm/vmapple.rst Subsystems ----------contrib/vmapple/uuid.sh new file +9
-0@@ -0,0 +1,9 @@ +#!/bin/sh +# Used for converting a guest provisioned using Virtualization.framework +# for use with the QEMU 'vmapple' aarch64 machine type. +# +# Extracts the Machine UUID from Virtualization.framework VM JSON file. +# (as produced by 'macosvm', passed as command line argument) + +plutil -extract machineId raw "$1" | base64 -d | plutil -extract ECID raw - +docs/system/arm/vmapple.rst new file +0
-0@@ -0,0 +1,63 @@
Alex, Phil, we now mandate a SPDX tag. Due to the license used in vmapple.c in this patch, are you OK with me squashing here:
-- >8 --
docs/system/arm/vmapple.rst +2 -0
@@ -0,0 +1,2 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later +
contrib/vmapple/uuid.sh +3 -0
@@ -1,0 +2 @@ +#
@@ -6,0 +8,2 @@ +# +# SPDX-License-Identifier: GPL-2.0-or-later
---
?
Quoted 63 lines
docs/system/arm/vmapple.rst new file +63
-0+VMApple machine emulation +======================================================================================== + +VMApple is the device model that the macOS built-in hypervisor called "Virtualization.framework" +exposes to Apple Silicon macOS guests. The "vmapple" machine model in QEMU implements the same +device model, but does not use any code from Virtualization.Framework. + +Prerequisites +------------- + +To run the vmapple machine model, you need to + + * Run on Apple Silicon + * Run on macOS 12.0 or above + * Have an already installed copy of a Virtualization.Framework macOS 12 virtual + machine. Note that newer versions than 12.x are currently NOT supported on + the guest side. I will assume that you installed it using the + `macosvm <https://github.com/s-u/macosvm>` CLI. + +First, we need to extract the UUID from the virtual machine that you installed. You can do this +by running the shell script in contrib/vmapple/uuid.sh on the macosvm.json file. + +.. code-block:: bash + :caption: uuid.sh script to extract the UUID from a macosvm.json file + + $ contrib/vmapple/uuid.sh "path/to/macosvm.json" + +Now we also need to trim the aux partition. It contains metadata that we can just discard: + +.. code-block:: bash + :caption: Command to trim the aux file + + $ dd if="aux.img" of="aux.img.trimmed" bs=$(( 0x4000 )) skip=1 + +How to run +---------- + +Then, we can launch QEMU with the Virtualization.Framework pre-boot environment and the readily +installed target disk images. I recommend to port forward the VM's ssh and vnc ports to the host +to get better interactive access into the target system: + +.. code-block:: bash + :caption: Example execution command line + + $ UUID="$(contrib/vmapple/uuid.sh 'macosvm.json')" + $ AVPBOOTER="/System/Library/Frameworks/Virtualization.framework/Resources/AVPBooter.vmapple2.bin" + $ AUX="aux.img.trimmed" + $ DISK="disk.img" + $ qemu-system-aarch64 \ + -serial mon:stdio \ + -m 4G \ + -accel hvf \ + -M vmapple,uuid="$UUID" \ + -bios "$AVPBOOTER" \ + -drive file="$AUX",if=pflash,format=raw \ + -drive file="$DISK",if=pflash,format=raw \ + -drive file="$AUX",if=none,id=aux,format=raw \ + -drive file="$DISK",if=none,id=root,format=raw \ + -device vmapple-virtio-blk-pci,variant=aux,drive=aux \ + -device vmapple-virtio-blk-pci,variant=root,drive=root \ + -netdev user,id=net0,ipv6=off,hostfwd=tcp::2222-:22,hostfwd=tcp::5901-:5900 \ + -device virtio-net-pci,netdev=net0 +
Re: [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type
Quoted 122 lines · Philippe Mathieu-Daudé
docs/system/arm/vmapple.rst
Quoted 82 lines · Phil Dennis-Jordan
From: Alexander Graf <[email protected]>
Apple defines a new "vmapple" machine type as part of its proprietary macOS Virtualization.Framework vmm. This machine type is similar to the virt one, but with subtle differences in base devices, a few special vmapple device additions and a vastly different boot chain.
This patch reimplements this machine type in QEMU. To use it, you have to have a readily installed version of macOS for VMApple, run on macOS with -accel hvf, pass the Virtualization.Framework boot rom (AVPBooter) in via -bios, pass the aux and root volume as pflash and pass aux and root volume as virtio drives. In addition, you also need to find the machine UUID and pass that as -M vmapple,uuid= parameter:
$ qemu-system-aarch64 -accel hvf -M vmapple,uuid=0x1234 -m 4G \ -bios /System/Library/Frameworks/Virtualization.framework/ Versions/A/Resources/AVPBooter.vmapple2.bin -drive file=aux,if=pflash,format=raw \ -drive file=root,if=pflash,format=raw \ -drive file=aux,if=none,id=aux,format=raw \ -device vmapple-virtio-blk-pci,variant=aux,drive=aux \ -drive file=root,if=none,id=root,format=raw \ -device vmapple-virtio-blk-pci,variant=root,drive=rootWith all these in place, you should be able to see macOS booting successfully.
Known issues:
- Currently only macOS 12 guests are supported. The boot process for 13+ will need further investigation and adjustment.Signed-off-by Alexander Graf <[email protected]>Co-authored-by Phil Dennis-Jordan <[email protected]>Signed-off-by Phil Dennis-Jordan <[email protected]>Reviewed-by Akihiko Odaki <[email protected]>---
MAINTAINERS | 1 + contrib/vmapple/uuid.sh | 9 +
docs/system/arm/vmapple.rst| 63 ++++ docs/system/target-arm.rst | 1 +
hw/vmapple/Kconfig | 20 ++ hw/vmapple/meson.build | 1 +
hw/vmapple/vmapple.c | 618 ++++++++++++++++++++++++++++++++++++7 files changed, 713 insertions(+)create mode 100755
contrib/vmapple/uuid.sh
create mode 100644docs/system/arm/vmapple.rst
create mode 100644hw/vmapple/vmapple.cMAINTAINERS +0
-0@@ -2791,6 +2791,7 @@ M: Phil Dennis-Jordan <[email protected]>S: Maintained
F: hw/vmapple/*
F:include/hw/vmapple/*
+F:docs/system/arm/vmapple.rst
Subsystems
----------contrib/vmapple/uuid.sh new file +8
-0@@ -0,0 +1,9 @@ +#!/bin/sh +# Used for converting a guest provisioned using Virtualization.framework +# for use with the QEMU 'vmapple' aarch64 machine type. +# +# Extracts the Machine UUID from Virtualization.framework VM JSON file. +# (as produced by 'macosvm', passed as command line argument) + +plutil -extract machineId raw "$1" | base64 -d | plutil -extract ECIDraw -
contrib/vmapple/uuid.sh new file +1
-0+docs/system/arm/vmapple.rst new file +0
-0@@ -0,0 +1,63 @@Alex, Phil, we now mandate a SPDX tag. Due to the license used in
vmapple.cin this patch, are you OK with me squashing here:-- >8 --
docs/system/arm/vmapple.rst +2
-0@@ -0,0 +1,2 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later +contrib/vmapple/uuid.sh +3
-1@@ -1,0 +2 @@ +#@@ -6,0 +8,2 @@ +# +# SPDX-License-Identifier: GPL-2.0-or-later ---?
Quoted 14 lines
docs/system/arm/vmapple.rst new file +4
-0+VMApple machine emulation +======================================================================================== + +VMApple is the device model that the macOS built-in hypervisor called"Virtualization.framework"
+exposes to Apple Silicon macOS guests. The "vmapple" machine model in QEMU implements the samedocs/system/arm/vmapple.rst new file +7
-0+device model, but does not use any code from Virtualization.Framework. + +Prerequisites +------------- + +To run the vmapple machine model, you need to +
Quoted 8 lines
Quoted 8 lines
+ * Run on Apple Silicon
+ * Run on macOS 12.0 or above
+ * Have an already installed copy of a Virtualization.Framework macOS 12 virtual
+ machine. Note that newer versions than 12.x are currently NOT supported on
+ the guest side. I will assume that you installed it using the +macosvm <https://github.com/s-u/macosvm>CLI.
I'm also squashing here:
-- >8 --
docs/system/arm/vmapple.rst +1 -1
@@ -19,3 +19,3 @@ To run the vmapple machine model, you need to the guest side. I will assume that you installed it using the - `macosvm <https://github.com/s-u/macosvm>` CLI. + `macosvm <https://github.com/s-u/macosvm>`__ CLI.
---
to avoid when building the documentation:
docs/system/arm/vmapple.rst:17:'any' reference target not found: https://github.com/s-u/macosvm
ninja: build stopped: subcommand failed.
Re: [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type
In reply to Philippe Mathieu-DaudéQuoted 79 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Phil Dennis-Jordan
From: Alexander Graf <[email protected]>
Apple defines a new "vmapple" machine type as part of its proprietary macOS Virtualization.Framework vmm. This machine type is similar to the virt one, but with subtle differences in base devices, a few special vmapple device additions and a vastly different boot chain.
Quoted 6 lines
This patch reimplements this machine type in QEMU. To use it, you have to have a readily installed version of macOS for VMApple, run on macOS with -accel hvf, pass the Virtualization.Framework boot rom (AVPBooter) in via -bios, pass the aux and root volume as pflash and pass aux and root volume as virtio drives. In addition, you also need to find the machine UUID and pass that as -M vmapple,uuid=
parameter:
Quoted 3 lines
$ qemu-system-aarch64 -accel hvf -M vmapple,uuid=0x1234 -m 4G \ -bios/System/Library/Frameworks/Virtualization.framework/Versions/A/Resources/AVPBooter.vmapple2.bin
Quoted 51 lines
-drive file=aux,if=pflash,format=raw \ -drive file=root,if=pflash,format=raw \ -drive file=aux,if=none,id=aux,format=raw \ -device vmapple-virtio-blk-pci,variant=aux,drive=aux \ -drive file=root,if=none,id=root,format=raw \ -device vmapple-virtio-blk-pci,variant=root,drive=rootWith all these in place, you should be able to see macOS booting successfully.
Known issues:
- Currently only macOS 12 guests are supported. The boot process for 13+ will need further investigation and adjustment.Signed-off-by Alexander Graf <[email protected]>Co-authored-by Phil Dennis-Jordan <[email protected]>Signed-off-by Phil Dennis-Jordan <[email protected]>Reviewed-by Akihiko Odaki <[email protected]>---
MAINTAINERS | 1 + contrib/vmapple/uuid.sh | 9 + docs/system/arm/vmapple.rst | 63 ++++ docs/system/target-arm.rst | 1 + hw/vmapple/Kconfig | 20 ++ hw/vmapple/meson.build | 1 + hw/vmapple/vmapple.c | 618 ++++++++++++++++++++++++++++++++++++ 7 files changed, 713 insertions(+)create mode 100755
contrib/vmapple/uuid.sh
create mode 100644docs/system/arm/vmapple.rst
create mode 100644hw/vmapple/vmapple.cMAINTAINERS +1
-0@@ -2791,6 +2791,7 @@ M: Phil Dennis-Jordan <[email protected]> S: Maintained F: hw/vmapple/* F: include/hw/vmapple/* +F: docs/system/arm/vmapple.rst Subsystems ----------contrib/vmapple/uuid.sh new file +0
-0contrib/vmapple/uuid.sh line 8
Quoted 8 lines
contrib/vmapple/uuid.sh new file +8
-0@@ -0,0 +1,9 @@ +#!/bin/sh +# Used for converting a guest provisioned using Virtualization.framework +# for use with the QEMU 'vmapple' aarch64 machine type. +# +# Extracts the Machine UUID from Virtualization.framework VM JSON file. +# (as produced by 'macosvm', passed as command line argument) + +plutil -extract machineId raw "$1" | base64 -d | plutil -extract ECIDraw -
Quoted 10 lines
docs/system/arm/vmapple.rst
Quoted 7 lines
contrib/vmapple/uuid.sh new file +1
-0+docs/system/arm/vmapple.rst new file +0
-0@@ -0,0 +1,63 @@Alex, Phil, we now mandate a SPDX tag. Due to the license used in
vmapple.cin this patch, are you OK with me squashing here:
Sorry about that, I forgot all about the SPDX tags in scripts and docs - yes, please add that SPDX on uuid.sh. The vmapple.rst is Alex's creation (I think I tweaked a few lines max) - but if that's the usual license we use for documentation as well then it seems a reasonable assumption to use GPL2+ there too if we don't hear from him.
Thanks for the doc syntax fix as well.
-- >8 --
Quoted 96 lines
docs/system/arm/vmapple.rst +2
-0@@ -0,0 +1,2 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later +contrib/vmapple/uuid.sh +3
-1@@ -1,0 +2 @@ +#@@ -6,0 +8,2 @@ +# +# SPDX-License-Identifier: GPL-2.0-or-later ---?
docs/system/arm/vmapple.rst line 1
Quoted 2 lines
docs/system/arm/vmapple.rst new file +1
-0+VMApple machine emulation+========================================================================================
docs/system/arm/vmapple.rst line 3
Quoted 2 lines
docs/system/arm/vmapple.rst new file +2
-0+ +VMApple is the device model that the macOS built-in hypervisor called"Virtualization.framework"
docs/system/arm/vmapple.rst line 4
Quoted 1 line
docs/system/arm/vmapple.rst new file +1
-0+exposes to Apple Silicon macOS guests. The "vmapple" machine model inQEMU implements the same
docs/system/arm/vmapple.rst line 14
Quoted 10 lines
docs/system/arm/vmapple.rst new file +10
-0+device model, but does not use any code from Virtualization.Framework. + +Prerequisites +------------- + +To run the vmapple machine model, you need to + + * Run on Apple Silicon + * Run on macOS 12.0 or above + * Have an already installed copy of a Virtualization.Framework macOS12 virtual
docs/system/arm/vmapple.rst line 15
Quoted 1 line
docs/system/arm/vmapple.rst new file +1
-0+ machine. Note that newer versions than 12.x are currently NOTsupported on
docs/system/arm/vmapple.rst line 19
Quoted 4 lines
docs/system/arm/vmapple.rst new file +4
-0+ the guest side. I will assume that you installed it using the + `macosvm <https://github.com/s-u/macosvm>` CLI. + +First, we need to extract the UUID from the virtual machine that youinstalled. You can do this
docs/system/arm/vmapple.rst line 20
Quoted 1 line
docs/system/arm/vmapple.rst new file +1
-0+by running the shell script in contrib/vmapple/uuid.sh on themacosvm.json file.
docs/system/arm/vmapple.rst line 27
Quoted 7 lines
docs/system/arm/vmapple.rst new file +7
-0+ +.. code-block:: bash + :caption: uuid.sh script to extract the UUID from a macosvm.json file + + $ contrib/vmapple/uuid.sh "path/to/macosvm.json" + +Now we also need to trim the aux partition. It contains metadata thatwe can just discard:
docs/system/arm/vmapple.rst line 37
Quoted 10 lines
docs/system/arm/vmapple.rst new file +10
-0+ +.. code-block:: bash + :caption: Command to trim the aux file + + $ dd if="aux.img" of="aux.img.trimmed" bs=$(( 0x4000 )) skip=1 + +How to run +---------- + +Then, we can launch QEMU with the Virtualization.Framework pre-bootenvironment and the readily
docs/system/arm/vmapple.rst line 38
Quoted 1 line
docs/system/arm/vmapple.rst new file +1
-0+installed target disk images. I recommend to port forward the VM's sshand vnc ports to the host
docs/system/arm/vmapple.rst line 45
Quoted 7 lines
docs/system/arm/vmapple.rst new file +7
-0+to get better interactive access into the target system: + +.. code-block:: bash + :caption: Example execution command line + + $ UUID="$(contrib/vmapple/uuid.sh 'macosvm.json')" + $AVPBOOTER="/System/Library/Frameworks/Virtualization.framework/Resources/AVPBooter.vmapple2.bin"
Quoted 5 lines
docs/system/arm/vmapple.rst new file +5
-0+ $ AUX="aux.img.trimmed" + $ DISK="disk.img" + $ qemu-system-aarch64 \ + -serial mon:stdio \ + -m 4G \docs/system/arm/vmapple.rst line 60
Quoted 10 lines
docs/system/arm/vmapple.rst new file +10
-0+ -accel hvf \ + -M vmapple,uuid="$UUID" \ + -bios "$AVPBOOTER" \ + -drive file="$AUX",if=pflash,format=raw \ + -drive file="$DISK",if=pflash,format=raw \ + -drive file="$AUX",if=none,id=aux,format=raw \ + -drive file="$DISK",if=none,id=root,format=raw \ + -device vmapple-virtio-blk-pci,variant=aux,drive=aux \ + -device vmapple-virtio-blk-pci,variant=root,drive=root \ + -netdevuser,id=net0,ipv6=off,hostfwd=tcp::2222-:22,hostfwd=tcp::5901-:5900 \
Quoted 2 lines
docs/system/arm/vmapple.rst new file +2
-0+ -device virtio-net-pci,netdev=net0 +
Re: [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type
Quoted 103 lines · Phil Dennis-Jordan
On Mon, 3 Mar 2025 at 19:20, Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
On 12/1/25 22:00, Phil Dennis-Jordan wrote:
> From: Alexander Graf <[email protected] <mailto:[email protected]>> >
> Apple defines a new "vmapple" machine type as part of its proprietary > macOS Virtualization.Framework vmm. This machine type is similar
to the
> virt one, but with subtle differences in base devices, a few special > vmapple device additions and a vastly different boot chain. >
> This patch reimplements this machine type in QEMU. To use it, you > have to have a readily installed version of macOS for VMApple, > run on macOS with -accel hvf, pass the Virtualization.Framework > boot rom (AVPBooter) in via -bios, pass the aux and root volume
as pflash
> and pass aux and root volume as virtio drives. In addition, you also > need to find the machine UUID and pass that as -M vmapple,uuid=
parameter:
>
> $ qemu-system-aarch64 -accel hvf -M vmapple,uuid=0x1234 -m 4G \
> -bios /System/Library/Frameworks/Virtualization.framework/
Versions/A/Resources/AVPBooter.vmapple2.bin
> -drive file=aux,if=pflash,format=raw \
> -drive file=root,if=pflash,format=raw \
> -drive file=aux,if=none,id=aux,format=raw \
> -device vmapple-virtio-blk-pci,variant=aux,drive=aux \
> -drive file=root,if=none,id=root,format=raw \
> -device vmapple-virtio-blk-pci,variant=root,drive=root >
> With all these in place, you should be able to see macOS booting > successfully.
>
> Known issues:
> - Currently only macOS 12 guests are supported. The boot
process for
> 13+ will need further investigation and adjustment.
>
> Signed-off-by: Alexander Graf <[email protected]
<mailto:[email protected]>>
> Co-authored-by: Phil Dennis-Jordan <[email protected]
<mailto:[email protected]>>
> Signed-off-by: Phil Dennis-Jordan <[email protected]
<mailto:[email protected]>>
> Reviewed-by: Akihiko Odaki <[email protected]
<mailto:[email protected]>>
> ---> MAINTAINERS | 1 +
> contrib/vmapple/uuid.sh | 9 +
> docs/system/arm/vmapple.rst | 63 ++++
> docs/system/target-arm.rst | 1 +
> hw/vmapple/Kconfig | 20 ++
> hw/vmapple/meson.build | 1 +
> hw/vmapple/vmapple.c | 618 +++++++++++++++++++++++++++++
+++++++
> 7 files changed, 713 insertions(+)
> create mode 100755contrib/vmapple/uuid.sh
> create mode 100644docs/system/arm/vmapple.rst
> create mode 100644hw/vmapple/vmapple.c
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> indexe220744abf..3a3d9e19f4100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -2791,6 +2791,7 @@ M: Phil Dennis-Jordan <[email protected]
<mailto:[email protected]>>
> S: Maintained
> F: hw/vmapple/*
> F:include/hw/vmapple/*
> +F:docs/system/arm/vmapple.rst
>
> Subsystems
> ----------
> diff --gita/contrib/vmapple/uuid.shb/contrib/vmapple/uuid.sh> new file mode 100755
> index 0000000000..956e8c3afe
> ---/dev/null
> +++b/contrib/vmapple/uuid.sh
> @@ -0,0 +1,9 @@
> +#!/bin/sh
> +# Used for converting a guest provisioned using
Virtualization.framework
> +# for use with the QEMU 'vmapple' aarch64 machine type. > +#
> +# Extracts the Machine UUID from Virtualization.framework VM
JSON file.
> +# (as produced by 'macosvm', passed as command line argument) > +
> +plutil -extract machineId raw "$1" | base64 -d | plutil -extract
ECID raw -
> +
> diff --gita/docs/system/arm/vmapple.rstb/docs/system/arm/
vmapple.rst
> new file mode 100644
> index 0000000000..5090a8997c
> ---/dev/null
> +++b/docs/system/arm/vmapple.rst
> @@ -0,0 +1,63 @@
Quoted 5 lines
Alex, Phil, we now mandate a SPDX tag. Due to the license used in
vmapple.cin this patch, are you OK with me squashing here:Sorry about that, I forgot all about the SPDX tags in scripts and docs - yes, please add that SPDX on
uuid.sh. Thevmapple.rstis Alex's creation (I think I tweaked a few lines max) - but if that's the usual license we use for documentation as well then it seems a reasonable assumption to use GPL2+ there too if we don't hear from him.
TBH IDK and IANAL :) "GPL-2.0-or-later" is about *program*, is it relevant for documentation? This is the single license used with SPDX in docs/:
$ git grep SPDX docs docs/system/devices/igb.rst:1:.. SPDX-License-Identifier: GPL-2.0-or-later docs/system/devices/virtio-gpu.rst:2: SPDX-License-Identifier: GPL-2.0-or-later
Note we also use the FreeBSD-DOC in bitmaps.rst (not as SPDX tag):
docs/interop/bitmaps.rst:5: This file is licensed via The FreeBSD Documentation License, the full
Per commit 2b96c1a4931 ("scripts: validate SPDX license choices"):
+ my $prefer = "GPL-2.0-or-later";
+ my @valid = qw(
+ GPL-2.0-only + LGPL-2.1-only + LGPL-2.1-or-later + BSD-2-Clause + BSD-3-Clause + MIT + );
GPL: "program"
LGPL: "library"
BSD/MIT: "software"
In doubt I'll stick with $prefer except if someone has a better clue / suggestion.
Quoted 22 lines
Thanks for the doc syntax fix as well.
-- >8 -- diff --git a/docs/system/arm/vmapple.rst b/docs/system/arm/vmapple.rst index 5090a8997c3..c5b1bcf45ea 100644 --- a/docs/system/arm/vmapple.rst +++ b/docs/system/arm/vmapple.rst @@ -0,0 +1,2 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + diff --git a/contrib/vmapple/uuid.sh b/contrib/vmapple/uuid.sh index 956e8c3afed..f5637221d23 100755 --- a/contrib/vmapple/uuid.sh +++ b/contrib/vmapple/uuid.sh @@ -1,0 +2 @@ +# @@ -6,0 +8,2 @@ +# +# SPDX-License-Identifier: GPL-2.0-or-later --- ?
Re: [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type
Quoted 52 lines · Philippe Mathieu-Daudé
Quoted 19 lines · Phil Dennis-Jordan
On Mon, 3 Mar 2025 at 19:20, Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
On 12/1/25 22:00, Phil Dennis-Jordan wrote:
> From: Alexander Graf <[email protected] <mailto:[email protected]>>> MAINTAINERS | 1 +
> contrib/vmapple/uuid.sh | 9 +
> docs/system/arm/vmapple.rst | 63 ++++
> docs/system/target-arm.rst | 1 +
> hw/vmapple/Kconfig | 20 ++
> hw/vmapple/meson.build | 1 +
> hw/vmapple/vmapple.c | 618 +++++++++++++++++++++++++++++
+++++++
> 7 files changed, 713 insertions(+)Quoted 7 lines
Alex, Phil, we now mandate a SPDX tag. Due to the license used in
vmapple.cin this patch, are you OK with me squashing here:Sorry about that, I forgot all about the SPDX tags in scripts and docs
- yes, please add that SPDX onuuid.sh. Thevmapple.rstis Alex's
creation (I think I tweaked a few lines max) - but if that's the usual license we use for documentation as well then it seems a reasonable assumption to use GPL2+ there too if we don't hear from him.TBH IDK and IANAL :) "GPL-2.0-or-later" is about *program*, is it relevant for documentation? This is the single license used with SPDX in docs/:
$ git grep SPDX docs docs/system/devices/igb.rst:1:.. SPDX-License-Identifier: GPL-2.0-or-later docs/system/devices/virtio-gpu.rst:2: SPDX-License-Identifier: GPL-2.0-or-laterNote we also use the FreeBSD-DOC in
bitmaps.rst(not as SPDX tag):docs/interop/bitmaps.rst:5: This file is licensed via The FreeBSD Documentation License, the full
Per commit
2b96c1a4931("scripts: validate SPDX license choices"):+ my $prefer = "GPL-2.0-or-later";
+ my @valid = qw(
+ GPL-2.0-only
+ LGPL-2.1-only
+ LGPL-2.1-or-later
+ BSD-2-Clause
+ BSD-3-Clause
+ MIT
+ );
Quoted 6 lines
GPL: "program"
LGPL: "library"
BSD/MIT: "software"In doubt I'll stick with $prefer except if someone has a better clue / suggestion.
FTR I'm going to send a PR including this series with the previously $prefer = "GPL-2.0-or-later" snippets squashed.
Regards,
Phil.
Re: [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type
In reply to Phil Dennis-JordanQuoted 92 lines · Phil Dennis-Jordan
From: Alexander Graf <[email protected]>
Apple defines a new "vmapple" machine type as part of its proprietary macOS Virtualization.Framework vmm. This machine type is similar to the virt one, but with subtle differences in base devices, a few special vmapple device additions and a vastly different boot chain.
This patch reimplements this machine type in QEMU. To use it, you have to have a readily installed version of macOS for VMApple, run on macOS with -accel hvf, pass the Virtualization.Framework boot rom (AVPBooter) in via -bios, pass the aux and root volume as pflash and pass aux and root volume as virtio drives. In addition, you also need to find the machine UUID and pass that as -M vmapple,uuid= parameter:
$ qemu-system-aarch64 -accel hvf -M vmapple,uuid=0x1234 -m 4G \ -bios /System/Library/Frameworks/Virtualization.framework/Versions/A/Resources/AVPBooter.vmapple2.bin -drive file=aux,if=pflash,format=raw \ -drive file=root,if=pflash,format=raw \ -drive file=aux,if=none,id=aux,format=raw \ -device vmapple-virtio-blk-pci,variant=aux,drive=aux \ -drive file=root,if=none,id=root,format=raw \ -device vmapple-virtio-blk-pci,variant=root,drive=rootWith all these in place, you should be able to see macOS booting successfully.
Known issues:
- Currently only macOS 12 guests are supported. The boot process for 13+ will need further investigation and adjustment.Signed-off-by Alexander Graf <[email protected]>Co-authored-by Phil Dennis-Jordan <[email protected]>Signed-off-by Phil Dennis-Jordan <[email protected]>Reviewed-by Akihiko Odaki <[email protected]>---
MAINTAINERS | 1 + contrib/vmapple/uuid.sh | 9 + docs/system/arm/vmapple.rst | 63 ++++ docs/system/target-arm.rst | 1 + hw/vmapple/Kconfig | 20 ++ hw/vmapple/meson.build | 1 + hw/vmapple/vmapple.c | 618 ++++++++++++++++++++++++++++++++++++ 7 files changed, 713 insertions(+)create mode 100755
contrib/vmapple/uuid.sh
create mode 100644docs/system/arm/vmapple.rst
create mode 100644hw/vmapple/vmapple.chw/vmapple/vmapple.c new file +36
-0@@ -0,0 +1,618 @@ +/* +* VMApple machine emulation +* +* Copyright © 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* VMApple is the device model that the macOS built-in hypervisor called +* "Virtualization.framework" exposes to Apple Silicon macOS guests. The +* machine model in this file implements the same device model in QEMU, but +* does not use any code from Virtualization.Framework. +*/ + +#include "qemu/osdep.h" +#include "qemu/bitops.h" +#include "qemu/datadir.h" +#include "qemu/error-report.h" +#include "qemu/guest-random.h" +#include "qemu/help-texts.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qemu/option.h" +#include "qemu/units.h" +#include "monitor/qdev.h" +#include "hw/boards.h" +#include "hw/irq.h" +#include "hw/loader.h" +#include "hw/qdev-properties.h" +#include "hw/sysbus.h" +#include "hw/usb.h" +#include "hw/arm/boot.h" +#include "hw/arm/primecell.h" +#include "hw/char/pl011.h"
hw/vmapple/vmapple.c line 46
Quoted 10 lines
hw/vmapple/vmapple.c new file +10
-0+#include "hw/intc/arm_gic.h" +#include "hw/intc/arm_gicv3_common.h" +#include "hw/misc/pvpanic.h" +#include "hw/pci-host/gpex.h" +#include "hw/usb/hcd-xhci-pci.h" +#include "hw/virtio/virtio-pci.h" +#include "hw/vmapple/vmapple.h" +#include "net/net.h" +#include "qapi/error.h" +#include "qapi/qmp/qlist.h"
FYI I replaced "qapi/qmp/qlist.h" by "qobject/qlist.h" due to commit 407bc4bf902 ("qapi: Move include/qapi/qmp/ to include/qobject/").
Quoted 7 lines
hw/vmapple/vmapple.c new file +7
-0+#include "qapi/visitor.h" +#include "qapi/qapi-visit-common.h" +#include "standard-headers/linux/input.h" +#include "system/hvf.h" +#include "system/reset.h" +#include "system/runstate.h" +#include "system/system.h"
Quoted 9 lines · Phil Dennis-Jordan
This patch set introduces a new ARM and macOS HVF specific machine type called "vmapple". There are also some patches for fixing XHCI spec compliance issues and adding a workaround to a quirk in the macOS guest's XHCI driver.
Phil Dennis-Jordan (3):
hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported
Patches 1 & 2 queued.
Phil Dennis-Jordan
Reviewed-by Michael S. TsirkinQuoted 7 lines · Philippe Mathieu-Daudé
Quoted 4 lines · Phil Dennis-Jordan
This patch set introduces a new ARM and macOS HVF specific machine type called "vmapple". There are also some patches for fixing XHCI spec compliance issues and adding a workaround to a quirk in the macOS guest's XHCI driver.
Quoted 6 lines
Quoted 3 lines
Phil Dennis-Jordan (3):
hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupportedPatches 1 & 2 queued.
Thanks!
It looks like I accidentally dropped Michael's Reviewed-by tag on patch 8:
https://patchew.org/QEMU/[email protected]/#[email protected]
Please add if v17 of the patch gets queued.
Phil
Quoted 5 lines · Phil Dennis-Jordan
This patch set introduces a new ARM and macOS HVF specific machine type called "vmapple". There are also some patches for fixing XHCI spec compliance issues and adding a workaround to a quirk in the macOS guest's XHCI driver.
Quoted 7 lines
The vmapple machine type approximates the configuration in macOS's own Virtualization.framework when running arm64 macOS guests. In addition to generic components such as a GICv3 and an XHCI USB controller, it includes nonstandard extensions to the virtio block device, a special "hardware" aes engine, a configuration device, a pvpanic variant, a "backdoor" interface, and of course the apple-gfx paravirtualised display adapter.
Hi!
It looks like this patchset has a few bugfixes which aren't specific to vmapple. These are already mentioned in this patchset description, namely:
hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported
Should these be picked up for qemu-stable?
Thanks,
/mjt
Quoted 350 lines
The macOS guest initially did not work well with QEMU's XHCI controller, which required some investigation, bug fixing, and a work-around.
Essentially, the macOS driver attempts to use XHCI event rings 1 and 2 even when there is only a single pin-based interrupt available. The interrupts for rings 1 and 2 are dropped, and so events are only handled after a timeout. The driver appears to expect the device to act as if interrupter mapping was not supported - the spec only mentions that interrupter mapping should be disabled if only one interrupter is enabled, not one interrupt, although there is potential ambiguity in the spec's wording around enabling and disabling interrupters.
In any case, this investigation has led to 3 changes:
* The spec requires that modulo arithmetic be used for selecting the MSI vector to notify from the interrupter/event ring index. (Patch 1)
* The spec requires that all events be directed at ring 0 if interrupter mapping is not available; the condition for this mentioned in the spec is when there is only 1 interrupter available. (Patch 2)
* A property is added to the PCI XHCI controller classes to disable interrupter mapping when using pin-based interrupts. This makes the macOS guest drivers work. (Patch 9) This is enabled in the vmapple machine type, which does not offer MSI(-X) support.There are currently a few limitations to the vmapple machine. These aren't intrinsic, just imperfect emulation of the VZF, but it's good enough to be just about usable for some purposes:
* macOS 12 guests only. Versions 13+ currently fail during early boot.
* macOS 11+ arm64 hosts only, with hvf accel. (Perhaps some differences between Apple M series CPUs and TCG's aarch64 implementation? macOS hosts only because ParavirtualizedGraphics.framework is a black box implementing most of the logic behind the apple-gfx device.)
* The guest OS must first be provisioned using Virtualization.framework; the disk images can subsequently be used in Qemu. (See docs.)Previous versions of this series also included the macOS PV graphics device ("apple-gfx"); those patches have already been merged, so the title has been changed. Previous iteration:
https://patchew.org/QEMU/[email protected]/Furthermore, the XHCI fixes and workaround were previously submitted as a separate patch set, of which a few patches have also been merged. "hw/usb/hcd-xhci: Fixes, improvements and macOS workaround"
https://patchew.org/QEMU/[email protected]/Finally, I've included one of Philippe Mathieu-Daudé's GICv3 patches which arose out of the discovery that the software GICv3 dependency was missing when building v16 and earlier versions of this series in a HVF-only configuration.
https://patchew.org/QEMU/[email protected]/---
v2 -> v3:
* Merged the apple-gfx and vmapple patchsets.
* Squashed a bunch of later apple-gfx patches into the main one. (dGPU support, queried MMIO area size, host GPU picking logic.)
* Rebased on latest upstream, fixing any breakages due to internal Qemu API changes.
* apple-gfx: Switched to re-entrant MMIO. This is supported by the underlying framework and simplifies the MMIO forwarding code which was previously different on x86-64 vs aarch64.
* vmapple: Fixes for minor bugs and comments from the last round of review.
* vmapple aes, conf, apple-gfx: Switched reset methods to implement the ResettableClass base's interface.
* vmapple: switched from virtio-hid to an XHCI USB controller and USB mouse and tablet devices. macOS does not provide drivers for virtio HID devices, at least not in version 12's vmapple kernel. So input now sort of works (interrupt issues) rather than not at all. Use network-based remote access to the guest OS as a work-around.v3 -> v4:
* Complete rework of the mechanism for handling runloop/libdispatch events on the main thread. PV graphics now work with the SDL UI.
* Renamed 'apple-gfx-vmapple' device to 'apple-gfx-mmio'
* hw/display/apple-gfx: threading model overhaul to be more consistent, safer, and more QEMU-idiomatic.
* display-modes property on the apple-gfx devices now uses the native array property mechanism and works on both device variants.
* hw/vmapple/aes: Improvements to logging and error handling.
* hw/vmapple/cfg: Bug fixes around device property default values.
* hw/vmapple/{aes,cfg,virtio-blk/vmapple}: Most header code moved into .c files, only a singlevmapple.hnow contains the #defines for the vmapple machine model-specific device type names.
* hw/block/virtio-blk: New patch for replacingvirtio_blk_free_requestwithg_free. (Optional)
* Various smaller changes following comments in v3 code review in apple-gfx, aes, cfg, bdif, virtio-blk-vmapple, and the vmapple machine type itself. See patch-specific v4 change notes for details.v4 -> v5:
* Simplified the main thread runloop mechanism. Back to setting
qemu_maindirectly, but narrowing the scope of what it needs to do, and it can now be NULL. (Meaning run the QEMU main event loop on the main thread as is traditional.)
* hw/display/apple-gfx: Further improvements to the BH based job code bridging the libdispatch & QEMU thread synchronisation impedance mismatch.
* hw/display/apple-gfx: Thread safety and object lifetime improvements.
* hw/display/apple-gfx-*: Better buffer and error handling in display mode property setters and getters.
* hw/vmapple/aes: More consistent and safer logging/tracing
* hw/vmapple/cfg: Better error reporting on overlong property strings.
* hw/vmapple/virtio-blk: Fixed theoretically-unaligned write to config buffer.
* vmapple machine type: Moved ecam region into machine state, improved device property setting error handling, improved ECID/UUID extraction script and docs.
* Various smaller fixes in apple-gfx/-mmio, apple-gfx-pci, vmapple/aes, vmapple/cfg, vmapple/virtio-blk, and vmapple machine type.
* Added SPDX license identifiers where they were missing.v5 -> v6:
* 01/15 (main/Cocoa/runloop): Combined functions, fixed whitespace
* 02/15 (apple-gfx): Further refinement of PVG threading: reduced some callback tasks from BHs to merely acquiring RCU read lock; replaced some libdispatch tasks with BHs; last remaining synchronous BH now uses emphemeral QemuSemaphore.
* 02/15 (apple-gfx): Readability improvements and other smaller tweaks (see patch change notes for details)
* 04/15 (display modes): Replaced use of alloca() with NSMutableArray.v6 -> v7:
* 02/15 (apple-gfx): Use
g_ptr_array_find()helper function, coding style tweak
* 03/15 (apple-gfx-pci): Removed an unused function parameter
* 04/15 (apple-gfx display mode property): Simplified error handling in property parsing.
* 10/15 (vmapple/aes): Coding style tweaks.
* 12/15 (vmapple/cfg): Changed error messages for overrun of properties with fixed-length strings to be more useful to users than developers.
* 15/15 (vmapple machine type): Tiny error handling fix, un-inlined functionv7 -> v8:
* 02/15 (apple-gfx): Naming and type use improvements, fixes for a bug and a leak.
* 04/15 (apple-gfx display mode property): Type use improvement
* 10/15 (vmapple/aes): Guest error logging tweaks.
* 11/15 (vmapple/bdif): Replaced uses ofcpu_physical_memory_readwithdma_memory_read, and ag_freecall withg_autofree.
* 12/15 (vmapple/cfg): Macro hygiene fix: consistently enclosing arguments in parens.
* 15/15 (vmapple machine type): Use less verbose pattern for defining uuid property.v8 -> v9:
* 01/16 (ui & main loop): Set
qemu_mainto NULL for GTK UI as well.
* 02/16 (apple-gfx): Pass device pointer tographic_console_init(), various non-functional changes.
* 03/16 (apple-gfx-pci): Fixup of changed common call, whitespace and comment formatting tweaks.
* 04/16 (apple-gfx display modes): Re-ordered type definitions so we can drop a 'struct' keyword.
* 10/16 (vmapple/aes): Replaced a use ofcpu_physical_memory_writewithdma_memory_write, minor style tweak.
* 11/16 (vmapple/bdif): Replaced uses ofcpu_physical_memory_writewithdma_memory_write.
* 13/16 (vmapple/virtio-blk): Correctly specifyclass_sizefor VMAppleVirtIOBlkClass.
* 15/16 (vmapple machine type): Documentation improvements, fixed variable name and struct field used during pvpanic device creation.
* 16/16 (NEW/RFC vmapple/virtio-blk): Proposed change to replace type hierarchy with a variant property. This seems cleaner and less confusing than the original approach to me, but I'm not sure if it warrants creation of a new QAPI enum and property type definition.v9 -> v10:
* 01/15 (ui & main loop): Added comments to
qemu_maindeclaration and GTK.
* 02/15 (apple-gfx): Reworked the way frame rendering code is threaded to use BHs for sections requiring BQL.
* 02/15 (apple-gfx): Fixed ./configure error on non-macOS platforms.
* 10/15 (vmapple/aes): Code style and comment improvements.
* 12/15 (vmapple/cfg): Slightly tidier error reporting for overlong property values.
* 13/15 (vmapple/virtio-blk): Folded v9 patch 16/16 into this one, changing the device type design to provide a single device type with a variant property instead of 2 different subtypes for aux and root volumes.
* 15/15 (vmapple machine type): Documentation fixup for changed virtio-blk device type; small improvements to shell commands in documentation; improved propagation of errors during cfg device instantiation.v10 -> v11:
* 01/15 (ui & main loop): Simplified
main.c, better comments & commit message
* 02/15 (apple-gfx): Give each PV display instance a unique serial number.
* 02 & 03/15 (apple-gfx, -pci): Formatting/style tweaks
* 15/15 (vmapple machine type): Improvements to shell code in docsv11 -> v12:
* 01/15 (ui & main loop): More precise wording of code comments.
* 02/15 (apple-gfx): Fixed memory management regressions introduced in v10; improved error handling; various more conmetic code adjustments
* 09/15 (GPEX): Fixed uses of deletedGPEX_NUM_IRQSconstant that have been added to QEMU since this patch was originally written.v12 -> v13:
* 15/15 (vmapple machine type): Bumped the machine type version from 9.2
to 10.0.* All patches in the series now have been positively reviewed and received corresponding reviewed-by tags.
v13 -> v14:
* 6/15 (hw/vmapple directory): Changed myself from reviewer to maintainer, as that seemed appropriate at this point.
* 15/15 (vmapple machine type): Gate creation of XHCI and USB HID devices behind if (defaults_enabled()).v14 -> v15
* Constified property tables to match Richard Henderson's recent project-
wide convention change. (patches 4/15, 7/15, 11/15, 12/15, & 13/15)v15 -> v16
* 14 patches now, as patch 8 has already been pulled. (Thanks Philippe!)
* Fixed a bunch of conflicts with upstream code motion:- DEFINE_PROP_END_OF_LIST removal (4/14 - apple-gfx mode list, 7/14 - pvpanic-mmio, 10/14 - bdif, 11/14 - cfg device, and 12/14 - vmapple-virtio-blk) - sysemu->system move/rename: (1/14 - ui/qemu-main, 2/14 - apple-gfx, 9/14 - aes, 10/14 - bdif, 14/14 - vmapple machine type)* 14/14 (vmapple machine type):
- Moved compatibility setting for removing legacy mode from virtio-pci to proper global property table rather than (ab)using sugar property.
- Removed a few superfluous #includes during sysemu rename cleanup.
- Removed machine type versioning as it's not necessary (yet?)
- Made memory map array constXHCI RFC -> v1:
* Gated conditional interrupter mapping support behind a property, enabled that property in the VMApple machine type.
* Added patch to fix the MSI vector assertion failure.
* Moved msi and msix properties from NEC XHCI controller to generic xhci-pci superclass as that also seems useful.
* Broke the workaround up into 2 patches, one for mapping disabling required by the standard, and one for the conditional disabling workaround.XHCI v1 -> v2:
* 1/6: Switch to modulo arithmetic for MSI vector number, as per spec.
* 6/6: Set the "conditional-intr-mapping" property viacompat_props.
* Commit message tweaksXHCI v2 -> v3:
* 2/6: In line with recent upstream changes, the property table is now const and no longer carries an end-of-list marker.
* The indentation fix (previously 5/6) has already been merged, so is no longer included.
* Added patch fixing up logging of certain unhandled MMIO cases. (4/6)
* 6/6: Moved the compat global property table into vmapple patch set -v16; we now just add the conditional-intr-mapping property to it in this patch. We also set the property on any device implementing the abstractTYPE_XHCI_PCIrather than only theTYPE_QEMU_XHCIdevice specifically.v16 -> v17
* Rebased on latest upstream (with minor conflict fixes)
* apple-gfx, GPEX, and ui/cocoa patches dropped as they have been merged.
* Unmerged patches from xhci series v3 combined into this series.
* vmapple machine type: Explicitly depend on software GICv3.
* vmapple machine type: Enable the new XHCI PCI conditional-intr-mapping property via the machine type's global compat property table.
* Integrated Philippe's patch on renaming the GICv3's confusing config name, and removing its TCG dependency. (It's needed with HVF too.)
* vmapple machine type: Dropped Tested-by tag because of above changesAlexander Graf (7):
hw: Add vmapple subdir
hw/misc/pvpanic: Add MMIO interface hw/vmapple/aes: Introduce aes engine hw/vmapple/bdif: Introduce vmapple backdoor interface hw/vmapple/cfg: Introduce vmapple cfg region hw/vmapple/virtio-blk: Add support for apple virtio-blk hw/vmapple/vmapple: Add vmapple machine typePhil Dennis-Jordan (3):
hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported hw/usb/hcd-xhci-pci: Adds property for disabling mapping in IRQ modePhilippe Mathieu-Daudé (1):
hw/intc: Remove TCG dependency onARM_GICV3MAINTAINERS | 8 + contrib/vmapple/uuid.sh | 9 + docs/system/arm/vmapple.rst | 63 +++ docs/system/target-arm.rst | 1 + hw/Kconfig | 1 + hw/block/virtio-blk.c | 19 +- hw/core/qdev-properties-system.c | 8 + hw/intc/Kconfig | 6 +- hw/intc/meson.build | 4 +- hw/meson.build | 1 + hw/misc/Kconfig | 4 + hw/misc/meson.build | 1 + hw/misc/pvpanic-mmio.c | 60 +++ hw/usb/hcd-xhci-pci.c | 25 ++ hw/usb/hcd-xhci-pci.h | 1 + hw/usb/hcd-xhci.c | 5 + hw/usb/hcd-xhci.h | 5 + hw/vmapple/Kconfig | 32 ++ hw/vmapple/aes.c | 581 ++++++++++++++++++++++++++ hw/vmapple/bdif.c | 274 ++++++++++++ hw/vmapple/cfg.c | 195 +++++++++ hw/vmapple/meson.build | 5 + hw/vmapple/trace-events | 21 + hw/vmapple/trace.h | 1 + hw/vmapple/virtio-blk.c | 204 +++++++++ hw/vmapple/vmapple.c | 618 ++++++++++++++++++++++++++++ include/hw/misc/pvpanic.h | 1 + include/hw/pci/pci_ids.h | 1 + include/hw/qdev-properties-system.h | 5 + include/hw/virtio/virtio-blk.h | 11 +- include/hw/vmapple/vmapple.h | 23 ++ include/qemu/cutils.h | 15 + meson.build | 1 + qapi/virtio.json | 14 + util/hexdump.c | 18 + 35 files changed, 2231 insertions(+), 10 deletions(-)create mode 100755
contrib/vmapple/uuid.sh
create mode 100644docs/system/arm/vmapple.rst
create mode 100644hw/misc/pvpanic-mmio.c
create mode 100644 hw/vmapple/Kconfig
create mode 100644hw/vmapple/aes.c
create mode 100644hw/vmapple/bdif.c
create mode 100644hw/vmapple/cfg.c
create mode 100644 hw/vmapple/meson.build
create mode 100644 hw/vmapple/trace-events
create mode 100644hw/vmapple/trace.h
create mode 100644hw/vmapple/virtio-blk.c
create mode 100644hw/vmapple/vmapple.c
create mode 100644include/hw/vmapple/vmapple.h
Quoted 16 lines · Michael Tokarev
Quoted 5 lines · Phil Dennis-Jordan
This patch set introduces a new ARM and macOS HVF specific machine type called "vmapple". There are also some patches for fixing XHCI spec compliance issues and adding a workaround to a quirk in the macOS guest's XHCI driver.
Quoted 7 lines
The vmapple machine type approximates the configuration in macOS's own Virtualization.framework when running arm64 macOS guests. In addition to generic components such as a GICv3 and an XHCI USB controller, it includes nonstandard extensions to the virtio block device, a special "hardware" aes engine, a configuration device, a pvpanic variant, a "backdoor" interface, and of course the apple-gfx paravirtualised display adapter.
Hi!
Quoted 9 lines
It looks like this patchset has a few bugfixes which aren't specific to vmapple. These are already mentioned in this patchset description, namely:
hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported
Should these be picked up for qemu-stable?
They should be pretty low-risk.
At least the first one very definitely fixes a bug, albeit obscure, that you can trigger in the wild. (Run a macOS guest and turn off MSI-X on the XHCI controller but leave MSI enabled, and QEMU will crash with a failed assertion.) So sure, why not apply this to stable.
I don't know if there are any extant guest OSes where the second patch is a necessary and sufficient fix. macOS will refuse to drive an XHCI controller with numintrs < 4 altogether. Other guest OSes I've tried never attempt to use more than one interrupter/event ring anyway. However, the patch implements the behaviour that is explicitly and clearly described in the spec regarding the situation of unsupported interrupter mapping.
macOS's driver needs this behaviour of no interrupter mapping when using pin-based interrupts even on a controller with nominally numintrs > 1, so to fix that you additionally need patch 9 and you enable the flag implemented in that patch. (I have to admit I'm still not convinced we need the flag: in my opinion the spec under-defines the pin-based situation anyway, and I struggle to imagine a sensible use case for the [current] behaviour with the flag disabled. More detailed discussion in the original RFC thread:
https://patchew.org/QEMU/[email protected]/ )
So the macOS compatibility fix for pin-based mode needs patches 2+9 and as it stands that introduces a new property, which I think disqualifies it from merging into *-stable?
I'm not sure it's worth applying patch 2 on its own to any stable branches.
I'm hoping Nick Piggin (cc'd) might post an updated and ready to merge version of his patches to upgrade the XHCI qtest suite, as I'd really like to build test cases for these patches on top of that.
Thanks,
Quoted 404 lines
/mjt
Quoted 30 lines
The macOS guest initially did not work well with QEMU's XHCI controller, which required some investigation, bug fixing, and a work-around.
Essentially, the macOS driver attempts to use XHCI event rings 1 and 2 even when there is only a single pin-based interrupt available. The interrupts for rings 1 and 2 are dropped, and so events are only handled after a timeout. The driver appears to expect the device to act as if interrupter mapping was not supported - the spec only mentions that interrupter mapping should be disabled if only one interrupter is enabled, not one interrupt, although there is potential ambiguity in the spec's wording around enabling and disabling interrupters.
In any case, this investigation has led to 3 changes:
* The spec requires that modulo arithmetic be used for selecting the MSI vector to notify from the interrupter/event ring index. (Patch 1)
* The spec requires that all events be directed at ring 0 if interrupter mapping is not available; the condition for this mentioned in the spec is when there is only 1 interrupter available. (Patch 2)
* A property is added to the PCI XHCI controller classes to disable interrupter mapping when using pin-based interrupts. This makes the macOS guest drivers work. (Patch 9) This is enabled in the vmapple machine type, which does not offer MSI(-X) support.There are currently a few limitations to the vmapple machine. These aren't intrinsic, just imperfect emulation of the VZF, but it's good enough to be just about usable for some purposes:
Quoted 6 lines
* macOS 12 guests only. Versions 13+ currently fail during early boot.
* macOS 11+ arm64 hosts only, with hvf accel. (Perhaps some differences between Apple M series CPUs and TCG's aarch64 implementation? macOS hosts only because ParavirtualizedGraphics.framework is a black box implementing most of the logic behind the apple-gfx device.)
* The guest OS must first be provisioned usingVirtualization.framework;
Quoted 62 lines
the disk images can subsequently be used in Qemu. (See docs.)
Previous versions of this series also included the macOS PV graphics device ("apple-gfx"); those patches have already been merged, so the title has been changed. Previous iteration:
https://patchew.org/QEMU/[email protected]/Furthermore, the XHCI fixes and workaround were previously submitted as a separate patch set, of which a few patches have also been merged. "hw/usb/hcd-xhci: Fixes, improvements and macOS workaround"
https://patchew.org/QEMU/[email protected]/Finally, I've included one of Philippe Mathieu-Daudé's GICv3 patches which arose out of the discovery that the software GICv3 dependency was missing when building v16 and earlier versions of this series in a HVF-only configuration.
https://patchew.org/QEMU/[email protected]/---
v2 -> v3:
* Merged the apple-gfx and vmapple patchsets.
* Squashed a bunch of later apple-gfx patches into the main one. (dGPU support, queried MMIO area size, host GPU picking logic.)
* Rebased on latest upstream, fixing any breakages due to internal Qemu API changes.
* apple-gfx: Switched to re-entrant MMIO. This is supported by the underlying framework and simplifies the MMIO forwarding code which was previously different on x86-64 vs aarch64.
* vmapple: Fixes for minor bugs and comments from the last round of review.
* vmapple aes, conf, apple-gfx: Switched reset methods to implement the ResettableClass base's interface.
* vmapple: switched from virtio-hid to an XHCI USB controller and USB mouse and tablet devices. macOS does not provide drivers for virtio HID devices, at least not in version 12's vmapple kernel. So input now sort of works (interrupt issues) rather than not at all. Use network-based remote access to the guest OS as a work-around.v3 -> v4:
* Complete rework of the mechanism for handling runloop/libdispatch events on the main thread. PV graphics now work with the SDL UI.
* Renamed 'apple-gfx-vmapple' device to 'apple-gfx-mmio'
* hw/display/apple-gfx: threading model overhaul to be more consistent, safer, and more QEMU-idiomatic.
* display-modes property on the apple-gfx devices now uses the native array property mechanism and works on both device variants.
* hw/vmapple/aes: Improvements to logging and error handling.
* hw/vmapple/cfg: Bug fixes around device property default values.
* hw/vmapple/{aes,cfg,virtio-blk/vmapple}: Most header code moved into .c files, only a singlevmapple.hnow contains the #defines for the vmapple machine model-specific device type names.
* hw/block/virtio-blk: New patch for replacingvirtio_blk_free_requestwithg_free. (Optional)
* Various smaller changes following comments in v3 code review in apple-gfx, aes, cfg, bdif, virtio-blk-vmapple, and the vmapple machine type itself. See patch-specific v4 change notes for details.Quoted 4 lines
v4 -> v5:
* Simplified the main thread runloop mechanism. Back to setting
qemu_maindirectly, but narrowing the scope of what it needs todo,
Quoted 3 lines
and it can now be NULL. (Meaning run the QEMU main event loop on the main thread as is traditional.)
* hw/display/apple-gfx: Further improvements to the BH based job codebridging
Quoted 3 lines
the libdispatch & QEMU thread synchronisation impedance mismatch.
* hw/display/apple-gfx: Thread safety and object lifetime improvements.
* hw/display/apple-gfx-*: Better buffer and error handling in displaymode
Quoted 4 lines
property setters and getters.
* hw/vmapple/aes: More consistent and safer logging/tracing
* hw/vmapple/cfg: Better error reporting on overlong property strings.
* hw/vmapple/virtio-blk: Fixed theoretically-unaligned write to configbuffer.
Quoted 1 line
* vmapple machine type: Moved ecam region into machine state, improved
device
Quoted 1 line
property setting error handling, improved ECID/UUID extraction
script and
Quoted 9 lines
docs.
* Various smaller fixes in apple-gfx/-mmio, apple-gfx-pci, vmapple/aes, vmapple/cfg, vmapple/virtio-blk, and vmapple machine type.
* Added SPDX license identifiers where they were missing.v5 -> v6:
* 01/15 (main/Cocoa/runloop): Combined functions, fixed whitespace
* 02/15 (apple-gfx): Further refinement of PVG threading: reduced somecallback
Quoted 1 line
tasks from BHs to merely acquiring RCU read lock; replaced some
libdispatch
Quoted 9 lines
tasks with BHs; last remaining synchronous BH now uses emphemeral QemuSemaphore.
* 02/15 (apple-gfx): Readability improvements and other smaller tweaks (see patch change notes for details)
* 04/15 (display modes): Replaced use ofalloca()with NSMutableArray.v6 -> v7:
* 02/15 (apple-gfx): Use
g_ptr_array_find()helper function, codingstyle tweak
Quoted 5 lines
* 03/15 (apple-gfx-pci): Removed an unused function parameter
* 04/15 (apple-gfx display mode property): Simplified error handling in property parsing.
* 10/15 (vmapple/aes): Coding style tweaks.
* 12/15 (vmapple/cfg): Changed error messages for overrun ofproperties with
Quoted 2 lines
fixed-length strings to be more useful to users than developers.
* 15/15 (vmapple machine type): Tiny error handling fix, un-inlinedfunction
Quoted 4 lines
v7 -> v8:
* 02/15 (apple-gfx): Naming and type use improvements, fixes for a bug
and a
Quoted 6 lines
leak.
* 04/15 (apple-gfx display mode property): Type use improvement
* 10/15 (vmapple/aes): Guest error logging tweaks.
* 11/15 (vmapple/bdif): Replaced uses ofcpu_physical_memory_readwithdma_memory_read, and ag_freecall withg_autofree.
* 12/15 (vmapple/cfg): Macro hygiene fix: consistently enclosingarguments in
Quoted 2 lines
parens.
* 15/15 (vmapple machine type): Use less verbose pattern for defininguuid
Quoted 6 lines
property.
v8 -> v9:
* 01/16 (ui & main loop): Set
qemu_mainto NULL for GTK UI as well.
* 02/16 (apple-gfx): Pass device pointer tographic_console_init(),various
Quoted 2 lines
non-functional changes.
* 03/16 (apple-gfx-pci): Fixup of changed common call, whitespace andcomment
Quoted 2 lines
formatting tweaks.
* 04/16 (apple-gfx display modes): Re-ordered type definitions so wecan drop
Quoted 8 lines
a 'struct' keyword.
* 10/16 (vmapple/aes): Replaced a use ofcpu_physical_memory_writewithdma_memory_write, minor style tweak.
* 11/16 (vmapple/bdif): Replaced uses ofcpu_physical_memory_writewithdma_memory_write.
* 13/16 (vmapple/virtio-blk): Correctly specifyclass_sizefor VMAppleVirtIOBlkClass.
* 15/16 (vmapple machine type): Documentation improvements, fixedvariable
Quoted 2 lines
name and struct field used during pvpanic device creation.
* 16/16 (NEW/RFC vmapple/virtio-blk): Proposed change to replace typehierarchy
Quoted 1 line
with a variant property. This seems cleaner and less confusing than
the
Quoted 1 line
original approach to me, but I'm not sure if it warrants creation of
a new
Quoted 5 lines
QAPI enum and property type definition.
v9 -> v10:
* 01/15 (ui & main loop): Added comments to
qemu_maindeclaration andGTK.
Quoted 1 line
* 02/15 (apple-gfx): Reworked the way frame rendering code is threaded
to use
Quoted 4 lines
BHs for sections requiring BQL.
* 02/15 (apple-gfx): Fixed ./configure error on non-macOS platforms.
* 10/15 (vmapple/aes): Code style and comment improvements.
* 12/15 (vmapple/cfg): Slightly tidier error reporting for overlongproperty
Quoted 2 lines
values.
* 13/15 (vmapple/virtio-blk): Folded v9 patch 16/16 into this one,changing
Quoted 3 lines
the device type design to provide a single device type with a variant
property instead of 2 different subtypes for aux and root volumes.
* 15/15 (vmapple machine type): Documentation fixup for changedvirtio-blk
Quoted 6 lines
device type; small improvements to shell commands in documentation; improved propagation of errors during cfg device instantiation.
v10 -> v11:
* 01/15 (ui & main loop): Simplified
main.c, better comments & commitmessage
Quoted 1 line
* 02/15 (apple-gfx): Give each PV display instance a unique serial
number.
Quoted 7 lines
* 02 & 03/15 (apple-gfx, -pci): Formatting/style tweaks
* 15/15 (vmapple machine type): Improvements to shell code in docsv11 -> v12:
* 01/15 (ui & main loop): More precise wording of code comments.
* 02/15 (apple-gfx): Fixed memory management regressions introduced inv10;
Quoted 2 lines
improved error handling; various more conmetic code adjustments
* 09/15 (GPEX): Fixed uses of deletedGPEX_NUM_IRQSconstant that havebeen
Quoted 5 lines
added to QEMU since this patch was originally written.
v12 -> v13:
* 15/15 (vmapple machine type): Bumped the machine type version from
9.2
Quoted 2 lines
to 10.0.* All patches in the series now have been positively reviewed and
received
Quoted 4 lines
corresponding reviewed-by tags.
v13 -> v14:
Quoted 8 lines
* 6/15 (hw/vmapple directory): Changed myself from reviewer to maintainer, as that seemed appropriate at this point.
* 15/15 (vmapple machine type): Gate creation of XHCI and USB HID devices behind if (defaults_enabled()).v14 -> v15
* Constified property tables to match Richard Henderson's recent
project-
Quoted 5 lines
wide convention change. (patches 4/15, 7/15, 11/15, 12/15, & 13/15)v15 -> v16
* 14 patches now, as patch 8 has already been pulled. (Thanks
Philippe!)
Quoted 2 lines
* Fixed a bunch of conflicts with upstream code motion:
-DEFINE_PROP_END_OF_LISTremoval (4/14 - apple-gfx mode list, 7/14-
Quoted 3 lines
pvpanic-mmio, 10/14 - bdif, 11/14 - cfg device, and 12/14 - vmapple-virtio-blk) - sysemu->system move/rename: (1/14 - ui/qemu-main, 2/14 -apple-gfx,
Quoted 3 lines
9/14 - aes, 10/14 - bdif, 14/14 - vmapple machine type)* 14/14 (vmapple machine type):
- Moved compatibility setting for removing legacy mode fromvirtio-pci
Quoted 1 line
to proper global property table rather than (ab)using sugar
property.
Quoted 7 lines
- Removed a few superfluous #includes during sysemu rename cleanup.
- Removed machine type versioning as it's not necessary (yet?)
- Made memory map array constXHCI RFC -> v1:
* Gated conditional interrupter mapping support behind a property,
enabled
Quoted 3 lines
that property in the VMApple machine type.
* Added patch to fix the MSI vector assertion failure.
* Moved msi and msix properties from NEC XHCI controller to genericxhci-pci
Quoted 2 lines
superclass as that also seems useful.
* Broke the workaround up into 2 patches, one for mapping disablingrequired
Quoted 8 lines
by the standard, and one for the conditional disabling workaround.
XHCI v1 -> v2:
* 1/6: Switch to modulo arithmetic for MSI vector number, as per spec.
* 6/6: Set the "conditional-intr-mapping" property viacompat_props.
* Commit message tweaksQuoted 5 lines
XHCI v2 -> v3:
* 2/6: In line with recent upstream changes, the property table is now const and no longer carries an end-of-list marker.
* The indentation fix (previously 5/6) has already been merged, so isno
Quoted 3 lines
longer included.
* Added patch fixing up logging of certain unhandled MMIO cases. (4/6)
* 6/6: Moved the compat global property table into vmapple patch set-v16;
Quoted 2 lines
we now just add the conditional-intr-mapping property to it in this patch. We also set the property on any device implementing the
abstract
Quoted 1 line
TYPE_XHCI_PCIrather than only theTYPE_QEMU_XHCIdevicespecifically.
Quoted 5 lines
v16 -> v17
* Rebased on latest upstream (with minor conflict fixes)
* apple-gfx, GPEX, and ui/cocoa patches dropped as they have beenmerged.
Quoted 3 lines
* Unmerged patches from xhci series v3 combined into this series.
* vmapple machine type: Explicitly depend on software GICv3.
* vmapple machine type: Enable the new XHCI PCIconditional-intr-mapping
Quoted 2 lines
property via the machine type's global compat property table.
* Integrated Philippe's patch on renaming the GICv3's confusing configname,
Quoted 71 lines
and removing its TCG dependency. (It's needed with HVF too.)
* vmapple machine type: Dropped Tested-by tag because of above changesAlexander Graf (7):
hw: Add vmapple subdir
hw/misc/pvpanic: Add MMIO interface hw/vmapple/aes: Introduce aes engine hw/vmapple/bdif: Introduce vmapple backdoor interface hw/vmapple/cfg: Introduce vmapple cfg region hw/vmapple/virtio-blk: Add support for apple virtio-blk hw/vmapple/vmapple: Add vmapple machine typePhil Dennis-Jordan (3):
hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported hw/usb/hcd-xhci-pci: Adds property for disabling mapping in IRQ modePhilippe Mathieu-Daudé (1):
hw/intc: Remove TCG dependency onARM_GICV3MAINTAINERS | 8 + contrib/vmapple/uuid.sh | 9 + docs/system/arm/vmapple.rst | 63 +++ docs/system/target-arm.rst | 1 + hw/Kconfig | 1 + hw/block/virtio-blk.c | 19 +- hw/core/qdev-properties-system.c | 8 + hw/intc/Kconfig | 6 +- hw/intc/meson.build | 4 +- hw/meson.build | 1 + hw/misc/Kconfig | 4 + hw/misc/meson.build | 1 + hw/misc/pvpanic-mmio.c | 60 +++ hw/usb/hcd-xhci-pci.c | 25 ++ hw/usb/hcd-xhci-pci.h | 1 + hw/usb/hcd-xhci.c | 5 + hw/usb/hcd-xhci.h | 5 + hw/vmapple/Kconfig | 32 ++ hw/vmapple/aes.c | 581 ++++++++++++++++++++++++++ hw/vmapple/bdif.c | 274 ++++++++++++ hw/vmapple/cfg.c | 195 +++++++++ hw/vmapple/meson.build | 5 + hw/vmapple/trace-events | 21 + hw/vmapple/trace.h | 1 + hw/vmapple/virtio-blk.c | 204 +++++++++ hw/vmapple/vmapple.c | 618 ++++++++++++++++++++++++++++ include/hw/misc/pvpanic.h | 1 + include/hw/pci/pci_ids.h | 1 + include/hw/qdev-properties-system.h | 5 + include/hw/virtio/virtio-blk.h | 11 +- include/hw/vmapple/vmapple.h | 23 ++ include/qemu/cutils.h | 15 + meson.build | 1 + qapi/virtio.json | 14 + util/hexdump.c | 18 + 35 files changed, 2231 insertions(+), 10 deletions(-)create mode 100755
contrib/vmapple/uuid.sh
create mode 100644docs/system/arm/vmapple.rst
create mode 100644hw/misc/pvpanic-mmio.c
create mode 100644 hw/vmapple/Kconfig
create mode 100644hw/vmapple/aes.c
create mode 100644hw/vmapple/bdif.c
create mode 100644hw/vmapple/cfg.c
create mode 100644 hw/vmapple/meson.build
create mode 100644 hw/vmapple/trace-events
create mode 100644hw/vmapple/trace.h
create mode 100644hw/vmapple/virtio-blk.c
create mode 100644hw/vmapple/vmapple.c
create mode 100644include/hw/vmapple/vmapple.h
Quoted 63 lines · Phil Dennis-Jordan
This patch set introduces a new ARM and macOS HVF specific machine type called "vmapple". There are also some patches for fixing XHCI spec compliance issues and adding a workaround to a quirk in the macOS guest's XHCI driver.
The vmapple machine type approximates the configuration in macOS's own Virtualization.framework when running arm64 macOS guests. In addition to generic components such as a GICv3 and an XHCI USB controller, it includes nonstandard extensions to the virtio block device, a special "hardware" aes engine, a configuration device, a pvpanic variant, a "backdoor" interface, and of course the apple-gfx paravirtualised display adapter.
The macOS guest initially did not work well with QEMU's XHCI controller, which required some investigation, bug fixing, and a work-around.
Essentially, the macOS driver attempts to use XHCI event rings 1 and 2 even when there is only a single pin-based interrupt available. The interrupts for rings 1 and 2 are dropped, and so events are only handled after a timeout. The driver appears to expect the device to act as if interrupter mapping was not supported - the spec only mentions that interrupter mapping should be disabled if only one interrupter is enabled, not one interrupt, although there is potential ambiguity in the spec's wording around enabling and disabling interrupters.
In any case, this investigation has led to 3 changes:
* The spec requires that modulo arithmetic be used for selecting the MSI vector to notify from the interrupter/event ring index. (Patch 1)
* The spec requires that all events be directed at ring 0 if interrupter mapping is not available; the condition for this mentioned in the spec is when there is only 1 interrupter available. (Patch 2)
* A property is added to the PCI XHCI controller classes to disable interrupter mapping when using pin-based interrupts. This makes the macOS guest drivers work. (Patch 9) This is enabled in the vmapple machine type, which does not offer MSI(-X) support.There are currently a few limitations to the vmapple machine. These aren't intrinsic, just imperfect emulation of the VZF, but it's good enough to be just about usable for some purposes:
* macOS 12 guests only. Versions 13+ currently fail during early boot.
* macOS 11+ arm64 hosts only, with hvf accel. (Perhaps some differences between Apple M series CPUs and TCG's aarch64 implementation? macOS hosts only because ParavirtualizedGraphics.framework is a black box implementing most of the logic behind the apple-gfx device.)
* The guest OS must first be provisioned using Virtualization.framework; the disk images can subsequently be used in Qemu. (See docs.)Previous versions of this series also included the macOS PV graphics device ("apple-gfx"); those patches have already been merged, so the title has been changed. Previous iteration:
https://patchew.org/QEMU/[email protected]/Furthermore, the XHCI fixes and workaround were previously submitted as a separate patch set, of which a few patches have also been merged. "hw/usb/hcd-xhci: Fixes, improvements and macOS workaround"
https://patchew.org/QEMU/[email protected]/
Quoted 5 lines
Finally, I've included one of Philippe Mathieu-Daudé's GICv3 patches which arose out of the discovery that the software GICv3 dependency was missing when building v16 and earlier versions of this series in a HVF-only configuration.
https://patchew.org/QEMU/[email protected]/
just to make sure, who is merging this? Me?
Quoted 297 lines
---
v2 -> v3:
* Merged the apple-gfx and vmapple patchsets.
* Squashed a bunch of later apple-gfx patches into the main one. (dGPU support, queried MMIO area size, host GPU picking logic.)
* Rebased on latest upstream, fixing any breakages due to internal Qemu API changes.
* apple-gfx: Switched to re-entrant MMIO. This is supported by the underlying framework and simplifies the MMIO forwarding code which was previously different on x86-64 vs aarch64.
* vmapple: Fixes for minor bugs and comments from the last round of review.
* vmapple aes, conf, apple-gfx: Switched reset methods to implement the ResettableClass base's interface.
* vmapple: switched from virtio-hid to an XHCI USB controller and USB mouse and tablet devices. macOS does not provide drivers for virtio HID devices, at least not in version 12's vmapple kernel. So input now sort of works (interrupt issues) rather than not at all. Use network-based remote access to the guest OS as a work-around.v3 -> v4:
* Complete rework of the mechanism for handling runloop/libdispatch events on the main thread. PV graphics now work with the SDL UI.
* Renamed 'apple-gfx-vmapple' device to 'apple-gfx-mmio'
* hw/display/apple-gfx: threading model overhaul to be more consistent, safer, and more QEMU-idiomatic.
* display-modes property on the apple-gfx devices now uses the native array property mechanism and works on both device variants.
* hw/vmapple/aes: Improvements to logging and error handling.
* hw/vmapple/cfg: Bug fixes around device property default values.
* hw/vmapple/{aes,cfg,virtio-blk/vmapple}: Most header code moved into .c files, only a singlevmapple.hnow contains the #defines for the vmapple machine model-specific device type names.
* hw/block/virtio-blk: New patch for replacingvirtio_blk_free_requestwithg_free. (Optional)
* Various smaller changes following comments in v3 code review in apple-gfx, aes, cfg, bdif, virtio-blk-vmapple, and the vmapple machine type itself. See patch-specific v4 change notes for details.v4 -> v5:
* Simplified the main thread runloop mechanism. Back to setting
qemu_maindirectly, but narrowing the scope of what it needs to do, and it can now be NULL. (Meaning run the QEMU main event loop on the main thread as is traditional.)
* hw/display/apple-gfx: Further improvements to the BH based job code bridging the libdispatch & QEMU thread synchronisation impedance mismatch.
* hw/display/apple-gfx: Thread safety and object lifetime improvements.
* hw/display/apple-gfx-*: Better buffer and error handling in display mode property setters and getters.
* hw/vmapple/aes: More consistent and safer logging/tracing
* hw/vmapple/cfg: Better error reporting on overlong property strings.
* hw/vmapple/virtio-blk: Fixed theoretically-unaligned write to config buffer.
* vmapple machine type: Moved ecam region into machine state, improved device property setting error handling, improved ECID/UUID extraction script and docs.
* Various smaller fixes in apple-gfx/-mmio, apple-gfx-pci, vmapple/aes, vmapple/cfg, vmapple/virtio-blk, and vmapple machine type.
* Added SPDX license identifiers where they were missing.v5 -> v6:
* 01/15 (main/Cocoa/runloop): Combined functions, fixed whitespace
* 02/15 (apple-gfx): Further refinement of PVG threading: reduced some callback tasks from BHs to merely acquiring RCU read lock; replaced some libdispatch tasks with BHs; last remaining synchronous BH now uses emphemeral QemuSemaphore.
* 02/15 (apple-gfx): Readability improvements and other smaller tweaks (see patch change notes for details)
* 04/15 (display modes): Replaced use of alloca() with NSMutableArray.v6 -> v7:
* 02/15 (apple-gfx): Use
g_ptr_array_find()helper function, coding style tweak
* 03/15 (apple-gfx-pci): Removed an unused function parameter
* 04/15 (apple-gfx display mode property): Simplified error handling in property parsing.
* 10/15 (vmapple/aes): Coding style tweaks.
* 12/15 (vmapple/cfg): Changed error messages for overrun of properties with fixed-length strings to be more useful to users than developers.
* 15/15 (vmapple machine type): Tiny error handling fix, un-inlined functionv7 -> v8:
* 02/15 (apple-gfx): Naming and type use improvements, fixes for a bug and a leak.
* 04/15 (apple-gfx display mode property): Type use improvement
* 10/15 (vmapple/aes): Guest error logging tweaks.
* 11/15 (vmapple/bdif): Replaced uses ofcpu_physical_memory_readwithdma_memory_read, and ag_freecall withg_autofree.
* 12/15 (vmapple/cfg): Macro hygiene fix: consistently enclosing arguments in parens.
* 15/15 (vmapple machine type): Use less verbose pattern for defining uuid property.v8 -> v9:
* 01/16 (ui & main loop): Set
qemu_mainto NULL for GTK UI as well.
* 02/16 (apple-gfx): Pass device pointer tographic_console_init(), various non-functional changes.
* 03/16 (apple-gfx-pci): Fixup of changed common call, whitespace and comment formatting tweaks.
* 04/16 (apple-gfx display modes): Re-ordered type definitions so we can drop a 'struct' keyword.
* 10/16 (vmapple/aes): Replaced a use ofcpu_physical_memory_writewithdma_memory_write, minor style tweak.
* 11/16 (vmapple/bdif): Replaced uses ofcpu_physical_memory_writewithdma_memory_write.
* 13/16 (vmapple/virtio-blk): Correctly specifyclass_sizefor VMAppleVirtIOBlkClass.
* 15/16 (vmapple machine type): Documentation improvements, fixed variable name and struct field used during pvpanic device creation.
* 16/16 (NEW/RFC vmapple/virtio-blk): Proposed change to replace type hierarchy with a variant property. This seems cleaner and less confusing than the original approach to me, but I'm not sure if it warrants creation of a new QAPI enum and property type definition.v9 -> v10:
* 01/15 (ui & main loop): Added comments to
qemu_maindeclaration and GTK.
* 02/15 (apple-gfx): Reworked the way frame rendering code is threaded to use BHs for sections requiring BQL.
* 02/15 (apple-gfx): Fixed ./configure error on non-macOS platforms.
* 10/15 (vmapple/aes): Code style and comment improvements.
* 12/15 (vmapple/cfg): Slightly tidier error reporting for overlong property values.
* 13/15 (vmapple/virtio-blk): Folded v9 patch 16/16 into this one, changing the device type design to provide a single device type with a variant property instead of 2 different subtypes for aux and root volumes.
* 15/15 (vmapple machine type): Documentation fixup for changed virtio-blk device type; small improvements to shell commands in documentation; improved propagation of errors during cfg device instantiation.v10 -> v11:
* 01/15 (ui & main loop): Simplified
main.c, better comments & commit message
* 02/15 (apple-gfx): Give each PV display instance a unique serial number.
* 02 & 03/15 (apple-gfx, -pci): Formatting/style tweaks
* 15/15 (vmapple machine type): Improvements to shell code in docsv11 -> v12:
* 01/15 (ui & main loop): More precise wording of code comments.
* 02/15 (apple-gfx): Fixed memory management regressions introduced in v10; improved error handling; various more conmetic code adjustments
* 09/15 (GPEX): Fixed uses of deletedGPEX_NUM_IRQSconstant that have been added to QEMU since this patch was originally written.v12 -> v13:
* 15/15 (vmapple machine type): Bumped the machine type version from 9.2 to 10.0.
* All patches in the series now have been positively reviewed and received corresponding reviewed-by tags.v13 -> v14:
* 6/15 (hw/vmapple directory): Changed myself from reviewer to maintainer, as that seemed appropriate at this point.
* 15/15 (vmapple machine type): Gate creation of XHCI and USB HID devices behind if (defaults_enabled()).v14 -> v15
* Constified property tables to match Richard Henderson's recent project- wide convention change. (patches 4/15, 7/15, 11/15, 12/15, & 13/15)
v15 -> v16
* 14 patches now, as patch 8 has already been pulled. (Thanks Philippe!)
* Fixed a bunch of conflicts with upstream code motion:- DEFINE_PROP_END_OF_LIST removal (4/14 - apple-gfx mode list, 7/14 - pvpanic-mmio, 10/14 - bdif, 11/14 - cfg device, and 12/14 - vmapple-virtio-blk) - sysemu->system move/rename: (1/14 - ui/qemu-main, 2/14 - apple-gfx, 9/14 - aes, 10/14 - bdif, 14/14 - vmapple machine type)* 14/14 (vmapple machine type):
- Moved compatibility setting for removing legacy mode from virtio-pci to proper global property table rather than (ab)using sugar property.
- Removed a few superfluous #includes during sysemu rename cleanup.
- Removed machine type versioning as it's not necessary (yet?)
- Made memory map array constXHCI RFC -> v1:
* Gated conditional interrupter mapping support behind a property, enabled that property in the VMApple machine type.
* Added patch to fix the MSI vector assertion failure.
* Moved msi and msix properties from NEC XHCI controller to generic xhci-pci superclass as that also seems useful.
* Broke the workaround up into 2 patches, one for mapping disabling required by the standard, and one for the conditional disabling workaround.XHCI v1 -> v2:
* 1/6: Switch to modulo arithmetic for MSI vector number, as per spec.
* 6/6: Set the "conditional-intr-mapping" property viacompat_props.
* Commit message tweaksXHCI v2 -> v3:
* 2/6: In line with recent upstream changes, the property table is now const and no longer carries an end-of-list marker.
* The indentation fix (previously 5/6) has already been merged, so is no longer included.
* Added patch fixing up logging of certain unhandled MMIO cases. (4/6)
* 6/6: Moved the compat global property table into vmapple patch set -v16; we now just add the conditional-intr-mapping property to it in this patch. We also set the property on any device implementing the abstractTYPE_XHCI_PCIrather than only theTYPE_QEMU_XHCIdevice specifically.v16 -> v17
* Rebased on latest upstream (with minor conflict fixes)
* apple-gfx, GPEX, and ui/cocoa patches dropped as they have been merged.
* Unmerged patches from xhci series v3 combined into this series.
* vmapple machine type: Explicitly depend on software GICv3.
* vmapple machine type: Enable the new XHCI PCI conditional-intr-mapping property via the machine type's global compat property table.
* Integrated Philippe's patch on renaming the GICv3's confusing config name, and removing its TCG dependency. (It's needed with HVF too.)
* vmapple machine type: Dropped Tested-by tag because of above changesAlexander Graf (7):
hw: Add vmapple subdir
hw/misc/pvpanic: Add MMIO interface hw/vmapple/aes: Introduce aes engine hw/vmapple/bdif: Introduce vmapple backdoor interface hw/vmapple/cfg: Introduce vmapple cfg region hw/vmapple/virtio-blk: Add support for apple virtio-blk hw/vmapple/vmapple: Add vmapple machine typePhil Dennis-Jordan (3):
hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported hw/usb/hcd-xhci-pci: Adds property for disabling mapping in IRQ modePhilippe Mathieu-Daudé (1):
hw/intc: Remove TCG dependency onARM_GICV3MAINTAINERS | 8 + contrib/vmapple/uuid.sh | 9 + docs/system/arm/vmapple.rst | 63 +++ docs/system/target-arm.rst | 1 + hw/Kconfig | 1 + hw/block/virtio-blk.c | 19 +- hw/core/qdev-properties-system.c | 8 + hw/intc/Kconfig | 6 +- hw/intc/meson.build | 4 +- hw/meson.build | 1 + hw/misc/Kconfig | 4 + hw/misc/meson.build | 1 + hw/misc/pvpanic-mmio.c | 60 +++ hw/usb/hcd-xhci-pci.c | 25 ++ hw/usb/hcd-xhci-pci.h | 1 + hw/usb/hcd-xhci.c | 5 + hw/usb/hcd-xhci.h | 5 + hw/vmapple/Kconfig | 32 ++ hw/vmapple/aes.c | 581 ++++++++++++++++++++++++++ hw/vmapple/bdif.c | 274 ++++++++++++ hw/vmapple/cfg.c | 195 +++++++++ hw/vmapple/meson.build | 5 + hw/vmapple/trace-events | 21 + hw/vmapple/trace.h | 1 + hw/vmapple/virtio-blk.c | 204 +++++++++ hw/vmapple/vmapple.c | 618 ++++++++++++++++++++++++++++ include/hw/misc/pvpanic.h | 1 + include/hw/pci/pci_ids.h | 1 + include/hw/qdev-properties-system.h | 5 + include/hw/virtio/virtio-blk.h | 11 +- include/hw/vmapple/vmapple.h | 23 ++ include/qemu/cutils.h | 15 + meson.build | 1 + qapi/virtio.json | 14 + util/hexdump.c | 18 + 35 files changed, 2231 insertions(+), 10 deletions(-) create mode 100755 contrib/vmapple/uuid.sh create mode 100644 docs/system/arm/vmapple.rst create mode 100644 hw/misc/pvpanic-mmio.c create mode 100644 hw/vmapple/Kconfig 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/meson.build create mode 100644 hw/vmapple/trace-events create mode 100644 hw/vmapple/trace.h create mode 100644 hw/vmapple/virtio-blk.c create mode 100644 hw/vmapple/vmapple.c create mode 100644 include/hw/vmapple/vmapple.hSignature · 1 line
2.39.5 (Apple Git-154)
Quoted 64 lines · Michael S. Tsirkin
Quoted 63 lines · Phil Dennis-Jordan
This patch set introduces a new ARM and macOS HVF specific machine type called "vmapple". There are also some patches for fixing XHCI spec compliance issues and adding a workaround to a quirk in the macOS guest's XHCI driver.
The vmapple machine type approximates the configuration in macOS's own Virtualization.framework when running arm64 macOS guests. In addition to generic components such as a GICv3 and an XHCI USB controller, it includes nonstandard extensions to the virtio block device, a special "hardware" aes engine, a configuration device, a pvpanic variant, a "backdoor" interface, and of course the apple-gfx paravirtualised display adapter.
The macOS guest initially did not work well with QEMU's XHCI controller, which required some investigation, bug fixing, and a work-around.
Essentially, the macOS driver attempts to use XHCI event rings 1 and 2 even when there is only a single pin-based interrupt available. The interrupts for rings 1 and 2 are dropped, and so events are only handled after a timeout. The driver appears to expect the device to act as if interrupter mapping was not supported - the spec only mentions that interrupter mapping should be disabled if only one interrupter is enabled, not one interrupt, although there is potential ambiguity in the spec's wording around enabling and disabling interrupters.
In any case, this investigation has led to 3 changes:
* The spec requires that modulo arithmetic be used for selecting the MSI vector to notify from the interrupter/event ring index. (Patch 1)
* The spec requires that all events be directed at ring 0 if interrupter mapping is not available; the condition for this mentioned in the spec is when there is only 1 interrupter available. (Patch 2)
* A property is added to the PCI XHCI controller classes to disable interrupter mapping when using pin-based interrupts. This makes the macOS guest drivers work. (Patch 9) This is enabled in the vmapple machine type, which does not offer MSI(-X) support.There are currently a few limitations to the vmapple machine. These aren't intrinsic, just imperfect emulation of the VZF, but it's good enough to be just about usable for some purposes:
* macOS 12 guests only. Versions 13+ currently fail during early boot.
* macOS 11+ arm64 hosts only, with hvf accel. (Perhaps some differences between Apple M series CPUs and TCG's aarch64 implementation? macOS hosts only because ParavirtualizedGraphics.framework is a black box implementing most of the logic behind the apple-gfx device.)
* The guest OS must first be provisioned using Virtualization.framework; the disk images can subsequently be used in Qemu. (See docs.)Previous versions of this series also included the macOS PV graphics device ("apple-gfx"); those patches have already been merged, so the title has been changed. Previous iteration:
https://patchew.org/QEMU/[email protected]/Furthermore, the XHCI fixes and workaround were previously submitted as a separate patch set, of which a few patches have also been merged. "hw/usb/hcd-xhci: Fixes, improvements and macOS workaround"
https://patchew.org/QEMU/[email protected]/
Quoted 9 lines
Quoted 5 lines
Finally, I've included one of Philippe Mathieu-Daudé's GICv3 patches which arose out of the discovery that the software GICv3 dependency was missing when building v16 and earlier versions of this series in a HVF-only configuration.
https://patchew.org/QEMU/[email protected]/just to make sure, who is merging this? Me?
ICYMI, Phil M-D has already pulled patches 1 & 2, and Stefan has merged them into staging & master.
As I understand it, Phil M-D was also in the process of merging the rest of v16 of this series before discovering the GICv3 dependency/Kconfig issue:
https://lore.kernel.org/qemu-devel/[email protected]/
I don't really mind either way who merges this, but he might have some more thoughts on the matter - there might be a specific reason he's so far only picked up those two patches. :-)
Quoted 340 lines
---
Quoted 42 lines
v2 -> v3:
* Merged the apple-gfx and vmapple patchsets.
* Squashed a bunch of later apple-gfx patches into the main one. (dGPU support, queried MMIO area size, host GPU picking logic.)
* Rebased on latest upstream, fixing any breakages due to internal Qemu API changes.
* apple-gfx: Switched to re-entrant MMIO. This is supported by the underlying framework and simplifies the MMIO forwarding code which was previously different on x86-64 vs aarch64.
* vmapple: Fixes for minor bugs and comments from the last round of review.
* vmapple aes, conf, apple-gfx: Switched reset methods to implement the ResettableClass base's interface.
* vmapple: switched from virtio-hid to an XHCI USB controller and USB mouse and tablet devices. macOS does not provide drivers for virtio HID devices, at least not in version 12's vmapple kernel. So input now sort of works (interrupt issues) rather than not at all. Use network-based remote access to the guest OS as a work-around.v3 -> v4:
* Complete rework of the mechanism for handling runloop/libdispatch events on the main thread. PV graphics now work with the SDL UI.
* Renamed 'apple-gfx-vmapple' device to 'apple-gfx-mmio'
* hw/display/apple-gfx: threading model overhaul to be more consistent, safer, and more QEMU-idiomatic.
* display-modes property on the apple-gfx devices now uses the native array property mechanism and works on both device variants.
* hw/vmapple/aes: Improvements to logging and error handling.
* hw/vmapple/cfg: Bug fixes around device property default values.
* hw/vmapple/{aes,cfg,virtio-blk/vmapple}: Most header code moved into .c files, only a singlevmapple.hnow contains the #defines for the vmapple machine model-specific device type names.
* hw/block/virtio-blk: New patch for replacingvirtio_blk_free_requestwithg_free. (Optional)
* Various smaller changes following comments in v3 code review in apple-gfx, aes, cfg, bdif, virtio-blk-vmapple, and the vmapple machine type itself. See patch-specific v4 change notes for details.Quoted 4 lines
v4 -> v5:
* Simplified the main thread runloop mechanism. Back to setting
qemu_maindirectly, but narrowing the scope of what it needs todo,
Quoted 3 lines
and it can now be NULL. (Meaning run the QEMU main event loop on the main thread as is traditional.)
* hw/display/apple-gfx: Further improvements to the BH based job codebridging
Quoted 3 lines
the libdispatch & QEMU thread synchronisation impedance mismatch.
* hw/display/apple-gfx: Thread safety and object lifetime improvements.
* hw/display/apple-gfx-*: Better buffer and error handling in displaymode
Quoted 4 lines
property setters and getters.
* hw/vmapple/aes: More consistent and safer logging/tracing
* hw/vmapple/cfg: Better error reporting on overlong property strings.
* hw/vmapple/virtio-blk: Fixed theoretically-unaligned write to configbuffer.
Quoted 1 line
* vmapple machine type: Moved ecam region into machine state, improved
device
Quoted 1 line
property setting error handling, improved ECID/UUID extraction script
and
Quoted 9 lines
docs.
* Various smaller fixes in apple-gfx/-mmio, apple-gfx-pci, vmapple/aes, vmapple/cfg, vmapple/virtio-blk, and vmapple machine type.
* Added SPDX license identifiers where they were missing.v5 -> v6:
* 01/15 (main/Cocoa/runloop): Combined functions, fixed whitespace
* 02/15 (apple-gfx): Further refinement of PVG threading: reduced somecallback
Quoted 1 line
tasks from BHs to merely acquiring RCU read lock; replaced some
libdispatch
Quoted 9 lines
tasks with BHs; last remaining synchronous BH now uses emphemeral QemuSemaphore.
* 02/15 (apple-gfx): Readability improvements and other smaller tweaks (see patch change notes for details)
* 04/15 (display modes): Replaced use ofalloca()with NSMutableArray.v6 -> v7:
* 02/15 (apple-gfx): Use
g_ptr_array_find()helper function, codingstyle tweak
Quoted 5 lines
* 03/15 (apple-gfx-pci): Removed an unused function parameter
* 04/15 (apple-gfx display mode property): Simplified error handling in property parsing.
* 10/15 (vmapple/aes): Coding style tweaks.
* 12/15 (vmapple/cfg): Changed error messages for overrun of propertieswith
Quoted 2 lines
fixed-length strings to be more useful to users than developers.
* 15/15 (vmapple machine type): Tiny error handling fix, un-inlinedfunction
Quoted 4 lines
v7 -> v8:
* 02/15 (apple-gfx): Naming and type use improvements, fixes for a bug
and a
Quoted 6 lines
leak.
* 04/15 (apple-gfx display mode property): Type use improvement
* 10/15 (vmapple/aes): Guest error logging tweaks.
* 11/15 (vmapple/bdif): Replaced uses ofcpu_physical_memory_readwithdma_memory_read, and ag_freecall withg_autofree.
* 12/15 (vmapple/cfg): Macro hygiene fix: consistently enclosingarguments in
Quoted 2 lines
parens.
* 15/15 (vmapple machine type): Use less verbose pattern for defininguuid
Quoted 6 lines
property.
v8 -> v9:
* 01/16 (ui & main loop): Set
qemu_mainto NULL for GTK UI as well.
* 02/16 (apple-gfx): Pass device pointer tographic_console_init(),various
Quoted 2 lines
non-functional changes.
* 03/16 (apple-gfx-pci): Fixup of changed common call, whitespace andcomment
Quoted 2 lines
formatting tweaks.
* 04/16 (apple-gfx display modes): Re-ordered type definitions so wecan drop
Quoted 8 lines
a 'struct' keyword.
* 10/16 (vmapple/aes): Replaced a use ofcpu_physical_memory_writewithdma_memory_write, minor style tweak.
* 11/16 (vmapple/bdif): Replaced uses ofcpu_physical_memory_writewithdma_memory_write.
* 13/16 (vmapple/virtio-blk): Correctly specifyclass_sizefor VMAppleVirtIOBlkClass.
* 15/16 (vmapple machine type): Documentation improvements, fixedvariable
Quoted 2 lines
name and struct field used during pvpanic device creation.
* 16/16 (NEW/RFC vmapple/virtio-blk): Proposed change to replace typehierarchy
Quoted 1 line
with a variant property. This seems cleaner and less confusing than
the
Quoted 1 line
original approach to me, but I'm not sure if it warrants creation of
a new
Quoted 5 lines
QAPI enum and property type definition.
v9 -> v10:
* 01/15 (ui & main loop): Added comments to
qemu_maindeclaration andGTK.
Quoted 1 line
* 02/15 (apple-gfx): Reworked the way frame rendering code is threaded
to use
Quoted 4 lines
BHs for sections requiring BQL.
* 02/15 (apple-gfx): Fixed ./configure error on non-macOS platforms.
* 10/15 (vmapple/aes): Code style and comment improvements.
* 12/15 (vmapple/cfg): Slightly tidier error reporting for overlongproperty
Quoted 2 lines
values.
* 13/15 (vmapple/virtio-blk): Folded v9 patch 16/16 into this one,changing
Quoted 3 lines
the device type design to provide a single device type with a variant
property instead of 2 different subtypes for aux and root volumes.
* 15/15 (vmapple machine type): Documentation fixup for changedvirtio-blk
Quoted 6 lines
device type; small improvements to shell commands in documentation; improved propagation of errors during cfg device instantiation.
v10 -> v11:
* 01/15 (ui & main loop): Simplified
main.c, better comments & commitmessage
Quoted 1 line
* 02/15 (apple-gfx): Give each PV display instance a unique serial
number.
Quoted 7 lines
* 02 & 03/15 (apple-gfx, -pci): Formatting/style tweaks
* 15/15 (vmapple machine type): Improvements to shell code in docsv11 -> v12:
* 01/15 (ui & main loop): More precise wording of code comments.
* 02/15 (apple-gfx): Fixed memory management regressions introduced inv10;
Quoted 2 lines
improved error handling; various more conmetic code adjustments
* 09/15 (GPEX): Fixed uses of deletedGPEX_NUM_IRQSconstant that havebeen
Quoted 7 lines
added to QEMU since this patch was originally written.
v12 -> v13:
* 15/15 (vmapple machine type): Bumped the machine type version from 9.2 to 10.0.
* All patches in the series now have been positively reviewed andreceived
Quoted 4 lines
corresponding reviewed-by tags.
v13 -> v14:
Quoted 8 lines
* 6/15 (hw/vmapple directory): Changed myself from reviewer to maintainer, as that seemed appropriate at this point.
* 15/15 (vmapple machine type): Gate creation of XHCI and USB HID devices behind if (defaults_enabled()).v14 -> v15
* Constified property tables to match Richard Henderson's recent
project-
Quoted 6 lines
wide convention change. (patches 4/15, 7/15, 11/15, 12/15, & 13/15)v15 -> v16
* 14 patches now, as patch 8 has already been pulled. (Thanks Philippe!)
* Fixed a bunch of conflicts with upstream code motion:Quoted 7 lines
- DEFINE_PROP_END_OF_LIST removal (4/14 - apple-gfx mode list, 7/14 - pvpanic-mmio, 10/14 - bdif, 11/14 - cfg device, and 12/14 - vmapple-virtio-blk) - sysemu->system move/rename: (1/14 - ui/qemu-main, 2/14 - apple-gfx, 9/14 - aes, 10/14 - bdif, 14/14 - vmapple machine type)* 14/14 (vmapple machine type):
- Moved compatibility setting for removing legacy mode fromvirtio-pci
Quoted 1 line
to proper global property table rather than (ab)using sugar
property.
Quoted 7 lines
- Removed a few superfluous #includes during sysemu rename cleanup.
- Removed machine type versioning as it's not necessary (yet?)
- Made memory map array constXHCI RFC -> v1:
* Gated conditional interrupter mapping support behind a property,
enabled
Quoted 3 lines
that property in the VMApple machine type.
* Added patch to fix the MSI vector assertion failure.
* Moved msi and msix properties from NEC XHCI controller to genericxhci-pci
Quoted 2 lines
superclass as that also seems useful.
* Broke the workaround up into 2 patches, one for mapping disablingrequired
Quoted 8 lines
by the standard, and one for the conditional disabling workaround.
XHCI v1 -> v2:
* 1/6: Switch to modulo arithmetic for MSI vector number, as per spec.
* 6/6: Set the "conditional-intr-mapping" property viacompat_props.
* Commit message tweaksQuoted 8 lines
XHCI v2 -> v3:
* 2/6: In line with recent upstream changes, the property table is now const and no longer carries an end-of-list marker.
* The indentation fix (previously 5/6) has already been merged, so is no longer included.
* Added patch fixing up logging of certain unhandled MMIO cases. (4/6)
* 6/6: Moved the compat global property table into vmapple patch set-v16;
Quoted 2 lines
we now just add the conditional-intr-mapping property to it in this patch. We also set the property on any device implementing the
abstract
Quoted 6 lines
TYPE_XHCI_PCIrather than only theTYPE_QEMU_XHCIdevice specifically.v16 -> v17
* Rebased on latest upstream (with minor conflict fixes)
* apple-gfx, GPEX, and ui/cocoa patches dropped as they have beenmerged.
Quoted 5 lines
* Unmerged patches from xhci series v3 combined into this series.
* vmapple machine type: Explicitly depend on software GICv3.
* vmapple machine type: Enable the new XHCI PCI conditional-intr-mapping property via the machine type's global compat property table.
* Integrated Philippe's patch on renaming the GICv3's confusing configname,
Quoted 73 lines
and removing its TCG dependency. (It's needed with HVF too.)
* vmapple machine type: Dropped Tested-by tag because of above changesAlexander Graf (7):
hw: Add vmapple subdir
hw/misc/pvpanic: Add MMIO interface hw/vmapple/aes: Introduce aes engine hw/vmapple/bdif: Introduce vmapple backdoor interface hw/vmapple/cfg: Introduce vmapple cfg region hw/vmapple/virtio-blk: Add support for apple virtio-blk hw/vmapple/vmapple: Add vmapple machine typePhil Dennis-Jordan (3):
hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported hw/usb/hcd-xhci-pci: Adds property for disabling mapping in IRQ modePhilippe Mathieu-Daudé (1):
hw/intc: Remove TCG dependency onARM_GICV3MAINTAINERS | 8 + contrib/vmapple/uuid.sh | 9 + docs/system/arm/vmapple.rst | 63 +++ docs/system/target-arm.rst | 1 + hw/Kconfig | 1 + hw/block/virtio-blk.c | 19 +- hw/core/qdev-properties-system.c | 8 + hw/intc/Kconfig | 6 +- hw/intc/meson.build | 4 +- hw/meson.build | 1 + hw/misc/Kconfig | 4 + hw/misc/meson.build | 1 + hw/misc/pvpanic-mmio.c | 60 +++ hw/usb/hcd-xhci-pci.c | 25 ++ hw/usb/hcd-xhci-pci.h | 1 + hw/usb/hcd-xhci.c | 5 + hw/usb/hcd-xhci.h | 5 + hw/vmapple/Kconfig | 32 ++ hw/vmapple/aes.c | 581 ++++++++++++++++++++++++++ hw/vmapple/bdif.c | 274 ++++++++++++ hw/vmapple/cfg.c | 195 +++++++++ hw/vmapple/meson.build | 5 + hw/vmapple/trace-events | 21 + hw/vmapple/trace.h | 1 + hw/vmapple/virtio-blk.c | 204 +++++++++ hw/vmapple/vmapple.c | 618 ++++++++++++++++++++++++++++ include/hw/misc/pvpanic.h | 1 + include/hw/pci/pci_ids.h | 1 + include/hw/qdev-properties-system.h | 5 + include/hw/virtio/virtio-blk.h | 11 +- include/hw/vmapple/vmapple.h | 23 ++ include/qemu/cutils.h | 15 + meson.build | 1 + qapi/virtio.json | 14 + util/hexdump.c | 18 + 35 files changed, 2231 insertions(+), 10 deletions(-) create mode 100755 contrib/vmapple/uuid.sh create mode 100644 docs/system/arm/vmapple.rst create mode 100644 hw/misc/pvpanic-mmio.c create mode 100644 hw/vmapple/Kconfig 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/meson.build create mode 100644 hw/vmapple/trace-events create mode 100644 hw/vmapple/trace.h create mode 100644 hw/vmapple/virtio-blk.c create mode 100644 hw/vmapple/vmapple.c create mode 100644 include/hw/vmapple/vmapple.h--
2.39.5 (Apple Git-154)
Quoted 84 lines · Phil Dennis-Jordan
On Wed, 15 Jan 2025 at 16:08, Michael S. Tsirkin <[email protected]> wrote:
On Sun, Jan 12, 2025 at 10:00:45PM +0100, Phil Dennis-Jordan wrote:
> This patch set introduces a new ARM and macOS HVF specific machine type > called "vmapple". There are also some patches for fixing XHCI spec > compliance issues and adding a workaround to a quirk in the macOS guest's > XHCI driver.
>
> The vmapple machine type approximates the configuration in macOS's own > Virtualization.framework when running arm64 macOS guests. In addition to > generic components such as a GICv3 and an XHCI USB controller, it > includes nonstandard extensions to the virtio block device, a special > "hardware" aes engine, a configuration device, a pvpanic variant, a > "backdoor" interface, and of course the apple-gfx paravirtualised display > adapter.
>
>
> The macOS guest initially did not work well with QEMU's XHCI controller, > which required some investigation, bug fixing, and a work-around. >
> Essentially, the macOS driver attempts to use XHCI event rings 1 and 2 > even when there is only a single pin-based interrupt available. The > interrupts for rings 1 and 2 are dropped, and so events are only handled > after a timeout. The driver appears to expect the device to act as if > interrupter mapping was not supported - the spec only mentions that > interrupter mapping should be disabled if only one interrupter is > enabled, not one interrupt, although there is potential ambiguity in > the spec's wording around enabling and disabling interrupters. >
> In any case, this investigation has led to 3 changes:
>
> * The spec requires that modulo arithmetic be used for selecting > the MSI vector to notify from the interrupter/event ring index. > (Patch 1)
> * The spec requires that all events be directed at ring 0 if > interrupter mapping is not available; the condition for this > mentioned in the spec is when there is only 1 interrupter > available. (Patch 2)
> * A property is added to the PCI XHCI controller classes to disable > interrupter mapping when using pin-based interrupts. This makes > the macOS guest drivers work. (Patch 9) This is enabled in the > vmapple machine type, which does not offer MSI(-X) support. >
> There are currently a few limitations to the vmapple machine. These > aren't intrinsic, just imperfect emulation of the VZF, but it's good > enough to be just about usable for some purposes:
>
> * macOS 12 guests only. Versions 13+ currently fail during early boot. > * macOS 11+ arm64 hosts only, with hvf accel. (Perhaps some differences > between Apple M series CPUs and TCG's aarch64 implementation? macOS > hosts only because ParavirtualizedGraphics.framework is a black box > implementing most of the logic behind the apple-gfx device.) > * The guest OS must first be provisioned using Virtualization.framework; > the disk images can subsequently be used in Qemu. (See docs.) >
>
> Previous versions of this series also included the macOS PV graphics > device ("apple-gfx"); those patches have already been merged, so > the title has been changed. Previous iteration:
> https://patchew.org/QEMU/[email protected]/
>
> Furthermore, the XHCI fixes and workaround were previously submitted > as a separate patch set, of which a few patches have also been merged. > "hw/usb/hcd-xhci: Fixes, improvements and macOS workaround" > https://patchew.org/QEMU/[email protected]/
>
> Finally, I've included one of Philippe Mathieu-Daudé's GICv3 patches > which arose out of the discovery that the software GICv3 dependency > was missing when building v16 and earlier versions of this series > in a HVF-only configuration.
> https://patchew.org/QEMU/[email protected]/just to make sure, who is merging this? Me?
ICYMI, Phil M-D has already pulled patches 1 & 2, and Stefan has merged them into staging & master.
As I understand it, Phil M-D was also in the process of merging the rest of v16 of this series before discovering the GICv3 dependency/Kconfig issue:
Quoted 7 lines
https://lore.kernel.org/qemu-devel/
[email protected]/I don't really mind either way who merges this, but he might have some more thoughts on the matter - there might be a specific reason he's so far only picked up those two patches. :-)
Excellent just making sure it's not lost.
Thanks!
Quoted 340 lines
Quoted 43 lines
---
v2 -> v3:
* Merged the apple-gfx and vmapple patchsets.
* Squashed a bunch of later apple-gfx patches into the main one. (dGPU support, queried MMIO area size, host GPU picking logic.)
* Rebased on latest upstream, fixing any breakages due to internal Qemu API changes.
* apple-gfx: Switched to re-entrant MMIO. This is supported by the underlying framework and simplifies the MMIO forwarding code which was previously different on x86-64 vs aarch64.
* vmapple: Fixes for minor bugs and comments from the last round of review.
* vmapple aes, conf, apple-gfx: Switched reset methods to implement the ResettableClass base's interface.
* vmapple: switched from virtio-hid to an XHCI USB controller and USB mouse and tablet devices. macOS does not provide drivers for virtio HID devices, at least not in version 12's vmapple kernel. So input now sort of works (interrupt issues) rather than not at all. Use network-based remote access to the guest OS as a work-around.v3 -> v4:
* Complete rework of the mechanism for handling runloop/libdispatch events on the main thread. PV graphics now work with the SDL UI.
* Renamed 'apple-gfx-vmapple' device to 'apple-gfx-mmio'
* hw/display/apple-gfx: threading model overhaul to be more consistent, safer, and more QEMU-idiomatic.
* display-modes property on the apple-gfx devices now uses the native array property mechanism and works on both device variants.
* hw/vmapple/aes: Improvements to logging and error handling.
* hw/vmapple/cfg: Bug fixes around device property default values.
* hw/vmapple/{aes,cfg,virtio-blk/vmapple}: Most header code moved into .c files, only a singlevmapple.hnow contains the #defines for the vmapple machine model-specific device type names.
* hw/block/virtio-blk: New patch for replacingvirtio_blk_free_requestwithg_free. (Optional)
* Various smaller changes following comments in v3 code review in apple-gfx, aes, cfg, bdif, virtio-blk-vmapple, and the vmapple machine type itself. See patch-specific v4 change notes for details.Quoted 4 lines
v4 -> v5:
* Simplified the main thread runloop mechanism. Back to setting
qemu_maindirectly, but narrowing the scope of what it needs todo,
> and it can now be NULL. (Meaning run the QEMU main event loop on > the main thread as is traditional.)
> * hw/display/apple-gfx: Further improvements to the BH based job code bridging
> the libdispatch & QEMU thread synchronisation impedance mismatch. > * hw/display/apple-gfx: Thread safety and object lifetime improvements. > * hw/display/apple-gfx-*: Better buffer and error handling in display mode
> property setters and getters.
> * hw/vmapple/aes: More consistent and safer logging/tracing > * hw/vmapple/cfg: Better error reporting on overlong property strings. > * hw/vmapple/virtio-blk: Fixed theoretically-unaligned write to config buffer.
> * vmapple machine type: Moved ecam region into machine state, improved device
> property setting error handling, improved ECID/UUID extraction script and
> docs.
> * Various smaller fixes in apple-gfx/-mmio, apple-gfx-pci, vmapple/aes, > vmapple/cfg, vmapple/virtio-blk, and vmapple machine type. > * Added SPDX license identifiers where they were missing.
>
> v5 -> v6:
>
> * 01/15 (main/Cocoa/runloop): Combined functions, fixed whitespace > * 02/15 (apple-gfx): Further refinement of PVG threading: reduced some callback
> tasks from BHs to merely acquiring RCU read lock; replaced some libdispatch
> tasks with BHs; last remaining synchronous BH now uses emphemeral > QemuSemaphore.
> * 02/15 (apple-gfx): Readability improvements and other smaller tweaks > (see patch change notes for details)
> * 04/15 (display modes): Replaced use of alloca() with NSMutableArray. >
> v6 -> v7:
>
> * 02/15 (apple-gfx): Useg_ptr_array_find()helper function, coding style tweak
> * 03/15 (apple-gfx-pci): Removed an unused function parameter > * 04/15 (apple-gfx display mode property): Simplified error handling in > property parsing.
> * 10/15 (vmapple/aes): Coding style tweaks.
> * 12/15 (vmapple/cfg): Changed error messages for overrun of properties with
> fixed-length strings to be more useful to users than developers. > * 15/15 (vmapple machine type): Tiny error handling fix, un-inlined function
>
> v7 -> v8:
>
> * 02/15 (apple-gfx): Naming and type use improvements, fixes for a bug and a
> leak.
> * 04/15 (apple-gfx display mode property): Type use improvement > * 10/15 (vmapple/aes): Guest error logging tweaks.
> * 11/15 (vmapple/bdif): Replaced uses ofcpu_physical_memory_readwith >dma_memory_read, and ag_freecall withg_autofree.
> * 12/15 (vmapple/cfg): Macro hygiene fix: consistently enclosing arguments in
> parens.
> * 15/15 (vmapple machine type): Use less verbose pattern for defining uuid
> property.
>
> v8 -> v9:
>
> * 01/16 (ui & main loop): Setqemu_mainto NULL for GTK UI as well. > * 02/16 (apple-gfx): Pass device pointer tographic_console_init(), various
> non-functional changes.
> * 03/16 (apple-gfx-pci): Fixup of changed common call, whitespace and comment
> formatting tweaks.
> * 04/16 (apple-gfx display modes): Re-ordered type definitions so we can drop
> a 'struct' keyword.
> * 10/16 (vmapple/aes): Replaced a use ofcpu_physical_memory_writewith >dma_memory_write, minor style tweak.
> * 11/16 (vmapple/bdif): Replaced uses ofcpu_physical_memory_writewith >dma_memory_write.
> * 13/16 (vmapple/virtio-blk): Correctly specifyclass_sizefor > VMAppleVirtIOBlkClass.
> * 15/16 (vmapple machine type): Documentation improvements, fixed variable
> name and struct field used during pvpanic device creation. > * 16/16 (NEW/RFC vmapple/virtio-blk): Proposed change to replace type hierarchy
> with a variant property. This seems cleaner and less confusing than the
> original approach to me, but I'm not sure if it warrants creation of a new
> QAPI enum and property type definition.
>
> v9 -> v10:
>
> * 01/15 (ui & main loop): Added comments toqemu_maindeclaration and GTK.
> * 02/15 (apple-gfx): Reworked the way frame rendering code is threaded to use
> BHs for sections requiring BQL.
> * 02/15 (apple-gfx): Fixed ./configure error on non-macOS platforms. > * 10/15 (vmapple/aes): Code style and comment improvements. > * 12/15 (vmapple/cfg): Slightly tidier error reporting for overlong property
> values.
> * 13/15 (vmapple/virtio-blk): Folded v9 patch 16/16 into this one, changing
> the device type design to provide a single device type with a variant > property instead of 2 different subtypes for aux and root volumes. > * 15/15 (vmapple machine type): Documentation fixup for changed virtio-blk
> device type; small improvements to shell commands in documentation; > improved propagation of errors during cfg device instantiation. >
> v10 -> v11:
>
> * 01/15 (ui & main loop): Simplifiedmain.c, better comments & commit message
> * 02/15 (apple-gfx): Give each PV display instance a unique serial number.
> * 02 & 03/15 (apple-gfx, -pci): Formatting/style tweaks
> * 15/15 (vmapple machine type): Improvements to shell code in docs >
> v11 -> v12:
>
> * 01/15 (ui & main loop): More precise wording of code comments. > * 02/15 (apple-gfx): Fixed memory management regressions introduced in v10;
> improved error handling; various more conmetic code adjustments > * 09/15 (GPEX): Fixed uses of deletedGPEX_NUM_IRQSconstant that have been
> added to QEMU since this patch was originally written.
>
> v12 -> v13:
>
> * 15/15 (vmapple machine type): Bumped the machine type version from 9.2 > to 10.0.
> * All patches in the series now have been positively reviewed and received
> corresponding reviewed-by tags.
>
> v13 -> v14:
>
> * 6/15 (hw/vmapple directory): Changed myself from reviewer > to maintainer, as that seemed appropriate at this point. > * 15/15 (vmapple machine type): Gate creation of XHCI and
> USB HID devices behind if (defaults_enabled()).
>
> v14 -> v15
>
> * Constified property tables to match Richard Henderson's recent project-
> wide convention change. (patches 4/15, 7/15, 11/15, 12/15, & 13/15) >
> v15 -> v16
>
> * 14 patches now, as patch 8 has already been pulled. (Thanks Philippe!) > * Fixed a bunch of conflicts with upstream code motion:
> -DEFINE_PROP_END_OF_LISTremoval (4/14 - apple-gfx mode list, 7/14 - > pvpanic-mmio, 10/14 - bdif, 11/14 - cfg device, and
> 12/14 - vmapple-virtio-blk)
> -sysemu->systemmove/rename: (1/14 - ui/qemu-main, 2/14 - apple-gfx, > 9/14 - aes, 10/14 - bdif, 14/14 - vmapple machine type) > * 14/14 (vmapple machine type):
> - Moved compatibility setting for removing legacy mode from virtio-pci
> to proper global property table rather than (ab)using sugar property.
> - Removed a few superfluous #includes during sysemu rename cleanup. > - Removed machine type versioning as it's not necessary (yet?) > - Made memory map array const
>
> XHCI RFC -> v1:
>
> * Gated conditional interrupter mapping support behind a property, enabled
> that property in the VMApple machine type.
> * Added patch to fix the MSI vector assertion failure.
> * Moved msi and msix properties from NEC XHCI controller to generic xhci-pci
> superclass as that also seems useful.
> * Broke the workaround up into 2 patches, one for mapping disabling required
> by the standard, and one for the conditional disabling workaround. >
> XHCI v1 -> v2:
>
> * 1/6: Switch to modulo arithmetic for MSI vector number, as per spec. > * 6/6: Set the "conditional-intr-mapping" property viacompat_props. > * Commit message tweaks
>
> XHCI v2 -> v3:
>
> * 2/6: In line with recent upstream changes, the property table is now > const and no longer carries an end-of-list marker.
> * The indentation fix (previously 5/6) has already been merged, so is no > longer included.
> * Added patch fixing up logging of certain unhandled MMIO cases. (4/6) > * 6/6: Moved the compat global property table into vmapple patch set -v16;
> we now just add the conditional-intr-mapping property to it in this > patch. We also set the property on any device implementing the abstract
>TYPE_XHCI_PCIrather than only theTYPE_QEMU_XHCIdevice specifically. >
> v16 -> v17
>
> * Rebased on latest upstream (with minor conflict fixes)
> * apple-gfx, GPEX, and ui/cocoa patches dropped as they have been merged.
> * Unmerged patches from xhci series v3 combined into this series. > * vmapple machine type: Explicitly depend on software GICv3. > * vmapple machine type: Enable the new XHCI PCI conditional-intr-mapping > property via the machine type's global compat property table. > * Integrated Philippe's patch on renaming the GICv3's confusing config name,
> and removing its TCG dependency. (It's needed with HVF too.) > * vmapple machine type: Dropped Tested-by tag because of above changes >
>
> Alexander Graf (7):
> hw: Add vmapple subdir
> hw/misc/pvpanic: Add MMIO interface
> hw/vmapple/aes: Introduce aes engine
> hw/vmapple/bdif: Introduce vmapple backdoor interface
> hw/vmapple/cfg: Introduce vmapple cfg region
> hw/vmapple/virtio-blk: Add support for apple virtio-blk
> hw/vmapple/vmapple: Add vmapple machine type
>
> Phil Dennis-Jordan (3):
> hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec > hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported > hw/usb/hcd-xhci-pci: Adds property for disabling mapping in IRQ mode >
> Philippe Mathieu-Daudé (1):
> hw/intc: Remove TCG dependency onARM_GICV3
>
> MAINTAINERS | 8 +
> contrib/vmapple/uuid.sh | 9 +
> docs/system/arm/vmapple.rst | 63 +++
> docs/system/target-arm.rst | 1 +
> hw/Kconfig | 1 +
> hw/block/virtio-blk.c | 19 +-
> hw/core/qdev-properties-system.c | 8 +
> hw/intc/Kconfig | 6 +-
> hw/intc/meson.build | 4 +-
> hw/meson.build | 1 +
> hw/misc/Kconfig | 4 +
> hw/misc/meson.build | 1 +
> hw/misc/pvpanic-mmio.c | 60 +++
> hw/usb/hcd-xhci-pci.c | 25 ++
> hw/usb/hcd-xhci-pci.h | 1 +
> hw/usb/hcd-xhci.c | 5 +
> hw/usb/hcd-xhci.h | 5 +
> hw/vmapple/Kconfig | 32 ++
> hw/vmapple/aes.c | 581 ++++++++++++++++++++++++++ > hw/vmapple/bdif.c | 274 ++++++++++++
> hw/vmapple/cfg.c | 195 +++++++++
> hw/vmapple/meson.build | 5 +
> hw/vmapple/trace-events | 21 +
> hw/vmapple/trace.h | 1 +
> hw/vmapple/virtio-blk.c | 204 +++++++++
> hw/vmapple/vmapple.c | 618 ++++++++++++++++++++++++++++ > include/hw/misc/pvpanic.h | 1 +
> include/hw/pci/pci_ids.h | 1 +
>include/hw/qdev-properties-system.h| 5 +
> include/hw/virtio/virtio-blk.h | 11 +-
> include/hw/vmapple/vmapple.h | 23 ++
> include/qemu/cutils.h | 15 +
> meson.build | 1 +
> qapi/virtio.json | 14 +
> util/hexdump.c | 18 +
> 35 files changed, 2231 insertions(+), 10 deletions(-)
> create mode 100755contrib/vmapple/uuid.sh
> create mode 100644docs/system/arm/vmapple.rst
> create mode 100644hw/misc/pvpanic-mmio.c
> create mode 100644 hw/vmapple/Kconfig
> create mode 100644hw/vmapple/aes.c
> create mode 100644hw/vmapple/bdif.c
> create mode 100644hw/vmapple/cfg.c
> create mode 100644 hw/vmapple/meson.build
> create mode 100644 hw/vmapple/trace-events
> create mode 100644hw/vmapple/trace.h
> create mode 100644hw/vmapple/virtio-blk.c
> create mode 100644hw/vmapple/vmapple.c
> create mode 100644include/hw/vmapple/vmapple.h
>
> --
> 2.39.5 (Apple Git-154)
Quoted 24 lines · Michael S. Tsirkin
Quoted 23 lines · Phil Dennis-Jordan
On Wed, 15 Jan 2025 at 16:08, Michael S. Tsirkin <[email protected]> wrote:
On Sun, Jan 12, 2025 at 10:00:45PM +0100, Phil Dennis-Jordan wrote:
> This patch set introduces a new ARM and macOS HVF specific machine type > called "vmapple". There are also some patches for fixing XHCI spec > compliance issues and adding a workaround to a quirk in the macOS guest's > XHCI driver.just to make sure, who is merging this? Me?
ICYMI, Phil M-D has already pulled patches 1 & 2, and Stefan has merged them into staging & master.
As I understand it, Phil M-D was also in the process of merging the rest of v16 of this series before discovering the GICv3 dependency/Kconfig issue:
Quoted 7 lines
Quoted 4 lines
I don't really mind either way who merges this, but he might have some more thoughts on the matter - there might be a specific reason he's so far only picked up those two patches. :-)
Excellent just making sure it's not lost.
Thanks!
Now queued, thanks!