Message ID | 20240717110326.45230-1-phil@philjordan.eu (mailing list archive) |
---|---|
Headers | show |
Series | hw/display/apple-gfx: New macOS PV Graphics device | expand |
On 2024/07/17 20:03, Phil Dennis-Jordan wrote: > This sequence of patches integrates the paravirtualised graphics device > implemented by macOS's ParavirtualizedGraphics.Framework into Qemu. > Combined with the guest drivers which ship with macOS versions 11 and up, > this allows the guest OS to use the host's GPU for hardware accelerated > 3D graphics, GPGPU compute (both using the 'Metal' graphics API), and > window compositing. > > Some background: > ---------------- > > The device exposed by the ParavirtualizedGraphics.Framework's (henceforth > PVG) public API consists of a PCI device with a single memory-mapped BAR; > the VMM is expected to pass reads and writes through to the framework, and > to forward interrupts emenating from it to the guest VM. > > The bulk of data exchange between host and guest occurs via shared memory, > however. For this purpose, PVG makes callbacks to VMM code for allocating, > mapping, unmapping, and deallocating "task" memory ranges. Each task > represents a contiguous host virtual address range, and PVG expects the > VMM to map specific guest system memory ranges to these host addresses via > subsequent map callbacks. Multiple tasks can exist at a time, each with > many mappings. > > Data is exchanged via an undocumented, Apple-proprietary protocol. The > PVG API only acts as a facilitator for establishing the communication > mechanism. This is perhaps not ideal, and among other things means it > only works on macOS hosts, but it's the only serious option we've got for > good performance and quality graphics with macOS guests at this time. > > The first iterations of this PVG integration into Qemu were developed > by Alexander Graf as part of his "vmapple" machine patch series for > supporting aarch64 macOS guests, and posted to qemu-devel in June and > August 2023: > > https://lore.kernel.org/all/20230830161425.91946-1-graf@amazon.com/T/ > > This integration mimics the "vmapple"/"apple-gfx" variant of the PVG device > used by Apple's own VMM, Virtualization.framework. This variant does not use > PCI but acts as a direct MMIO system device; there are two MMIO ranges, one > behaving identically to the PCI BAR, while the other's functionality is > exposed by private APIs in the PVG framework. It is only available on aarch64 > macOS hosts. > > I had prior to this simultaneously and independently developed my own PVG > integration for Qemu using the public PCI device APIs, with x86-64 and > corresponding macOS guests and hosts as the target. After some months of > use in production, I was slowly reviewing the code and readying it for > upstreaming around the time Alexander posted his vmapple patches. > > I ended up reviewing the vmapple PVG code in detail; I identified a number > of issues with it (mainly thanks to my prior trial-and-error working with > the framework) but overall I thought it a better basis for refinement > than my own version: > > - It implemented the vmapple variant of the device. I thought it better to > port the part I understood well (PCI variant) to this than trying to port > the part I didn't understand well (MMIO vmapple variant) to my own code. > - The code was already tidier than my own. > > It also became clear in out-of-band communication that Alexander would > probably not end up having the time to see the patch through to inclusion, > and was happy for me to start making changes and to integrate my PCI code. I think you also need to take over the base vmapple change because PVG cannot be tested without it; Only macOS can use PVG, and macOS requires vmapple in my understanding. Regards, Akihiko Odaki
On Sat 20. Jul 2024 at 16:42, Akihiko Odaki <akihiko.odaki@daynix.com> wrote: > > > It also became clear in out-of-band communication that Alexander would > > probably not end up having the time to see the patch through to > inclusion, > > and was happy for me to start making changes and to integrate my PCI > code. > > I think you also need to take over the base vmapple change because PVG > cannot be tested without it; Only macOS can use PVG, and macOS requires > vmapple in my understanding. The PCI device variant works fine with x86-64 macOS as the guest system. (Or technically any UEFI based guest as the bootrom comes with a UEFI frame buffer driver; it just won’t have any acceleration features unless you boot macOS.) If preferable I can leave out the vmapple/MMIO device variant (the -vmapple.m file) until the rest of the vmapple machine type modifications are ready. There still appears to be some kind of interrupt delivery issue with some devices on vmapple, so USB HID events are very slow. Or I can submit it as is if that’s not a dealbreaker. (How do I handle Alex’ unmodified patches though, as git send-email tries to send them from the patch author’s email address, which means the email rapidly gets shot down by DKIM mismatch or whatever?) Thanks, Phil
On 2024/07/21 0:16, Phil Dennis-Jordan wrote: > > > On Sat 20. Jul 2024 at 16:42, Akihiko Odaki <akihiko.odaki@daynix.com > <mailto:akihiko.odaki@daynix.com>> wrote: > > > > It also became clear in out-of-band communication that Alexander > would > > probably not end up having the time to see the patch through to > inclusion, > > and was happy for me to start making changes and to integrate my > PCI code. > > I think you also need to take over the base vmapple change because PVG > cannot be tested without it; Only macOS can use PVG, and macOS requires > vmapple in my understanding. > > > The PCI device variant works fine with x86-64 macOS as the guest system. > (Or technically any UEFI based guest as the bootrom comes with a UEFI > frame buffer driver; it just won’t have any acceleration features unless > you boot macOS.) I tried apple-gfx-pci with AArch64 and x86-64 EDK firmware on M2 MacBook Air, but it didn't work. I guess the bootrom does not work with Apple Silicon. > > If preferable I can leave out the vmapple/MMIO device variant (the > -vmapple.m file) until the rest of the vmapple machine type > modifications are ready. There still appears to be some kind of > interrupt delivery issue with some devices on vmapple, so USB HID events > are very slow. Or I can submit it as is if that’s not a dealbreaker. The vmapple variant should be omitted for now. It is fine for me to submit the vmapple variant with the other vmapple changes as long as that behavior is documented. > (How do I handle Alex’ unmodified patches though, as git send-email > tries to send them from the patch author’s email address, which means > the email rapidly gets shot down by DKIM mismatch or whatever?) I think you can set sendemail.from configuration or specify --from option. Regards, Akihiko Odaki