hw/display/apple-gfx: Introduce ParavirtualizedGraphics.Framework support
authorPhil Dennis-Jordan <phil@philjordan.eu>
Wed, 14 Jun 2023 22:57:33 +0000 (22:57 +0000)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 31 Dec 2024 20:21:34 +0000 (21:21 +0100)
commit2352159c97a1fd245e998daafa08fcaaf57d4fa8
tree3a90f7cfba8d012d45a3573e1836b058d02175a6
parentf5ab12caba4f1656479c1feb5248beac1c833243
hw/display/apple-gfx: Introduce ParavirtualizedGraphics.Framework support

MacOS provides a framework (library) that allows any vmm to implement a
paravirtualized 3d graphics passthrough to the host metal stack called
ParavirtualizedGraphics.Framework (PVG). The library abstracts away
almost every aspect of the paravirtualized device model and only provides
and receives callbacks on MMIO access as well as to share memory address
space between the VM and PVG.

This patch implements a QEMU device that drives PVG for the VMApple
variant of it.

Signed-off-by: Alexander Graf <graf@amazon.com>
Co-authored-by: Alexander Graf <graf@amazon.com>
Subsequent changes:

 * Cherry-pick/rebase conflict fixes, API use updates.
 * Moved from hw/vmapple/ (useful outside that machine type)
 * Overhaul of threading model, many thread safety improvements.
 * Asynchronous rendering.
 * Memory and object lifetime fixes.
 * Refactoring to split generic and (vmapple) MMIO variant specific
   code.

Implementation wise, most of the complexity lies in the differing threading
models of ParavirtualizedGraphics.framework, which uses libdispatch and
internal locks, versus QEMU, which heavily uses the BQL, especially during
memory-mapped device I/O. Great care has therefore been taken to prevent
deadlocks by never calling into PVG methods while holding the BQL, and
similarly never acquiring the BQL in a callback from PVG. Different strategies
have been used (libdispatch, blocking and non-blocking BHs, RCU, etc.)
depending on the specific requirements at each framework entry and exit point.

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>
Message-ID: <20241223221645.29911-3-phil@philjordan.eu>
[PMD: Re-ordered imported headers, style fixups]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
hw/display/Kconfig
hw/display/apple-gfx-mmio.m [new file with mode: 0644]
hw/display/apple-gfx.h [new file with mode: 0644]
hw/display/apple-gfx.m [new file with mode: 0644]
hw/display/meson.build
hw/display/trace-events
meson.build