* [PATCH v17 00/11] New vmapple machine type and xhci fixes
@ 2025-01-12 21:00 Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 01/11] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec Phil Dennis-Jordan
` (13 more replies)
0 siblings, 14 replies; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-01-12 21:00 UTC (permalink / raw)
To: qemu-devel
Cc: agraf, phil, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm
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/20241223221645.29911-1-phil@philjordan.eu/
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/20241227121336.25838-1-phil@philjordan.eu/
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/20241227202435.48055-1-philmd@linaro.org/
---
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
--
2.39.5 (Apple Git-154)
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v17 01/11] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec
2025-01-12 21:00 [PATCH v17 00/11] New vmapple machine type and xhci fixes Phil Dennis-Jordan
@ 2025-01-12 21:00 ` Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 02/11] hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported Phil Dennis-Jordan
` (12 subsequent siblings)
13 siblings, 0 replies; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-01-12 21:00 UTC (permalink / raw)
To: qemu-devel
Cc: agraf, phil, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm
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.
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
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(+)
diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
index a069b42338..49642aab58 100644
--- a/hw/usb/hcd-xhci-pci.c
+++ b/hw/usb/hcd-xhci-pci.c
@@ -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;
}
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v17 02/11] hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported
2025-01-12 21:00 [PATCH v17 00/11] New vmapple machine type and xhci fixes Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 01/11] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec Phil Dennis-Jordan
@ 2025-01-12 21:00 ` Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 03/11] hw: Add vmapple subdir Phil Dennis-Jordan
` (11 subsequent siblings)
13 siblings, 0 replies; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-01-12 21:00 UTC (permalink / raw)
To: qemu-devel
Cc: agraf, phil, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm
The 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.
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/usb/hcd-xhci.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 7dc0994c89..00d5bc3779 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -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;
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v17 03/11] hw: Add vmapple subdir
2025-01-12 21:00 [PATCH v17 00/11] New vmapple machine type and xhci fixes Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 01/11] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 02/11] hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported Phil Dennis-Jordan
@ 2025-01-12 21:00 ` Phil Dennis-Jordan
2025-03-03 17:52 ` Philippe Mathieu-Daudé
2025-01-12 21:00 ` [PATCH v17 04/11] hw/misc/pvpanic: Add MMIO interface Phil Dennis-Jordan
` (10 subsequent siblings)
13 siblings, 1 reply; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-01-12 21:00 UTC (permalink / raw)
To: qemu-devel
Cc: agraf, phil, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm, Alexander Graf,
Akihiko Odaki
From: Alexander Graf <graf@amazon.com>
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 <graf@amazon.com>
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
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
diff --git a/MAINTAINERS b/MAINTAINERS
index 2101b51217..e220744abf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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 <agraf@csgraf.de>
+M: Phil Dennis-Jordan <phil@philjordan.eu>
+S: Maintained
+F: hw/vmapple/*
+F: include/hw/vmapple/*
+
Subsystems
----------
Overall Audio backends
diff --git a/hw/Kconfig b/hw/Kconfig
index 1b4e9bb07f..2871784cfd 100644
--- a/hw/Kconfig
+++ b/hw/Kconfig
@@ -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
diff --git a/hw/meson.build b/hw/meson.build
index b827c82c5d..9c4f6d0d63 100644
--- a/hw/meson.build
+++ b/hw/meson.build
@@ -39,6 +39,7 @@ subdir('ufs')
subdir('usb')
subdir('vfio')
subdir('virtio')
+subdir('vmapple')
subdir('watchdog')
subdir('xen')
subdir('xenpv')
diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/hw/vmapple/Kconfig
@@ -0,0 +1 @@
+
diff --git a/hw/vmapple/meson.build b/hw/vmapple/meson.build
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/hw/vmapple/trace-events b/hw/vmapple/trace-events
new file mode 100644
index 0000000000..9ccc579048
--- /dev/null
+++ b/hw/vmapple/trace-events
@@ -0,0 +1,2 @@
+# See docs/devel/tracing.rst for syntax documentation.
+
diff --git a/hw/vmapple/trace.h b/hw/vmapple/trace.h
new file mode 100644
index 0000000000..572adbefe0
--- /dev/null
+++ b/hw/vmapple/trace.h
@@ -0,0 +1 @@
+#include "trace/trace-hw_vmapple.h"
diff --git a/meson.build b/meson.build
index d06f59095c..812ef33550 100644
--- a/meson.build
+++ b/meson.build
@@ -3588,6 +3588,7 @@ if have_system
'hw/usb',
'hw/vfio',
'hw/virtio',
+ 'hw/vmapple',
'hw/watchdog',
'hw/xen',
'hw/gpio',
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v17 04/11] hw/misc/pvpanic: Add MMIO interface
2025-01-12 21:00 [PATCH v17 00/11] New vmapple machine type and xhci fixes Phil Dennis-Jordan
` (2 preceding siblings ...)
2025-01-12 21:00 ` [PATCH v17 03/11] hw: Add vmapple subdir Phil Dennis-Jordan
@ 2025-01-12 21:00 ` Phil Dennis-Jordan
2025-03-03 17:54 ` Philippe Mathieu-Daudé
2025-01-12 21:00 ` [PATCH v17 05/11] hw/vmapple/aes: Introduce aes engine Phil Dennis-Jordan
` (9 subsequent siblings)
13 siblings, 1 reply; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-01-12 21:00 UTC (permalink / raw)
To: qemu-devel
Cc: agraf, phil, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm, Alexander Graf,
Akihiko Odaki
From: Alexander Graf <graf@amazon.com>
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 <graf@amazon.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
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
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
index 8f9ce2f68c..16cf872e40 100644
--- a/hw/misc/Kconfig
+++ b/hw/misc/Kconfig
@@ -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
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
index 55f493521b..6187caaf71 100644
--- a/hw/misc/meson.build
+++ b/hw/misc/meson.build
@@ -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',
diff --git a/hw/misc/pvpanic-mmio.c b/hw/misc/pvpanic-mmio.c
new file mode 100644
index 0000000000..70097cecc7
--- /dev/null
+++ b/hw/misc/pvpanic-mmio.c
@@ -0,0 +1,60 @@
+/*
+ * QEMU simulated pvpanic device (MMIO frontend)
+ *
+ * Copyright © 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+
+#include "hw/qdev-properties.h"
+#include "hw/misc/pvpanic.h"
+#include "hw/sysbus.h"
+#include "standard-headers/misc/pvpanic.h"
+
+OBJECT_DECLARE_SIMPLE_TYPE(PVPanicMMIOState, PVPANIC_MMIO_DEVICE)
+
+#define PVPANIC_MMIO_SIZE 0x2
+
+struct PVPanicMMIOState {
+ SysBusDevice parent_obj;
+
+ PVPanicState pvpanic;
+};
+
+static void pvpanic_mmio_initfn(Object *obj)
+{
+ PVPanicMMIOState *s = PVPANIC_MMIO_DEVICE(obj);
+
+ pvpanic_setup_io(&s->pvpanic, DEVICE(s), PVPANIC_MMIO_SIZE);
+ sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->pvpanic.mr);
+}
+
+static const Property pvpanic_mmio_properties[] = {
+ DEFINE_PROP_UINT8("events", PVPanicMMIOState, pvpanic.events,
+ PVPANIC_PANICKED | PVPANIC_CRASH_LOADED),
+};
+
+static void pvpanic_mmio_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+
+ device_class_set_props(dc, pvpanic_mmio_properties);
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+}
+
+static const TypeInfo pvpanic_mmio_info = {
+ .name = TYPE_PVPANIC_MMIO_DEVICE,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(PVPanicMMIOState),
+ .instance_init = pvpanic_mmio_initfn,
+ .class_init = pvpanic_mmio_class_init,
+};
+
+static void pvpanic_register_types(void)
+{
+ type_register_static(&pvpanic_mmio_info);
+}
+
+type_init(pvpanic_register_types)
diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h
index 9a71a5ad0d..049a94c112 100644
--- a/include/hw/misc/pvpanic.h
+++ b/include/hw/misc/pvpanic.h
@@ -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"
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v17 05/11] hw/vmapple/aes: Introduce aes engine
2025-01-12 21:00 [PATCH v17 00/11] New vmapple machine type and xhci fixes Phil Dennis-Jordan
` (3 preceding siblings ...)
2025-01-12 21:00 ` [PATCH v17 04/11] hw/misc/pvpanic: Add MMIO interface Phil Dennis-Jordan
@ 2025-01-12 21:00 ` Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 06/11] hw/vmapple/bdif: Introduce vmapple backdoor interface Phil Dennis-Jordan
` (8 subsequent siblings)
13 siblings, 0 replies; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-01-12 21:00 UTC (permalink / raw)
To: qemu-devel
Cc: agraf, phil, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm, Alexander Graf,
Akihiko Odaki
From: Alexander Graf <graf@amazon.com>
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.
Signed-off-by: Alexander Graf <graf@amazon.com>
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
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
diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig
index 8b13789179..a73504d599 100644
--- a/hw/vmapple/Kconfig
+++ b/hw/vmapple/Kconfig
@@ -1 +1,3 @@
+config VMAPPLE_AES
+ bool
diff --git a/hw/vmapple/aes.c b/hw/vmapple/aes.c
new file mode 100644
index 0000000000..3a7641ab4b
--- /dev/null
+++ b/hw/vmapple/aes.c
@@ -0,0 +1,581 @@
+/*
+ * QEMU Apple AES device 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
+ */
+
+#include "qemu/osdep.h"
+#include "trace.h"
+#include "crypto/hash.h"
+#include "crypto/aes.h"
+#include "crypto/cipher.h"
+#include "hw/irq.h"
+#include "hw/sysbus.h"
+#include "hw/vmapple/vmapple.h"
+#include "migration/vmstate.h"
+#include "qemu/cutils.h"
+#include "qemu/log.h"
+#include "qemu/module.h"
+#include "system/dma.h"
+
+OBJECT_DECLARE_SIMPLE_TYPE(AESState, APPLE_AES)
+
+#define MAX_FIFO_SIZE 9
+
+#define CMD_KEY 0x1
+#define CMD_KEY_CONTEXT_SHIFT 27
+#define CMD_KEY_CONTEXT_MASK (0x1 << CMD_KEY_CONTEXT_SHIFT)
+#define CMD_KEY_SELECT_MAX_IDX 0x7
+#define CMD_KEY_SELECT_SHIFT 24
+#define CMD_KEY_SELECT_MASK (CMD_KEY_SELECT_MAX_IDX << CMD_KEY_SELECT_SHIFT)
+#define CMD_KEY_KEY_LEN_NUM 4u
+#define CMD_KEY_KEY_LEN_SHIFT 22
+#define CMD_KEY_KEY_LEN_MASK ((CMD_KEY_KEY_LEN_NUM - 1u) << CMD_KEY_KEY_LEN_SHIFT)
+#define CMD_KEY_ENCRYPT_SHIFT 20
+#define CMD_KEY_ENCRYPT_MASK (0x1 << CMD_KEY_ENCRYPT_SHIFT)
+#define CMD_KEY_BLOCK_MODE_SHIFT 16
+#define CMD_KEY_BLOCK_MODE_MASK (0x3 << CMD_KEY_BLOCK_MODE_SHIFT)
+#define CMD_IV 0x2
+#define CMD_IV_CONTEXT_SHIFT 26
+#define CMD_IV_CONTEXT_MASK (0x3 << CMD_KEY_CONTEXT_SHIFT)
+#define CMD_DSB 0x3
+#define CMD_SKG 0x4
+#define CMD_DATA 0x5
+#define CMD_DATA_KEY_CTX_SHIFT 27
+#define CMD_DATA_KEY_CTX_MASK (0x1 << CMD_DATA_KEY_CTX_SHIFT)
+#define CMD_DATA_IV_CTX_SHIFT 25
+#define CMD_DATA_IV_CTX_MASK (0x3 << CMD_DATA_IV_CTX_SHIFT)
+#define CMD_DATA_LEN_MASK 0xffffff
+#define CMD_STORE_IV 0x6
+#define CMD_STORE_IV_ADDR_MASK 0xffffff
+#define CMD_WRITE_REG 0x7
+#define CMD_FLAG 0x8
+#define CMD_FLAG_STOP_MASK BIT(26)
+#define CMD_FLAG_RAISE_IRQ_MASK BIT(27)
+#define CMD_FLAG_INFO_MASK 0xff
+#define CMD_MAX 0x10
+
+#define CMD_SHIFT 28
+
+#define REG_STATUS 0xc
+#define REG_STATUS_DMA_READ_RUNNING BIT(0)
+#define REG_STATUS_DMA_READ_PENDING BIT(1)
+#define REG_STATUS_DMA_WRITE_RUNNING BIT(2)
+#define REG_STATUS_DMA_WRITE_PENDING BIT(3)
+#define REG_STATUS_BUSY BIT(4)
+#define REG_STATUS_EXECUTING BIT(5)
+#define REG_STATUS_READY BIT(6)
+#define REG_STATUS_TEXT_DPA_SEEDED BIT(7)
+#define REG_STATUS_UNWRAP_DPA_SEEDED BIT(8)
+
+#define REG_IRQ_STATUS 0x18
+#define REG_IRQ_STATUS_INVALID_CMD BIT(2)
+#define REG_IRQ_STATUS_FLAG BIT(5)
+#define REG_IRQ_ENABLE 0x1c
+#define REG_WATERMARK 0x20
+#define REG_Q_STATUS 0x24
+#define REG_FLAG_INFO 0x30
+#define REG_FIFO 0x200
+
+static const uint32_t key_lens[CMD_KEY_KEY_LEN_NUM] = {
+ [0] = 16,
+ [1] = 24,
+ [2] = 32,
+ [3] = 64,
+};
+
+typedef struct Key {
+ uint32_t key_len;
+ uint8_t key[32];
+} Key;
+
+typedef struct IV {
+ uint32_t iv[4];
+} IV;
+
+static Key builtin_keys[CMD_KEY_SELECT_MAX_IDX + 1] = {
+ [1] = {
+ .key_len = 32,
+ .key = { 0x1 },
+ },
+ [2] = {
+ .key_len = 32,
+ .key = { 0x2 },
+ },
+ [3] = {
+ .key_len = 32,
+ .key = { 0x3 },
+ }
+};
+
+struct AESState {
+ SysBusDevice parent_obj;
+
+ qemu_irq irq;
+ MemoryRegion iomem1;
+ MemoryRegion iomem2;
+ AddressSpace *as;
+
+ uint32_t status;
+ uint32_t q_status;
+ uint32_t irq_status;
+ uint32_t irq_enable;
+ uint32_t watermark;
+ uint32_t flag_info;
+ uint32_t fifo[MAX_FIFO_SIZE];
+ uint32_t fifo_idx;
+ Key key[2];
+ IV iv[4];
+ bool is_encrypt;
+ QCryptoCipherMode block_mode;
+};
+
+static void aes_update_irq(AESState *s)
+{
+ qemu_set_irq(s->irq, !!(s->irq_status & s->irq_enable));
+}
+
+static uint64_t aes1_read(void *opaque, hwaddr offset, unsigned size)
+{
+ AESState *s = opaque;
+ uint64_t res = 0;
+
+ switch (offset) {
+ case REG_STATUS:
+ res = s->status;
+ break;
+ case REG_IRQ_STATUS:
+ res = s->irq_status;
+ break;
+ case REG_IRQ_ENABLE:
+ res = s->irq_enable;
+ break;
+ case REG_WATERMARK:
+ res = s->watermark;
+ break;
+ case REG_Q_STATUS:
+ res = s->q_status;
+ break;
+ case REG_FLAG_INFO:
+ res = s->flag_info;
+ break;
+
+ default:
+ qemu_log_mask(LOG_UNIMP, "%s: Unknown AES MMIO offset %" PRIx64 "\n",
+ __func__, offset);
+ break;
+ }
+
+ trace_aes_read(offset, res);
+
+ return res;
+}
+
+static void fifo_append(AESState *s, uint64_t val)
+{
+ if (s->fifo_idx == MAX_FIFO_SIZE) {
+ /* Exceeded the FIFO. Bail out */
+ return;
+ }
+
+ s->fifo[s->fifo_idx++] = val;
+}
+
+static bool has_payload(AESState *s, uint32_t elems)
+{
+ return s->fifo_idx >= elems + 1;
+}
+
+static bool cmd_key(AESState *s)
+{
+ uint32_t cmd = s->fifo[0];
+ uint32_t key_select = (cmd & CMD_KEY_SELECT_MASK) >> CMD_KEY_SELECT_SHIFT;
+ uint32_t ctxt = (cmd & CMD_KEY_CONTEXT_MASK) >> CMD_KEY_CONTEXT_SHIFT;
+ uint32_t key_len;
+
+ switch ((cmd & CMD_KEY_BLOCK_MODE_MASK) >> CMD_KEY_BLOCK_MODE_SHIFT) {
+ case 0:
+ s->block_mode = QCRYPTO_CIPHER_MODE_ECB;
+ break;
+ case 1:
+ s->block_mode = QCRYPTO_CIPHER_MODE_CBC;
+ break;
+ default:
+ return false;
+ }
+
+ s->is_encrypt = cmd & CMD_KEY_ENCRYPT_MASK;
+ key_len = key_lens[(cmd & CMD_KEY_KEY_LEN_MASK) >> CMD_KEY_KEY_LEN_SHIFT];
+
+ if (key_select) {
+ trace_aes_cmd_key_select_builtin(ctxt, key_select,
+ s->is_encrypt ? "en" : "de",
+ QCryptoCipherMode_str(s->block_mode));
+ s->key[ctxt] = builtin_keys[key_select];
+ } else {
+ trace_aes_cmd_key_select_new(ctxt, key_len,
+ s->is_encrypt ? "en" : "de",
+ QCryptoCipherMode_str(s->block_mode));
+ if (key_len > sizeof(s->key[ctxt].key)) {
+ return false;
+ }
+ if (!has_payload(s, key_len / sizeof(uint32_t))) {
+ /* wait for payload */
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: No payload\n", __func__);
+ return false;
+ }
+ memcpy(&s->key[ctxt].key, &s->fifo[1], key_len);
+ s->key[ctxt].key_len = key_len;
+ }
+
+ return true;
+}
+
+static bool cmd_iv(AESState *s)
+{
+ uint32_t cmd = s->fifo[0];
+ uint32_t ctxt = (cmd & CMD_IV_CONTEXT_MASK) >> CMD_IV_CONTEXT_SHIFT;
+
+ if (!has_payload(s, 4)) {
+ /* wait for payload */
+ return false;
+ }
+ memcpy(&s->iv[ctxt].iv, &s->fifo[1], sizeof(s->iv[ctxt].iv));
+ trace_aes_cmd_iv(ctxt, s->fifo[1], s->fifo[2], s->fifo[3], s->fifo[4]);
+
+ return true;
+}
+
+static void dump_data(const char *desc, const void *p, size_t len)
+{
+ static const size_t MAX_LEN = 0x1000;
+ char hex[MAX_LEN * 2 + 1] = "";
+
+ if (len > MAX_LEN) {
+ return;
+ }
+
+ qemu_hexdump_to_buffer(hex, sizeof(hex), p, len);
+ trace_aes_dump_data(desc, hex);
+}
+
+static bool cmd_data(AESState *s)
+{
+ uint32_t cmd = s->fifo[0];
+ uint32_t ctxt_iv = 0;
+ uint32_t ctxt_key = (cmd & CMD_DATA_KEY_CTX_MASK) >> CMD_DATA_KEY_CTX_SHIFT;
+ uint32_t len = cmd & CMD_DATA_LEN_MASK;
+ uint64_t src_addr = s->fifo[2];
+ uint64_t dst_addr = s->fifo[3];
+ QCryptoCipherAlgo alg;
+ g_autoptr(QCryptoCipher) cipher = NULL;
+ g_autoptr(GByteArray) src = NULL;
+ g_autoptr(GByteArray) dst = NULL;
+ MemTxResult r;
+
+ src_addr |= ((uint64_t)s->fifo[1] << 16) & 0xffff00000000ULL;
+ dst_addr |= ((uint64_t)s->fifo[1] << 32) & 0xffff00000000ULL;
+
+ trace_aes_cmd_data(ctxt_key, ctxt_iv, src_addr, dst_addr, len);
+
+ if (!has_payload(s, 3)) {
+ /* wait for payload */
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: No payload\n", __func__);
+ return false;
+ }
+
+ if (ctxt_key >= ARRAY_SIZE(s->key) ||
+ ctxt_iv >= ARRAY_SIZE(s->iv)) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Invalid key or iv\n", __func__);
+ return false;
+ }
+
+ src = g_byte_array_sized_new(len);
+ g_byte_array_set_size(src, len);
+ dst = g_byte_array_sized_new(len);
+ g_byte_array_set_size(dst, len);
+
+ r = dma_memory_read(s->as, src_addr, src->data, len, MEMTXATTRS_UNSPECIFIED);
+ if (r != MEMTX_OK) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA read of %"PRIu32" bytes "
+ "from 0x%"PRIx64" failed. (r=%d)\n",
+ __func__, len, src_addr, r);
+ return false;
+ }
+
+ dump_data("cmd_data(): src_data=", src->data, len);
+
+ switch (s->key[ctxt_key].key_len) {
+ case 128 / 8:
+ alg = QCRYPTO_CIPHER_ALGO_AES_128;
+ break;
+ case 192 / 8:
+ alg = QCRYPTO_CIPHER_ALGO_AES_192;
+ break;
+ case 256 / 8:
+ alg = QCRYPTO_CIPHER_ALGO_AES_256;
+ break;
+ default:
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Invalid key length\n", __func__);
+ return false;
+ }
+ cipher = qcrypto_cipher_new(alg, s->block_mode,
+ s->key[ctxt_key].key,
+ s->key[ctxt_key].key_len, NULL);
+ if (!cipher) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to create cipher object\n",
+ __func__);
+ return false;
+ }
+ if (s->block_mode != QCRYPTO_CIPHER_MODE_ECB) {
+ if (qcrypto_cipher_setiv(cipher, (void *)s->iv[ctxt_iv].iv,
+ sizeof(s->iv[ctxt_iv].iv), NULL) != 0) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to set IV\n", __func__);
+ return false;
+ }
+ }
+ if (s->is_encrypt) {
+ if (qcrypto_cipher_encrypt(cipher, src->data, dst->data, len, NULL) != 0) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Encryption failed\n", __func__);
+ return false;
+ }
+ } else {
+ if (qcrypto_cipher_decrypt(cipher, src->data, dst->data, len, NULL) != 0) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Decryption failed\n", __func__);
+ return false;
+ }
+ }
+
+ dump_data("cmd_data(): dst_data=", dst->data, len);
+ r = dma_memory_write(s->as, dst_addr, dst->data, len, MEMTXATTRS_UNSPECIFIED);
+ if (r != MEMTX_OK) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA write of %"PRIu32" bytes "
+ "to 0x%"PRIx64" failed. (r=%d)\n",
+ __func__, len, src_addr, r);
+ return false;
+ }
+
+ return true;
+}
+
+static bool cmd_store_iv(AESState *s)
+{
+ uint32_t cmd = s->fifo[0];
+ uint32_t ctxt = (cmd & CMD_IV_CONTEXT_MASK) >> CMD_IV_CONTEXT_SHIFT;
+ uint64_t addr = s->fifo[1];
+ MemTxResult dma_result;
+
+ if (!has_payload(s, 1)) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: No payload\n", __func__);
+ return false;
+ }
+
+ if (ctxt >= ARRAY_SIZE(s->iv)) {
+ qemu_log_mask(LOG_GUEST_ERROR,
+ "%s: Invalid context. ctxt = %u, allowed: 0..%zu\n",
+ __func__, ctxt, ARRAY_SIZE(s->iv) - 1);
+ return false;
+ }
+
+ addr |= ((uint64_t)cmd << 32) & 0xff00000000ULL;
+ dma_result = dma_memory_write(&address_space_memory, addr,
+ &s->iv[ctxt].iv, sizeof(s->iv[ctxt].iv),
+ MEMTXATTRS_UNSPECIFIED);
+
+ trace_aes_cmd_store_iv(ctxt, addr, s->iv[ctxt].iv[0], s->iv[ctxt].iv[1],
+ s->iv[ctxt].iv[2], s->iv[ctxt].iv[3]);
+
+ return dma_result == MEMTX_OK;
+}
+
+static bool cmd_flag(AESState *s)
+{
+ uint32_t cmd = s->fifo[0];
+ uint32_t raise_irq = cmd & CMD_FLAG_RAISE_IRQ_MASK;
+
+ /* We always process data when it's coming in, so fire an IRQ immediately */
+ if (raise_irq) {
+ s->irq_status |= REG_IRQ_STATUS_FLAG;
+ }
+
+ s->flag_info = cmd & CMD_FLAG_INFO_MASK;
+
+ trace_aes_cmd_flag(!!raise_irq, s->flag_info);
+
+ return true;
+}
+
+static void fifo_process(AESState *s)
+{
+ uint32_t cmd = s->fifo[0] >> CMD_SHIFT;
+ bool success = false;
+
+ if (!s->fifo_idx) {
+ return;
+ }
+
+ switch (cmd) {
+ case CMD_KEY:
+ success = cmd_key(s);
+ break;
+ case CMD_IV:
+ success = cmd_iv(s);
+ break;
+ case CMD_DATA:
+ success = cmd_data(s);
+ break;
+ case CMD_STORE_IV:
+ success = cmd_store_iv(s);
+ break;
+ case CMD_FLAG:
+ success = cmd_flag(s);
+ break;
+ default:
+ s->irq_status |= REG_IRQ_STATUS_INVALID_CMD;
+ break;
+ }
+
+ if (success) {
+ s->fifo_idx = 0;
+ }
+
+ trace_aes_fifo_process(cmd, success);
+}
+
+static void aes1_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
+{
+ AESState *s = opaque;
+
+ trace_aes_write(offset, val);
+
+ switch (offset) {
+ case REG_IRQ_STATUS:
+ s->irq_status &= ~val;
+ break;
+ case REG_IRQ_ENABLE:
+ s->irq_enable = val;
+ break;
+ case REG_FIFO:
+ fifo_append(s, val);
+ fifo_process(s);
+ break;
+ default:
+ qemu_log_mask(LOG_UNIMP,
+ "%s: Unknown AES MMIO offset %"PRIx64", data %"PRIx64"\n",
+ __func__, offset, val);
+ return;
+ }
+
+ aes_update_irq(s);
+}
+
+static const MemoryRegionOps aes1_ops = {
+ .read = aes1_read,
+ .write = aes1_write,
+ .endianness = DEVICE_NATIVE_ENDIAN,
+ .valid = {
+ .min_access_size = 4,
+ .max_access_size = 8,
+ },
+ .impl = {
+ .min_access_size = 4,
+ .max_access_size = 4,
+ },
+};
+
+static uint64_t aes2_read(void *opaque, hwaddr offset, unsigned size)
+{
+ uint64_t res = 0;
+
+ switch (offset) {
+ case 0:
+ res = 0;
+ break;
+ default:
+ qemu_log_mask(LOG_UNIMP,
+ "%s: Unknown AES MMIO 2 offset %"PRIx64"\n",
+ __func__, offset);
+ break;
+ }
+
+ trace_aes_2_read(offset, res);
+
+ return res;
+}
+
+static void aes2_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
+{
+ trace_aes_2_write(offset, val);
+
+ switch (offset) {
+ default:
+ qemu_log_mask(LOG_UNIMP,
+ "%s: Unknown AES MMIO 2 offset %"PRIx64", data %"PRIx64"\n",
+ __func__, offset, val);
+ return;
+ }
+}
+
+static const MemoryRegionOps aes2_ops = {
+ .read = aes2_read,
+ .write = aes2_write,
+ .endianness = DEVICE_NATIVE_ENDIAN,
+ .valid = {
+ .min_access_size = 4,
+ .max_access_size = 8,
+ },
+ .impl = {
+ .min_access_size = 4,
+ .max_access_size = 4,
+ },
+};
+
+static void aes_reset(Object *obj, ResetType type)
+{
+ AESState *s = APPLE_AES(obj);
+
+ s->status = 0x3f80;
+ s->q_status = 2;
+ s->irq_status = 0;
+ s->irq_enable = 0;
+ s->watermark = 0;
+}
+
+static void aes_init(Object *obj)
+{
+ AESState *s = APPLE_AES(obj);
+
+ memory_region_init_io(&s->iomem1, obj, &aes1_ops, s, TYPE_APPLE_AES, 0x4000);
+ memory_region_init_io(&s->iomem2, obj, &aes2_ops, s, TYPE_APPLE_AES, 0x4000);
+ sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem1);
+ sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem2);
+ sysbus_init_irq(SYS_BUS_DEVICE(s), &s->irq);
+ s->as = &address_space_memory;
+}
+
+static void aes_class_init(ObjectClass *klass, void *data)
+{
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
+
+ rc->phases.hold = aes_reset;
+}
+
+static const TypeInfo aes_info = {
+ .name = TYPE_APPLE_AES,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(AESState),
+ .class_init = aes_class_init,
+ .instance_init = aes_init,
+};
+
+static void aes_register_types(void)
+{
+ type_register_static(&aes_info);
+}
+
+type_init(aes_register_types)
diff --git a/hw/vmapple/meson.build b/hw/vmapple/meson.build
index e69de29bb2..bcd4dcb28d 100644
--- a/hw/vmapple/meson.build
+++ b/hw/vmapple/meson.build
@@ -0,0 +1 @@
+system_ss.add(when: 'CONFIG_VMAPPLE_AES', if_true: files('aes.c'))
diff --git a/hw/vmapple/trace-events b/hw/vmapple/trace-events
index 9ccc579048..0d4a73d7d1 100644
--- a/hw/vmapple/trace-events
+++ b/hw/vmapple/trace-events
@@ -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"
+
diff --git a/include/hw/vmapple/vmapple.h b/include/hw/vmapple/vmapple.h
new file mode 100644
index 0000000000..6762b6c869
--- /dev/null
+++ b/include/hw/vmapple/vmapple.h
@@ -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 */
diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
index 34a9b9b220..36c68ce86c 100644
--- a/include/qemu/cutils.h
+++ b/include/qemu/cutils.h
@@ -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
diff --git a/util/hexdump.c b/util/hexdump.c
index ae0d4992dc..f29ffceb74 100644
--- a/util/hexdump.c
+++ b/util/hexdump.c
@@ -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';
+}
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v17 06/11] hw/vmapple/bdif: Introduce vmapple backdoor interface
2025-01-12 21:00 [PATCH v17 00/11] New vmapple machine type and xhci fixes Phil Dennis-Jordan
` (4 preceding siblings ...)
2025-01-12 21:00 ` [PATCH v17 05/11] hw/vmapple/aes: Introduce aes engine Phil Dennis-Jordan
@ 2025-01-12 21:00 ` Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 07/11] hw/vmapple/cfg: Introduce vmapple cfg region Phil Dennis-Jordan
` (7 subsequent siblings)
13 siblings, 0 replies; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-01-12 21:00 UTC (permalink / raw)
To: qemu-devel
Cc: agraf, phil, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm, Alexander Graf,
Akihiko Odaki
From: Alexander Graf <graf@amazon.com>
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.
Signed-off-by: Alexander Graf <graf@amazon.com>
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
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
diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig
index a73504d599..68f88876eb 100644
--- a/hw/vmapple/Kconfig
+++ b/hw/vmapple/Kconfig
@@ -1,3 +1,6 @@
config VMAPPLE_AES
bool
+config VMAPPLE_BDIF
+ bool
+
diff --git a/hw/vmapple/bdif.c b/hw/vmapple/bdif.c
new file mode 100644
index 0000000000..5827dd2aab
--- /dev/null
+++ b/hw/vmapple/bdif.c
@@ -0,0 +1,274 @@
+/*
+ * VMApple Backdoor Interface
+ *
+ * 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
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/units.h"
+#include "qemu/log.h"
+#include "qemu/module.h"
+#include "trace.h"
+#include "hw/vmapple/vmapple.h"
+#include "hw/sysbus.h"
+#include "hw/block/block.h"
+#include "qapi/error.h"
+#include "system/block-backend.h"
+#include "system/dma.h"
+
+OBJECT_DECLARE_SIMPLE_TYPE(VMAppleBdifState, VMAPPLE_BDIF)
+
+struct VMAppleBdifState {
+ SysBusDevice parent_obj;
+
+ BlockBackend *aux;
+ BlockBackend *root;
+ MemoryRegion mmio;
+};
+
+#define VMAPPLE_BDIF_SIZE 0x00200000
+
+#define REG_DEVID_MASK 0xffff0000
+#define DEVID_ROOT 0x00000000
+#define DEVID_AUX 0x00010000
+#define DEVID_USB 0x00100000
+
+#define REG_STATUS 0x0
+#define REG_STATUS_ACTIVE BIT(0)
+#define REG_CFG 0x4
+#define REG_CFG_ACTIVE BIT(1)
+#define REG_UNK1 0x8
+#define REG_BUSY 0x10
+#define REG_BUSY_READY BIT(0)
+#define REG_UNK2 0x400
+#define REG_CMD 0x408
+#define REG_NEXT_DEVICE 0x420
+#define REG_UNK3 0x434
+
+typedef struct VblkSector {
+ uint32_t pad;
+ uint32_t pad2;
+ uint32_t sector;
+ uint32_t pad3;
+} VblkSector;
+
+typedef struct VblkReqCmd {
+ uint64_t addr;
+ uint32_t len;
+ uint32_t flags;
+} VblkReqCmd;
+
+typedef struct VblkReq {
+ VblkReqCmd sector;
+ VblkReqCmd data;
+ VblkReqCmd retval;
+} VblkReq;
+
+#define VBLK_DATA_FLAGS_READ 0x00030001
+#define VBLK_DATA_FLAGS_WRITE 0x00010001
+
+#define VBLK_RET_SUCCESS 0
+#define VBLK_RET_FAILED 1
+
+static uint64_t bdif_read(void *opaque, hwaddr offset, unsigned size)
+{
+ uint64_t ret = -1;
+ uint64_t devid = offset & REG_DEVID_MASK;
+
+ switch (offset & ~REG_DEVID_MASK) {
+ case REG_STATUS:
+ ret = REG_STATUS_ACTIVE;
+ break;
+ case REG_CFG:
+ ret = REG_CFG_ACTIVE;
+ break;
+ case REG_UNK1:
+ ret = 0x420;
+ break;
+ case REG_BUSY:
+ ret = REG_BUSY_READY;
+ break;
+ case REG_UNK2:
+ ret = 0x1;
+ break;
+ case REG_UNK3:
+ ret = 0x0;
+ break;
+ case REG_NEXT_DEVICE:
+ switch (devid) {
+ case DEVID_ROOT:
+ ret = 0x8000000;
+ break;
+ case DEVID_AUX:
+ ret = 0x10000;
+ break;
+ }
+ break;
+ }
+
+ trace_bdif_read(offset, size, ret);
+ return ret;
+}
+
+static void le2cpu_sector(VblkSector *sector)
+{
+ sector->sector = le32_to_cpu(sector->sector);
+}
+
+static void le2cpu_reqcmd(VblkReqCmd *cmd)
+{
+ cmd->addr = le64_to_cpu(cmd->addr);
+ cmd->len = le32_to_cpu(cmd->len);
+ cmd->flags = le32_to_cpu(cmd->flags);
+}
+
+static void le2cpu_req(VblkReq *req)
+{
+ le2cpu_reqcmd(&req->sector);
+ le2cpu_reqcmd(&req->data);
+ le2cpu_reqcmd(&req->retval);
+}
+
+static void vblk_cmd(uint64_t devid, BlockBackend *blk, uint64_t gp_addr,
+ uint64_t static_off)
+{
+ VblkReq req;
+ VblkSector sector;
+ uint64_t off = 0;
+ g_autofree char *buf = NULL;
+ uint8_t ret = VBLK_RET_FAILED;
+ int r;
+ MemTxResult dma_result;
+
+ dma_result = dma_memory_read(&address_space_memory, gp_addr,
+ &req, sizeof(req), MEMTXATTRS_UNSPECIFIED);
+ if (dma_result != MEMTX_OK) {
+ goto out;
+ }
+
+ le2cpu_req(&req);
+
+ if (req.sector.len != sizeof(sector)) {
+ goto out;
+ }
+
+ /* Read the vblk command */
+ dma_result = dma_memory_read(&address_space_memory, req.sector.addr,
+ §or, sizeof(sector),
+ MEMTXATTRS_UNSPECIFIED);
+ if (dma_result != MEMTX_OK) {
+ goto out;
+ }
+ le2cpu_sector(§or);
+
+ off = sector.sector * 512ULL + static_off;
+
+ /* Sanity check that we're not allocating bogus sizes */
+ if (req.data.len > 128 * MiB) {
+ goto out;
+ }
+
+ buf = g_malloc0(req.data.len);
+ switch (req.data.flags) {
+ case VBLK_DATA_FLAGS_READ:
+ r = blk_pread(blk, off, req.data.len, buf, 0);
+ trace_bdif_vblk_read(devid == DEVID_AUX ? "aux" : "root",
+ req.data.addr, off, req.data.len, r);
+ if (r < 0) {
+ goto out;
+ }
+ dma_result = dma_memory_write(&address_space_memory, req.data.addr, buf,
+ req.data.len, MEMTXATTRS_UNSPECIFIED);
+ if (dma_result == MEMTX_OK) {
+ ret = VBLK_RET_SUCCESS;
+ }
+ break;
+ case VBLK_DATA_FLAGS_WRITE:
+ /* Not needed, iBoot only reads */
+ break;
+ default:
+ break;
+ }
+
+out:
+ dma_memory_write(&address_space_memory, req.retval.addr, &ret, 1,
+ MEMTXATTRS_UNSPECIFIED);
+}
+
+static void bdif_write(void *opaque, hwaddr offset,
+ uint64_t value, unsigned size)
+{
+ VMAppleBdifState *s = opaque;
+ uint64_t devid = (offset & REG_DEVID_MASK);
+
+ trace_bdif_write(offset, size, value);
+
+ switch (offset & ~REG_DEVID_MASK) {
+ case REG_CMD:
+ switch (devid) {
+ case DEVID_ROOT:
+ vblk_cmd(devid, s->root, value, 0x0);
+ break;
+ case DEVID_AUX:
+ vblk_cmd(devid, s->aux, value, 0x0);
+ break;
+ }
+ break;
+ }
+}
+
+static const MemoryRegionOps bdif_ops = {
+ .read = bdif_read,
+ .write = bdif_write,
+ .endianness = DEVICE_NATIVE_ENDIAN,
+ .valid = {
+ .min_access_size = 1,
+ .max_access_size = 8,
+ },
+ .impl = {
+ .min_access_size = 1,
+ .max_access_size = 8,
+ },
+};
+
+static void bdif_init(Object *obj)
+{
+ VMAppleBdifState *s = VMAPPLE_BDIF(obj);
+
+ memory_region_init_io(&s->mmio, obj, &bdif_ops, obj,
+ "VMApple Backdoor Interface", VMAPPLE_BDIF_SIZE);
+ sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio);
+}
+
+static const Property bdif_properties[] = {
+ DEFINE_PROP_DRIVE("aux", VMAppleBdifState, aux),
+ DEFINE_PROP_DRIVE("root", VMAppleBdifState, root),
+};
+
+static void bdif_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+
+ dc->desc = "VMApple Backdoor Interface";
+ device_class_set_props(dc, bdif_properties);
+}
+
+static const TypeInfo bdif_info = {
+ .name = TYPE_VMAPPLE_BDIF,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(VMAppleBdifState),
+ .instance_init = bdif_init,
+ .class_init = bdif_class_init,
+};
+
+static void bdif_register_types(void)
+{
+ type_register_static(&bdif_info);
+}
+
+type_init(bdif_register_types)
diff --git a/hw/vmapple/meson.build b/hw/vmapple/meson.build
index bcd4dcb28d..d4624713de 100644
--- a/hw/vmapple/meson.build
+++ b/hw/vmapple/meson.build
@@ -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'))
diff --git a/hw/vmapple/trace-events b/hw/vmapple/trace-events
index 0d4a73d7d1..d86f64d50f 100644
--- a/hw/vmapple/trace-events
+++ b/hw/vmapple/trace-events
@@ -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"
+
diff --git a/include/hw/vmapple/vmapple.h b/include/hw/vmapple/vmapple.h
index 6762b6c869..9090e9c5ac 100644
--- a/include/hw/vmapple/vmapple.h
+++ b/include/hw/vmapple/vmapple.h
@@ -14,4 +14,6 @@
#define TYPE_APPLE_AES "apple-aes"
+#define TYPE_VMAPPLE_BDIF "vmapple-bdif"
+
#endif /* HW_VMAPPLE_VMAPPLE_H */
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v17 07/11] hw/vmapple/cfg: Introduce vmapple cfg region
2025-01-12 21:00 [PATCH v17 00/11] New vmapple machine type and xhci fixes Phil Dennis-Jordan
` (5 preceding siblings ...)
2025-01-12 21:00 ` [PATCH v17 06/11] hw/vmapple/bdif: Introduce vmapple backdoor interface Phil Dennis-Jordan
@ 2025-01-12 21:00 ` Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 08/11] hw/vmapple/virtio-blk: Add support for apple virtio-blk Phil Dennis-Jordan
` (6 subsequent siblings)
13 siblings, 0 replies; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-01-12 21:00 UTC (permalink / raw)
To: qemu-devel
Cc: agraf, phil, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm, Alexander Graf,
Akihiko Odaki
From: Alexander Graf <graf@amazon.com>
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.
Signed-off-by: Alexander Graf <graf@amazon.com>
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
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
diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig
index 68f88876eb..8bbeb9a923 100644
--- a/hw/vmapple/Kconfig
+++ b/hw/vmapple/Kconfig
@@ -4,3 +4,6 @@ config VMAPPLE_AES
config VMAPPLE_BDIF
bool
+config VMAPPLE_CFG
+ bool
+
diff --git a/hw/vmapple/cfg.c b/hw/vmapple/cfg.c
new file mode 100644
index 0000000000..63414d801f
--- /dev/null
+++ b/hw/vmapple/cfg.c
@@ -0,0 +1,195 @@
+/*
+ * VMApple Configuration Region
+ *
+ * Copyright © 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/vmapple/vmapple.h"
+#include "hw/sysbus.h"
+#include "qemu/log.h"
+#include "qemu/module.h"
+#include "qapi/error.h"
+#include "net/net.h"
+
+OBJECT_DECLARE_SIMPLE_TYPE(VMAppleCfgState, VMAPPLE_CFG)
+
+#define VMAPPLE_CFG_SIZE 0x00010000
+
+typedef struct VMAppleCfg {
+ uint32_t version; /* 0x000 */
+ uint32_t nr_cpus; /* 0x004 */
+ uint32_t unk1; /* 0x008 */
+ uint32_t unk2; /* 0x00c */
+ uint32_t unk3; /* 0x010 */
+ uint32_t unk4; /* 0x014 */
+ uint64_t ecid; /* 0x018 */
+ uint64_t ram_size; /* 0x020 */
+ uint32_t run_installer1; /* 0x028 */
+ uint32_t unk5; /* 0x02c */
+ uint32_t unk6; /* 0x030 */
+ uint32_t run_installer2; /* 0x034 */
+ uint32_t rnd; /* 0x038 */
+ uint32_t unk7; /* 0x03c */
+ MACAddr mac_en0; /* 0x040 */
+ uint8_t pad1[2];
+ MACAddr mac_en1; /* 0x048 */
+ uint8_t pad2[2];
+ MACAddr mac_wifi0; /* 0x050 */
+ uint8_t pad3[2];
+ MACAddr mac_bt0; /* 0x058 */
+ uint8_t pad4[2];
+ uint8_t reserved[0xa0]; /* 0x060 */
+ uint32_t cpu_ids[0x80]; /* 0x100 */
+ uint8_t scratch[0x200]; /* 0x180 */
+ char serial[32]; /* 0x380 */
+ char unk8[32]; /* 0x3a0 */
+ char model[32]; /* 0x3c0 */
+ uint8_t unk9[32]; /* 0x3e0 */
+ uint32_t unk10; /* 0x400 */
+ char soc_name[32]; /* 0x404 */
+} VMAppleCfg;
+
+struct VMAppleCfgState {
+ SysBusDevice parent_obj;
+ VMAppleCfg cfg;
+
+ MemoryRegion mem;
+ char *serial;
+ char *model;
+ char *soc_name;
+};
+
+static void vmapple_cfg_reset(Object *obj, ResetType type)
+{
+ VMAppleCfgState *s = VMAPPLE_CFG(obj);
+ VMAppleCfg *cfg;
+
+ cfg = memory_region_get_ram_ptr(&s->mem);
+ memset(cfg, 0, VMAPPLE_CFG_SIZE);
+ *cfg = s->cfg;
+}
+
+static bool set_fixlen_property_or_error(char *restrict dst,
+ const char *restrict src,
+ size_t dst_size, Error **errp,
+ const char *property_name)
+{
+ ERRP_GUARD();
+ size_t len;
+
+ len = g_strlcpy(dst, src, dst_size);
+ if (len < dst_size) { /* len does not count nul terminator */
+ return true;
+ }
+
+ error_setg(errp, "Provided value too long for property '%s'", property_name);
+ error_append_hint(errp, "length (%zu) exceeds maximum of %zu\n",
+ len, dst_size - 1);
+ return false;
+}
+
+#define set_fixlen_property_or_return(dst_array, src, errp, property_name) \
+ do { \
+ if (!set_fixlen_property_or_error((dst_array), (src), \
+ ARRAY_SIZE(dst_array), \
+ (errp), (property_name))) { \
+ return; \
+ } \
+ } while (0)
+
+static void vmapple_cfg_realize(DeviceState *dev, Error **errp)
+{
+ VMAppleCfgState *s = VMAPPLE_CFG(dev);
+ uint32_t i;
+
+ if (!s->serial) {
+ s->serial = g_strdup("1234");
+ }
+ if (!s->model) {
+ s->model = g_strdup("VM0001");
+ }
+ if (!s->soc_name) {
+ s->soc_name = g_strdup("Apple M1 (Virtual)");
+ }
+
+ set_fixlen_property_or_return(s->cfg.serial, s->serial, errp, "serial");
+ set_fixlen_property_or_return(s->cfg.model, s->model, errp, "model");
+ set_fixlen_property_or_return(s->cfg.soc_name, s->soc_name, errp, "soc_name");
+ set_fixlen_property_or_return(s->cfg.unk8, "D/A", errp, "unk8");
+ s->cfg.version = 2;
+ s->cfg.unk1 = 1;
+ s->cfg.unk2 = 1;
+ s->cfg.unk3 = 0x20;
+ s->cfg.unk4 = 0;
+ s->cfg.unk5 = 1;
+ s->cfg.unk6 = 1;
+ s->cfg.unk7 = 0;
+ s->cfg.unk10 = 1;
+
+ if (s->cfg.nr_cpus > ARRAY_SIZE(s->cfg.cpu_ids)) {
+ error_setg(errp,
+ "Failed to create %u CPUs, vmapple machine supports %zu max",
+ s->cfg.nr_cpus, ARRAY_SIZE(s->cfg.cpu_ids));
+ return;
+ }
+ for (i = 0; i < s->cfg.nr_cpus; i++) {
+ s->cfg.cpu_ids[i] = i;
+ }
+}
+
+static void vmapple_cfg_init(Object *obj)
+{
+ VMAppleCfgState *s = VMAPPLE_CFG(obj);
+
+ memory_region_init_ram(&s->mem, obj, "VMApple Config", VMAPPLE_CFG_SIZE,
+ &error_fatal);
+ sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mem);
+}
+
+static const Property vmapple_cfg_properties[] = {
+ DEFINE_PROP_UINT32("nr-cpus", VMAppleCfgState, cfg.nr_cpus, 1),
+ DEFINE_PROP_UINT64("ecid", VMAppleCfgState, cfg.ecid, 0),
+ DEFINE_PROP_UINT64("ram-size", VMAppleCfgState, cfg.ram_size, 0),
+ DEFINE_PROP_UINT32("run_installer1", VMAppleCfgState, cfg.run_installer1, 0),
+ DEFINE_PROP_UINT32("run_installer2", VMAppleCfgState, cfg.run_installer2, 0),
+ DEFINE_PROP_UINT32("rnd", VMAppleCfgState, cfg.rnd, 0),
+ DEFINE_PROP_MACADDR("mac-en0", VMAppleCfgState, cfg.mac_en0),
+ DEFINE_PROP_MACADDR("mac-en1", VMAppleCfgState, cfg.mac_en1),
+ DEFINE_PROP_MACADDR("mac-wifi0", VMAppleCfgState, cfg.mac_wifi0),
+ DEFINE_PROP_MACADDR("mac-bt0", VMAppleCfgState, cfg.mac_bt0),
+ DEFINE_PROP_STRING("serial", VMAppleCfgState, serial),
+ DEFINE_PROP_STRING("model", VMAppleCfgState, model),
+ DEFINE_PROP_STRING("soc_name", VMAppleCfgState, soc_name),
+};
+
+static void vmapple_cfg_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
+
+ dc->realize = vmapple_cfg_realize;
+ dc->desc = "VMApple Configuration Region";
+ device_class_set_props(dc, vmapple_cfg_properties);
+ rc->phases.hold = vmapple_cfg_reset;
+}
+
+static const TypeInfo vmapple_cfg_info = {
+ .name = TYPE_VMAPPLE_CFG,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(VMAppleCfgState),
+ .instance_init = vmapple_cfg_init,
+ .class_init = vmapple_cfg_class_init,
+};
+
+static void vmapple_cfg_register_types(void)
+{
+ type_register_static(&vmapple_cfg_info);
+}
+
+type_init(vmapple_cfg_register_types)
diff --git a/hw/vmapple/meson.build b/hw/vmapple/meson.build
index d4624713de..64b78693a3 100644
--- a/hw/vmapple/meson.build
+++ b/hw/vmapple/meson.build
@@ -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'))
diff --git a/include/hw/vmapple/vmapple.h b/include/hw/vmapple/vmapple.h
index 9090e9c5ac..3bba59f5ec 100644
--- a/include/hw/vmapple/vmapple.h
+++ b/include/hw/vmapple/vmapple.h
@@ -16,4 +16,6 @@
#define TYPE_VMAPPLE_BDIF "vmapple-bdif"
+#define TYPE_VMAPPLE_CFG "vmapple-cfg"
+
#endif /* HW_VMAPPLE_VMAPPLE_H */
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v17 08/11] hw/vmapple/virtio-blk: Add support for apple virtio-blk
2025-01-12 21:00 [PATCH v17 00/11] New vmapple machine type and xhci fixes Phil Dennis-Jordan
` (6 preceding siblings ...)
2025-01-12 21:00 ` [PATCH v17 07/11] hw/vmapple/cfg: Introduce vmapple cfg region Phil Dennis-Jordan
@ 2025-01-12 21:00 ` Phil Dennis-Jordan
2025-01-15 12:36 ` Akihiko Odaki
2025-01-12 21:00 ` [PATCH v17 09/11] hw/usb/hcd-xhci-pci: Adds property for disabling mapping in IRQ mode Phil Dennis-Jordan
` (5 subsequent siblings)
13 siblings, 1 reply; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-01-12 21:00 UTC (permalink / raw)
To: qemu-devel
Cc: agraf, phil, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm, Alexander Graf,
Akihiko Odaki
From: Alexander Graf <graf@amazon.com>
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 <graf@amazon.com>
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com>
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
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index e0acce89e1..4d27afabf0 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -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)
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index a96675beb0..6be44ddb46 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -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,
+};
diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig
index 8bbeb9a923..bcd1be63e3 100644
--- a/hw/vmapple/Kconfig
+++ b/hw/vmapple/Kconfig
@@ -7,3 +7,6 @@ config VMAPPLE_BDIF
config VMAPPLE_CFG
bool
+config VMAPPLE_VIRTIO_BLK
+ bool
+
diff --git a/hw/vmapple/meson.build b/hw/vmapple/meson.build
index 64b78693a3..bf17cf906c 100644
--- a/hw/vmapple/meson.build
+++ b/hw/vmapple/meson.build
@@ -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'))
diff --git a/hw/vmapple/virtio-blk.c b/hw/vmapple/virtio-blk.c
new file mode 100644
index 0000000000..6b434b8842
--- /dev/null
+++ b/hw/vmapple/virtio-blk.c
@@ -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)
diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h
index f1a53fea8d..33e2898be9 100644
--- a/include/hw/pci/pci_ids.h
+++ b/include/hw/pci/pci_ids.h
@@ -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
diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properties-system.h
index 7ec37f6316..3631e30969 100644
--- a/include/hw/qdev-properties-system.h
+++ b/include/hw/qdev-properties-system.h
@@ -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
diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
index 8a16218c40..3d8dee7ec1 100644
--- a/include/hw/virtio/virtio-blk.h
+++ b/include/hw/virtio/virtio-blk.h
@@ -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
diff --git a/include/hw/vmapple/vmapple.h b/include/hw/vmapple/vmapple.h
index 3bba59f5ec..9c1ad1bd8c 100644
--- a/include/hw/vmapple/vmapple.h
+++ b/include/hw/vmapple/vmapple.h
@@ -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 */
diff --git a/qapi/virtio.json b/qapi/virtio.json
index 2529c2d8b2..d351d2166e 100644
--- a/qapi/virtio.json
+++ b/qapi/virtio.json
@@ -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' ] }
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v17 09/11] hw/usb/hcd-xhci-pci: Adds property for disabling mapping in IRQ mode
2025-01-12 21:00 [PATCH v17 00/11] New vmapple machine type and xhci fixes Phil Dennis-Jordan
` (7 preceding siblings ...)
2025-01-12 21:00 ` [PATCH v17 08/11] hw/vmapple/virtio-blk: Add support for apple virtio-blk Phil Dennis-Jordan
@ 2025-01-12 21:00 ` Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 10/11] hw/intc: Remove TCG dependency on ARM_GICV3 Phil Dennis-Jordan
` (4 subsequent siblings)
13 siblings, 0 replies; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-01-12 21:00 UTC (permalink / raw)
To: qemu-devel
Cc: agraf, phil, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm
This 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.
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
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(-)
diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
index 49642aab58..d908eb787d 100644
--- a/hw/usb/hcd-xhci-pci.c
+++ b/hw/usb/hcd-xhci-pci.c
@@ -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 = {
diff --git a/hw/usb/hcd-xhci-pci.h b/hw/usb/hcd-xhci-pci.h
index 08f70ce97c..5b61ae8455 100644
--- a/hw/usb/hcd-xhci-pci.h
+++ b/hw/usb/hcd-xhci-pci.h
@@ -40,6 +40,7 @@ typedef struct XHCIPciState {
XHCIState xhci;
OnOffAuto msi;
OnOffAuto msix;
+ bool conditional_intr_mapping;
} XHCIPciState;
#endif
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 00d5bc3779..64c3a23b9b 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -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;
}
diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
index 9609b83514..9c3974f148 100644
--- a/hw/usb/hcd-xhci.h
+++ b/hw/usb/hcd-xhci.h
@@ -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 */
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v17 10/11] hw/intc: Remove TCG dependency on ARM_GICV3
2025-01-12 21:00 [PATCH v17 00/11] New vmapple machine type and xhci fixes Phil Dennis-Jordan
` (8 preceding siblings ...)
2025-01-12 21:00 ` [PATCH v17 09/11] hw/usb/hcd-xhci-pci: Adds property for disabling mapping in IRQ mode Phil Dennis-Jordan
@ 2025-01-12 21:00 ` Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type Phil Dennis-Jordan
` (3 subsequent siblings)
13 siblings, 0 replies; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-01-12 21:00 UTC (permalink / raw)
To: qemu-devel
Cc: agraf, phil, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm
From: Philippe Mathieu-Daudé <philmd@linaro.org>
The TYPE_ARM_GICV3 model doesn't have any particular
dependency on TCG, remove it. Rename the Kconfig selector
ARM_GICV3_TCG -> ARM_GICV3.
Fixes: a8a5546798c ("hw/intc/arm_gicv3: Introduce CONFIG_ARM_GIC_TCG Kconfig selector")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Phil Dennis-Jordan <phil@philjordan.eu>
---
hw/intc/Kconfig | 6 +++---
hw/intc/meson.build | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig
index dd405bdb5d..7547528f2c 100644
--- a/hw/intc/Kconfig
+++ b/hw/intc/Kconfig
@@ -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
diff --git a/hw/intc/meson.build b/hw/intc/meson.build
index 510fdfb688..602da304b0 100644
--- a/hw/intc/meson.build
+++ b/hw/intc/meson.build
@@ -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'))
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type
2025-01-12 21:00 [PATCH v17 00/11] New vmapple machine type and xhci fixes Phil Dennis-Jordan
` (9 preceding siblings ...)
2025-01-12 21:00 ` [PATCH v17 10/11] hw/intc: Remove TCG dependency on ARM_GICV3 Phil Dennis-Jordan
@ 2025-01-12 21:00 ` Phil Dennis-Jordan
2025-03-03 18:20 ` Philippe Mathieu-Daudé
2025-03-03 21:51 ` Philippe Mathieu-Daudé
2025-01-13 17:31 ` [PATCH v17 00/11] New vmapple machine type and xhci fixes Philippe Mathieu-Daudé
` (2 subsequent siblings)
13 siblings, 2 replies; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-01-12 21:00 UTC (permalink / raw)
To: qemu-devel
Cc: agraf, phil, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm, Alexander Graf,
Akihiko Odaki
From: Alexander Graf <graf@amazon.com>
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 <graf@amazon.com>
Co-authored-by: Phil Dennis-Jordan <phil@philjordan.eu>
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
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
diff --git a/MAINTAINERS b/MAINTAINERS
index e220744abf..3a3d9e19f4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2791,6 +2791,7 @@ M: Phil Dennis-Jordan <phil@philjordan.eu>
S: Maintained
F: hw/vmapple/*
F: include/hw/vmapple/*
+F: docs/system/arm/vmapple.rst
Subsystems
----------
diff --git a/contrib/vmapple/uuid.sh b/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 --git a/docs/system/arm/vmapple.rst b/docs/system/arm/vmapple.rst
new file mode 100644
index 0000000000..5090a8997c
--- /dev/null
+++ b/docs/system/arm/vmapple.rst
@@ -0,0 +1,63 @@
+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
+
diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst
index 9aaa9c414c..3426f79100 100644
--- a/docs/system/target-arm.rst
+++ b/docs/system/target-arm.rst
@@ -102,6 +102,7 @@ Board-specific documentation
arm/stellaris
arm/stm32
arm/virt
+ arm/vmapple
arm/xenpvh
arm/xlnx-versal-virt
arm/xlnx-zynq
diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig
index bcd1be63e3..36db9e35a7 100644
--- a/hw/vmapple/Kconfig
+++ b/hw/vmapple/Kconfig
@@ -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
diff --git a/hw/vmapple/meson.build b/hw/vmapple/meson.build
index bf17cf906c..e572f7d560 100644
--- a/hw/vmapple/meson.build
+++ b/hw/vmapple/meson.build
@@ -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'))
diff --git a/hw/vmapple/vmapple.c b/hw/vmapple/vmapple.c
new file mode 100644
index 0000000000..ec0896dd32
--- /dev/null
+++ b/hw/vmapple/vmapple.c
@@ -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"
+#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"
+#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"
+
+struct VMAppleMachineState {
+ MachineState parent;
+
+ Notifier machine_done;
+ struct arm_boot_info bootinfo;
+ const MemMapEntry *memmap;
+ const int *irqmap;
+ DeviceState *gic;
+ DeviceState *cfg;
+ DeviceState *pvpanic;
+ Notifier powerdown_notifier;
+ PCIBus *bus;
+ MemoryRegion fw_mr;
+ MemoryRegion ecam_alias;
+ uint64_t uuid;
+};
+
+#define TYPE_VMAPPLE_MACHINE MACHINE_TYPE_NAME("vmapple")
+OBJECT_DECLARE_SIMPLE_TYPE(VMAppleMachineState, VMAPPLE_MACHINE)
+
+/* Number of external interrupt lines to configure the GIC with */
+#define NUM_IRQS 256
+
+enum {
+ VMAPPLE_FIRMWARE,
+ VMAPPLE_CONFIG,
+ VMAPPLE_MEM,
+ VMAPPLE_GIC_DIST,
+ VMAPPLE_GIC_REDIST,
+ VMAPPLE_UART,
+ VMAPPLE_RTC,
+ VMAPPLE_PCIE,
+ VMAPPLE_PCIE_MMIO,
+ VMAPPLE_PCIE_ECAM,
+ VMAPPLE_GPIO,
+ VMAPPLE_PVPANIC,
+ VMAPPLE_APV_GFX,
+ VMAPPLE_APV_IOSFC,
+ VMAPPLE_AES_1,
+ VMAPPLE_AES_2,
+ VMAPPLE_BDOOR,
+ VMAPPLE_MEMMAP_LAST,
+};
+
+static const MemMapEntry memmap[] = {
+ [VMAPPLE_FIRMWARE] = { 0x00100000, 0x00100000 },
+ [VMAPPLE_CONFIG] = { 0x00400000, 0x00010000 },
+
+ [VMAPPLE_GIC_DIST] = { 0x10000000, 0x00010000 },
+ [VMAPPLE_GIC_REDIST] = { 0x10010000, 0x00400000 },
+
+ [VMAPPLE_UART] = { 0x20010000, 0x00010000 },
+ [VMAPPLE_RTC] = { 0x20050000, 0x00001000 },
+ [VMAPPLE_GPIO] = { 0x20060000, 0x00001000 },
+ [VMAPPLE_PVPANIC] = { 0x20070000, 0x00000002 },
+ [VMAPPLE_BDOOR] = { 0x30000000, 0x00200000 },
+ [VMAPPLE_APV_GFX] = { 0x30200000, 0x00010000 },
+ [VMAPPLE_APV_IOSFC] = { 0x30210000, 0x00010000 },
+ [VMAPPLE_AES_1] = { 0x30220000, 0x00004000 },
+ [VMAPPLE_AES_2] = { 0x30230000, 0x00004000 },
+ [VMAPPLE_PCIE_ECAM] = { 0x40000000, 0x10000000 },
+ [VMAPPLE_PCIE_MMIO] = { 0x50000000, 0x1fff0000 },
+
+ /* Actual RAM size depends on configuration */
+ [VMAPPLE_MEM] = { 0x70000000ULL, GiB},
+};
+
+static const int irqmap[] = {
+ [VMAPPLE_UART] = 1,
+ [VMAPPLE_RTC] = 2,
+ [VMAPPLE_GPIO] = 0x5,
+ [VMAPPLE_APV_IOSFC] = 0x10,
+ [VMAPPLE_APV_GFX] = 0x11,
+ [VMAPPLE_AES_1] = 0x12,
+ [VMAPPLE_PCIE] = 0x20,
+};
+
+#define GPEX_NUM_IRQS 16
+
+static void create_bdif(VMAppleMachineState *vms, MemoryRegion *mem)
+{
+ DeviceState *bdif;
+ SysBusDevice *bdif_sb;
+ DriveInfo *di_aux = drive_get(IF_PFLASH, 0, 0);
+ DriveInfo *di_root = drive_get(IF_PFLASH, 0, 1);
+
+ if (!di_aux) {
+ error_report("No AUX device. Please specify one as pflash drive.");
+ exit(1);
+ }
+
+ if (!di_root) {
+ /* Fall back to the first IF_VIRTIO device as root device */
+ di_root = drive_get(IF_VIRTIO, 0, 0);
+ }
+
+ if (!di_root) {
+ error_report("No root device. Please specify one as virtio drive.");
+ exit(1);
+ }
+
+ /* PV backdoor device */
+ bdif = qdev_new(TYPE_VMAPPLE_BDIF);
+ bdif_sb = SYS_BUS_DEVICE(bdif);
+ sysbus_mmio_map(bdif_sb, 0, vms->memmap[VMAPPLE_BDOOR].base);
+
+ qdev_prop_set_drive(DEVICE(bdif), "aux", blk_by_legacy_dinfo(di_aux));
+ qdev_prop_set_drive(DEVICE(bdif), "root", blk_by_legacy_dinfo(di_root));
+
+ sysbus_realize_and_unref(bdif_sb, &error_fatal);
+}
+
+static void create_pvpanic(VMAppleMachineState *vms, MemoryRegion *mem)
+{
+ SysBusDevice *pvpanic;
+
+ vms->pvpanic = qdev_new(TYPE_PVPANIC_MMIO_DEVICE);
+ pvpanic = SYS_BUS_DEVICE(vms->pvpanic);
+ sysbus_mmio_map(pvpanic, 0, vms->memmap[VMAPPLE_PVPANIC].base);
+
+ sysbus_realize_and_unref(pvpanic, &error_fatal);
+}
+
+static bool create_cfg(VMAppleMachineState *vms, MemoryRegion *mem,
+ Error **errp)
+{
+ ERRP_GUARD();
+ SysBusDevice *cfg;
+ MachineState *machine = MACHINE(vms);
+ uint32_t rnd = 1;
+
+ vms->cfg = qdev_new(TYPE_VMAPPLE_CFG);
+ cfg = SYS_BUS_DEVICE(vms->cfg);
+ sysbus_mmio_map(cfg, 0, vms->memmap[VMAPPLE_CONFIG].base);
+
+ qemu_guest_getrandom_nofail(&rnd, sizeof(rnd));
+
+ qdev_prop_set_uint32(vms->cfg, "nr-cpus", machine->smp.cpus);
+ qdev_prop_set_uint64(vms->cfg, "ecid", vms->uuid);
+ qdev_prop_set_uint64(vms->cfg, "ram-size", machine->ram_size);
+ qdev_prop_set_uint32(vms->cfg, "rnd", rnd);
+
+ if (!sysbus_realize_and_unref(cfg, errp)) {
+ error_prepend(errp, "Error creating vmapple cfg device: ");
+ return false;
+ }
+
+ return true;
+}
+
+static void create_gfx(VMAppleMachineState *vms, MemoryRegion *mem)
+{
+ int irq_gfx = vms->irqmap[VMAPPLE_APV_GFX];
+ int irq_iosfc = vms->irqmap[VMAPPLE_APV_IOSFC];
+ SysBusDevice *gfx;
+
+ gfx = SYS_BUS_DEVICE(qdev_new("apple-gfx-mmio"));
+ sysbus_mmio_map(gfx, 0, vms->memmap[VMAPPLE_APV_GFX].base);
+ sysbus_mmio_map(gfx, 1, vms->memmap[VMAPPLE_APV_IOSFC].base);
+ sysbus_connect_irq(gfx, 0, qdev_get_gpio_in(vms->gic, irq_gfx));
+ sysbus_connect_irq(gfx, 1, qdev_get_gpio_in(vms->gic, irq_iosfc));
+ sysbus_realize_and_unref(gfx, &error_fatal);
+}
+
+static void create_aes(VMAppleMachineState *vms, MemoryRegion *mem)
+{
+ int irq = vms->irqmap[VMAPPLE_AES_1];
+ SysBusDevice *aes;
+
+ aes = SYS_BUS_DEVICE(qdev_new(TYPE_APPLE_AES));
+ sysbus_mmio_map(aes, 0, vms->memmap[VMAPPLE_AES_1].base);
+ sysbus_mmio_map(aes, 1, vms->memmap[VMAPPLE_AES_2].base);
+ sysbus_connect_irq(aes, 0, qdev_get_gpio_in(vms->gic, irq));
+ sysbus_realize_and_unref(aes, &error_fatal);
+}
+
+static int arm_gic_ppi_index(int cpu_nr, int ppi_index)
+{
+ return NUM_IRQS + cpu_nr * GIC_INTERNAL + ppi_index;
+}
+
+static void create_gic(VMAppleMachineState *vms, MemoryRegion *mem)
+{
+ MachineState *ms = MACHINE(vms);
+ /* We create a standalone GIC */
+ SysBusDevice *gicbusdev;
+ QList *redist_region_count;
+ int i;
+ unsigned int smp_cpus = ms->smp.cpus;
+
+ vms->gic = qdev_new(gicv3_class_name());
+ qdev_prop_set_uint32(vms->gic, "revision", 3);
+ qdev_prop_set_uint32(vms->gic, "num-cpu", smp_cpus);
+ /*
+ * Note that the num-irq property counts both internal and external
+ * interrupts; there are always 32 of the former (mandated by GIC spec).
+ */
+ qdev_prop_set_uint32(vms->gic, "num-irq", NUM_IRQS + 32);
+
+ uint32_t redist0_capacity =
+ vms->memmap[VMAPPLE_GIC_REDIST].size / GICV3_REDIST_SIZE;
+ uint32_t redist0_count = MIN(smp_cpus, redist0_capacity);
+
+ redist_region_count = qlist_new();
+ qlist_append_int(redist_region_count, redist0_count);
+ qdev_prop_set_array(vms->gic, "redist-region-count", redist_region_count);
+
+ gicbusdev = SYS_BUS_DEVICE(vms->gic);
+ sysbus_realize_and_unref(gicbusdev, &error_fatal);
+ sysbus_mmio_map(gicbusdev, 0, vms->memmap[VMAPPLE_GIC_DIST].base);
+ sysbus_mmio_map(gicbusdev, 1, vms->memmap[VMAPPLE_GIC_REDIST].base);
+
+ /*
+ * Wire the outputs from each CPU's generic timer and the GICv3
+ * maintenance interrupt signal to the appropriate GIC PPI inputs,
+ * and the GIC's IRQ/FIQ/VIRQ/VFIQ interrupt outputs to the CPU's inputs.
+ */
+ for (i = 0; i < smp_cpus; i++) {
+ DeviceState *cpudev = DEVICE(qemu_get_cpu(i));
+
+ /* Map the virt timer to PPI 27 */
+ qdev_connect_gpio_out(cpudev, GTIMER_VIRT,
+ qdev_get_gpio_in(vms->gic,
+ arm_gic_ppi_index(i, 27)));
+
+ /* Map the GIC IRQ and FIQ lines to CPU */
+ sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
+ sysbus_connect_irq(gicbusdev, i + smp_cpus,
+ qdev_get_gpio_in(cpudev, ARM_CPU_FIQ));
+ }
+}
+
+static void create_uart(const VMAppleMachineState *vms, int uart,
+ MemoryRegion *mem, Chardev *chr)
+{
+ hwaddr base = vms->memmap[uart].base;
+ int irq = vms->irqmap[uart];
+ DeviceState *dev = qdev_new(TYPE_PL011);
+ SysBusDevice *s = SYS_BUS_DEVICE(dev);
+
+ qdev_prop_set_chr(dev, "chardev", chr);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
+ memory_region_add_subregion(mem, base,
+ sysbus_mmio_get_region(s, 0));
+ sysbus_connect_irq(s, 0, qdev_get_gpio_in(vms->gic, irq));
+}
+
+static void create_rtc(const VMAppleMachineState *vms)
+{
+ hwaddr base = vms->memmap[VMAPPLE_RTC].base;
+ int irq = vms->irqmap[VMAPPLE_RTC];
+
+ sysbus_create_simple("pl031", base, qdev_get_gpio_in(vms->gic, irq));
+}
+
+static DeviceState *gpio_key_dev;
+static void vmapple_powerdown_req(Notifier *n, void *opaque)
+{
+ /* use gpio Pin 3 for power button event */
+ qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1);
+}
+
+static void create_gpio_devices(const VMAppleMachineState *vms, int gpio,
+ MemoryRegion *mem)
+{
+ DeviceState *pl061_dev;
+ hwaddr base = vms->memmap[gpio].base;
+ int irq = vms->irqmap[gpio];
+ SysBusDevice *s;
+
+ pl061_dev = qdev_new("pl061");
+ /* Pull lines down to 0 if not driven by the PL061 */
+ qdev_prop_set_uint32(pl061_dev, "pullups", 0);
+ qdev_prop_set_uint32(pl061_dev, "pulldowns", 0xff);
+ s = SYS_BUS_DEVICE(pl061_dev);
+ sysbus_realize_and_unref(s, &error_fatal);
+ memory_region_add_subregion(mem, base, sysbus_mmio_get_region(s, 0));
+ sysbus_connect_irq(s, 0, qdev_get_gpio_in(vms->gic, irq));
+ gpio_key_dev = sysbus_create_simple("gpio-key", -1,
+ qdev_get_gpio_in(pl061_dev, 3));
+}
+
+static void vmapple_firmware_init(VMAppleMachineState *vms,
+ MemoryRegion *sysmem)
+{
+ hwaddr size = vms->memmap[VMAPPLE_FIRMWARE].size;
+ hwaddr base = vms->memmap[VMAPPLE_FIRMWARE].base;
+ const char *bios_name;
+ int image_size;
+ char *fname;
+
+ bios_name = MACHINE(vms)->firmware;
+ if (!bios_name) {
+ error_report("No firmware specified");
+ exit(1);
+ }
+
+ fname = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+ if (!fname) {
+ error_report("Could not find ROM image '%s'", bios_name);
+ exit(1);
+ }
+
+ memory_region_init_ram(&vms->fw_mr, NULL, "firmware", size, &error_fatal);
+ image_size = load_image_mr(fname, &vms->fw_mr);
+
+ g_free(fname);
+ if (image_size < 0) {
+ error_report("Could not load ROM image '%s'", bios_name);
+ exit(1);
+ }
+
+ memory_region_add_subregion(get_system_memory(), base, &vms->fw_mr);
+}
+
+static void create_pcie(VMAppleMachineState *vms)
+{
+ hwaddr base_mmio = vms->memmap[VMAPPLE_PCIE_MMIO].base;
+ hwaddr size_mmio = vms->memmap[VMAPPLE_PCIE_MMIO].size;
+ hwaddr base_ecam = vms->memmap[VMAPPLE_PCIE_ECAM].base;
+ hwaddr size_ecam = vms->memmap[VMAPPLE_PCIE_ECAM].size;
+ int irq = vms->irqmap[VMAPPLE_PCIE];
+ MemoryRegion *mmio_alias;
+ MemoryRegion *mmio_reg;
+ MemoryRegion *ecam_reg;
+ DeviceState *dev;
+ int i;
+ PCIHostState *pci;
+ DeviceState *usb_controller;
+ USBBus *usb_bus;
+
+ dev = qdev_new(TYPE_GPEX_HOST);
+ qdev_prop_set_uint32(dev, "num-irqs", GPEX_NUM_IRQS);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
+
+ /* Map only the first size_ecam bytes of ECAM space */
+ ecam_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
+ memory_region_init_alias(&vms->ecam_alias, OBJECT(dev), "pcie-ecam",
+ ecam_reg, 0, size_ecam);
+ memory_region_add_subregion(get_system_memory(), base_ecam,
+ &vms->ecam_alias);
+
+ /*
+ * Map the MMIO window from [0x50000000-0x7fff0000] in PCI space into
+ * system address space at [0x50000000-0x7fff0000].
+ */
+ mmio_alias = g_new0(MemoryRegion, 1);
+ mmio_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 1);
+ memory_region_init_alias(mmio_alias, OBJECT(dev), "pcie-mmio",
+ mmio_reg, base_mmio, size_mmio);
+ memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias);
+
+ for (i = 0; i < GPEX_NUM_IRQS; i++) {
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), i,
+ qdev_get_gpio_in(vms->gic, irq + i));
+ gpex_set_irq_num(GPEX_HOST(dev), i, irq + i);
+ }
+
+ pci = PCI_HOST_BRIDGE(dev);
+ vms->bus = pci->bus;
+ g_assert(vms->bus);
+
+ while ((dev = qemu_create_nic_device("virtio-net-pci", true, NULL))) {
+ qdev_realize_and_unref(dev, BUS(vms->bus), &error_fatal);
+ }
+
+ if (defaults_enabled()) {
+ usb_controller = qdev_new(TYPE_QEMU_XHCI);
+ qdev_realize_and_unref(usb_controller, BUS(pci->bus), &error_fatal);
+
+ usb_bus = USB_BUS(object_resolve_type_unambiguous(TYPE_USB_BUS,
+ &error_fatal));
+ usb_create_simple(usb_bus, "usb-kbd");
+ usb_create_simple(usb_bus, "usb-tablet");
+ }
+}
+
+static void vmapple_reset(void *opaque)
+{
+ VMAppleMachineState *vms = opaque;
+ hwaddr base = vms->memmap[VMAPPLE_FIRMWARE].base;
+
+ cpu_set_pc(first_cpu, base);
+}
+
+static void mach_vmapple_init(MachineState *machine)
+{
+ VMAppleMachineState *vms = VMAPPLE_MACHINE(machine);
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
+ const CPUArchIdList *possible_cpus;
+ MemoryRegion *sysmem = get_system_memory();
+ int n;
+ unsigned int smp_cpus = machine->smp.cpus;
+ unsigned int max_cpus = machine->smp.max_cpus;
+
+ vms->memmap = memmap;
+ machine->usb = true;
+
+ possible_cpus = mc->possible_cpu_arch_ids(machine);
+ assert(possible_cpus->len == max_cpus);
+ for (n = 0; n < possible_cpus->len; n++) {
+ Object *cpu;
+ CPUState *cs;
+
+ if (n >= smp_cpus) {
+ break;
+ }
+
+ cpu = object_new(possible_cpus->cpus[n].type);
+ object_property_set_int(cpu, "mp-affinity",
+ possible_cpus->cpus[n].arch_id, &error_fatal);
+
+ cs = CPU(cpu);
+ cs->cpu_index = n;
+
+ numa_cpu_pre_plug(&possible_cpus->cpus[cs->cpu_index], DEVICE(cpu),
+ &error_fatal);
+
+ if (object_property_find(cpu, "has_el3")) {
+ object_property_set_bool(cpu, "has_el3", false, &error_fatal);
+ }
+ if (object_property_find(cpu, "has_el2")) {
+ object_property_set_bool(cpu, "has_el2", false, &error_fatal);
+ }
+ object_property_set_int(cpu, "psci-conduit", QEMU_PSCI_CONDUIT_HVC,
+ &error_fatal);
+
+ /* Secondary CPUs start in PSCI powered-down state */
+ if (n > 0) {
+ object_property_set_bool(cpu, "start-powered-off", true,
+ &error_fatal);
+ }
+
+ object_property_set_link(cpu, "memory", OBJECT(sysmem), &error_abort);
+ qdev_realize(DEVICE(cpu), NULL, &error_fatal);
+ object_unref(cpu);
+ }
+
+ memory_region_add_subregion(sysmem, vms->memmap[VMAPPLE_MEM].base,
+ machine->ram);
+
+ create_gic(vms, sysmem);
+ create_bdif(vms, sysmem);
+ create_pvpanic(vms, sysmem);
+ create_aes(vms, sysmem);
+ create_gfx(vms, sysmem);
+ create_uart(vms, VMAPPLE_UART, sysmem, serial_hd(0));
+ create_rtc(vms);
+ create_pcie(vms);
+
+ create_gpio_devices(vms, VMAPPLE_GPIO, sysmem);
+
+ vmapple_firmware_init(vms, sysmem);
+ create_cfg(vms, sysmem, &error_fatal);
+
+ /* connect powerdown request */
+ vms->powerdown_notifier.notify = vmapple_powerdown_req;
+ qemu_register_powerdown_notifier(&vms->powerdown_notifier);
+
+ vms->bootinfo.ram_size = machine->ram_size;
+ vms->bootinfo.board_id = -1;
+ vms->bootinfo.loader_start = vms->memmap[VMAPPLE_MEM].base;
+ vms->bootinfo.skip_dtb_autoload = true;
+ vms->bootinfo.firmware_loaded = true;
+ arm_load_kernel(ARM_CPU(first_cpu), machine, &vms->bootinfo);
+
+ qemu_register_reset(vmapple_reset, vms);
+}
+
+static CpuInstanceProperties
+vmapple_cpu_index_to_props(MachineState *ms, unsigned cpu_index)
+{
+ MachineClass *mc = MACHINE_GET_CLASS(ms);
+ const CPUArchIdList *possible_cpus = mc->possible_cpu_arch_ids(ms);
+
+ assert(cpu_index < possible_cpus->len);
+ return possible_cpus->cpus[cpu_index].props;
+}
+
+
+static int64_t vmapple_get_default_cpu_node_id(const MachineState *ms, int idx)
+{
+ return idx % ms->numa_state->num_nodes;
+}
+
+static const CPUArchIdList *vmapple_possible_cpu_arch_ids(MachineState *ms)
+{
+ int n;
+ unsigned int max_cpus = ms->smp.max_cpus;
+
+ if (ms->possible_cpus) {
+ assert(ms->possible_cpus->len == max_cpus);
+ return ms->possible_cpus;
+ }
+
+ ms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) +
+ sizeof(CPUArchId) * max_cpus);
+ ms->possible_cpus->len = max_cpus;
+ for (n = 0; n < ms->possible_cpus->len; n++) {
+ ms->possible_cpus->cpus[n].type = ms->cpu_type;
+ ms->possible_cpus->cpus[n].arch_id =
+ arm_build_mp_affinity(n, GICV3_TARGETLIST_BITS);
+ ms->possible_cpus->cpus[n].props.has_thread_id = true;
+ ms->possible_cpus->cpus[n].props.thread_id = n;
+ }
+ return ms->possible_cpus;
+}
+
+static GlobalProperty vmapple_compat_defaults[] = {
+ { TYPE_VIRTIO_PCI, "disable-legacy", "on" },
+ /*
+ * macOS XHCI driver attempts to schedule events onto even rings 1 & 2
+ * even when (as here) there is no MSI(-X) support. Disabling interrupter
+ * mapping in the XHCI controller works around the problem.
+ */
+ { TYPE_XHCI_PCI, "conditional-intr-mapping", "on" },
+};
+
+static void vmapple_machine_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+
+ mc->init = mach_vmapple_init;
+ mc->max_cpus = 32;
+ mc->block_default_type = IF_VIRTIO;
+ mc->no_cdrom = 1;
+ mc->pci_allow_0_address = true;
+ mc->minimum_page_bits = 12;
+ mc->possible_cpu_arch_ids = vmapple_possible_cpu_arch_ids;
+ mc->cpu_index_to_instance_props = vmapple_cpu_index_to_props;
+ mc->default_cpu_type = ARM_CPU_TYPE_NAME("host");
+ mc->get_default_cpu_node_id = vmapple_get_default_cpu_node_id;
+ mc->default_ram_id = "mach-vmapple.ram";
+ mc->desc = "Apple aarch64 Virtual Machine";
+
+ compat_props_add(mc->compat_props, vmapple_compat_defaults,
+ G_N_ELEMENTS(vmapple_compat_defaults));
+}
+
+static void vmapple_instance_init(Object *obj)
+{
+ VMAppleMachineState *vms = VMAPPLE_MACHINE(obj);
+
+ vms->irqmap = irqmap;
+
+ object_property_add_uint64_ptr(obj, "uuid", &vms->uuid,
+ OBJ_PROP_FLAG_READWRITE);
+ object_property_set_description(obj, "uuid", "Machine UUID (SDOM)");
+}
+
+static const TypeInfo vmapple_machine_info = {
+ .name = TYPE_VMAPPLE_MACHINE,
+ .parent = TYPE_MACHINE,
+ .instance_size = sizeof(VMAppleMachineState),
+ .class_init = vmapple_machine_class_init,
+ .instance_init = vmapple_instance_init,
+};
+
+static void machvmapple_machine_init(void)
+{
+ type_register_static(&vmapple_machine_info);
+}
+type_init(machvmapple_machine_init);
+
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH v17 00/11] New vmapple machine type and xhci fixes
2025-01-12 21:00 [PATCH v17 00/11] New vmapple machine type and xhci fixes Phil Dennis-Jordan
` (10 preceding siblings ...)
2025-01-12 21:00 ` [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type Phil Dennis-Jordan
@ 2025-01-13 17:31 ` Philippe Mathieu-Daudé
2025-01-14 13:47 ` Phil Dennis-Jordan
2025-01-15 13:05 ` Michael Tokarev
2025-01-15 15:08 ` Michael S. Tsirkin
13 siblings, 1 reply; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-13 17:31 UTC (permalink / raw)
To: Phil Dennis-Jordan, qemu-devel
Cc: agraf, peter.maydell, pbonzini, mst, stefanha, kwolf, hreitz,
berrange, eduardo, marcel.apfelbaum, marcandre.lureau, eblake,
armbru, qemu-block, qemu-arm
On 12/1/25 22:00, 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.
> 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.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v17 00/11] New vmapple machine type and xhci fixes
2025-01-13 17:31 ` [PATCH v17 00/11] New vmapple machine type and xhci fixes Philippe Mathieu-Daudé
@ 2025-01-14 13:47 ` Phil Dennis-Jordan
0 siblings, 0 replies; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-01-14 13:47 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, agraf, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
eblake, armbru, qemu-block, qemu-arm
[-- Attachment #1: Type: text/plain, Size: 897 bytes --]
On Mon, 13 Jan 2025 at 18:31, Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:
> On 12/1/25 22:00, 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.
>
>
> > 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.
>
Thanks!
It looks like I accidentally dropped Michael's Reviewed-by tag on patch 8:
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
https://patchew.org/QEMU/20241223221645.29911-1-phil@philjordan.eu/#20250108082246-mutt-send-email-mst@kernel.org
Please add if v17 of the patch gets queued.
Phil
[-- Attachment #2: Type: text/html, Size: 1548 bytes --]
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v17 08/11] hw/vmapple/virtio-blk: Add support for apple virtio-blk
2025-01-12 21:00 ` [PATCH v17 08/11] hw/vmapple/virtio-blk: Add support for apple virtio-blk Phil Dennis-Jordan
@ 2025-01-15 12:36 ` Akihiko Odaki
0 siblings, 0 replies; 30+ messages in thread
From: Akihiko Odaki @ 2025-01-15 12:36 UTC (permalink / raw)
To: Phil Dennis-Jordan, qemu-devel
Cc: agraf, peter.maydell, pbonzini, mst, stefanha, kwolf, hreitz,
berrange, eduardo, marcel.apfelbaum, marcandre.lureau, philmd,
eblake, armbru, qemu-block, qemu-arm, Alexander Graf
On 2025/01/13 6:00, Phil Dennis-Jordan wrote:
> From: Alexander Graf <graf@amazon.com>
>
> 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 <graf@amazon.com>
> Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>
> 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
>
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index e0acce89e1..4d27afabf0 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -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;
It seems you broke the indention here while rebasing.
> 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)
> diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
> index a96675beb0..6be44ddb46 100644
> --- a/hw/core/qdev-properties-system.c
> +++ b/hw/core/qdev-properties-system.c
> @@ -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,
> +};
> diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig
> index 8bbeb9a923..bcd1be63e3 100644
> --- a/hw/vmapple/Kconfig
> +++ b/hw/vmapple/Kconfig
> @@ -7,3 +7,6 @@ config VMAPPLE_BDIF
> config VMAPPLE_CFG
> bool
>
> +config VMAPPLE_VIRTIO_BLK
> + bool
> +
> diff --git a/hw/vmapple/meson.build b/hw/vmapple/meson.build
> index 64b78693a3..bf17cf906c 100644
> --- a/hw/vmapple/meson.build
> +++ b/hw/vmapple/meson.build
> @@ -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'))
> diff --git a/hw/vmapple/virtio-blk.c b/hw/vmapple/virtio-blk.c
> new file mode 100644
> index 0000000000..6b434b8842
> --- /dev/null
> +++ b/hw/vmapple/virtio-blk.c
> @@ -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)
> diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h
> index f1a53fea8d..33e2898be9 100644
> --- a/include/hw/pci/pci_ids.h
> +++ b/include/hw/pci/pci_ids.h
> @@ -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
> diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properties-system.h
> index 7ec37f6316..3631e30969 100644
> --- a/include/hw/qdev-properties-system.h
> +++ b/include/hw/qdev-properties-system.h
> @@ -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
> diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
> index 8a16218c40..3d8dee7ec1 100644
> --- a/include/hw/virtio/virtio-blk.h
> +++ b/include/hw/virtio/virtio-blk.h
> @@ -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
> diff --git a/include/hw/vmapple/vmapple.h b/include/hw/vmapple/vmapple.h
> index 3bba59f5ec..9c1ad1bd8c 100644
> --- a/include/hw/vmapple/vmapple.h
> +++ b/include/hw/vmapple/vmapple.h
> @@ -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 */
> diff --git a/qapi/virtio.json b/qapi/virtio.json
> index 2529c2d8b2..d351d2166e 100644
> --- a/qapi/virtio.json
> +++ b/qapi/virtio.json
> @@ -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' ] }
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v17 00/11] New vmapple machine type and xhci fixes
2025-01-12 21:00 [PATCH v17 00/11] New vmapple machine type and xhci fixes Phil Dennis-Jordan
` (11 preceding siblings ...)
2025-01-13 17:31 ` [PATCH v17 00/11] New vmapple machine type and xhci fixes Philippe Mathieu-Daudé
@ 2025-01-15 13:05 ` Michael Tokarev
2025-01-15 13:56 ` Phil Dennis-Jordan
2025-01-15 15:08 ` Michael S. Tsirkin
13 siblings, 1 reply; 30+ messages in thread
From: Michael Tokarev @ 2025-01-15 13:05 UTC (permalink / raw)
To: Phil Dennis-Jordan, qemu-devel
Cc: agraf, peter.maydell, pbonzini, mst, stefanha, kwolf, hreitz,
berrange, eduardo, marcel.apfelbaum, marcandre.lureau, philmd,
eblake, armbru, qemu-block, qemu-arm
13.01.2025 00:00, 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.
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
> 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/20241223221645.29911-1-phil@philjordan.eu/
>
> 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/20241227121336.25838-1-phil@philjordan.eu/
>
> 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/20241227202435.48055-1-philmd@linaro.org/
>
> ---
>
> 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
>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v17 00/11] New vmapple machine type and xhci fixes
2025-01-15 13:05 ` Michael Tokarev
@ 2025-01-15 13:56 ` Phil Dennis-Jordan
0 siblings, 0 replies; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-01-15 13:56 UTC (permalink / raw)
To: Michael Tokarev
Cc: qemu-devel, agraf, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm, Nicholas Piggin
[-- Attachment #1: Type: text/plain, Size: 21632 bytes --]
On Wed, 15 Jan 2025 at 14:05, Michael Tokarev <mjt@tls.msk.ru> wrote:
> 13.01.2025 00:00, 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.
>
> 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?
>
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/20241201160316.96121-1-phil@philjordan.eu/ )
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,
>
> /mjt
>
> > 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/20241223221645.29911-1-phil@philjordan.eu/
> >
> > 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/20241227121336.25838-1-phil@philjordan.eu/
> >
> > 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/20241227202435.48055-1-philmd@linaro.org/
> >
> > ---
> >
> > 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
> >
>
>
[-- Attachment #2: Type: text/html, Size: 25662 bytes --]
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v17 00/11] New vmapple machine type and xhci fixes
2025-01-12 21:00 [PATCH v17 00/11] New vmapple machine type and xhci fixes Phil Dennis-Jordan
` (12 preceding siblings ...)
2025-01-15 13:05 ` Michael Tokarev
@ 2025-01-15 15:08 ` Michael S. Tsirkin
2025-01-15 15:33 ` Phil Dennis-Jordan
13 siblings, 1 reply; 30+ messages in thread
From: Michael S. Tsirkin @ 2025-01-15 15:08 UTC (permalink / raw)
To: Phil Dennis-Jordan
Cc: qemu-devel, agraf, peter.maydell, pbonzini, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm
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/20241223221645.29911-1-phil@philjordan.eu/
>
> 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/20241227121336.25838-1-phil@philjordan.eu/
>
> 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/20241227202435.48055-1-philmd@linaro.org/
just to make sure, who is merging this? Me?
> ---
>
> 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
>
> --
> 2.39.5 (Apple Git-154)
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v17 00/11] New vmapple machine type and xhci fixes
2025-01-15 15:08 ` Michael S. Tsirkin
@ 2025-01-15 15:33 ` Phil Dennis-Jordan
2025-01-15 15:40 ` Michael S. Tsirkin
0 siblings, 1 reply; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-01-15 15:33 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: qemu-devel, agraf, peter.maydell, pbonzini, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm
[-- Attachment #1: Type: text/plain, Size: 19821 bytes --]
On Wed, 15 Jan 2025 at 16:08, Michael S. Tsirkin <mst@redhat.com> 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/20241223221645.29911-1-phil@philjordan.eu/
> >
> > 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/20241227121336.25838-1-phil@philjordan.eu/
> >
> > 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/20241227202435.48055-1-philmd@linaro.org/
>
>
> 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/8554330d-fd9b-4fa5-b37c-161f70b71f7d@linaro.org/
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. :-)
> ---
> >
> > 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
> >
> > --
> > 2.39.5 (Apple Git-154)
>
>
[-- Attachment #2: Type: text/html, Size: 23548 bytes --]
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v17 00/11] New vmapple machine type and xhci fixes
2025-01-15 15:33 ` Phil Dennis-Jordan
@ 2025-01-15 15:40 ` Michael S. Tsirkin
2025-03-03 17:26 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 30+ messages in thread
From: Michael S. Tsirkin @ 2025-01-15 15:40 UTC (permalink / raw)
To: Phil Dennis-Jordan
Cc: qemu-devel, agraf, peter.maydell, pbonzini, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
philmd, eblake, armbru, qemu-block, qemu-arm
On Wed, Jan 15, 2025 at 04:33:45PM +0100, Phil Dennis-Jordan wrote:
>
>
> On Wed, 15 Jan 2025 at 16:08, Michael S. Tsirkin <mst@redhat.com> 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/20241223221645.29911-1-phil@philjordan.eu/
> >
> > 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/20241227121336.25838-1-phil@philjordan.eu/
> >
> > 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/20241227202435.48055-1-philmd@linaro.org/
>
>
> 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/
> 8554330d-fd9b-4fa5-b37c-161f70b71f7d@linaro.org/
>
> 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!
> > ---
> >
> > 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
> >
> > --
> > 2.39.5 (Apple Git-154)
>
>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v17 00/11] New vmapple machine type and xhci fixes
2025-01-15 15:40 ` Michael S. Tsirkin
@ 2025-03-03 17:26 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-03 17:26 UTC (permalink / raw)
To: Michael S. Tsirkin, Phil Dennis-Jordan
Cc: qemu-devel, agraf, peter.maydell, pbonzini, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
eblake, armbru, qemu-block, qemu-arm
On 15/1/25 16:40, Michael S. Tsirkin wrote:
> On Wed, Jan 15, 2025 at 04:33:45PM +0100, Phil Dennis-Jordan wrote:
>>
>>
>> On Wed, 15 Jan 2025 at 16:08, Michael S. Tsirkin <mst@redhat.com> 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:
>>
>> https://lore.kernel.org/qemu-devel/
>> 8554330d-fd9b-4fa5-b37c-161f70b71f7d@linaro.org/
>>
>> 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!
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v17 03/11] hw: Add vmapple subdir
2025-01-12 21:00 ` [PATCH v17 03/11] hw: Add vmapple subdir Phil Dennis-Jordan
@ 2025-03-03 17:52 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-03 17:52 UTC (permalink / raw)
To: Phil Dennis-Jordan, qemu-devel
Cc: agraf, peter.maydell, pbonzini, mst, stefanha, kwolf, hreitz,
berrange, eduardo, marcel.apfelbaum, marcandre.lureau, eblake,
armbru, qemu-block, qemu-arm, Alexander Graf, Akihiko Odaki
On 12/1/25 22:00, Phil Dennis-Jordan wrote:
> From: Alexander Graf <graf@amazon.com>
>
> 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 <graf@amazon.com>
> Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
> 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
> diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig
> new file mode 100644
> index 0000000000..8b13789179
> --- /dev/null
> +++ b/hw/vmapple/Kconfig
> @@ -0,0 +1 @@
> +
> diff --git a/hw/vmapple/meson.build b/hw/vmapple/meson.build
> new file mode 100644
> index 0000000000..e69de29bb2
> diff --git a/hw/vmapple/trace-events b/hw/vmapple/trace-events
> new file mode 100644
> index 0000000000..9ccc579048
> --- /dev/null
> +++ b/hw/vmapple/trace-events
> @@ -0,0 +1,2 @@
> +# See docs/devel/tracing.rst for syntax documentation.
> +
> diff --git a/hw/vmapple/trace.h b/hw/vmapple/trace.h
> new file mode 100644
> index 0000000000..572adbefe0
> --- /dev/null
> +++ b/hw/vmapple/trace.h
> @@ -0,0 +1 @@
> +#include "trace/trace-hw_vmapple.h"
> diff --git a/meson.build b/meson.build
> index d06f59095c..812ef33550 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -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 --
diff --git a/hw/vmapple/trace.h b/hw/vmapple/trace.h
index 572adbefe04..d099d5ecd9e 100644
--- a/hw/vmapple/trace.h
+++ b/hw/vmapple/trace.h
@@ -0,0 +1 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig
index 8b137891791..315c06b689c 100644
--- a/hw/vmapple/Kconfig
+++ b/hw/vmapple/Kconfig
@@ -1 +1 @@
-
+# SPDX-License-Identifier: GPL-2.0-or-later
diff --git a/hw/vmapple/meson.build b/hw/vmapple/meson.build
index e69de29bb2d..315c06b689c 100644
--- a/hw/vmapple/meson.build
+++ b/hw/vmapple/meson.build
@@ -0,0 +1 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
diff --git a/hw/vmapple/trace-events b/hw/vmapple/trace-events
index 9ccc5790487..21125794121 100644
--- a/hw/vmapple/trace-events
+++ b/hw/vmapple/trace-events
@@ -2 +2 @@
-
+# SPDX-License-Identifier: GPL-2.0-or-later
---
?
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH v17 04/11] hw/misc/pvpanic: Add MMIO interface
2025-01-12 21:00 ` [PATCH v17 04/11] hw/misc/pvpanic: Add MMIO interface Phil Dennis-Jordan
@ 2025-03-03 17:54 ` Philippe Mathieu-Daudé
2025-03-03 20:30 ` Phil Dennis-Jordan
0 siblings, 1 reply; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-03 17:54 UTC (permalink / raw)
To: Phil Dennis-Jordan, qemu-devel
Cc: agraf, peter.maydell, pbonzini, mst, stefanha, kwolf, hreitz,
berrange, eduardo, marcel.apfelbaum, marcandre.lureau, eblake,
armbru, qemu-block, qemu-arm, Alexander Graf, Akihiko Odaki
On 12/1/25 22:00, Phil Dennis-Jordan wrote:
> From: Alexander Graf <graf@amazon.com>
>
> 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 <graf@amazon.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
>
> 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 +++++++++++++++++++++++++++++++++++++++
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.
> include/hw/misc/pvpanic.h | 1 +
> 4 files changed, 66 insertions(+)
> create mode 100644 hw/misc/pvpanic-mmio.c
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type
2025-01-12 21:00 ` [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type Phil Dennis-Jordan
@ 2025-03-03 18:20 ` Philippe Mathieu-Daudé
2025-03-03 19:23 ` Philippe Mathieu-Daudé
2025-03-03 20:36 ` Phil Dennis-Jordan
2025-03-03 21:51 ` Philippe Mathieu-Daudé
1 sibling, 2 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-03 18:20 UTC (permalink / raw)
To: Phil Dennis-Jordan, qemu-devel
Cc: agraf, peter.maydell, pbonzini, mst, stefanha, kwolf, hreitz,
berrange, eduardo, marcel.apfelbaum, marcandre.lureau, eblake,
armbru, qemu-block, qemu-arm, Alexander Graf, Akihiko Odaki
On 12/1/25 22:00, Phil Dennis-Jordan wrote:
> From: Alexander Graf <graf@amazon.com>
>
> 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 <graf@amazon.com>
> Co-authored-by: Phil Dennis-Jordan <phil@philjordan.eu>
> Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
> 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
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index e220744abf..3a3d9e19f4 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -2791,6 +2791,7 @@ M: Phil Dennis-Jordan <phil@philjordan.eu>
> S: Maintained
> F: hw/vmapple/*
> F: include/hw/vmapple/*
> +F: docs/system/arm/vmapple.rst
>
> Subsystems
> ----------
> diff --git a/contrib/vmapple/uuid.sh b/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 --git a/docs/system/arm/vmapple.rst b/docs/system/arm/vmapple.rst
> new file mode 100644
> index 0000000000..5090a8997c
> --- /dev/null
> +++ b/docs/system/arm/vmapple.rst
> @@ -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 --
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
---
?
> +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
> +
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type
2025-03-03 18:20 ` Philippe Mathieu-Daudé
@ 2025-03-03 19:23 ` Philippe Mathieu-Daudé
2025-03-03 20:36 ` Phil Dennis-Jordan
1 sibling, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-03 19:23 UTC (permalink / raw)
To: Phil Dennis-Jordan, qemu-devel
Cc: agraf, peter.maydell, pbonzini, mst, stefanha, kwolf, hreitz,
berrange, eduardo, marcel.apfelbaum, marcandre.lureau, eblake,
armbru, qemu-block, qemu-arm, Alexander Graf, Akihiko Odaki
On 3/3/25 19:20, Philippe Mathieu-Daudé wrote:
> On 12/1/25 22:00, Phil Dennis-Jordan wrote:
>> From: Alexander Graf <graf@amazon.com>
>>
>> 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 <graf@amazon.com>
>> Co-authored-by: Phil Dennis-Jordan <phil@philjordan.eu>
>> Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
>> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>> ---
>
>
>> 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
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index e220744abf..3a3d9e19f4 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -2791,6 +2791,7 @@ M: Phil Dennis-Jordan <phil@philjordan.eu>
>> S: Maintained
>> F: hw/vmapple/*
>> F: include/hw/vmapple/*
>> +F: docs/system/arm/vmapple.rst
>> Subsystems
>> ----------
>> diff --git a/contrib/vmapple/uuid.sh b/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 --git a/docs/system/arm/vmapple.rst b/docs/system/arm/vmapple.rst
>> new file mode 100644
>> index 0000000000..5090a8997c
>> --- /dev/null
>> +++ b/docs/system/arm/vmapple.rst
>> @@ -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 --
> 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
> ---
>
> ?
>
>> +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.
I'm also squashing here:
-- >8 --
diff --git a/docs/system/arm/vmapple.rst b/docs/system/arm/vmapple.rst
index c5b1bcf45e..35c329ea5a 100644
--- a/docs/system/arm/vmapple.rst
+++ b/docs/system/arm/vmapple.rst
@@ -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.
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH v17 04/11] hw/misc/pvpanic: Add MMIO interface
2025-03-03 17:54 ` Philippe Mathieu-Daudé
@ 2025-03-03 20:30 ` Phil Dennis-Jordan
0 siblings, 0 replies; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-03-03 20:30 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, agraf, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
eblake, armbru, qemu-block, qemu-arm, Alexander Graf,
Akihiko Odaki
[-- Attachment #1: Type: text/plain, Size: 1584 bytes --]
On Mon, 3 Mar 2025 at 18:54, Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:
> On 12/1/25 22:00, Phil Dennis-Jordan wrote:
> > From: Alexander Graf <graf@amazon.com>
> >
> > 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 <graf@amazon.com>
> > Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> > Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> > Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
> > Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> > Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> > ---
> >
> > 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 +++++++++++++++++++++++++++++++++++++++
>
> Missing MAINTAINERS update, who is going to maintain this file?
Good spot!
> 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!
> > include/hw/misc/pvpanic.h | 1 +
> > 4 files changed, 66 insertions(+)
> > create mode 100644 hw/misc/pvpanic-mmio.c
>
>
[-- Attachment #2: Type: text/html, Size: 2895 bytes --]
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type
2025-03-03 18:20 ` Philippe Mathieu-Daudé
2025-03-03 19:23 ` Philippe Mathieu-Daudé
@ 2025-03-03 20:36 ` Phil Dennis-Jordan
2025-03-03 22:11 ` Philippe Mathieu-Daudé
1 sibling, 1 reply; 30+ messages in thread
From: Phil Dennis-Jordan @ 2025-03-03 20:36 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, agraf, peter.maydell, pbonzini, mst, stefanha, kwolf,
hreitz, berrange, eduardo, marcel.apfelbaum, marcandre.lureau,
eblake, armbru, qemu-block, qemu-arm, Alexander Graf,
Akihiko Odaki
[-- Attachment #1: Type: text/plain, Size: 7660 bytes --]
On Mon, 3 Mar 2025 at 19:20, Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:
> On 12/1/25 22:00, Phil Dennis-Jordan wrote:
> > From: Alexander Graf <graf@amazon.com>
> >
> > 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 <graf@amazon.com>
> > Co-authored-by: Phil Dennis-Jordan <phil@philjordan.eu>
> > Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
> > Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> > ---
>
>
> > 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
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index e220744abf..3a3d9e19f4 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -2791,6 +2791,7 @@ M: Phil Dennis-Jordan <phil@philjordan.eu>
> > S: Maintained
> > F: hw/vmapple/*
> > F: include/hw/vmapple/*
> > +F: docs/system/arm/vmapple.rst
> >
> > Subsystems
> > ----------
> > diff --git a/contrib/vmapple/uuid.sh b/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 --git a/docs/system/arm/vmapple.rst b/docs/system/arm/vmapple.rst
> > new file mode 100644
> > index 0000000000..5090a8997c
> > --- /dev/null
> > +++ b/docs/system/arm/vmapple.rst
> > @@ -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:
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 --
> 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
> ---
>
> ?
>
> > +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
> > +
>
[-- Attachment #2: Type: text/html, Size: 9732 bytes --]
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type
2025-01-12 21:00 ` [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type Phil Dennis-Jordan
2025-03-03 18:20 ` Philippe Mathieu-Daudé
@ 2025-03-03 21:51 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-03 21:51 UTC (permalink / raw)
To: Phil Dennis-Jordan, qemu-devel
Cc: agraf, peter.maydell, pbonzini, mst, stefanha, kwolf, hreitz,
berrange, eduardo, marcel.apfelbaum, marcandre.lureau, eblake,
armbru, qemu-block, qemu-arm, Alexander Graf, Akihiko Odaki
On 12/1/25 22:00, Phil Dennis-Jordan wrote:
> From: Alexander Graf <graf@amazon.com>
>
> 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 <graf@amazon.com>
> Co-authored-by: Phil Dennis-Jordan <phil@philjordan.eu>
> Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
> 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
> diff --git a/hw/vmapple/vmapple.c b/hw/vmapple/vmapple.c
> new file mode 100644
> index 0000000000..ec0896dd32
> --- /dev/null
> +++ b/hw/vmapple/vmapple.c
> @@ -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"
> +#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/").
> +#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"
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type
2025-03-03 20:36 ` Phil Dennis-Jordan
@ 2025-03-03 22:11 ` Philippe Mathieu-Daudé
2025-03-05 1:20 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-03 22:11 UTC (permalink / raw)
To: Phil Dennis-Jordan, peter.maydell, berrange, pbonzini, John Snow,
Kashyap Chamarthy
Cc: qemu-devel, agraf, mst, stefanha, kwolf, hreitz, eduardo,
marcel.apfelbaum, marcandre.lureau, eblake, armbru, qemu-block,
qemu-arm, Alexander Graf, Akihiko Odaki
On 3/3/25 21:36, Phil Dennis-Jordan wrote:
>
>
> On Mon, 3 Mar 2025 at 19:20, Philippe Mathieu-Daudé <philmd@linaro.org
> <mailto:philmd@linaro.org>> wrote:
>
> On 12/1/25 22:00, Phil Dennis-Jordan wrote:
> > From: Alexander Graf <graf@amazon.com <mailto:graf@amazon.com>>
> >
> > 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 <graf@amazon.com
> <mailto:graf@amazon.com>>
> > Co-authored-by: Phil Dennis-Jordan <phil@philjordan.eu
> <mailto:phil@philjordan.eu>>
> > Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu
> <mailto:phil@philjordan.eu>>
> > Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com
> <mailto:akihiko.odaki@daynix.com>>
> > ---
>
>
> > 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
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index e220744abf..3a3d9e19f4 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -2791,6 +2791,7 @@ M: Phil Dennis-Jordan <phil@philjordan.eu
> <mailto:phil@philjordan.eu>>
> > S: Maintained
> > F: hw/vmapple/*
> > F: include/hw/vmapple/*
> > +F: docs/system/arm/vmapple.rst
> >
> > Subsystems
> > ----------
> > diff --git a/contrib/vmapple/uuid.sh b/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 --git a/docs/system/arm/vmapple.rst b/docs/system/arm/
> vmapple.rst
> > new file mode 100644
> > index 0000000000..5090a8997c
> > --- /dev/null
> > +++ b/docs/system/arm/vmapple.rst
> > @@ -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:
>
>
> 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.
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.
> 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
> ---
>
> ?
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type
2025-03-03 22:11 ` Philippe Mathieu-Daudé
@ 2025-03-05 1:20 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 1:20 UTC (permalink / raw)
To: Phil Dennis-Jordan, peter.maydell, berrange, pbonzini, John Snow,
Kashyap Chamarthy
Cc: qemu-devel, agraf, mst, stefanha, kwolf, hreitz, eduardo,
marcel.apfelbaum, marcandre.lureau, eblake, armbru, qemu-block,
qemu-arm, Alexander Graf, Akihiko Odaki
On 3/3/25 23:11, Philippe Mathieu-Daudé wrote:
> On 3/3/25 21:36, Phil Dennis-Jordan wrote:
>>
>>
>> On Mon, 3 Mar 2025 at 19:20, Philippe Mathieu-Daudé <philmd@linaro.org
>> <mailto:philmd@linaro.org>> wrote:
>>
>> On 12/1/25 22:00, Phil Dennis-Jordan wrote:
>> > From: Alexander Graf <graf@amazon.com <mailto:graf@amazon.com>>
>> > 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(+)
>> 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:
>>
>>
>> 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.
>
> 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.
FTR I'm going to send a PR including this series with the previously
$prefer = "GPL-2.0-or-later" snippets squashed.
Regards,
Phil.
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2025-03-05 1:21 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-12 21:00 [PATCH v17 00/11] New vmapple machine type and xhci fixes Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 01/11] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 02/11] hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 03/11] hw: Add vmapple subdir Phil Dennis-Jordan
2025-03-03 17:52 ` Philippe Mathieu-Daudé
2025-01-12 21:00 ` [PATCH v17 04/11] hw/misc/pvpanic: Add MMIO interface Phil Dennis-Jordan
2025-03-03 17:54 ` Philippe Mathieu-Daudé
2025-03-03 20:30 ` Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 05/11] hw/vmapple/aes: Introduce aes engine Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 06/11] hw/vmapple/bdif: Introduce vmapple backdoor interface Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 07/11] hw/vmapple/cfg: Introduce vmapple cfg region Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 08/11] hw/vmapple/virtio-blk: Add support for apple virtio-blk Phil Dennis-Jordan
2025-01-15 12:36 ` Akihiko Odaki
2025-01-12 21:00 ` [PATCH v17 09/11] hw/usb/hcd-xhci-pci: Adds property for disabling mapping in IRQ mode Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 10/11] hw/intc: Remove TCG dependency on ARM_GICV3 Phil Dennis-Jordan
2025-01-12 21:00 ` [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type Phil Dennis-Jordan
2025-03-03 18:20 ` Philippe Mathieu-Daudé
2025-03-03 19:23 ` Philippe Mathieu-Daudé
2025-03-03 20:36 ` Phil Dennis-Jordan
2025-03-03 22:11 ` Philippe Mathieu-Daudé
2025-03-05 1:20 ` Philippe Mathieu-Daudé
2025-03-03 21:51 ` Philippe Mathieu-Daudé
2025-01-13 17:31 ` [PATCH v17 00/11] New vmapple machine type and xhci fixes Philippe Mathieu-Daudé
2025-01-14 13:47 ` Phil Dennis-Jordan
2025-01-15 13:05 ` Michael Tokarev
2025-01-15 13:56 ` Phil Dennis-Jordan
2025-01-15 15:08 ` Michael S. Tsirkin
2025-01-15 15:33 ` Phil Dennis-Jordan
2025-01-15 15:40 ` Michael S. Tsirkin
2025-03-03 17:26 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).