... | ... | ||
---|---|---|---|
31 | hosts only because ParavirtualizedGraphics.framework is a black box | 31 | hosts only because ParavirtualizedGraphics.framework is a black box |
32 | implementing most of the logic behind the apple-gfx device.) | 32 | implementing most of the logic behind the apple-gfx device.) |
33 | * PCI devices use legacy IRQs, not MSI/MSI-X. As far as I can tell, | 33 | * PCI devices use legacy IRQs, not MSI/MSI-X. As far as I can tell, |
34 | we'd need to include the GICv3 ITS, but it's unclear to me what | 34 | we'd need to include the GICv3 ITS, but it's unclear to me what |
35 | exactly needs wiring up. | 35 | exactly needs wiring up. |
36 | * Due to lack of MSI(-X), event delivery from USB devices to the guest | 36 | * Due to a quirk (bug?) in the macOS XHCI driver when MSI-X is not |
37 | macOS isn't working correctly. My current conclusion is that the | 37 | available, correct functioning of the USB controller (and thus |
38 | OS's XHCI driver simply was never designed to work with legacy IRQs. | 38 | keyboard/tablet) requires a small workaround in the XHCI controller |
39 | The upshot is that keyboard and mouse/tablet input is very laggy. | 39 | device. This is part of another patch series: |
40 | The solution would be to implement MSI(-X) support or figure out how | 40 | https://patchew.org/QEMU/20241208191646.64857-1-phil@philjordan.eu/ |
41 | to make hcd-xhci-sysbus work with the macOS guest, if at all possible. | ||
42 | (EHCI and UHCI/OHCI controllers are not an option as the VMAPPLE | ||
43 | guest kernel does not include drivers for these.) | ||
44 | * The guest OS must first be provisioned using Virtualization.framework; | 41 | * The guest OS must first be provisioned using Virtualization.framework; |
45 | the disk images can subsequently be used in Qemu. (See docs.) | 42 | the disk images can subsequently be used in Qemu. (See docs.) |
46 | 43 | ||
47 | The apple-gfx device can be used independently from the vmapple machine | 44 | The apple-gfx device can be used independently from the vmapple machine |
48 | type, at least in the PCI variant. It mainly targets x86-64 macOS guests | 45 | type, at least in the PCI variant. It mainly targets x86-64 macOS guests |
... | ... | ||
192 | * 16/16 (NEW/RFC vmapple/virtio-blk): Proposed change to replace type hierarchy | 189 | * 16/16 (NEW/RFC vmapple/virtio-blk): Proposed change to replace type hierarchy |
193 | with a variant property. This seems cleaner and less confusing than the | 190 | with a variant property. This seems cleaner and less confusing than the |
194 | original approach to me, but I'm not sure if it warrants creation of a new | 191 | original approach to me, but I'm not sure if it warrants creation of a new |
195 | QAPI enum and property type definition. | 192 | QAPI enum and property type definition. |
196 | 193 | ||
194 | v9 -> v10: | ||
195 | |||
196 | * 01/15 (ui & main loop): Added comments to qemu_main declaration and GTK. | ||
197 | * 02/15 (apple-gfx): Reworked the way frame rendering code is threaded to use | ||
198 | BHs for sections requiring BQL. | ||
199 | * 02/15 (apple-gfx): Fixed ./configure error on non-macOS platforms. | ||
200 | * 10/15 (vmapple/aes): Code style and comment improvements. | ||
201 | * 12/15 (vmapple/cfg): Slightly tidier error reporting for overlong property | ||
202 | values. | ||
203 | * 13/15 (vmapple/virtio-blk): Folded v9 patch 16/16 into this one, changing | ||
204 | the device type design to provide a single device type with a variant | ||
205 | property instead of 2 different subtypes for aux and root volumes. | ||
206 | * 15/15 (vmapple machine type): Documentation fixup for changed virtio-blk | ||
207 | device type; small improvements to shell commands in documentation; | ||
208 | improved propagation of errors during cfg device instantiation. | ||
209 | |||
210 | v10 -> v11: | ||
211 | |||
212 | * 01/15 (ui & main loop): Simplified main.c, better comments & commit message | ||
213 | * 02/15 (apple-gfx): Give each PV display instance a unique serial number. | ||
214 | * 02 & 03/15 (apple-gfx, -pci): Formatting/style tweaks | ||
215 | * 15/15 (vmapple machine type): Improvements to shell code in docs | ||
216 | |||
217 | v11 -> v12: | ||
218 | |||
219 | * 01/15 (ui & main loop): More precise wording of code comments. | ||
220 | * 02/15 (apple-gfx): Fixed memory management regressions introduced in v10; | ||
221 | improved error handling; various more conmetic code adjustments | ||
222 | * 09/15 (GPEX): Fixed uses of deleted GPEX_NUM_IRQS constant that have been | ||
223 | added to QEMU since this patch was originally written. | ||
224 | |||
225 | v12 -> v13 | ||
226 | |||
227 | * 15/15 (vmapple machine type): Bumped the machine type version from 9.2 | ||
228 | to 10.0. | ||
229 | * All patches in the series now have been positively reviewed and received | ||
230 | corresponding reviewed-by tags. | ||
231 | |||
197 | Alexander Graf (9): | 232 | Alexander Graf (9): |
198 | hw: Add vmapple subdir | 233 | hw: Add vmapple subdir |
199 | hw/misc/pvpanic: Add MMIO interface | 234 | hw/misc/pvpanic: Add MMIO interface |
200 | hvf: arm: Ignore writes to CNTP_CTL_EL0 | 235 | hvf: arm: Ignore writes to CNTP_CTL_EL0 |
201 | gpex: Allow more than 4 legacy IRQs | 236 | gpex: Allow more than 4 legacy IRQs |
202 | hw/vmapple/aes: Introduce aes engine | 237 | hw/vmapple/aes: Introduce aes engine |
203 | hw/vmapple/bdif: Introduce vmapple backdoor interface | 238 | hw/vmapple/bdif: Introduce vmapple backdoor interface |
204 | hw/vmapple/cfg: Introduce vmapple cfg region | 239 | hw/vmapple/cfg: Introduce vmapple cfg region |
205 | hw/vmapple/virtio-blk: Add support for apple virtio-blk | 240 | hw/vmapple/virtio-blk: Add support for apple virtio-blk |
206 | hw/vmapple/vmapple: Add vmapple machine type | 241 | hw/vmapple/vmapple: Add vmapple machine type |
207 | 242 | ||
208 | Phil Dennis-Jordan (7): | 243 | Phil Dennis-Jordan (6): |
209 | ui & main loop: Redesign of system-specific main thread event handling | 244 | ui & main loop: Redesign of system-specific main thread event handling |
210 | hw/display/apple-gfx: Introduce ParavirtualizedGraphics.Framework | 245 | hw/display/apple-gfx: Introduce ParavirtualizedGraphics.Framework |
211 | support | 246 | support |
212 | hw/display/apple-gfx: Adds PCI implementation | 247 | hw/display/apple-gfx: Adds PCI implementation |
213 | hw/display/apple-gfx: Adds configurable mode list | 248 | hw/display/apple-gfx: Adds configurable mode list |
214 | MAINTAINERS: Add myself as maintainer for apple-gfx, reviewer for HVF | 249 | MAINTAINERS: Add myself as maintainer for apple-gfx, reviewer for HVF |
215 | hw/block/virtio-blk: Replaces request free function with g_free | 250 | hw/block/virtio-blk: Replaces request free function with g_free |
216 | hw/vmapple/virtio-blk: Replace variant types with property on base | ||
217 | 251 | ||
218 | MAINTAINERS | 15 + | 252 | MAINTAINERS | 15 + |
219 | contrib/vmapple/uuid.sh | 9 + | 253 | contrib/vmapple/uuid.sh | 9 + |
220 | docs/system/arm/vmapple.rst | 63 ++ | 254 | docs/system/arm/vmapple.rst | 63 ++ |
221 | docs/system/target-arm.rst | 1 + | 255 | docs/system/target-arm.rst | 1 + |
222 | hw/Kconfig | 1 + | 256 | hw/Kconfig | 1 + |
223 | hw/arm/sbsa-ref.c | 2 +- | 257 | hw/arm/sbsa-ref.c | 2 +- |
224 | hw/arm/virt.c | 2 +- | 258 | hw/arm/virt.c | 2 +- |
225 | hw/block/virtio-blk.c | 58 +- | 259 | hw/block/virtio-blk.c | 58 +- |
226 | hw/core/qdev-properties-system.c | 8 + | 260 | hw/core/qdev-properties-system.c | 8 + |
227 | hw/display/Kconfig | 13 + | 261 | hw/display/Kconfig | 13 + |
228 | hw/display/apple-gfx-mmio.m | 289 ++++++++++ | 262 | hw/display/apple-gfx-mmio.m | 289 +++++++++ |
229 | hw/display/apple-gfx-pci.m | 157 +++++ | 263 | hw/display/apple-gfx-pci.m | 157 +++++ |
230 | hw/display/apple-gfx.h | 76 +++ | 264 | hw/display/apple-gfx.h | 77 +++ |
231 | hw/display/apple-gfx.m | 861 ++++++++++++++++++++++++++++ | 265 | hw/display/apple-gfx.m | 880 ++++++++++++++++++++++++++++ |
232 | hw/display/meson.build | 5 + | 266 | hw/display/meson.build | 7 + |
233 | hw/display/trace-events | 30 + | 267 | hw/display/trace-events | 30 + |
234 | hw/i386/microvm.c | 2 +- | 268 | hw/i386/microvm.c | 2 +- |
235 | hw/loongarch/virt.c | 2 +- | 269 | hw/loongarch/virt.c | 12 +- |
236 | hw/meson.build | 1 + | 270 | hw/meson.build | 1 + |
237 | hw/mips/loongson3_virt.c | 2 +- | 271 | hw/mips/loongson3_virt.c | 2 +- |
238 | hw/misc/Kconfig | 4 + | 272 | hw/misc/Kconfig | 4 + |
239 | hw/misc/meson.build | 1 + | 273 | hw/misc/meson.build | 1 + |
240 | hw/misc/pvpanic-mmio.c | 61 ++ | 274 | hw/misc/pvpanic-mmio.c | 61 ++ |
241 | hw/openrisc/virt.c | 12 +- | 275 | hw/openrisc/virt.c | 12 +- |
242 | hw/pci-host/gpex.c | 43 +- | 276 | hw/pci-host/gpex.c | 43 +- |
243 | hw/riscv/virt.c | 12 +- | 277 | hw/riscv/virt.c | 12 +- |
244 | hw/vmapple/Kconfig | 32 ++ | 278 | hw/vmapple/Kconfig | 32 + |
245 | hw/vmapple/aes.c | 582 +++++++++++++++++++ | 279 | hw/vmapple/aes.c | 581 ++++++++++++++++++ |
246 | hw/vmapple/bdif.c | 275 +++++++++ | 280 | hw/vmapple/bdif.c | 275 +++++++++ |
247 | hw/vmapple/cfg.c | 196 +++++++ | 281 | hw/vmapple/cfg.c | 196 +++++++ |
248 | hw/vmapple/meson.build | 5 + | 282 | hw/vmapple/meson.build | 5 + |
249 | hw/vmapple/trace-events | 21 + | 283 | hw/vmapple/trace-events | 21 + |
250 | hw/vmapple/trace.h | 1 + | 284 | hw/vmapple/trace.h | 1 + |
251 | hw/vmapple/virtio-blk.c | 201 +++++++ | 285 | hw/vmapple/virtio-blk.c | 205 +++++++ |
252 | hw/vmapple/vmapple.c | 639 +++++++++++++++++++++ | 286 | hw/vmapple/vmapple.c | 646 ++++++++++++++++++++ |
287 | hw/xen/xen-pvh-common.c | 2 +- | ||
253 | hw/xtensa/virt.c | 2 +- | 288 | hw/xtensa/virt.c | 2 +- |
254 | include/hw/misc/pvpanic.h | 1 + | 289 | include/hw/misc/pvpanic.h | 1 + |
255 | include/hw/pci-host/gpex.h | 7 +- | 290 | include/hw/pci-host/gpex.h | 7 +- |
256 | include/hw/pci/pci_ids.h | 1 + | 291 | include/hw/pci/pci_ids.h | 1 + |
257 | include/hw/qdev-properties-system.h | 6 + | 292 | include/hw/qdev-properties-system.h | 5 + |
258 | include/hw/virtio/virtio-blk.h | 11 +- | 293 | include/hw/virtio/virtio-blk.h | 11 +- |
259 | include/hw/vmapple/vmapple.h | 23 + | 294 | include/hw/vmapple/vmapple.h | 23 + |
260 | include/qemu-main.h | 3 +- | 295 | include/qemu-main.h | 14 +- |
261 | include/qemu/cutils.h | 15 + | 296 | include/qemu/cutils.h | 15 + |
262 | include/qemu/typedefs.h | 1 + | ||
263 | meson.build | 5 + | 297 | meson.build | 5 + |
264 | qapi/virtio.json | 14 + | 298 | qapi/virtio.json | 14 + |
265 | system/main.c | 50 +- | 299 | system/main.c | 37 +- |
266 | target/arm/hvf/hvf.c | 9 + | 300 | target/arm/hvf/hvf.c | 9 + |
267 | ui/cocoa.m | 54 +- | 301 | ui/cocoa.m | 54 +- |
268 | ui/gtk.c | 3 + | 302 | ui/gtk.c | 4 + |
269 | ui/sdl2.c | 4 + | 303 | ui/sdl2.c | 4 + |
270 | util/hexdump.c | 18 + | 304 | util/hexdump.c | 18 + |
271 | 53 files changed, 3803 insertions(+), 106 deletions(-) | 305 | 53 files changed, 3840 insertions(+), 110 deletions(-) |
272 | create mode 100755 contrib/vmapple/uuid.sh | 306 | create mode 100755 contrib/vmapple/uuid.sh |
273 | create mode 100644 docs/system/arm/vmapple.rst | 307 | create mode 100644 docs/system/arm/vmapple.rst |
274 | create mode 100644 hw/display/apple-gfx-mmio.m | 308 | create mode 100644 hw/display/apple-gfx-mmio.m |
275 | create mode 100644 hw/display/apple-gfx-pci.m | 309 | create mode 100644 hw/display/apple-gfx-pci.m |
276 | create mode 100644 hw/display/apple-gfx.h | 310 | create mode 100644 hw/display/apple-gfx.h |
... | ... | ||
286 | create mode 100644 hw/vmapple/virtio-blk.c | 320 | create mode 100644 hw/vmapple/virtio-blk.c |
287 | create mode 100644 hw/vmapple/vmapple.c | 321 | create mode 100644 hw/vmapple/vmapple.c |
288 | create mode 100644 include/hw/vmapple/vmapple.h | 322 | create mode 100644 include/hw/vmapple/vmapple.h |
289 | 323 | ||
290 | -- | 324 | -- |
291 | 2.39.3 (Apple Git-145) | 325 | 2.39.5 (Apple Git-154) |
292 | 326 | ||
293 | 327 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
42 | This means that on macOS, the platform's runloop events are always | 42 | This means that on macOS, the platform's runloop events are always |
43 | handled, regardless of chosen UI. The new PV graphics device will | 43 | handled, regardless of chosen UI. The new PV graphics device will |
44 | thus work in all configurations. There is no functional change on other | 44 | thus work in all configurations. There is no functional change on other |
45 | operating systems. | 45 | operating systems. |
46 | 46 | ||
47 | Implementing this via a global function pointer variable is a bit | ||
48 | ugly, but it's probably worth investigating the existing UI thread rule | ||
49 | violations in the SDL (e.g. #2537) and GTK+ back-ends. Fixing those | ||
50 | issues might precipitate requirements similar but not identical to those | ||
51 | of the Cocoa UI; hopefully we'll see some kind of pattern emerge, which | ||
52 | can then be used as a basis for an overhaul. (In fact, it may turn | ||
53 | out to be simplest to split the UI/native platform event thread from the | ||
54 | QEMU main event loop on all platforms, with any UI or even none at all.) | ||
55 | |||
47 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> | 56 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> |
48 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | 57 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> |
58 | Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
49 | --- | 59 | --- |
60 | |||
50 | v5: | 61 | v5: |
51 | 62 | ||
52 | * Simplified the way of setting/clearing the main loop by going back | 63 | * Simplified the way of setting/clearing the main loop by going back |
53 | to setting qemu_main directly, but narrowing the scope of what it | 64 | to setting qemu_main directly, but narrowing the scope of what it |
54 | needs to do, and it can now be NULL. | 65 | needs to do, and it can now be NULL. |
... | ... | ||
62 | 73 | ||
63 | v9: | 74 | v9: |
64 | 75 | ||
65 | * Set qemu_main to NULL for GTK UI as well. | 76 | * Set qemu_main to NULL for GTK UI as well. |
66 | 77 | ||
67 | include/qemu-main.h | 3 +-- | 78 | v10: |
68 | include/qemu/typedefs.h | 1 + | 79 | |
69 | system/main.c | 50 ++++++++++++++++++++++++++++++++++---- | 80 | * Added comments clarifying the functionality and purpose of qemu_main. |
70 | ui/cocoa.m | 54 ++++++++++------------------------------- | 81 | |
71 | ui/gtk.c | 3 +++ | 82 | v11: |
72 | ui/sdl2.c | 4 +++ | 83 | |
73 | 6 files changed, 67 insertions(+), 48 deletions(-) | 84 | * Removed the qemu_main_fn typedef again. |
85 | * Consolidation of main, qemu_default_main, and call_qemu_default_main | ||
86 | so that the latter has been eliminated altogether. | ||
87 | * Reinstated the #include <SDL.h> directive, added comment saying | ||
88 | why it's needed. | ||
89 | * Improved the comment on the qemu_main global variable. | ||
90 | * Expanded the commit message. | ||
91 | |||
92 | v12: | ||
93 | |||
94 | * More precise wording of code comments. | ||
95 | |||
96 | include/qemu-main.h | 14 +++++++++++- | ||
97 | system/main.c | 37 +++++++++++++++++++++++++++---- | ||
98 | ui/cocoa.m | 54 +++++++++++---------------------------------- | ||
99 | ui/gtk.c | 4 ++++ | ||
100 | ui/sdl2.c | 4 ++++ | ||
101 | 5 files changed, 67 insertions(+), 46 deletions(-) | ||
74 | 102 | ||
75 | diff --git a/include/qemu-main.h b/include/qemu-main.h | 103 | diff --git a/include/qemu-main.h b/include/qemu-main.h |
76 | index XXXXXXX..XXXXXXX 100644 | 104 | index XXXXXXX..XXXXXXX 100644 |
77 | --- a/include/qemu-main.h | 105 | --- a/include/qemu-main.h |
78 | +++ b/include/qemu-main.h | 106 | +++ b/include/qemu-main.h |
79 | @@ -XXX,XX +XXX,XX @@ | 107 | @@ -XXX,XX +XXX,XX @@ |
80 | #ifndef QEMU_MAIN_H | 108 | #ifndef QEMU_MAIN_H |
81 | #define QEMU_MAIN_H | 109 | #define QEMU_MAIN_H |
82 | 110 | ||
83 | -int qemu_default_main(void); | 111 | -int qemu_default_main(void); |
84 | -extern int (*qemu_main)(void); | 112 | +/* |
85 | +extern qemu_main_fn qemu_main; | 113 | + * The function to run on the main (initial) thread of the process. |
114 | + * NULL means QEMU's main event loop. | ||
115 | + * When non-NULL, QEMU's main event loop will run on a purposely created | ||
116 | + * thread, after which the provided function pointer will be invoked on | ||
117 | + * the initial thread. | ||
118 | + * This is useful on platforms which treat the main thread as special | ||
119 | + * (macOS/Darwin) and/or require all UI API calls to occur from the main | ||
120 | + * thread. Those platforms can initialise it to a specific function, | ||
121 | + * while UI implementations may reset it to NULL during their init if they | ||
122 | + * will handle system and UI events on the main thread via QEMU's own main | ||
123 | + * event loop. | ||
124 | + */ | ||
125 | extern int (*qemu_main)(void); | ||
86 | 126 | ||
87 | #endif /* QEMU_MAIN_H */ | 127 | #endif /* QEMU_MAIN_H */ |
88 | diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/include/qemu/typedefs.h | ||
91 | +++ b/include/qemu/typedefs.h | ||
92 | @@ -XXX,XX +XXX,XX @@ typedef struct IRQState *qemu_irq; | ||
93 | * Function types | ||
94 | */ | ||
95 | typedef void (*qemu_irq_handler)(void *opaque, int n, int level); | ||
96 | +typedef int (*qemu_main_fn)(void); | ||
97 | |||
98 | #endif /* QEMU_TYPEDEFS_H */ | ||
99 | diff --git a/system/main.c b/system/main.c | 128 | diff --git a/system/main.c b/system/main.c |
100 | index XXXXXXX..XXXXXXX 100644 | 129 | index XXXXXXX..XXXXXXX 100644 |
101 | --- a/system/main.c | 130 | --- a/system/main.c |
102 | +++ b/system/main.c | 131 | +++ b/system/main.c |
103 | @@ -XXX,XX +XXX,XX @@ | 132 | @@ -XXX,XX +XXX,XX @@ |
104 | 133 | ||
105 | #include "qemu/osdep.h" | 134 | #include "qemu/osdep.h" |
106 | #include "qemu-main.h" | 135 | #include "qemu-main.h" |
107 | +#include "qemu/main-loop.h" | 136 | +#include "qemu/main-loop.h" |
108 | #include "sysemu/sysemu.h" | 137 | #include "sysemu/sysemu.h" |
109 | 138 | ||
110 | -#ifdef CONFIG_SDL | 139 | #ifdef CONFIG_SDL |
111 | -#include <SDL.h> | 140 | +/* |
141 | + * SDL insists on wrapping the main() function with its own implementation on | ||
142 | + * some platforms; it does so via a macro that renames our main function, so | ||
143 | + * <SDL.h> must be #included here even with no SDL code called from this file. | ||
144 | + */ | ||
145 | #include <SDL.h> | ||
146 | #endif | ||
147 | |||
148 | -int qemu_default_main(void) | ||
112 | +#ifdef CONFIG_DARWIN | 149 | +#ifdef CONFIG_DARWIN |
113 | +#include <CoreFoundation/CoreFoundation.h> | 150 | +#include <CoreFoundation/CoreFoundation.h> |
114 | #endif | 151 | +#endif |
115 | 152 | + | |
116 | -int qemu_default_main(void) | 153 | +static void *qemu_default_main(void *opaque) |
117 | +static int qemu_default_main(void) | ||
118 | { | 154 | { |
119 | int status; | 155 | int status; |
120 | 156 | ||
121 | @@ -XXX,XX +XXX,XX @@ int qemu_default_main(void) | 157 | + bql_lock(); |
122 | return status; | 158 | status = qemu_main_loop(); |
123 | } | 159 | qemu_cleanup(status); |
160 | + bql_unlock(); | ||
161 | |||
162 | - return status; | ||
163 | + exit(status); | ||
164 | } | ||
124 | 165 | ||
125 | -int (*qemu_main)(void) = qemu_default_main; | 166 | -int (*qemu_main)(void) = qemu_default_main; |
126 | +/* | 167 | +int (*qemu_main)(void); |
127 | + * Various macOS system libraries, including the Cocoa UI and anything using | ||
128 | + * libdispatch, such as ParavirtualizedGraphics.framework, requires that the | ||
129 | + * main runloop, on the main (initial) thread be running or at least regularly | ||
130 | + * polled for events. A special mode is therefore supported, where the QEMU | ||
131 | + * main loop runs on a separate thread and the main thread handles the | ||
132 | + * CF/Cocoa runloop. | ||
133 | + */ | ||
134 | + | ||
135 | +static void *call_qemu_default_main(void *opaque) | ||
136 | +{ | ||
137 | + int status; | ||
138 | + | ||
139 | + bql_lock(); | ||
140 | + status = qemu_default_main(); | ||
141 | + bql_unlock(); | ||
142 | + | ||
143 | + exit(status); | ||
144 | +} | ||
145 | + | 168 | + |
146 | +#ifdef CONFIG_DARWIN | 169 | +#ifdef CONFIG_DARWIN |
147 | +static int os_darwin_cfrunloop_main(void) | 170 | +static int os_darwin_cfrunloop_main(void) |
148 | +{ | 171 | +{ |
149 | + CFRunLoopRun(); | 172 | + CFRunLoopRun(); |
150 | + abort(); | 173 | + g_assert_not_reached(); |
151 | +} | 174 | +} |
152 | + | 175 | +int (*qemu_main)(void) = os_darwin_cfrunloop_main; |
153 | +qemu_main_fn qemu_main = os_darwin_cfrunloop_main; | ||
154 | +#else | ||
155 | +qemu_main_fn qemu_main; | ||
156 | +#endif | 176 | +#endif |
157 | 177 | ||
158 | int main(int argc, char **argv) | 178 | int main(int argc, char **argv) |
159 | { | 179 | { |
160 | + QemuThread main_loop_thread; | ||
161 | + | ||
162 | qemu_init(argc, argv); | 180 | qemu_init(argc, argv); |
163 | - return qemu_main(); | 181 | - return qemu_main(); |
182 | + bql_unlock(); | ||
164 | + if (qemu_main) { | 183 | + if (qemu_main) { |
184 | + QemuThread main_loop_thread; | ||
165 | + qemu_thread_create(&main_loop_thread, "qemu_main", | 185 | + qemu_thread_create(&main_loop_thread, "qemu_main", |
166 | + call_qemu_default_main, NULL, QEMU_THREAD_DETACHED); | 186 | + qemu_default_main, NULL, QEMU_THREAD_DETACHED); |
167 | + bql_unlock(); | ||
168 | + return qemu_main(); | 187 | + return qemu_main(); |
169 | + } else { | 188 | + } else { |
170 | + qemu_default_main(); | 189 | + qemu_default_main(NULL); |
171 | + } | 190 | + } |
172 | } | 191 | } |
173 | diff --git a/ui/cocoa.m b/ui/cocoa.m | 192 | diff --git a/ui/cocoa.m b/ui/cocoa.m |
174 | index XXXXXXX..XXXXXXX 100644 | 193 | index XXXXXXX..XXXXXXX 100644 |
175 | --- a/ui/cocoa.m | 194 | --- a/ui/cocoa.m |
... | ... | ||
294 | @@ -XXX,XX +XXX,XX @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts) | 313 | @@ -XXX,XX +XXX,XX @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts) |
295 | #ifdef CONFIG_GTK_CLIPBOARD | 314 | #ifdef CONFIG_GTK_CLIPBOARD |
296 | gd_clipboard_init(s); | 315 | gd_clipboard_init(s); |
297 | #endif /* CONFIG_GTK_CLIPBOARD */ | 316 | #endif /* CONFIG_GTK_CLIPBOARD */ |
298 | + | 317 | + |
318 | + /* GTK's event polling must happen on the main thread. */ | ||
299 | + qemu_main = NULL; | 319 | + qemu_main = NULL; |
300 | } | 320 | } |
301 | 321 | ||
302 | static void early_gtk_display_init(DisplayOptions *opts) | 322 | static void early_gtk_display_init(DisplayOptions *opts) |
303 | diff --git a/ui/sdl2.c b/ui/sdl2.c | 323 | diff --git a/ui/sdl2.c b/ui/sdl2.c |
... | ... | ||
321 | + qemu_main = NULL; | 341 | + qemu_main = NULL; |
322 | } | 342 | } |
323 | 343 | ||
324 | static QemuDisplay qemu_display_sdl2 = { | 344 | static QemuDisplay qemu_display_sdl2 = { |
325 | -- | 345 | -- |
326 | 2.39.3 (Apple Git-145) | 346 | 2.39.5 (Apple Git-154) | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
29 | similarly never acquiring the BQL in a callback from PVG. Different strategies | 29 | similarly never acquiring the BQL in a callback from PVG. Different strategies |
30 | have been used (libdispatch, blocking and non-blocking BHs, RCU, etc.) | 30 | have been used (libdispatch, blocking and non-blocking BHs, RCU, etc.) |
31 | depending on the specific requirements at each framework entry and exit point. | 31 | depending on the specific requirements at each framework entry and exit point. |
32 | 32 | ||
33 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> | 33 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> |
34 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
35 | Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
34 | --- | 36 | --- |
35 | 37 | ||
36 | v2: | 38 | v2: |
37 | 39 | ||
38 | * Cherry-pick/rebase conflict fixes | 40 | * Cherry-pick/rebase conflict fixes |
... | ... | ||
136 | * Slightly re-ordered initialisation code. | 138 | * Slightly re-ordered initialisation code. |
137 | * Simplified error handling during realize(). | 139 | * Simplified error handling during realize(). |
138 | * Simplified code without functional changes, adjusted code & comment | 140 | * Simplified code without functional changes, adjusted code & comment |
139 | formatting. | 141 | formatting. |
140 | 142 | ||
143 | v10: | ||
144 | |||
145 | * Reworked the way frame rendering code is threaded to use BHs for sections | ||
146 | requiring BQL. | ||
147 | * Fix for ./configure error on non-macOS platforms. | ||
148 | * Code formatting tweaks. | ||
149 | |||
150 | v11: | ||
151 | |||
152 | * Generate unique display serial number for each apple-gfx device instance. | ||
153 | * Dropped redundant local variable initialisation. | ||
154 | |||
155 | v12: | ||
156 | |||
157 | * Removed 2 redundant variable initialisations. | ||
158 | * Removed dedicated rendering dispatch_queue, use global queue instead. | ||
159 | * Fixed an object leak regression introduced in v10. Solved by placing | ||
160 | @autoreleasepool blocks around the relevant Objective-C code in the BH | ||
161 | functions replacing the dispatch_async tasks. (dispatch_async implicitly | ||
162 | cleaned up autoreleased objects.) | ||
163 | * Fixed missing retain/release of command buffers when handing off to a | ||
164 | non-BH thread. (Problem masked at runtime by above leak.) | ||
165 | * Better handling of render command encoding errors. | ||
166 | * Re-arranged positions of static variables in the file. | ||
167 | |||
141 | hw/display/Kconfig | 9 + | 168 | hw/display/Kconfig | 9 + |
142 | hw/display/apple-gfx-mmio.m | 281 +++++++++++++ | 169 | hw/display/apple-gfx-mmio.m | 281 +++++++++++++ |
143 | hw/display/apple-gfx.h | 65 +++ | 170 | hw/display/apple-gfx.h | 66 +++ |
144 | hw/display/apple-gfx.m | 764 ++++++++++++++++++++++++++++++++++++ | 171 | hw/display/apple-gfx.m | 783 ++++++++++++++++++++++++++++++++++++ |
145 | hw/display/meson.build | 4 + | 172 | hw/display/meson.build | 6 + |
146 | hw/display/trace-events | 28 ++ | 173 | hw/display/trace-events | 28 ++ |
147 | meson.build | 4 + | 174 | meson.build | 4 + |
148 | 7 files changed, 1155 insertions(+) | 175 | 7 files changed, 1177 insertions(+) |
149 | create mode 100644 hw/display/apple-gfx-mmio.m | 176 | create mode 100644 hw/display/apple-gfx-mmio.m |
150 | create mode 100644 hw/display/apple-gfx.h | 177 | create mode 100644 hw/display/apple-gfx.h |
151 | create mode 100644 hw/display/apple-gfx.m | 178 | create mode 100644 hw/display/apple-gfx.m |
152 | 179 | ||
153 | diff --git a/hw/display/Kconfig b/hw/display/Kconfig | 180 | diff --git a/hw/display/Kconfig b/hw/display/Kconfig |
... | ... | ||
357 | +static PGIOSurfaceHostDevice *apple_gfx_prepare_iosurface_host_device( | 384 | +static PGIOSurfaceHostDevice *apple_gfx_prepare_iosurface_host_device( |
358 | + AppleGFXMMIOState *s) | 385 | + AppleGFXMMIOState *s) |
359 | +{ | 386 | +{ |
360 | + PGIOSurfaceHostDeviceDescriptor *iosfc_desc = | 387 | + PGIOSurfaceHostDeviceDescriptor *iosfc_desc = |
361 | + [PGIOSurfaceHostDeviceDescriptor new]; | 388 | + [PGIOSurfaceHostDeviceDescriptor new]; |
362 | + PGIOSurfaceHostDevice *iosfc_host_dev = nil; | 389 | + PGIOSurfaceHostDevice *iosfc_host_dev; |
363 | + | 390 | + |
364 | + iosfc_desc.mapMemory = | 391 | + iosfc_desc.mapMemory = |
365 | + ^bool(uint64_t phys, uint64_t len, bool ro, void **va, void *e, void *f) { | 392 | + ^bool(uint64_t phys, uint64_t len, bool ro, void **va, void *e, void *f) { |
366 | + *va = apple_gfx_mmio_map_surface_memory(phys, len, ro); | 393 | + *va = apple_gfx_mmio_map_surface_memory(phys, len, ro); |
367 | + | 394 | + |
... | ... | ||
495 | + id<PGDevice> pgdev; | 522 | + id<PGDevice> pgdev; |
496 | + id<PGDisplay> pgdisp; | 523 | + id<PGDisplay> pgdisp; |
497 | + QemuConsole *con; | 524 | + QemuConsole *con; |
498 | + id<MTLDevice> mtl; | 525 | + id<MTLDevice> mtl; |
499 | + id<MTLCommandQueue> mtl_queue; | 526 | + id<MTLCommandQueue> mtl_queue; |
500 | + dispatch_queue_t render_queue; | ||
501 | + | 527 | + |
502 | + /* List `tasks` is protected by task_mutex */ | 528 | + /* List `tasks` is protected by task_mutex */ |
503 | + QemuMutex task_mutex; | 529 | + QemuMutex task_mutex; |
504 | + PGTaskList tasks; | 530 | + PGTaskList tasks; |
505 | + | 531 | + |
... | ... | ||
509 | + id<MTLTexture> texture; | 535 | + id<MTLTexture> texture; |
510 | + int8_t pending_frames; /* # guest frames in the rendering pipeline */ | 536 | + int8_t pending_frames; /* # guest frames in the rendering pipeline */ |
511 | + bool gfx_update_requested; /* QEMU display system wants a new frame */ | 537 | + bool gfx_update_requested; /* QEMU display system wants a new frame */ |
512 | + bool new_frame_ready; /* Guest has rendered a frame, ready to be used */ | 538 | + bool new_frame_ready; /* Guest has rendered a frame, ready to be used */ |
513 | + bool using_managed_texture_storage; | 539 | + bool using_managed_texture_storage; |
540 | + uint32_t rendering_frame_width; | ||
541 | + uint32_t rendering_frame_height; | ||
514 | + | 542 | + |
515 | + /* Mutable state (atomic) */ | 543 | + /* Mutable state (atomic) */ |
516 | + bool cursor_show; | 544 | + bool cursor_show; |
517 | +} AppleGFXState; | 545 | +} AppleGFXState; |
518 | + | 546 | + |
... | ... | ||
566 | + | 594 | + |
567 | +static const PGDisplayCoord_t apple_gfx_modes[] = { | 595 | +static const PGDisplayCoord_t apple_gfx_modes[] = { |
568 | + { .x = 1440, .y = 1080 }, | 596 | + { .x = 1440, .y = 1080 }, |
569 | + { .x = 1280, .y = 1024 }, | 597 | + { .x = 1280, .y = 1024 }, |
570 | +}; | 598 | +}; |
599 | + | ||
600 | +static Error *apple_gfx_mig_blocker; | ||
601 | +static uint32_t next_pgdisplay_serial_num = 1; | ||
602 | + | ||
603 | +static dispatch_queue_t get_background_queue(void) | ||
604 | +{ | ||
605 | + return dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | ||
606 | +} | ||
571 | + | 607 | + |
572 | +/* ------ PGTask and task operations: new/destroy/map/unmap ------ */ | 608 | +/* ------ PGTask and task operations: new/destroy/map/unmap ------ */ |
573 | + | 609 | + |
574 | +/* | 610 | +/* |
575 | + * This implements the type declared in <ParavirtualizedGraphics/PGDevice.h> | 611 | + * This implements the type declared in <ParavirtualizedGraphics/PGDevice.h> |
... | ... | ||
601 | + * Protected by AppleGFXState's task_mutex. | 637 | + * Protected by AppleGFXState's task_mutex. |
602 | + */ | 638 | + */ |
603 | + GPtrArray *mapped_regions; | 639 | + GPtrArray *mapped_regions; |
604 | +}; | 640 | +}; |
605 | + | 641 | + |
606 | +static Error *apple_gfx_mig_blocker; | ||
607 | + | ||
608 | +static PGTask_t *apple_gfx_new_task(AppleGFXState *s, uint64_t len) | 642 | +static PGTask_t *apple_gfx_new_task(AppleGFXState *s, uint64_t len) |
609 | +{ | 643 | +{ |
610 | + mach_vm_address_t task_mem; | 644 | + mach_vm_address_t task_mem; |
611 | + PGTask_t *task; | 645 | + PGTask_t *task; |
612 | + kern_return_t r; | 646 | + kern_return_t r; |
... | ... | ||
750 | + g_assert(r == KERN_SUCCESS); | 784 | + g_assert(r == KERN_SUCCESS); |
751 | +} | 785 | +} |
752 | + | 786 | + |
753 | +/* ------ Rendering and frame management ------ */ | 787 | +/* ------ Rendering and frame management ------ */ |
754 | + | 788 | + |
755 | +static void apple_gfx_render_frame_completed(AppleGFXState *s, | 789 | +static void apple_gfx_render_frame_completed_bh(void *opaque); |
756 | + uint32_t width, uint32_t height); | 790 | + |
757 | + | 791 | +static void apple_gfx_render_new_frame(AppleGFXState *s) |
758 | +static void apple_gfx_render_new_frame_bql_unlock(AppleGFXState *s) | 792 | +{ |
759 | +{ | ||
760 | + BOOL r; | ||
761 | + bool managed_texture = s->using_managed_texture_storage; | 793 | + bool managed_texture = s->using_managed_texture_storage; |
762 | + uint32_t width = surface_width(s->surface); | 794 | + uint32_t width = surface_width(s->surface); |
763 | + uint32_t height = surface_height(s->surface); | 795 | + uint32_t height = surface_height(s->surface); |
764 | + MTLRegion region = MTLRegionMake2D(0, 0, width, height); | 796 | + MTLRegion region = MTLRegionMake2D(0, 0, width, height); |
765 | + id<MTLCommandBuffer> command_buffer = [s->mtl_queue commandBuffer]; | 797 | + id<MTLCommandBuffer> command_buffer = [s->mtl_queue commandBuffer]; |
766 | + id<MTLTexture> texture = s->texture; | 798 | + id<MTLTexture> texture = s->texture; |
767 | + | 799 | + |
768 | + assert(bql_locked()); | 800 | + assert(bql_locked()); |
769 | + [texture retain]; | 801 | + [texture retain]; |
770 | + | 802 | + [command_buffer retain]; |
771 | + bql_unlock(); | 803 | + |
772 | + | 804 | + s->rendering_frame_width = width; |
805 | + s->rendering_frame_height = height; | ||
806 | + | ||
807 | + dispatch_async(get_background_queue(), ^{ | ||
808 | + /* | ||
809 | + * This is not safe to call from the BQL/BH due to PVG-internal locks | ||
810 | + * causing deadlocks. | ||
811 | + */ | ||
812 | + bool r = [s->pgdisp encodeCurrentFrameToCommandBuffer:command_buffer | ||
813 | + texture:texture | ||
814 | + region:region]; | ||
815 | + if (!r) { | ||
816 | + [texture release]; | ||
817 | + [command_buffer release]; | ||
818 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
819 | + "%s: encodeCurrentFrameToCommandBuffer:texture:region: " | ||
820 | + "failed\n", __func__); | ||
821 | + bql_lock(); | ||
822 | + --s->pending_frames; | ||
823 | + if (s->pending_frames > 0) { | ||
824 | + apple_gfx_render_new_frame(s); | ||
825 | + } | ||
826 | + bql_unlock(); | ||
827 | + return; | ||
828 | + } | ||
829 | + | ||
830 | + if (managed_texture) { | ||
831 | + /* "Managed" textures exist in both VRAM and RAM and must be synced. */ | ||
832 | + id<MTLBlitCommandEncoder> blit = [command_buffer blitCommandEncoder]; | ||
833 | + [blit synchronizeResource:texture]; | ||
834 | + [blit endEncoding]; | ||
835 | + } | ||
836 | + [texture release]; | ||
837 | + [command_buffer addCompletedHandler: | ||
838 | + ^(id<MTLCommandBuffer> cb) | ||
839 | + { | ||
840 | + aio_bh_schedule_oneshot(qemu_get_aio_context(), | ||
841 | + apple_gfx_render_frame_completed_bh, s); | ||
842 | + }]; | ||
843 | + [command_buffer commit]; | ||
844 | + [command_buffer release]; | ||
845 | + }); | ||
846 | +} | ||
847 | + | ||
848 | +static void copy_mtl_texture_to_surface_mem(id<MTLTexture> texture, void *vram) | ||
849 | +{ | ||
773 | + /* | 850 | + /* |
774 | + * This is not safe to call from the BQL due to PVG-internal locks causing | 851 | + * TODO: Skip this entirely on a pure Metal or headless/guest-only |
775 | + * deadlocks. | 852 | + * rendering path, else use a blit command encoder? Needs careful |
853 | + * (double?) buffering design. | ||
776 | + */ | 854 | + */ |
777 | + r = [s->pgdisp encodeCurrentFrameToCommandBuffer:command_buffer | ||
778 | + texture:texture | ||
779 | + region:region]; | ||
780 | + if (!r) { | ||
781 | + [texture release]; | ||
782 | + bql_lock(); | ||
783 | + --s->pending_frames; | ||
784 | + bql_unlock(); | ||
785 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
786 | + "%s: encodeCurrentFrameToCommandBuffer:texture:region: " | ||
787 | + "failed\n", __func__); | ||
788 | + return; | ||
789 | + } | ||
790 | + | ||
791 | + if (managed_texture) { | ||
792 | + /* "Managed" textures exist in both VRAM and RAM and must be synced. */ | ||
793 | + id<MTLBlitCommandEncoder> blit = [command_buffer blitCommandEncoder]; | ||
794 | + [blit synchronizeResource:texture]; | ||
795 | + [blit endEncoding]; | ||
796 | + } | ||
797 | + [texture release]; | ||
798 | + [command_buffer addCompletedHandler: | ||
799 | + ^(id<MTLCommandBuffer> cb) | ||
800 | + { | ||
801 | + dispatch_async(s->render_queue, ^{ | ||
802 | + apple_gfx_render_frame_completed(s, width, height); | ||
803 | + }); | ||
804 | + }]; | ||
805 | + [command_buffer commit]; | ||
806 | +} | ||
807 | + | ||
808 | +static void copy_mtl_texture_to_surface_mem(id<MTLTexture> texture, void *vram) | ||
809 | +{ | ||
810 | + /* TODO: Skip this entirely on a pure Metal or headless/guest-only | ||
811 | + * rendering path, else use a blit command encoder? Needs careful | ||
812 | + * (double?) buffering design. */ | ||
813 | + size_t width = texture.width, height = texture.height; | 855 | + size_t width = texture.width, height = texture.height; |
814 | + MTLRegion region = MTLRegionMake2D(0, 0, width, height); | 856 | + MTLRegion region = MTLRegionMake2D(0, 0, width, height); |
815 | + [texture getBytes:vram | 857 | + [texture getBytes:vram |
816 | + bytesPerRow:(width * 4) | 858 | + bytesPerRow:(width * 4) |
817 | + bytesPerImage:(width * height * 4) | 859 | + bytesPerImage:(width * height * 4) |
818 | + fromRegion:region | 860 | + fromRegion:region |
819 | + mipmapLevel:0 | 861 | + mipmapLevel:0 |
820 | + slice:0]; | 862 | + slice:0]; |
821 | +} | 863 | +} |
822 | + | 864 | + |
823 | +static void apple_gfx_render_frame_completed(AppleGFXState *s, | 865 | +static void apple_gfx_render_frame_completed_bh(void *opaque) |
824 | + uint32_t width, uint32_t height) | 866 | +{ |
825 | +{ | 867 | + AppleGFXState *s = opaque; |
826 | + bql_lock(); | 868 | + |
827 | + --s->pending_frames; | 869 | + @autoreleasepool { |
828 | + assert(s->pending_frames >= 0); | 870 | + --s->pending_frames; |
829 | + | 871 | + assert(s->pending_frames >= 0); |
830 | + /* Only update display if mode hasn't changed since we started rendering. */ | 872 | + |
831 | + if (width == surface_width(s->surface) && | 873 | + /* Only update display if mode hasn't changed since we started rendering. */ |
832 | + height == surface_height(s->surface)) { | 874 | + if (s->rendering_frame_width == surface_width(s->surface) && |
833 | + copy_mtl_texture_to_surface_mem(s->texture, surface_data(s->surface)); | 875 | + s->rendering_frame_height == surface_height(s->surface)) { |
834 | + if (s->gfx_update_requested) { | 876 | + copy_mtl_texture_to_surface_mem(s->texture, surface_data(s->surface)); |
835 | + s->gfx_update_requested = false; | 877 | + if (s->gfx_update_requested) { |
836 | + dpy_gfx_update_full(s->con); | 878 | + s->gfx_update_requested = false; |
837 | + graphic_hw_update_done(s->con); | 879 | + dpy_gfx_update_full(s->con); |
838 | + s->new_frame_ready = false; | 880 | + graphic_hw_update_done(s->con); |
839 | + } else { | 881 | + s->new_frame_ready = false; |
840 | + s->new_frame_ready = true; | 882 | + } else { |
883 | + s->new_frame_ready = true; | ||
884 | + } | ||
841 | + } | 885 | + } |
842 | + } | 886 | + if (s->pending_frames > 0) { |
843 | + if (s->pending_frames > 0) { | 887 | + apple_gfx_render_new_frame(s); |
844 | + apple_gfx_render_new_frame_bql_unlock(s); | 888 | + } |
845 | + } else { | ||
846 | + bql_unlock(); | ||
847 | + } | 889 | + } |
848 | +} | 890 | +} |
849 | + | 891 | + |
850 | +static void apple_gfx_fb_update_display(void *opaque) | 892 | +static void apple_gfx_fb_update_display(void *opaque) |
851 | +{ | 893 | +{ |
... | ... | ||
891 | + width:width | 933 | + width:width |
892 | + height:height | 934 | + height:height |
893 | + mipmapped:NO]; | 935 | + mipmapped:NO]; |
894 | + textureDescriptor.usage = s->pgdisp.minimumTextureUsage; | 936 | + textureDescriptor.usage = s->pgdisp.minimumTextureUsage; |
895 | + s->texture = [s->mtl newTextureWithDescriptor:textureDescriptor]; | 937 | + s->texture = [s->mtl newTextureWithDescriptor:textureDescriptor]; |
896 | + } | 938 | + s->using_managed_texture_storage = |
897 | + | 939 | + (s->texture.storageMode == MTLStorageModeManaged); |
898 | + s->using_managed_texture_storage = | 940 | + } |
899 | + (s->texture.storageMode == MTLStorageModeManaged); | 941 | + |
900 | + dpy_gfx_replace_surface(s->con, s->surface); | 942 | + dpy_gfx_replace_surface(s->con, s->surface); |
901 | +} | 943 | +} |
902 | + | 944 | + |
903 | +static void update_cursor(AppleGFXState *s) | 945 | +static void update_cursor(AppleGFXState *s) |
904 | +{ | 946 | +{ |
... | ... | ||
1008 | + return job.success; | 1050 | + return job.success; |
1009 | +} | 1051 | +} |
1010 | + | 1052 | + |
1011 | +/* ------ Memory-mapped device I/O operations ------ */ | 1053 | +/* ------ Memory-mapped device I/O operations ------ */ |
1012 | + | 1054 | + |
1013 | +static dispatch_queue_t get_background_queue(void) | ||
1014 | +{ | ||
1015 | + return dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | ||
1016 | +} | ||
1017 | + | ||
1018 | +typedef struct AppleGFXIOJob { | 1055 | +typedef struct AppleGFXIOJob { |
1019 | + AppleGFXState *state; | 1056 | + AppleGFXState *state; |
1020 | + uint64_t offset; | 1057 | + uint64_t offset; |
1021 | + uint64_t value; | 1058 | + uint64_t value; |
1022 | + bool completed; | 1059 | + bool completed; |
... | ... | ||
1151 | + void * _Nonnull dst) { | 1188 | + void * _Nonnull dst) { |
1152 | + return apple_gfx_read_memory(s, physical_address, length, dst); | 1189 | + return apple_gfx_read_memory(s, physical_address, length, dst); |
1153 | + }; | 1190 | + }; |
1154 | +} | 1191 | +} |
1155 | + | 1192 | + |
1193 | +static void new_frame_handler_bh(void *opaque) | ||
1194 | +{ | ||
1195 | + AppleGFXState *s = opaque; | ||
1196 | + | ||
1197 | + /* Drop frames if guest gets too far ahead. */ | ||
1198 | + if (s->pending_frames >= 2) { | ||
1199 | + return; | ||
1200 | + } | ||
1201 | + ++s->pending_frames; | ||
1202 | + if (s->pending_frames > 1) { | ||
1203 | + return; | ||
1204 | + } | ||
1205 | + | ||
1206 | + @autoreleasepool { | ||
1207 | + apple_gfx_render_new_frame(s); | ||
1208 | + } | ||
1209 | +} | ||
1210 | + | ||
1156 | +static PGDisplayDescriptor *apple_gfx_prepare_display_descriptor(AppleGFXState *s) | 1211 | +static PGDisplayDescriptor *apple_gfx_prepare_display_descriptor(AppleGFXState *s) |
1157 | +{ | 1212 | +{ |
1158 | + PGDisplayDescriptor *disp_desc = [PGDisplayDescriptor new]; | 1213 | + PGDisplayDescriptor *disp_desc = [PGDisplayDescriptor new]; |
1159 | + | 1214 | + |
1160 | + disp_desc.name = @"QEMU display"; | 1215 | + disp_desc.name = @"QEMU display"; |
1161 | + disp_desc.sizeInMillimeters = NSMakeSize(400., 300.); /* A 20" display */ | 1216 | + disp_desc.sizeInMillimeters = NSMakeSize(400., 300.); /* A 20" display */ |
1162 | + disp_desc.queue = dispatch_get_main_queue(); | 1217 | + disp_desc.queue = dispatch_get_main_queue(); |
1163 | + disp_desc.newFrameEventHandler = ^(void) { | 1218 | + disp_desc.newFrameEventHandler = ^(void) { |
1164 | + trace_apple_gfx_new_frame(); | 1219 | + trace_apple_gfx_new_frame(); |
1165 | + dispatch_async(s->render_queue, ^{ | 1220 | + aio_bh_schedule_oneshot(qemu_get_aio_context(), new_frame_handler_bh, s); |
1166 | + /* Drop frames if we get too far ahead. */ | ||
1167 | + bql_lock(); | ||
1168 | + if (s->pending_frames >= 2) { | ||
1169 | + bql_unlock(); | ||
1170 | + return; | ||
1171 | + } | ||
1172 | + ++s->pending_frames; | ||
1173 | + if (s->pending_frames > 1) { | ||
1174 | + bql_unlock(); | ||
1175 | + return; | ||
1176 | + } | ||
1177 | + @autoreleasepool { | ||
1178 | + apple_gfx_render_new_frame_bql_unlock(s); | ||
1179 | + } | ||
1180 | + }); | ||
1181 | + }; | 1221 | + }; |
1182 | + disp_desc.modeChangeHandler = ^(PGDisplayCoord_t sizeInPixels, | 1222 | + disp_desc.modeChangeHandler = ^(PGDisplayCoord_t sizeInPixels, |
1183 | + OSType pixelFormat) { | 1223 | + OSType pixelFormat) { |
1184 | + trace_apple_gfx_mode_change(sizeInPixels.x, sizeInPixels.y); | 1224 | + trace_apple_gfx_mode_change(sizeInPixels.x, sizeInPixels.y); |
1185 | + | 1225 | + |
... | ... | ||
1212 | +} | 1252 | +} |
1213 | + | 1253 | + |
1214 | +static NSArray<PGDisplayMode*>* apple_gfx_prepare_display_mode_array(void) | 1254 | +static NSArray<PGDisplayMode*>* apple_gfx_prepare_display_mode_array(void) |
1215 | +{ | 1255 | +{ |
1216 | + PGDisplayMode *modes[ARRAY_SIZE(apple_gfx_modes)]; | 1256 | + PGDisplayMode *modes[ARRAY_SIZE(apple_gfx_modes)]; |
1217 | + NSArray<PGDisplayMode*>* mode_array = nil; | 1257 | + NSArray<PGDisplayMode*>* mode_array; |
1218 | + int i; | 1258 | + int i; |
1219 | + | 1259 | + |
1220 | + for (i = 0; i < ARRAY_SIZE(apple_gfx_modes); i++) { | 1260 | + for (i = 0; i < ARRAY_SIZE(apple_gfx_modes); i++) { |
1221 | + modes[i] = | 1261 | + modes[i] = |
1222 | + [[PGDisplayMode alloc] initWithSizeInPixels:apple_gfx_modes[i] refreshRateInHz:60.]; | 1262 | + [[PGDisplayMode alloc] initWithSizeInPixels:apple_gfx_modes[i] refreshRateInHz:60.]; |
... | ... | ||
1259 | +} | 1299 | +} |
1260 | + | 1300 | + |
1261 | +bool apple_gfx_common_realize(AppleGFXState *s, DeviceState *dev, | 1301 | +bool apple_gfx_common_realize(AppleGFXState *s, DeviceState *dev, |
1262 | + PGDeviceDescriptor *desc, Error **errp) | 1302 | + PGDeviceDescriptor *desc, Error **errp) |
1263 | +{ | 1303 | +{ |
1264 | + PGDisplayDescriptor *disp_desc = nil; | 1304 | + PGDisplayDescriptor *disp_desc; |
1265 | + | 1305 | + |
1266 | + if (apple_gfx_mig_blocker == NULL) { | 1306 | + if (apple_gfx_mig_blocker == NULL) { |
1267 | + error_setg(&apple_gfx_mig_blocker, | 1307 | + error_setg(&apple_gfx_mig_blocker, |
1268 | + "Migration state blocked by apple-gfx display device"); | 1308 | + "Migration state blocked by apple-gfx display device"); |
1269 | + if (migrate_add_blocker(&apple_gfx_mig_blocker, errp) < 0) { | 1309 | + if (migrate_add_blocker(&apple_gfx_mig_blocker, errp) < 0) { |
1270 | + return false; | 1310 | + return false; |
1271 | + } | 1311 | + } |
1272 | + } | 1312 | + } |
1273 | + | 1313 | + |
1274 | + qemu_mutex_init(&s->task_mutex); | 1314 | + qemu_mutex_init(&s->task_mutex); |
1275 | + QTAILQ_INIT(&s->tasks); | 1315 | + QTAILQ_INIT(&s->tasks); |
1276 | + s->render_queue = dispatch_queue_create("apple-gfx.render", | ||
1277 | + DISPATCH_QUEUE_SERIAL); | ||
1278 | + s->mtl = copy_suitable_metal_device(); | 1316 | + s->mtl = copy_suitable_metal_device(); |
1279 | + s->mtl_queue = [s->mtl newCommandQueue]; | 1317 | + s->mtl_queue = [s->mtl newCommandQueue]; |
1280 | + | 1318 | + |
1281 | + desc.device = s->mtl; | 1319 | + desc.device = s->mtl; |
1282 | + | 1320 | + |
... | ... | ||
1285 | + s->cursor_show = true; | 1323 | + s->cursor_show = true; |
1286 | + | 1324 | + |
1287 | + s->pgdev = PGNewDeviceWithDescriptor(desc); | 1325 | + s->pgdev = PGNewDeviceWithDescriptor(desc); |
1288 | + | 1326 | + |
1289 | + disp_desc = apple_gfx_prepare_display_descriptor(s); | 1327 | + disp_desc = apple_gfx_prepare_display_descriptor(s); |
1328 | + /* | ||
1329 | + * Although the framework does, this integration currently does not support | ||
1330 | + * multiple virtual displays connected to a single PV graphics device. | ||
1331 | + * It is however possible to create | ||
1332 | + * more than one instance of the device, each with one display. The macOS | ||
1333 | + * guest will ignore these displays if they share the same serial number, | ||
1334 | + * so ensure each instance gets a unique one. | ||
1335 | + */ | ||
1290 | + s->pgdisp = [s->pgdev newDisplayWithDescriptor:disp_desc | 1336 | + s->pgdisp = [s->pgdev newDisplayWithDescriptor:disp_desc |
1291 | + port:0 serialNum:1234]; | 1337 | + port:0 |
1338 | + serialNum:next_pgdisplay_serial_num++]; | ||
1292 | + [disp_desc release]; | 1339 | + [disp_desc release]; |
1293 | + s->pgdisp.modeList = apple_gfx_prepare_display_mode_array(); | 1340 | + s->pgdisp.modeList = apple_gfx_prepare_display_mode_array(); |
1294 | + | 1341 | + |
1295 | + s->con = graphic_console_init(dev, 0, &apple_gfx_fb_ops, s); | 1342 | + s->con = graphic_console_init(dev, 0, &apple_gfx_fb_ops, s); |
1296 | + return true; | 1343 | + return true; |
... | ... | ||
1301 | +++ b/hw/display/meson.build | 1348 | +++ b/hw/display/meson.build |
1302 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_ARTIST', if_true: files('artist.c')) | 1349 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_ARTIST', if_true: files('artist.c')) |
1303 | 1350 | ||
1304 | system_ss.add(when: 'CONFIG_ATI_VGA', if_true: [files('ati.c', 'ati_2d.c', 'ati_dbg.c'), pixman]) | 1351 | system_ss.add(when: 'CONFIG_ATI_VGA', if_true: [files('ati.c', 'ati_2d.c', 'ati_dbg.c'), pixman]) |
1305 | 1352 | ||
1306 | +system_ss.add(when: 'CONFIG_MAC_PVG', if_true: [files('apple-gfx.m'), pvg, metal]) | 1353 | +if host_os == 'darwin' |
1307 | +if cpu == 'aarch64' | 1354 | + system_ss.add(when: 'CONFIG_MAC_PVG', if_true: [files('apple-gfx.m'), pvg, metal]) |
1308 | + system_ss.add(when: 'CONFIG_MAC_PVG_MMIO', if_true: [files('apple-gfx-mmio.m'), pvg, metal]) | 1355 | + if cpu == 'aarch64' |
1356 | + system_ss.add(when: 'CONFIG_MAC_PVG_MMIO', if_true: [files('apple-gfx-mmio.m'), pvg, metal]) | ||
1357 | + endif | ||
1309 | +endif | 1358 | +endif |
1310 | 1359 | ||
1311 | if config_all_devices.has_key('CONFIG_VIRTIO_GPU') | 1360 | if config_all_devices.has_key('CONFIG_VIRTIO_GPU') |
1312 | virtio_gpu_ss = ss.source_set() | 1361 | virtio_gpu_ss = ss.source_set() |
1313 | diff --git a/hw/display/trace-events b/hw/display/trace-events | 1362 | diff --git a/hw/display/trace-events b/hw/display/trace-events |
... | ... | ||
1352 | +++ b/meson.build | 1401 | +++ b/meson.build |
1353 | @@ -XXX,XX +XXX,XX @@ socket = [] | 1402 | @@ -XXX,XX +XXX,XX @@ socket = [] |
1354 | version_res = [] | 1403 | version_res = [] |
1355 | coref = [] | 1404 | coref = [] |
1356 | iokit = [] | 1405 | iokit = [] |
1357 | +pvg = [] | 1406 | +pvg = not_found |
1358 | +metal = [] | 1407 | +metal = [] |
1359 | emulator_link_args = [] | 1408 | emulator_link_args = [] |
1360 | midl = not_found | 1409 | midl = not_found |
1361 | widl = not_found | 1410 | widl = not_found |
1362 | @@ -XXX,XX +XXX,XX @@ elif host_os == 'darwin' | 1411 | @@ -XXX,XX +XXX,XX @@ elif host_os == 'darwin' |
... | ... | ||
1367 | + metal = dependency('appleframeworks', modules: 'Metal') | 1416 | + metal = dependency('appleframeworks', modules: 'Metal') |
1368 | elif host_os == 'sunos' | 1417 | elif host_os == 'sunos' |
1369 | socket = [cc.find_library('socket'), | 1418 | socket = [cc.find_library('socket'), |
1370 | cc.find_library('nsl'), | 1419 | cc.find_library('nsl'), |
1371 | -- | 1420 | -- |
1372 | 2.39.3 (Apple Git-145) | 1421 | 2.39.5 (Apple Git-154) |
1373 | 1422 | ||
1374 | 1423 | diff view generated by jsdifflib |
1 | This change wires up the PCI variant of the paravirtualised | 1 | This change wires up the PCI variant of the paravirtualised |
---|---|---|---|
2 | graphics device, mainly useful for x86-64 macOS guests, implemented | 2 | graphics device, mainly useful for x86-64 macOS guests, implemented |
3 | by macOS's ParavirtualizedGraphics.framework. It builds on code | 3 | by macOS's ParavirtualizedGraphics.framework. It builds on code |
4 | shared with the vmapple/mmio variant of the PVG device. | 4 | shared with the vmapple/mmio variant of the PVG device. |
5 | 5 | ||
6 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> | 6 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> |
7 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
7 | --- | 8 | --- |
8 | 9 | ||
9 | v4: | 10 | v4: |
10 | 11 | ||
11 | * Threading improvements analogous to those in common apple-gfx code | 12 | * Threading improvements analogous to those in common apple-gfx code |
... | ... | ||
22 | 23 | ||
23 | v9: | 24 | v9: |
24 | 25 | ||
25 | * Fixup of changed common call. | 26 | * Fixup of changed common call. |
26 | * Whitespace and comment formatting tweaks. | 27 | * Whitespace and comment formatting tweaks. |
28 | |||
29 | v11: | ||
30 | |||
31 | * Comment formatting fix. | ||
27 | 32 | ||
28 | hw/display/Kconfig | 4 + | 33 | hw/display/Kconfig | 4 + |
29 | hw/display/apple-gfx-pci.m | 150 +++++++++++++++++++++++++++++++++++++ | 34 | hw/display/apple-gfx-pci.m | 150 +++++++++++++++++++++++++++++++++++++ |
30 | hw/display/meson.build | 1 + | 35 | hw/display/meson.build | 1 + |
31 | 3 files changed, 155 insertions(+) | 36 | 3 files changed, 155 insertions(+) |
... | ... | ||
179 | + pci->vendor_id = PG_PCI_VENDOR_ID; | 184 | + pci->vendor_id = PG_PCI_VENDOR_ID; |
180 | + pci->device_id = PG_PCI_DEVICE_ID; | 185 | + pci->device_id = PG_PCI_DEVICE_ID; |
181 | + pci->class_id = PCI_CLASS_DISPLAY_OTHER; | 186 | + pci->class_id = PCI_CLASS_DISPLAY_OTHER; |
182 | + pci->realize = apple_gfx_pci_realize; | 187 | + pci->realize = apple_gfx_pci_realize; |
183 | + | 188 | + |
184 | + // TODO: Property for setting mode list | 189 | + /* TODO: Property for setting mode list */ |
185 | +} | 190 | +} |
186 | + | 191 | + |
187 | +static TypeInfo apple_gfx_pci_types[] = { | 192 | +static TypeInfo apple_gfx_pci_types[] = { |
188 | + { | 193 | + { |
189 | + .name = TYPE_APPLE_GFX_PCI, | 194 | + .name = TYPE_APPLE_GFX_PCI, |
... | ... | ||
201 | + | 206 | + |
202 | diff --git a/hw/display/meson.build b/hw/display/meson.build | 207 | diff --git a/hw/display/meson.build b/hw/display/meson.build |
203 | index XXXXXXX..XXXXXXX 100644 | 208 | index XXXXXXX..XXXXXXX 100644 |
204 | --- a/hw/display/meson.build | 209 | --- a/hw/display/meson.build |
205 | +++ b/hw/display/meson.build | 210 | +++ b/hw/display/meson.build |
206 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_MAC_PVG', if_true: [files('apple-gfx.m'), pv | 211 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_ATI_VGA', if_true: [files('ati.c', 'ati_2d.c', 'ati_ |
207 | if cpu == 'aarch64' | 212 | |
208 | system_ss.add(when: 'CONFIG_MAC_PVG_MMIO', if_true: [files('apple-gfx-mmio.m'), pvg, metal]) | 213 | if host_os == 'darwin' |
209 | endif | 214 | system_ss.add(when: 'CONFIG_MAC_PVG', if_true: [files('apple-gfx.m'), pvg, metal]) |
210 | +system_ss.add(when: 'CONFIG_MAC_PVG_PCI', if_true: [files('apple-gfx-pci.m'), pvg, metal]) | 215 | + system_ss.add(when: 'CONFIG_MAC_PVG_PCI', if_true: [files('apple-gfx-pci.m'), pvg, metal]) |
211 | 216 | if cpu == 'aarch64' | |
212 | if config_all_devices.has_key('CONFIG_VIRTIO_GPU') | 217 | system_ss.add(when: 'CONFIG_MAC_PVG_MMIO', if_true: [files('apple-gfx-mmio.m'), pvg, metal]) |
213 | virtio_gpu_ss = ss.source_set() | 218 | endif |
214 | -- | 219 | -- |
215 | 2.39.3 (Apple Git-145) | 220 | 2.39.5 (Apple Git-154) |
216 | 221 | ||
217 | 222 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
6 | less awkward to use, for example: | 6 | less awkward to use, for example: |
7 | 7 | ||
8 | -device '{"driver":"apple-gfx-pci", "display-modes":["1920x1080@60", "3840x2160@60"]}' | 8 | -device '{"driver":"apple-gfx-pci", "display-modes":["1920x1080@60", "3840x2160@60"]}' |
9 | 9 | ||
10 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> | 10 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> |
11 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
12 | Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
11 | --- | 13 | --- |
12 | 14 | ||
13 | v4: | 15 | v4: |
14 | 16 | ||
15 | * Switched to the native array property type, which recently gained | 17 | * Switched to the native array property type, which recently gained |
... | ... | ||
92 | DeviceClass *dc = DEVICE_CLASS(klass); | 94 | DeviceClass *dc = DEVICE_CLASS(klass); |
93 | @@ -XXX,XX +XXX,XX @@ static void apple_gfx_pci_class_init(ObjectClass *klass, void *data) | 95 | @@ -XXX,XX +XXX,XX @@ static void apple_gfx_pci_class_init(ObjectClass *klass, void *data) |
94 | pci->class_id = PCI_CLASS_DISPLAY_OTHER; | 96 | pci->class_id = PCI_CLASS_DISPLAY_OTHER; |
95 | pci->realize = apple_gfx_pci_realize; | 97 | pci->realize = apple_gfx_pci_realize; |
96 | 98 | ||
97 | - // TODO: Property for setting mode list | 99 | - /* TODO: Property for setting mode list */ |
98 | + device_class_set_props(dc, apple_gfx_pci_properties); | 100 | + device_class_set_props(dc, apple_gfx_pci_properties); |
99 | } | 101 | } |
100 | 102 | ||
101 | static TypeInfo apple_gfx_pci_types[] = { | 103 | static TypeInfo apple_gfx_pci_types[] = { |
102 | diff --git a/hw/display/apple-gfx.h b/hw/display/apple-gfx.h | 104 | diff --git a/hw/display/apple-gfx.h b/hw/display/apple-gfx.h |
... | ... | ||
123 | + | 125 | + |
124 | typedef struct AppleGFXState { | 126 | typedef struct AppleGFXState { |
125 | /* Initialised on init/realize() */ | 127 | /* Initialised on init/realize() */ |
126 | MemoryRegion iomem_gfx; | 128 | MemoryRegion iomem_gfx; |
127 | @@ -XXX,XX +XXX,XX @@ typedef struct AppleGFXState { | 129 | @@ -XXX,XX +XXX,XX @@ typedef struct AppleGFXState { |
130 | QemuConsole *con; | ||
128 | id<MTLDevice> mtl; | 131 | id<MTLDevice> mtl; |
129 | id<MTLCommandQueue> mtl_queue; | 132 | id<MTLCommandQueue> mtl_queue; |
130 | dispatch_queue_t render_queue; | ||
131 | + AppleGFXDisplayMode *display_modes; | 133 | + AppleGFXDisplayMode *display_modes; |
132 | + uint32_t num_display_modes; | 134 | + uint32_t num_display_modes; |
133 | 135 | ||
134 | /* List `tasks` is protected by task_mutex */ | 136 | /* List `tasks` is protected by task_mutex */ |
135 | QemuMutex task_mutex; | 137 | QemuMutex task_mutex; |
... | ... | ||
156 | + { 1920, 1080, 60 }, | 158 | + { 1920, 1080, 60 }, |
157 | + { 1440, 1080, 60 }, | 159 | + { 1440, 1080, 60 }, |
158 | + { 1280, 1024, 60 }, | 160 | + { 1280, 1024, 60 }, |
159 | }; | 161 | }; |
160 | 162 | ||
161 | /* ------ PGTask and task operations: new/destroy/map/unmap ------ */ | 163 | static Error *apple_gfx_mig_blocker; |
162 | @@ -XXX,XX +XXX,XX @@ static void apple_gfx_register_task_mapping_handlers(AppleGFXState *s, | 164 | @@ -XXX,XX +XXX,XX @@ static void new_frame_handler_bh(void *opaque) |
163 | return disp_desc; | 165 | return disp_desc; |
164 | } | 166 | } |
165 | 167 | ||
166 | -static NSArray<PGDisplayMode*>* apple_gfx_prepare_display_mode_array(void) | 168 | -static NSArray<PGDisplayMode*>* apple_gfx_prepare_display_mode_array(void) |
167 | +static NSArray<PGDisplayMode *> *apple_gfx_create_display_mode_array( | 169 | +static NSArray<PGDisplayMode *> *apple_gfx_create_display_mode_array( |
168 | + const AppleGFXDisplayMode display_modes[], uint32_t display_mode_count) | 170 | + const AppleGFXDisplayMode display_modes[], uint32_t display_mode_count) |
169 | { | 171 | { |
170 | - PGDisplayMode *modes[ARRAY_SIZE(apple_gfx_modes)]; | 172 | - PGDisplayMode *modes[ARRAY_SIZE(apple_gfx_modes)]; |
171 | - NSArray<PGDisplayMode*>* mode_array = nil; | 173 | - NSArray<PGDisplayMode*>* mode_array; |
172 | - int i; | 174 | - int i; |
173 | - | 175 | - |
174 | - for (i = 0; i < ARRAY_SIZE(apple_gfx_modes); i++) { | 176 | - for (i = 0; i < ARRAY_SIZE(apple_gfx_modes); i++) { |
175 | - modes[i] = | 177 | - modes[i] = |
176 | - [[PGDisplayMode alloc] initWithSizeInPixels:apple_gfx_modes[i] refreshRateInHz:60.]; | 178 | - [[PGDisplayMode alloc] initWithSizeInPixels:apple_gfx_modes[i] refreshRateInHz:60.]; |
... | ... | ||
200 | 202 | ||
201 | return mode_array; | 203 | return mode_array; |
202 | @@ -XXX,XX +XXX,XX @@ bool apple_gfx_common_realize(AppleGFXState *s, DeviceState *dev, | 204 | @@ -XXX,XX +XXX,XX @@ bool apple_gfx_common_realize(AppleGFXState *s, DeviceState *dev, |
203 | PGDeviceDescriptor *desc, Error **errp) | 205 | PGDeviceDescriptor *desc, Error **errp) |
204 | { | 206 | { |
205 | PGDisplayDescriptor *disp_desc = nil; | 207 | PGDisplayDescriptor *disp_desc; |
206 | + const AppleGFXDisplayMode *display_modes = apple_gfx_default_modes; | 208 | + const AppleGFXDisplayMode *display_modes = apple_gfx_default_modes; |
207 | + uint32_t num_display_modes = ARRAY_SIZE(apple_gfx_default_modes); | 209 | + uint32_t num_display_modes = ARRAY_SIZE(apple_gfx_default_modes); |
208 | + NSArray<PGDisplayMode *> *mode_array; | 210 | + NSArray<PGDisplayMode *> *mode_array; |
209 | 211 | ||
210 | if (apple_gfx_mig_blocker == NULL) { | 212 | if (apple_gfx_mig_blocker == NULL) { |
211 | error_setg(&apple_gfx_mig_blocker, | 213 | error_setg(&apple_gfx_mig_blocker, |
212 | @@ -XXX,XX +XXX,XX @@ bool apple_gfx_common_realize(AppleGFXState *s, DeviceState *dev, | 214 | @@ -XXX,XX +XXX,XX @@ bool apple_gfx_common_realize(AppleGFXState *s, DeviceState *dev, |
213 | s->pgdisp = [s->pgdev newDisplayWithDescriptor:disp_desc | 215 | port:0 |
214 | port:0 serialNum:1234]; | 216 | serialNum:next_pgdisplay_serial_num++]; |
215 | [disp_desc release]; | 217 | [disp_desc release]; |
216 | - s->pgdisp.modeList = apple_gfx_prepare_display_mode_array(); | 218 | - s->pgdisp.modeList = apple_gfx_prepare_display_mode_array(); |
217 | + | 219 | + |
218 | + if (s->display_modes != NULL && s->num_display_modes > 0) { | 220 | + if (s->display_modes != NULL && s->num_display_modes > 0) { |
219 | + trace_apple_gfx_common_realize_modes_property(s->num_display_modes); | 221 | + trace_apple_gfx_common_realize_modes_property(s->num_display_modes); |
... | ... | ||
322 | +apple_gfx_display_mode(uint32_t mode_idx, uint16_t width_px, uint16_t height_px) "mode %2"PRIu32": %4"PRIu16"x%4"PRIu16 | 324 | +apple_gfx_display_mode(uint32_t mode_idx, uint16_t width_px, uint16_t height_px) "mode %2"PRIu32": %4"PRIu16"x%4"PRIu16 |
323 | 325 | ||
324 | # apple-gfx-mmio.m | 326 | # apple-gfx-mmio.m |
325 | apple_gfx_mmio_iosfc_read(uint64_t offset, uint64_t res) "offset=0x%"PRIx64" res=0x%"PRIx64 | 327 | apple_gfx_mmio_iosfc_read(uint64_t offset, uint64_t res) "offset=0x%"PRIx64" res=0x%"PRIx64 |
326 | -- | 328 | -- |
327 | 2.39.3 (Apple Git-145) | 329 | 2.39.5 (Apple Git-154) | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
47 | + | 47 | + |
48 | PIIX4 South Bridge (i82371AB) | 48 | PIIX4 South Bridge (i82371AB) |
49 | M: Hervé Poussineau <hpoussin@reactos.org> | 49 | M: Hervé Poussineau <hpoussin@reactos.org> |
50 | M: Philippe Mathieu-Daudé <philmd@linaro.org> | 50 | M: Philippe Mathieu-Daudé <philmd@linaro.org> |
51 | -- | 51 | -- |
52 | 2.39.3 (Apple Git-145) | 52 | 2.39.5 (Apple Git-154) |
53 | 53 | ||
54 | 54 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
5 | a single target directory. | 5 | a single target directory. |
6 | 6 | ||
7 | Signed-off-by: Alexander Graf <graf@amazon.com> | 7 | Signed-off-by: Alexander Graf <graf@amazon.com> |
8 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> | 8 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> |
9 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | 9 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> |
10 | Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
10 | --- | 11 | --- |
11 | MAINTAINERS | 7 +++++++ | 12 | MAINTAINERS | 7 +++++++ |
12 | hw/Kconfig | 1 + | 13 | hw/Kconfig | 1 + |
13 | hw/meson.build | 1 + | 14 | hw/meson.build | 1 + |
14 | hw/vmapple/Kconfig | 1 + | 15 | hw/vmapple/Kconfig | 1 + |
... | ... | ||
100 | + 'hw/vmapple', | 101 | + 'hw/vmapple', |
101 | 'hw/watchdog', | 102 | 'hw/watchdog', |
102 | 'hw/xen', | 103 | 'hw/xen', |
103 | 'hw/gpio', | 104 | 'hw/gpio', |
104 | -- | 105 | -- |
105 | 2.39.3 (Apple Git-145) | 106 | 2.39.5 (Apple Git-154) | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
6 | Signed-off-by: Alexander Graf <graf@amazon.com> | 6 | Signed-off-by: Alexander Graf <graf@amazon.com> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 8 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> | 9 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> |
10 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | 10 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> |
11 | Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
11 | --- | 12 | --- |
12 | 13 | ||
13 | v3: | 14 | v3: |
14 | * Rebased on upstream, updated a header path | 15 | * Rebased on upstream, updated a header path |
15 | 16 | ||
... | ... | ||
125 | +#define TYPE_PVPANIC_MMIO_DEVICE "pvpanic-mmio" | 126 | +#define TYPE_PVPANIC_MMIO_DEVICE "pvpanic-mmio" |
126 | 127 | ||
127 | #define PVPANIC_IOPORT_PROP "ioport" | 128 | #define PVPANIC_IOPORT_PROP "ioport" |
128 | 129 | ||
129 | -- | 130 | -- |
130 | 2.39.3 (Apple Git-145) | 131 | 2.39.5 (Apple Git-154) |
131 | 132 | ||
132 | 133 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
5 | a full physical timer emulation, so let's just ignore those writes. | 5 | a full physical timer emulation, so let's just ignore those writes. |
6 | 6 | ||
7 | Signed-off-by: Alexander Graf <graf@amazon.com> | 7 | Signed-off-by: Alexander Graf <graf@amazon.com> |
8 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> | 8 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> |
9 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | 9 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> |
10 | Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
10 | --- | 11 | --- |
11 | target/arm/hvf/hvf.c | 9 +++++++++ | 12 | target/arm/hvf/hvf.c | 9 +++++++++ |
12 | 1 file changed, 9 insertions(+) | 13 | 1 file changed, 9 insertions(+) |
13 | 14 | ||
14 | diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c | 15 | diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c |
... | ... | ||
44 | + return 0; | 45 | + return 0; |
45 | case SYSREG_OSDLR_EL1: | 46 | case SYSREG_OSDLR_EL1: |
46 | /* Dummy register */ | 47 | /* Dummy register */ |
47 | return 0; | 48 | return 0; |
48 | -- | 49 | -- |
49 | 2.39.3 (Apple Git-145) | 50 | 2.39.5 (Apple Git-154) | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
7 | In this mode, GPEX will export more IRQ lines, one for each device. | 7 | In this mode, GPEX will export more IRQ lines, one for each device. |
8 | 8 | ||
9 | Signed-off-by: Alexander Graf <graf@amazon.com> | 9 | Signed-off-by: Alexander Graf <graf@amazon.com> |
10 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> | 10 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> |
11 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | 11 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> |
12 | Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
12 | --- | 13 | --- |
13 | 14 | ||
14 | v4: | 15 | v4: |
15 | 16 | ||
16 | * Turned pair of IRQ arrays into array of structs. | 17 | * Turned pair of IRQ arrays into array of structs. |
17 | * Simplified swizzling logic selection. | 18 | * Simplified swizzling logic selection. |
19 | |||
20 | v12: | ||
21 | |||
22 | * Fixed uses of deleted GPEX_NUM_IRQS constant that have been | ||
23 | added to QEMU since this patch was originally written. | ||
18 | 24 | ||
19 | hw/arm/sbsa-ref.c | 2 +- | 25 | hw/arm/sbsa-ref.c | 2 +- |
20 | hw/arm/virt.c | 2 +- | 26 | hw/arm/virt.c | 2 +- |
21 | hw/i386/microvm.c | 2 +- | 27 | hw/i386/microvm.c | 2 +- |
22 | hw/loongarch/virt.c | 2 +- | 28 | hw/loongarch/virt.c | 12 +++++------ |
23 | hw/mips/loongson3_virt.c | 2 +- | 29 | hw/mips/loongson3_virt.c | 2 +- |
24 | hw/openrisc/virt.c | 12 +++++------ | 30 | hw/openrisc/virt.c | 12 +++++------ |
25 | hw/pci-host/gpex.c | 43 ++++++++++++++++++++++++++++++-------- | 31 | hw/pci-host/gpex.c | 43 ++++++++++++++++++++++++++++++-------- |
26 | hw/riscv/virt.c | 12 +++++------ | 32 | hw/riscv/virt.c | 12 +++++------ |
33 | hw/xen/xen-pvh-common.c | 2 +- | ||
27 | hw/xtensa/virt.c | 2 +- | 34 | hw/xtensa/virt.c | 2 +- |
28 | include/hw/pci-host/gpex.h | 7 +++---- | 35 | include/hw/pci-host/gpex.h | 7 +++---- |
29 | 10 files changed, 55 insertions(+), 31 deletions(-) | 36 | 11 files changed, 61 insertions(+), 37 deletions(-) |
30 | 37 | ||
31 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | 38 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
32 | index XXXXXXX..XXXXXXX 100644 | 39 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/hw/arm/sbsa-ref.c | 40 | --- a/hw/arm/sbsa-ref.c |
34 | +++ b/hw/arm/sbsa-ref.c | 41 | +++ b/hw/arm/sbsa-ref.c |
... | ... | ||
69 | } | 76 | } |
70 | diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c | 77 | diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c |
71 | index XXXXXXX..XXXXXXX 100644 | 78 | index XXXXXXX..XXXXXXX 100644 |
72 | --- a/hw/loongarch/virt.c | 79 | --- a/hw/loongarch/virt.c |
73 | +++ b/hw/loongarch/virt.c | 80 | +++ b/hw/loongarch/virt.c |
81 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_pcie_irq_map_node(const LoongArchVirtMachineState *lvms, | ||
82 | { | ||
83 | int pin, dev; | ||
84 | uint32_t irq_map_stride = 0; | ||
85 | - uint32_t full_irq_map[GPEX_NUM_IRQS *GPEX_NUM_IRQS * 10] = {}; | ||
86 | + uint32_t full_irq_map[PCI_NUM_PINS * PCI_NUM_PINS * 10] = {}; | ||
87 | uint32_t *irq_map = full_irq_map; | ||
88 | const MachineState *ms = MACHINE(lvms); | ||
89 | |||
90 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_pcie_irq_map_node(const LoongArchVirtMachineState *lvms, | ||
91 | * to wrap to any number of devices. | ||
92 | */ | ||
93 | |||
94 | - for (dev = 0; dev < GPEX_NUM_IRQS; dev++) { | ||
95 | + for (dev = 0; dev < PCI_NUM_PINS; dev++) { | ||
96 | int devfn = dev * 0x8; | ||
97 | |||
98 | - for (pin = 0; pin < GPEX_NUM_IRQS; pin++) { | ||
99 | - int irq_nr = 16 + ((pin + PCI_SLOT(devfn)) % GPEX_NUM_IRQS); | ||
100 | + for (pin = 0; pin < PCI_NUM_PINS; pin++) { | ||
101 | + int irq_nr = 16 + ((pin + PCI_SLOT(devfn)) % PCI_NUM_PINS); | ||
102 | int i = 0; | ||
103 | |||
104 | /* Fill PCI address cells */ | ||
105 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_pcie_irq_map_node(const LoongArchVirtMachineState *lvms, | ||
106 | |||
107 | |||
108 | qemu_fdt_setprop(ms->fdt, nodename, "interrupt-map", full_irq_map, | ||
109 | - GPEX_NUM_IRQS * GPEX_NUM_IRQS * | ||
110 | + PCI_NUM_PINS * PCI_NUM_PINS * | ||
111 | irq_map_stride * sizeof(uint32_t)); | ||
112 | qemu_fdt_setprop_cells(ms->fdt, nodename, "interrupt-map-mask", | ||
113 | 0x1800, 0, 0, 0x7); | ||
74 | @@ -XXX,XX +XXX,XX @@ static void virt_devices_init(DeviceState *pch_pic, | 114 | @@ -XXX,XX +XXX,XX @@ static void virt_devices_init(DeviceState *pch_pic, |
75 | memory_region_add_subregion(get_system_memory(), VIRT_PCI_IO_BASE, | 115 | memory_region_add_subregion(get_system_memory(), VIRT_PCI_IO_BASE, |
76 | pio_alias); | 116 | pio_alias); |
77 | 117 | ||
78 | - for (i = 0; i < GPEX_NUM_IRQS; i++) { | 118 | - for (i = 0; i < GPEX_NUM_IRQS; i++) { |
... | ... | ||
303 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, pio_base); | 343 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, pio_base); |
304 | 344 | ||
305 | - for (i = 0; i < GPEX_NUM_IRQS; i++) { | 345 | - for (i = 0; i < GPEX_NUM_IRQS; i++) { |
306 | + for (i = 0; i < PCI_NUM_PINS; i++) { | 346 | + for (i = 0; i < PCI_NUM_PINS; i++) { |
307 | irq = qdev_get_gpio_in(irqchip, PCIE_IRQ + i); | 347 | irq = qdev_get_gpio_in(irqchip, PCIE_IRQ + i); |
348 | |||
349 | sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, irq); | ||
350 | diff --git a/hw/xen/xen-pvh-common.c b/hw/xen/xen-pvh-common.c | ||
351 | index XXXXXXX..XXXXXXX 100644 | ||
352 | --- a/hw/xen/xen-pvh-common.c | ||
353 | +++ b/hw/xen/xen-pvh-common.c | ||
354 | @@ -XXX,XX +XXX,XX @@ static inline void xenpvh_gpex_init(XenPVHMachineState *s, | ||
355 | */ | ||
356 | assert(xpc->set_pci_intx_irq); | ||
357 | |||
358 | - for (i = 0; i < GPEX_NUM_IRQS; i++) { | ||
359 | + for (i = 0; i < PCI_NUM_PINS; i++) { | ||
360 | qemu_irq irq = qemu_allocate_irq(xpc->set_pci_intx_irq, s, i); | ||
308 | 361 | ||
309 | sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, irq); | 362 | sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, irq); |
310 | diff --git a/hw/xtensa/virt.c b/hw/xtensa/virt.c | 363 | diff --git a/hw/xtensa/virt.c b/hw/xtensa/virt.c |
311 | index XXXXXXX..XXXXXXX 100644 | 364 | index XXXXXXX..XXXXXXX 100644 |
312 | --- a/hw/xtensa/virt.c | 365 | --- a/hw/xtensa/virt.c |
... | ... | ||
351 | + uint8_t num_irqs; | 404 | + uint8_t num_irqs; |
352 | 405 | ||
353 | bool allow_unmapped_accesses; | 406 | bool allow_unmapped_accesses; |
354 | 407 | ||
355 | -- | 408 | -- |
356 | 2.39.3 (Apple Git-145) | 409 | 2.39.5 (Apple Git-154) | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
6 | 6 | ||
7 | Add device emulation for this device model. | 7 | Add device emulation for this device model. |
8 | 8 | ||
9 | Signed-off-by: Alexander Graf <graf@amazon.com> | 9 | Signed-off-by: Alexander Graf <graf@amazon.com> |
10 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> | 10 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> |
11 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
12 | Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
11 | --- | 13 | --- |
12 | 14 | ||
13 | v3: | 15 | v3: |
14 | 16 | ||
15 | * Rebased on latest upstream and fixed minor breakages. | 17 | * Rebased on latest upstream and fixed minor breakages. |
... | ... | ||
37 | v9: | 39 | v9: |
38 | 40 | ||
39 | * Replaced a use of cpu_physical_memory_write with dma_memory_write. | 41 | * Replaced a use of cpu_physical_memory_write with dma_memory_write. |
40 | * Dropped unnecessary use of ternary operator for bool -> 0/1. | 42 | * Dropped unnecessary use of ternary operator for bool -> 0/1. |
41 | 43 | ||
44 | v10: | ||
45 | |||
46 | * Code style and comment improvements. | ||
47 | |||
42 | hw/vmapple/Kconfig | 2 + | 48 | hw/vmapple/Kconfig | 2 + |
43 | hw/vmapple/aes.c | 582 +++++++++++++++++++++++++++++++++++ | 49 | hw/vmapple/aes.c | 581 +++++++++++++++++++++++++++++++++++ |
44 | hw/vmapple/meson.build | 1 + | 50 | hw/vmapple/meson.build | 1 + |
45 | hw/vmapple/trace-events | 14 + | 51 | hw/vmapple/trace-events | 14 + |
46 | include/hw/vmapple/vmapple.h | 17 + | 52 | include/hw/vmapple/vmapple.h | 17 + |
47 | include/qemu/cutils.h | 15 + | 53 | include/qemu/cutils.h | 15 + |
48 | util/hexdump.c | 18 ++ | 54 | util/hexdump.c | 18 ++ |
49 | 7 files changed, 649 insertions(+) | 55 | 7 files changed, 648 insertions(+) |
50 | create mode 100644 hw/vmapple/aes.c | 56 | create mode 100644 hw/vmapple/aes.c |
51 | create mode 100644 include/hw/vmapple/vmapple.h | 57 | create mode 100644 include/hw/vmapple/vmapple.h |
52 | 58 | ||
53 | diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig | 59 | diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig |
54 | index XXXXXXX..XXXXXXX 100644 | 60 | index XXXXXXX..XXXXXXX 100644 |
... | ... | ||
252 | + s->fifo[s->fifo_idx++] = val; | 258 | + s->fifo[s->fifo_idx++] = val; |
253 | +} | 259 | +} |
254 | + | 260 | + |
255 | +static bool has_payload(AESState *s, uint32_t elems) | 261 | +static bool has_payload(AESState *s, uint32_t elems) |
256 | +{ | 262 | +{ |
257 | + return s->fifo_idx >= (elems + 1); | 263 | + return s->fifo_idx >= elems + 1; |
258 | +} | 264 | +} |
259 | + | 265 | + |
260 | +static bool cmd_key(AESState *s) | 266 | +static bool cmd_key(AESState *s) |
261 | +{ | 267 | +{ |
262 | + uint32_t cmd = s->fifo[0]; | 268 | + uint32_t cmd = s->fifo[0]; |
... | ... | ||
355 | + return false; | 361 | + return false; |
356 | + } | 362 | + } |
357 | + | 363 | + |
358 | + if (ctxt_key >= ARRAY_SIZE(s->key) || | 364 | + if (ctxt_key >= ARRAY_SIZE(s->key) || |
359 | + ctxt_iv >= ARRAY_SIZE(s->iv)) { | 365 | + ctxt_iv >= ARRAY_SIZE(s->iv)) { |
360 | + /* Invalid input */ | ||
361 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Invalid key or iv\n", __func__); | 366 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Invalid key or iv\n", __func__); |
362 | + return false; | 367 | + return false; |
363 | + } | 368 | + } |
364 | + | 369 | + |
365 | + src = g_byte_array_sized_new(len); | 370 | + src = g_byte_array_sized_new(len); |
... | ... | ||
665 | +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" | 670 | +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" |
666 | +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" | 671 | +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" |
667 | +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" | 672 | +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" |
668 | +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" | 673 | +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" |
669 | +aes_cmd_flag(uint32_t raise, uint32_t flag_info) "raise=%d flag_info=0x%x" | 674 | +aes_cmd_flag(uint32_t raise, uint32_t flag_info) "raise=%d flag_info=0x%x" |
670 | +aes_fifo_process(uint32_t cmd, uint32_t success) "cmd=%d success=%d" | 675 | +aes_fifo_process(uint32_t cmd, bool success) "cmd=%d success=%d" |
671 | +aes_write(uint64_t offset, uint64_t val) "offset=0x%"PRIx64" val=0x%"PRIx64 | 676 | +aes_write(uint64_t offset, uint64_t val) "offset=0x%"PRIx64" val=0x%"PRIx64 |
672 | +aes_2_read(uint64_t offset, uint64_t res) "offset=0x%"PRIx64" res=0x%"PRIx64 | 677 | +aes_2_read(uint64_t offset, uint64_t res) "offset=0x%"PRIx64" res=0x%"PRIx64 |
673 | +aes_2_write(uint64_t offset, uint64_t val) "offset=0x%"PRIx64" val=0x%"PRIx64 | 678 | +aes_2_write(uint64_t offset, uint64_t val) "offset=0x%"PRIx64" val=0x%"PRIx64 |
674 | +aes_dump_data(const char *desc, const char *hex) "%s%s" | 679 | +aes_dump_data(const char *desc, const char *hex) "%s%s" |
675 | + | 680 | + |
... | ... | ||
752 | + *(buffer++) = hexdump_nibble(val & 0xf); | 757 | + *(buffer++) = hexdump_nibble(val & 0xf); |
753 | + } | 758 | + } |
754 | + *buffer = '\0'; | 759 | + *buffer = '\0'; |
755 | +} | 760 | +} |
756 | -- | 761 | -- |
757 | 2.39.3 (Apple Git-145) | 762 | 2.39.5 (Apple Git-154) |
758 | 763 | ||
759 | 764 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
8 | understanding. I left out any USB OTG parts; they're only needed for | 8 | understanding. I left out any USB OTG parts; they're only needed for |
9 | guest recovery and I don't understand the protocol yet. | 9 | guest recovery and I don't understand the protocol yet. |
10 | 10 | ||
11 | Signed-off-by: Alexander Graf <graf@amazon.com> | 11 | Signed-off-by: Alexander Graf <graf@amazon.com> |
12 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> | 12 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> |
13 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
14 | Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
13 | --- | 15 | --- |
14 | 16 | ||
15 | v4: | 17 | v4: |
16 | 18 | ||
17 | * Moved most header code to .c, rest to vmapple.h | 19 | * Moved most header code to .c, rest to vmapple.h |
... | ... | ||
23 | * Replaced an instance of g_free with g_autofree. | 25 | * Replaced an instance of g_free with g_autofree. |
24 | 26 | ||
25 | v9: | 27 | v9: |
26 | 28 | ||
27 | * Replaced uses of cpu_physical_memory_write with dma_memory_write. | 29 | * Replaced uses of cpu_physical_memory_write with dma_memory_write. |
28 | 30 | ||
29 | hw/vmapple/Kconfig | 3 + | 31 | hw/vmapple/Kconfig | 3 + |
30 | hw/vmapple/bdif.c | 275 +++++++++++++++++++++++++++++++++++ | 32 | hw/vmapple/bdif.c | 275 +++++++++++++++++++++++++++++++++++ |
31 | hw/vmapple/meson.build | 1 + | 33 | hw/vmapple/meson.build | 1 + |
32 | hw/vmapple/trace-events | 5 + | 34 | hw/vmapple/trace-events | 5 + |
33 | include/hw/vmapple/vmapple.h | 2 + | 35 | include/hw/vmapple/vmapple.h | 2 + |
... | ... | ||
356 | 358 | ||
357 | +#define TYPE_VMAPPLE_BDIF "vmapple-bdif" | 359 | +#define TYPE_VMAPPLE_BDIF "vmapple-bdif" |
358 | + | 360 | + |
359 | #endif /* HW_VMAPPLE_VMAPPLE_H */ | 361 | #endif /* HW_VMAPPLE_VMAPPLE_H */ |
360 | -- | 362 | -- |
361 | 2.39.3 (Apple Git-145) | 363 | 2.39.5 (Apple Git-154) |
362 | 364 | ||
363 | 365 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
8 | then map at the fixed location in the address space. That way, we can | 8 | then map at the fixed location in the address space. That way, we can |
9 | influence and annotate all configuration fields easily. | 9 | influence and annotate all configuration fields easily. |
10 | 10 | ||
11 | Signed-off-by: Alexander Graf <graf@amazon.com> | 11 | Signed-off-by: Alexander Graf <graf@amazon.com> |
12 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> | 12 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> |
13 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
14 | Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
13 | --- | 15 | --- |
14 | 16 | ||
15 | v3: | 17 | v3: |
16 | 18 | ||
17 | * Replaced legacy device reset method with Resettable method | 19 | * Replaced legacy device reset method with Resettable method |
... | ... | ||
32 | fixed-length strings to be more useful to users than developers. | 34 | fixed-length strings to be more useful to users than developers. |
33 | 35 | ||
34 | v8: | 36 | v8: |
35 | 37 | ||
36 | * Consistent parenthesising of macro arguments for better safety. | 38 | * Consistent parenthesising of macro arguments for better safety. |
39 | |||
40 | v10: | ||
41 | |||
42 | * Slightly tidier error reporting for overlong property values. | ||
37 | 43 | ||
38 | hw/vmapple/Kconfig | 3 + | 44 | hw/vmapple/Kconfig | 3 + |
39 | hw/vmapple/cfg.c | 196 +++++++++++++++++++++++++++++++++++ | 45 | hw/vmapple/cfg.c | 196 +++++++++++++++++++++++++++++++++++ |
40 | hw/vmapple/meson.build | 1 + | 46 | hw/vmapple/meson.build | 1 + |
41 | include/hw/vmapple/vmapple.h | 2 + | 47 | include/hw/vmapple/vmapple.h | 2 + |
... | ... | ||
139 | +static bool set_fixlen_property_or_error(char *restrict dst, | 145 | +static bool set_fixlen_property_or_error(char *restrict dst, |
140 | + const char *restrict src, | 146 | + const char *restrict src, |
141 | + size_t dst_size, Error **errp, | 147 | + size_t dst_size, Error **errp, |
142 | + const char *property_name) | 148 | + const char *property_name) |
143 | +{ | 149 | +{ |
150 | + ERRP_GUARD(); | ||
144 | + size_t len; | 151 | + size_t len; |
145 | + | 152 | + |
146 | + len = g_strlcpy(dst, src, dst_size); | 153 | + len = g_strlcpy(dst, src, dst_size); |
147 | + if (len < dst_size) { /* len does not count nul terminator */ | 154 | + if (len < dst_size) { /* len does not count nul terminator */ |
148 | + return true; | 155 | + return true; |
149 | + } | 156 | + } |
150 | + | 157 | + |
151 | + error_setg(errp, | 158 | + error_setg(errp, "Provided value too long for property '%s'", property_name); |
152 | + "Failed to set property '%s' on VMApple 'cfg' device: length " | 159 | + error_append_hint(errp, "length (%zu) exceeds maximum of %zu\n", |
153 | + "(%zu) exceeds maximum of %zu", | 160 | + len, dst_size - 1); |
154 | + property_name, len, dst_size - 1); | ||
155 | + return false; | 161 | + return false; |
156 | +} | 162 | +} |
157 | + | 163 | + |
158 | +#define set_fixlen_property_or_return(dst_array, src, errp, property_name) \ | 164 | +#define set_fixlen_property_or_return(dst_array, src, errp, property_name) \ |
159 | + do { \ | 165 | + do { \ |
... | ... | ||
273 | 279 | ||
274 | +#define TYPE_VMAPPLE_CFG "vmapple-cfg" | 280 | +#define TYPE_VMAPPLE_CFG "vmapple-cfg" |
275 | + | 281 | + |
276 | #endif /* HW_VMAPPLE_VMAPPLE_H */ | 282 | #endif /* HW_VMAPPLE_VMAPPLE_H */ |
277 | -- | 283 | -- |
278 | 2.39.3 (Apple Git-145) | 284 | 2.39.5 (Apple Git-154) |
279 | 285 | ||
280 | 286 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
8 | This patch first creates a mechanism for virtio-blk downstream classes to | 8 | This patch first creates a mechanism for virtio-blk downstream classes to |
9 | handle unknown commands. It then creates such a downstream class and a new | 9 | handle unknown commands. It then creates such a downstream class and a new |
10 | vmapple-virtio-blk-pci class which support the additional apple type config | 10 | vmapple-virtio-blk-pci class which support the additional apple type config |
11 | identifier as well as the barrier command. | 11 | identifier as well as the barrier command. |
12 | 12 | ||
13 | It then exposes 2 subclasses from that that we can use to expose root and | 13 | The 'aux' or 'root' device type are selected using the 'variant' property. |
14 | aux virtio-blk devices: "vmapple-virtio-root" and "vmapple-virtio-aux". | ||
15 | 14 | ||
16 | Signed-off-by: Alexander Graf <graf@amazon.com> | 15 | Signed-off-by: Alexander Graf <graf@amazon.com> |
17 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> | 16 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> |
18 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | 17 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> |
18 | Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
19 | --- | 19 | --- |
20 | 20 | ||
21 | v4: | 21 | v4: |
22 | 22 | ||
23 | * Use recommended object type declaration pattern. | 23 | * Use recommended object type declaration pattern. |
... | ... | ||
31 | 31 | ||
32 | v9: | 32 | v9: |
33 | 33 | ||
34 | * Correctly specify class_size for VMAppleVirtIOBlkClass | 34 | * Correctly specify class_size for VMAppleVirtIOBlkClass |
35 | 35 | ||
36 | hw/block/virtio-blk.c | 19 ++- | 36 | v10: |
37 | hw/vmapple/Kconfig | 3 + | 37 | |
38 | hw/vmapple/meson.build | 1 + | 38 | * Folded v9 patch 16/16 into this one, changing the device type design to |
39 | hw/vmapple/virtio-blk.c | 227 +++++++++++++++++++++++++++++++++ | 39 | provide a single device type with a variant property instead of 2 different |
40 | include/hw/pci/pci_ids.h | 1 + | 40 | subtypes for aux and root volumes. |
41 | include/hw/virtio/virtio-blk.h | 12 +- | 41 | * Tidied up error reporting for the variant property. |
42 | include/hw/vmapple/vmapple.h | 4 + | 42 | |
43 | 7 files changed, 262 insertions(+), 5 deletions(-) | 43 | hw/block/virtio-blk.c | 19 ++- |
44 | hw/core/qdev-properties-system.c | 8 ++ | ||
45 | hw/vmapple/Kconfig | 3 + | ||
46 | hw/vmapple/meson.build | 1 + | ||
47 | hw/vmapple/virtio-blk.c | 205 ++++++++++++++++++++++++++++ | ||
48 | include/hw/pci/pci_ids.h | 1 + | ||
49 | include/hw/qdev-properties-system.h | 5 + | ||
50 | include/hw/virtio/virtio-blk.h | 12 +- | ||
51 | include/hw/vmapple/vmapple.h | 2 + | ||
52 | qapi/virtio.json | 14 ++ | ||
53 | 10 files changed, 265 insertions(+), 5 deletions(-) | ||
44 | create mode 100644 hw/vmapple/virtio-blk.c | 54 | create mode 100644 hw/vmapple/virtio-blk.c |
45 | 55 | ||
46 | diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c | 56 | diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c |
47 | index XXXXXXX..XXXXXXX 100644 | 57 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/hw/block/virtio-blk.c | 58 | --- a/hw/block/virtio-blk.c |
... | ... | ||
89 | .class_init = virtio_blk_class_init, | 99 | .class_init = virtio_blk_class_init, |
90 | + .class_size = sizeof(VirtIOBlkClass), | 100 | + .class_size = sizeof(VirtIOBlkClass), |
91 | }; | 101 | }; |
92 | 102 | ||
93 | static void virtio_register_types(void) | 103 | static void virtio_register_types(void) |
104 | diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c | ||
105 | index XXXXXXX..XXXXXXX 100644 | ||
106 | --- a/hw/core/qdev-properties-system.c | ||
107 | +++ b/hw/core/qdev-properties-system.c | ||
108 | @@ -XXX,XX +XXX,XX @@ const PropertyInfo qdev_prop_iothread_vq_mapping_list = { | ||
109 | .set = set_iothread_vq_mapping_list, | ||
110 | .release = release_iothread_vq_mapping_list, | ||
111 | }; | ||
112 | + | ||
113 | +const PropertyInfo qdev_prop_vmapple_virtio_blk_variant = { | ||
114 | + .name = "VMAppleVirtioBlkVariant", | ||
115 | + .enum_table = &VMAppleVirtioBlkVariant_lookup, | ||
116 | + .get = qdev_propinfo_get_enum, | ||
117 | + .set = qdev_propinfo_set_enum, | ||
118 | + .set_default_value = qdev_propinfo_set_default_value_enum, | ||
119 | +}; | ||
94 | diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig | 120 | diff --git a/hw/vmapple/Kconfig b/hw/vmapple/Kconfig |
95 | index XXXXXXX..XXXXXXX 100644 | 121 | index XXXXXXX..XXXXXXX 100644 |
96 | --- a/hw/vmapple/Kconfig | 122 | --- a/hw/vmapple/Kconfig |
97 | +++ b/hw/vmapple/Kconfig | 123 | +++ b/hw/vmapple/Kconfig |
98 | @@ -XXX,XX +XXX,XX @@ config VMAPPLE_BDIF | 124 | @@ -XXX,XX +XXX,XX @@ config VMAPPLE_BDIF |
... | ... | ||
141 | +#include "qemu/bswap.h" | 167 | +#include "qemu/bswap.h" |
142 | +#include "qemu/log.h" | 168 | +#include "qemu/log.h" |
143 | +#include "qemu/module.h" | 169 | +#include "qemu/module.h" |
144 | +#include "qapi/error.h" | 170 | +#include "qapi/error.h" |
145 | + | 171 | + |
172 | +#define TYPE_VMAPPLE_VIRTIO_BLK "vmapple-virtio-blk" | ||
146 | +OBJECT_DECLARE_TYPE(VMAppleVirtIOBlk, VMAppleVirtIOBlkClass, VMAPPLE_VIRTIO_BLK) | 173 | +OBJECT_DECLARE_TYPE(VMAppleVirtIOBlk, VMAppleVirtIOBlkClass, VMAPPLE_VIRTIO_BLK) |
147 | + | 174 | + |
148 | +typedef struct VMAppleVirtIOBlkClass { | 175 | +typedef struct VMAppleVirtIOBlkClass { |
149 | + VirtIOBlkClass parent; | 176 | + VirtIOBlkClass parent; |
150 | + | 177 | + |
... | ... | ||
158 | +} VMAppleVirtIOBlk; | 185 | +} VMAppleVirtIOBlk; |
159 | + | 186 | + |
160 | +/* | 187 | +/* |
161 | + * vmapple-virtio-blk-pci: This extends VirtioPCIProxy. | 188 | + * vmapple-virtio-blk-pci: This extends VirtioPCIProxy. |
162 | + */ | 189 | + */ |
163 | +#define TYPE_VMAPPLE_VIRTIO_BLK_PCI "vmapple-virtio-blk-pci-base" | ||
164 | +OBJECT_DECLARE_SIMPLE_TYPE(VMAppleVirtIOBlkPCI, VMAPPLE_VIRTIO_BLK_PCI) | 190 | +OBJECT_DECLARE_SIMPLE_TYPE(VMAppleVirtIOBlkPCI, VMAPPLE_VIRTIO_BLK_PCI) |
165 | + | 191 | + |
166 | +#define VIRTIO_BLK_T_APPLE_BARRIER 0x10000 | 192 | +#define VIRTIO_BLK_T_APPLE_BARRIER 0x10000 |
167 | + | ||
168 | +#define VIRTIO_APPLE_TYPE_ROOT 1 | ||
169 | +#define VIRTIO_APPLE_TYPE_AUX 2 | ||
170 | + | 193 | + |
171 | +static bool vmapple_virtio_blk_handle_unknown_request(VirtIOBlockReq *req, | 194 | +static bool vmapple_virtio_blk_handle_unknown_request(VirtIOBlockReq *req, |
172 | + MultiReqBuffer *mrb, | 195 | + MultiReqBuffer *mrb, |
173 | + uint32_t type) | 196 | + uint32_t type) |
174 | +{ | 197 | +{ |
... | ... | ||
226 | +/* PCI Devices */ | 249 | +/* PCI Devices */ |
227 | + | 250 | + |
228 | +struct VMAppleVirtIOBlkPCI { | 251 | +struct VMAppleVirtIOBlkPCI { |
229 | + VirtIOPCIProxy parent_obj; | 252 | + VirtIOPCIProxy parent_obj; |
230 | + VMAppleVirtIOBlk vdev; | 253 | + VMAppleVirtIOBlk vdev; |
231 | + uint32_t apple_type; | 254 | + VMAppleVirtioBlkVariant variant; |
232 | +}; | 255 | +}; |
233 | + | 256 | + |
234 | + | 257 | + |
235 | +static Property vmapple_virtio_blk_pci_properties[] = { | 258 | +static Property vmapple_virtio_blk_pci_properties[] = { |
236 | + DEFINE_PROP_UINT32("class", VirtIOPCIProxy, class_code, 0), | 259 | + DEFINE_PROP_UINT32("class", VirtIOPCIProxy, class_code, 0), |
237 | + DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, | 260 | + DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, |
238 | + VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), | 261 | + VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), |
239 | + DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, | 262 | + DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, |
240 | + DEV_NVECTORS_UNSPECIFIED), | 263 | + DEV_NVECTORS_UNSPECIFIED), |
264 | + DEFINE_PROP_VMAPPLE_VIRTIO_BLK_VARIANT("variant", VMAppleVirtIOBlkPCI, variant, | ||
265 | + VM_APPLE_VIRTIO_BLK_VARIANT_UNSPECIFIED), | ||
241 | + DEFINE_PROP_END_OF_LIST(), | 266 | + DEFINE_PROP_END_OF_LIST(), |
242 | +}; | 267 | +}; |
243 | + | 268 | + |
244 | +static void vmapple_virtio_blk_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) | 269 | +static void vmapple_virtio_blk_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) |
245 | +{ | 270 | +{ |
271 | + ERRP_GUARD(); | ||
246 | + VMAppleVirtIOBlkPCI *dev = VMAPPLE_VIRTIO_BLK_PCI(vpci_dev); | 272 | + VMAppleVirtIOBlkPCI *dev = VMAPPLE_VIRTIO_BLK_PCI(vpci_dev); |
247 | + DeviceState *vdev = DEVICE(&dev->vdev); | 273 | + DeviceState *vdev = DEVICE(&dev->vdev); |
248 | + VirtIOBlkConf *conf = &dev->vdev.parent_obj.conf; | 274 | + VirtIOBlkConf *conf = &dev->vdev.parent_obj.conf; |
275 | + | ||
276 | + if (dev->variant == VM_APPLE_VIRTIO_BLK_VARIANT_UNSPECIFIED) { | ||
277 | + error_setg(errp, "vmapple virtio block device variant unspecified"); | ||
278 | + error_append_hint(errp, | ||
279 | + "Variant property must be set to 'aux' or 'root'.\n" | ||
280 | + "Use a regular virtio-blk-pci device instead when " | ||
281 | + "neither is applicaple.\n"); | ||
282 | + return; | ||
283 | + } | ||
249 | + | 284 | + |
250 | + if (conf->num_queues == VIRTIO_BLK_AUTO_NUM_QUEUES) { | 285 | + if (conf->num_queues == VIRTIO_BLK_AUTO_NUM_QUEUES) { |
251 | + conf->num_queues = virtio_pci_optimal_num_queues(0); | 286 | + conf->num_queues = virtio_pci_optimal_num_queues(0); |
252 | + } | 287 | + } |
253 | + | 288 | + |
... | ... | ||
260 | + * Let's just expose the feature so the rest of the virtio-blk logic | 295 | + * Let's just expose the feature so the rest of the virtio-blk logic |
261 | + * allocates enough space for us. The guest will ignore zones anyway. | 296 | + * allocates enough space for us. The guest will ignore zones anyway. |
262 | + */ | 297 | + */ |
263 | + virtio_add_feature(&dev->vdev.parent_obj.host_features, VIRTIO_BLK_F_ZONED); | 298 | + virtio_add_feature(&dev->vdev.parent_obj.host_features, VIRTIO_BLK_F_ZONED); |
264 | + /* Propagate the apple type down to the virtio-blk device */ | 299 | + /* Propagate the apple type down to the virtio-blk device */ |
265 | + dev->vdev.apple_type = dev->apple_type; | 300 | + dev->vdev.apple_type = dev->variant; |
266 | + /* and spawn the virtio-blk device */ | 301 | + /* and spawn the virtio-blk device */ |
267 | + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); | 302 | + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); |
268 | + | 303 | + |
269 | + /* | 304 | + /* |
270 | + * The virtio-pci machinery adjusts its vendor/device ID based on whether | 305 | + * The virtio-pci machinery adjusts its vendor/device ID based on whether |
... | ... | ||
298 | + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), | 333 | + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), |
299 | + TYPE_VMAPPLE_VIRTIO_BLK); | 334 | + TYPE_VMAPPLE_VIRTIO_BLK); |
300 | +} | 335 | +} |
301 | + | 336 | + |
302 | +static const VirtioPCIDeviceTypeInfo vmapple_virtio_blk_pci_info = { | 337 | +static const VirtioPCIDeviceTypeInfo vmapple_virtio_blk_pci_info = { |
303 | + .base_name = TYPE_VMAPPLE_VIRTIO_BLK_PCI, | 338 | + .generic_name = TYPE_VMAPPLE_VIRTIO_BLK_PCI, |
304 | + .generic_name = "vmapple-virtio-blk-pci", | ||
305 | + .instance_size = sizeof(VMAppleVirtIOBlkPCI), | 339 | + .instance_size = sizeof(VMAppleVirtIOBlkPCI), |
306 | + .instance_init = vmapple_virtio_blk_pci_instance_init, | 340 | + .instance_init = vmapple_virtio_blk_pci_instance_init, |
307 | + .class_init = vmapple_virtio_blk_pci_class_init, | 341 | + .class_init = vmapple_virtio_blk_pci_class_init, |
308 | +}; | 342 | +}; |
309 | + | 343 | + |
310 | +static void vmapple_virtio_root_instance_init(Object *obj) | ||
311 | +{ | ||
312 | + VMAppleVirtIOBlkPCI *dev = VMAPPLE_VIRTIO_BLK_PCI(obj); | ||
313 | + | ||
314 | + dev->apple_type = VIRTIO_APPLE_TYPE_ROOT; | ||
315 | +} | ||
316 | + | ||
317 | +static const TypeInfo vmapple_virtio_root_info = { | ||
318 | + .name = TYPE_VMAPPLE_VIRTIO_ROOT, | ||
319 | + .parent = "vmapple-virtio-blk-pci", | ||
320 | + .instance_size = sizeof(VMAppleVirtIOBlkPCI), | ||
321 | + .instance_init = vmapple_virtio_root_instance_init, | ||
322 | +}; | ||
323 | + | ||
324 | +static void vmapple_virtio_aux_instance_init(Object *obj) | ||
325 | +{ | ||
326 | + VMAppleVirtIOBlkPCI *dev = VMAPPLE_VIRTIO_BLK_PCI(obj); | ||
327 | + | ||
328 | + dev->apple_type = VIRTIO_APPLE_TYPE_AUX; | ||
329 | +} | ||
330 | + | ||
331 | +static const TypeInfo vmapple_virtio_aux_info = { | ||
332 | + .name = TYPE_VMAPPLE_VIRTIO_AUX, | ||
333 | + .parent = "vmapple-virtio-blk-pci", | ||
334 | + .instance_size = sizeof(VMAppleVirtIOBlkPCI), | ||
335 | + .instance_init = vmapple_virtio_aux_instance_init, | ||
336 | +}; | ||
337 | + | ||
338 | +static void vmapple_virtio_blk_register_types(void) | 344 | +static void vmapple_virtio_blk_register_types(void) |
339 | +{ | 345 | +{ |
340 | + type_register_static(&vmapple_virtio_blk_info); | 346 | + type_register_static(&vmapple_virtio_blk_info); |
341 | + virtio_pci_types_register(&vmapple_virtio_blk_pci_info); | 347 | + virtio_pci_types_register(&vmapple_virtio_blk_pci_info); |
342 | + type_register_static(&vmapple_virtio_root_info); | ||
343 | + type_register_static(&vmapple_virtio_aux_info); | ||
344 | +} | 348 | +} |
345 | + | 349 | + |
346 | +type_init(vmapple_virtio_blk_register_types) | 350 | +type_init(vmapple_virtio_blk_register_types) |
347 | diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h | 351 | diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h |
348 | index XXXXXXX..XXXXXXX 100644 | 352 | index XXXXXXX..XXXXXXX 100644 |
... | ... | ||
354 | #define PCI_DEVICE_ID_APPLE_UNI_N_GMAC 0x0021 | 358 | #define PCI_DEVICE_ID_APPLE_UNI_N_GMAC 0x0021 |
355 | +#define PCI_DEVICE_ID_APPLE_VIRTIO_BLK 0x1a00 | 359 | +#define PCI_DEVICE_ID_APPLE_VIRTIO_BLK 0x1a00 |
356 | 360 | ||
357 | #define PCI_VENDOR_ID_SUN 0x108e | 361 | #define PCI_VENDOR_ID_SUN 0x108e |
358 | #define PCI_DEVICE_ID_SUN_EBUS 0x1000 | 362 | #define PCI_DEVICE_ID_SUN_EBUS 0x1000 |
363 | diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properties-system.h | ||
364 | index XXXXXXX..XXXXXXX 100644 | ||
365 | --- a/include/hw/qdev-properties-system.h | ||
366 | +++ b/include/hw/qdev-properties-system.h | ||
367 | @@ -XXX,XX +XXX,XX @@ extern const PropertyInfo qdev_prop_pcie_link_speed; | ||
368 | extern const PropertyInfo qdev_prop_pcie_link_width; | ||
369 | extern const PropertyInfo qdev_prop_cpus390entitlement; | ||
370 | extern const PropertyInfo qdev_prop_iothread_vq_mapping_list; | ||
371 | +extern const PropertyInfo qdev_prop_vmapple_virtio_blk_variant; | ||
372 | |||
373 | #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \ | ||
374 | DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t) | ||
375 | @@ -XXX,XX +XXX,XX @@ extern const PropertyInfo qdev_prop_iothread_vq_mapping_list; | ||
376 | DEFINE_PROP(_name, _state, _field, qdev_prop_iothread_vq_mapping_list, \ | ||
377 | IOThreadVirtQueueMappingList *) | ||
378 | |||
379 | +#define DEFINE_PROP_VMAPPLE_VIRTIO_BLK_VARIANT(_n, _s, _f, _d) \ | ||
380 | + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_vmapple_virtio_blk_variant, \ | ||
381 | + VMAppleVirtioBlkVariant) | ||
382 | + | ||
383 | #endif | ||
359 | diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h | 384 | diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h |
360 | index XXXXXXX..XXXXXXX 100644 | 385 | index XXXXXXX..XXXXXXX 100644 |
361 | --- a/include/hw/virtio/virtio-blk.h | 386 | --- a/include/hw/virtio/virtio-blk.h |
362 | +++ b/include/hw/virtio/virtio-blk.h | 387 | +++ b/include/hw/virtio/virtio-blk.h |
363 | @@ -XXX,XX +XXX,XX @@ | 388 | @@ -XXX,XX +XXX,XX @@ |
... | ... | ||
392 | +++ b/include/hw/vmapple/vmapple.h | 417 | +++ b/include/hw/vmapple/vmapple.h |
393 | @@ -XXX,XX +XXX,XX @@ | 418 | @@ -XXX,XX +XXX,XX @@ |
394 | 419 | ||
395 | #define TYPE_VMAPPLE_CFG "vmapple-cfg" | 420 | #define TYPE_VMAPPLE_CFG "vmapple-cfg" |
396 | 421 | ||
397 | +#define TYPE_VMAPPLE_VIRTIO_BLK "vmapple-virtio-blk" | 422 | +#define TYPE_VMAPPLE_VIRTIO_BLK_PCI "vmapple-virtio-blk-pci" |
398 | +#define TYPE_VMAPPLE_VIRTIO_ROOT "vmapple-virtio-root" | ||
399 | +#define TYPE_VMAPPLE_VIRTIO_AUX "vmapple-virtio-aux" | ||
400 | + | 423 | + |
401 | #endif /* HW_VMAPPLE_VMAPPLE_H */ | 424 | #endif /* HW_VMAPPLE_VMAPPLE_H */ |
425 | diff --git a/qapi/virtio.json b/qapi/virtio.json | ||
426 | index XXXXXXX..XXXXXXX 100644 | ||
427 | --- a/qapi/virtio.json | ||
428 | +++ b/qapi/virtio.json | ||
429 | @@ -XXX,XX +XXX,XX @@ | ||
430 | ## | ||
431 | { 'enum': 'GranuleMode', | ||
432 | 'data': [ '4k', '8k', '16k', '64k', 'host' ] } | ||
433 | + | ||
434 | +## | ||
435 | +# @VMAppleVirtioBlkVariant: | ||
436 | +# | ||
437 | +# @unspecified: The default, not a valid setting. | ||
438 | +# | ||
439 | +# @root: Block device holding the root volume | ||
440 | +# | ||
441 | +# @aux: Block device holding auxiliary data required for boot | ||
442 | +# | ||
443 | +# Since: 9.2 | ||
444 | +## | ||
445 | +{ 'enum': 'VMAppleVirtioBlkVariant', | ||
446 | + 'data': [ 'unspecified', 'root', 'aux' ] } | ||
402 | -- | 447 | -- |
403 | 2.39.3 (Apple Git-145) | 448 | 2.39.5 (Apple Git-154) |
404 | 449 | ||
405 | 450 | diff view generated by jsdifflib |
1 | The virtio_blk_free_request() function has been a 1-liner forwarding | 1 | The virtio_blk_free_request() function has been a 1-liner forwarding |
---|---|---|---|
2 | to g_free() for a while now. We may as well call g_free on the request | 2 | to g_free() for a while now. We may as well call g_free on the request |
3 | pointer directly. | 3 | pointer directly. |
4 | 4 | ||
5 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> | 5 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> |
6 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | 6 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> |
7 | Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
7 | --- | 8 | --- |
8 | hw/block/virtio-blk.c | 43 +++++++++++++++------------------- | 9 | hw/block/virtio-blk.c | 43 +++++++++++++++------------------- |
9 | hw/vmapple/virtio-blk.c | 2 +- | 10 | hw/vmapple/virtio-blk.c | 2 +- |
10 | include/hw/virtio/virtio-blk.h | 1 - | 11 | include/hw/virtio/virtio-blk.h | 1 - |
11 | 3 files changed, 20 insertions(+), 26 deletions(-) | 12 | 3 files changed, 20 insertions(+), 26 deletions(-) |
... | ... | ||
221 | -void virtio_blk_free_request(VirtIOBlockReq *req); | 222 | -void virtio_blk_free_request(VirtIOBlockReq *req); |
222 | void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status); | 223 | void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status); |
223 | 224 | ||
224 | #endif | 225 | #endif |
225 | -- | 226 | -- |
226 | 2.39.3 (Apple Git-145) | 227 | 2.39.5 (Apple Git-154) | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
15 | $ qemu-system-aarch64 -accel hvf -M vmapple,uuid=0x1234 -m 4G \ | 15 | $ qemu-system-aarch64 -accel hvf -M vmapple,uuid=0x1234 -m 4G \ |
16 | -bios /System/Library/Frameworks/Virtualization.framework/Versions/A/Resources/AVPBooter.vmapple2.bin | 16 | -bios /System/Library/Frameworks/Virtualization.framework/Versions/A/Resources/AVPBooter.vmapple2.bin |
17 | -drive file=aux,if=pflash,format=raw \ | 17 | -drive file=aux,if=pflash,format=raw \ |
18 | -drive file=root,if=pflash,format=raw \ | 18 | -drive file=root,if=pflash,format=raw \ |
19 | -drive file=aux,if=none,id=aux,format=raw \ | 19 | -drive file=aux,if=none,id=aux,format=raw \ |
20 | -device vmapple-virtio-aux,drive=aux \ | 20 | -device vmapple-virtio-blk-pci,variant=aux,drive=aux \ |
21 | -drive file=root,if=none,id=root,format=raw \ | 21 | -drive file=root,if=none,id=root,format=raw \ |
22 | -device vmapple-virtio-root,drive=root | 22 | -device vmapple-virtio-blk-pci,variant=root,drive=root |
23 | 23 | ||
24 | With all these in place, you should be able to see macOS booting | 24 | With all these in place, you should be able to see macOS booting |
25 | successfully. | 25 | successfully. |
26 | 26 | ||
27 | Known issues: | 27 | Known issues: |
28 | - Keyboard and mouse/tablet input is laggy. The reason for this is | 28 | - Keyboard and mouse/tablet input is laggy. The reason is a quirk/bug |
29 | either that macOS's XHCI driver is broken when the device/platform | 29 | in macOS's XHCI driver when using pin-based interrupts instead of |
30 | does not support MSI/MSI-X, or there's some unfortunate interplay | 30 | MSI-X. A workaround is in the works. |
31 | with Qemu's XHCI implementation in this scenario. | ||
32 | - Currently only macOS 12 guests are supported. The boot process for | 31 | - Currently only macOS 12 guests are supported. The boot process for |
33 | 13+ will need further investigation and adjustment. | 32 | 13+ will need further investigation and adjustment. |
34 | 33 | ||
35 | Signed-off-by: Alexander Graf <graf@amazon.com> | 34 | Signed-off-by: Alexander Graf <graf@amazon.com> |
36 | Co-authored-by: Phil Dennis-Jordan <phil@philjordan.eu> | 35 | Co-authored-by: Phil Dennis-Jordan <phil@philjordan.eu> |
37 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> | 36 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> |
37 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
38 | Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
38 | --- | 39 | --- |
39 | 40 | ||
40 | v3: | 41 | v3: |
41 | * Rebased on latest upstream, updated affinity and NIC creation | 42 | * Rebased on latest upstream, updated affinity and NIC creation |
42 | API usage | 43 | API usage |
... | ... | ||
69 | 70 | ||
70 | v9: | 71 | v9: |
71 | * Documentation improvements | 72 | * Documentation improvements |
72 | * Fixed variable name and struct field used during pvpanic device creation. | 73 | * Fixed variable name and struct field used during pvpanic device creation. |
73 | 74 | ||
75 | v10: | ||
76 | * Documentation fixup for changed virtio-blk device type. | ||
77 | * Small improvements to shell commands in documentation. | ||
78 | * Improved propagation of errors during cfg device instantiation. | ||
79 | |||
80 | v11: | ||
81 | * Quoted more strings in the documentation's shell script code. | ||
82 | |||
83 | v13: | ||
84 | * Bumped the machine type version from 9.2 to 10.0. | ||
74 | 85 | ||
75 | MAINTAINERS | 1 + | 86 | MAINTAINERS | 1 + |
76 | contrib/vmapple/uuid.sh | 9 + | 87 | contrib/vmapple/uuid.sh | 9 + |
77 | docs/system/arm/vmapple.rst | 63 ++++ | 88 | docs/system/arm/vmapple.rst | 63 ++++ |
78 | docs/system/target-arm.rst | 1 + | 89 | docs/system/target-arm.rst | 1 + |
79 | hw/vmapple/Kconfig | 20 ++ | 90 | hw/vmapple/Kconfig | 20 ++ |
80 | hw/vmapple/meson.build | 1 + | 91 | hw/vmapple/meson.build | 1 + |
81 | hw/vmapple/vmapple.c | 639 ++++++++++++++++++++++++++++++++++++ | 92 | hw/vmapple/vmapple.c | 646 ++++++++++++++++++++++++++++++++++++ |
82 | 7 files changed, 734 insertions(+) | 93 | 7 files changed, 741 insertions(+) |
83 | create mode 100755 contrib/vmapple/uuid.sh | 94 | create mode 100755 contrib/vmapple/uuid.sh |
84 | create mode 100644 docs/system/arm/vmapple.rst | 95 | create mode 100644 docs/system/arm/vmapple.rst |
85 | create mode 100644 hw/vmapple/vmapple.c | 96 | create mode 100644 hw/vmapple/vmapple.c |
86 | 97 | ||
87 | diff --git a/MAINTAINERS b/MAINTAINERS | 98 | diff --git a/MAINTAINERS b/MAINTAINERS |
... | ... | ||
159 | +to get better interactive access into the target system: | 170 | +to get better interactive access into the target system: |
160 | + | 171 | + |
161 | +.. code-block:: bash | 172 | +.. code-block:: bash |
162 | + :caption: Example execution command line | 173 | + :caption: Example execution command line |
163 | + | 174 | + |
164 | + $ UUID=$(uuid.sh macosvm.json) | 175 | + $ UUID="$(contrib/vmapple/uuid.sh 'macosvm.json')" |
165 | + $ AVPBOOTER=/System/Library/Frameworks/Virtualization.framework/Resources/AVPBooter.vmapple2.bin | 176 | + $ AVPBOOTER="/System/Library/Frameworks/Virtualization.framework/Resources/AVPBooter.vmapple2.bin" |
166 | + $ AUX=aux.img.trimmed | 177 | + $ AUX="aux.img.trimmed" |
167 | + $ DISK=disk.img | 178 | + $ DISK="disk.img" |
168 | + $ qemu-system-aarch64 \ | 179 | + $ qemu-system-aarch64 \ |
169 | + -serial mon:stdio \ | 180 | + -serial mon:stdio \ |
170 | + -m 4G \ | 181 | + -m 4G \ |
171 | + -accel hvf \ | 182 | + -accel hvf \ |
172 | + -M vmapple,uuid="$UUID" \ | 183 | + -M vmapple,uuid="$UUID" \ |
173 | + -bios "$AVPBOOTER" \ | 184 | + -bios "$AVPBOOTER" \ |
174 | + -drive file="$AUX",if=pflash,format=raw \ | 185 | + -drive file="$AUX",if=pflash,format=raw \ |
175 | + -drive file="$DISK",if=pflash,format=raw \ | 186 | + -drive file="$DISK",if=pflash,format=raw \ |
176 | + -drive file="$AUX",if=none,id=aux,format=raw \ | 187 | + -drive file="$AUX",if=none,id=aux,format=raw \ |
177 | + -drive file="$DISK",if=none,id=root,format=raw \ | 188 | + -drive file="$DISK",if=none,id=root,format=raw \ |
178 | + -device vmapple-virtio-aux,drive=aux \ | 189 | + -device vmapple-virtio-blk-pci,variant=aux,drive=aux \ |
179 | + -device vmapple-virtio-root,drive=root \ | 190 | + -device vmapple-virtio-blk-pci,variant=root,drive=root \ |
180 | + -netdev user,id=net0,ipv6=off,hostfwd=tcp::2222-:22,hostfwd=tcp::5901-:5900 \ | 191 | + -netdev user,id=net0,ipv6=off,hostfwd=tcp::2222-:22,hostfwd=tcp::5901-:5900 \ |
181 | + -device virtio-net-pci,netdev=net0 | 192 | + -device virtio-net-pci,netdev=net0 |
182 | + | 193 | + |
183 | diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst | 194 | diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst |
184 | index XXXXXXX..XXXXXXX 100644 | 195 | index XXXXXXX..XXXXXXX 100644 |
... | ... | ||
444 | + sysbus_mmio_map(pvpanic, 0, vms->memmap[VMAPPLE_PVPANIC].base); | 455 | + sysbus_mmio_map(pvpanic, 0, vms->memmap[VMAPPLE_PVPANIC].base); |
445 | + | 456 | + |
446 | + sysbus_realize_and_unref(pvpanic, &error_fatal); | 457 | + sysbus_realize_and_unref(pvpanic, &error_fatal); |
447 | +} | 458 | +} |
448 | + | 459 | + |
449 | +static void create_cfg(VMAppleMachineState *vms, MemoryRegion *mem) | 460 | +static bool create_cfg(VMAppleMachineState *vms, MemoryRegion *mem, |
450 | +{ | 461 | + Error **errp) |
462 | +{ | ||
463 | + ERRP_GUARD(); | ||
451 | + SysBusDevice *cfg; | 464 | + SysBusDevice *cfg; |
452 | + MachineState *machine = MACHINE(vms); | 465 | + MachineState *machine = MACHINE(vms); |
453 | + uint32_t rnd = 1; | 466 | + uint32_t rnd = 1; |
454 | + | 467 | + |
455 | + vms->cfg = qdev_new(TYPE_VMAPPLE_CFG); | 468 | + vms->cfg = qdev_new(TYPE_VMAPPLE_CFG); |
... | ... | ||
461 | + qdev_prop_set_uint32(vms->cfg, "nr-cpus", machine->smp.cpus); | 474 | + qdev_prop_set_uint32(vms->cfg, "nr-cpus", machine->smp.cpus); |
462 | + qdev_prop_set_uint64(vms->cfg, "ecid", vms->uuid); | 475 | + qdev_prop_set_uint64(vms->cfg, "ecid", vms->uuid); |
463 | + qdev_prop_set_uint64(vms->cfg, "ram-size", machine->ram_size); | 476 | + qdev_prop_set_uint64(vms->cfg, "ram-size", machine->ram_size); |
464 | + qdev_prop_set_uint32(vms->cfg, "rnd", rnd); | 477 | + qdev_prop_set_uint32(vms->cfg, "rnd", rnd); |
465 | + | 478 | + |
466 | + sysbus_realize_and_unref(cfg, &error_fatal); | 479 | + if (!sysbus_realize_and_unref(cfg, errp)) { |
480 | + error_prepend(errp, "Error creating vmapple cfg device: "); | ||
481 | + return false; | ||
482 | + } | ||
483 | + | ||
484 | + return true; | ||
467 | +} | 485 | +} |
468 | + | 486 | + |
469 | +static void create_gfx(VMAppleMachineState *vms, MemoryRegion *mem) | 487 | +static void create_gfx(VMAppleMachineState *vms, MemoryRegion *mem) |
470 | +{ | 488 | +{ |
471 | + int irq_gfx = vms->irqmap[VMAPPLE_APV_GFX]; | 489 | + int irq_gfx = vms->irqmap[VMAPPLE_APV_GFX]; |
... | ... | ||
765 | + create_pcie(vms); | 783 | + create_pcie(vms); |
766 | + | 784 | + |
767 | + create_gpio_devices(vms, VMAPPLE_GPIO, sysmem); | 785 | + create_gpio_devices(vms, VMAPPLE_GPIO, sysmem); |
768 | + | 786 | + |
769 | + vmapple_firmware_init(vms, sysmem); | 787 | + vmapple_firmware_init(vms, sysmem); |
770 | + create_cfg(vms, sysmem); | 788 | + create_cfg(vms, sysmem, &error_fatal); |
771 | + | 789 | + |
772 | + /* connect powerdown request */ | 790 | + /* connect powerdown request */ |
773 | + vms->powerdown_notifier.notify = vmapple_powerdown_req; | 791 | + vms->powerdown_notifier.notify = vmapple_powerdown_req; |
774 | + qemu_register_powerdown_notifier(&vms->powerdown_notifier); | 792 | + qemu_register_powerdown_notifier(&vms->powerdown_notifier); |
775 | + | 793 | + |
... | ... | ||
867 | +{ | 885 | +{ |
868 | + type_register_static(&vmapple_machine_info); | 886 | + type_register_static(&vmapple_machine_info); |
869 | +} | 887 | +} |
870 | +type_init(machvmapple_machine_init); | 888 | +type_init(machvmapple_machine_init); |
871 | + | 889 | + |
872 | +static void vmapple_machine_9_2_options(MachineClass *mc) | 890 | +static void vmapple_machine_10_0_options(MachineClass *mc) |
873 | +{ | 891 | +{ |
874 | +} | 892 | +} |
875 | +DEFINE_VMAPPLE_MACHINE_AS_LATEST(9, 2) | 893 | +DEFINE_VMAPPLE_MACHINE_AS_LATEST(10, 0) |
876 | + | 894 | + |
877 | -- | 895 | -- |
878 | 2.39.3 (Apple Git-145) | 896 | 2.39.5 (Apple Git-154) |
879 | 897 | ||
880 | 898 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This reduces the type hierarchy of the vmapple-virtio-blk-pci-base | ||
2 | type and vmapple-virtio-root/vmapple-virtio-aux leaf types with a single | ||
3 | vmapple-virtio-blk-pci type which exposes a 'variant' enum property | ||
4 | which can be set to 'aux' or 'root'. | ||
5 | 1 | ||
6 | This change removes a bunch of device type boilerplate at the cost of | ||
7 | defining a new qapi enum and qdev property type. | ||
8 | |||
9 | Documentation for the vmapple machine type is also updated. | ||
10 | |||
11 | Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu> | ||
12 | --- | ||
13 | docs/system/arm/vmapple.rst | 4 +-- | ||
14 | hw/core/qdev-properties-system.c | 8 +++++ | ||
15 | hw/vmapple/virtio-blk.c | 50 +++++++---------------------- | ||
16 | include/hw/qdev-properties-system.h | 6 ++++ | ||
17 | include/hw/vmapple/vmapple.h | 4 +-- | ||
18 | qapi/virtio.json | 14 ++++++++ | ||
19 | 6 files changed, 43 insertions(+), 43 deletions(-) | ||
20 | |||
21 | diff --git a/docs/system/arm/vmapple.rst b/docs/system/arm/vmapple.rst | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/docs/system/arm/vmapple.rst | ||
24 | +++ b/docs/system/arm/vmapple.rst | ||
25 | @@ -XXX,XX +XXX,XX @@ to get better interactive access into the target system: | ||
26 | -drive file="$DISK",if=pflash,format=raw \ | ||
27 | -drive file="$AUX",if=none,id=aux,format=raw \ | ||
28 | -drive file="$DISK",if=none,id=root,format=raw \ | ||
29 | - -device vmapple-virtio-aux,drive=aux \ | ||
30 | - -device vmapple-virtio-root,drive=root \ | ||
31 | + -device vmapple-virtio-blk-pci,variant=aux,drive=aux \ | ||
32 | + -device vmapple-virtio-blk-pci,variant=root,drive=root \ | ||
33 | -netdev user,id=net0,ipv6=off,hostfwd=tcp::2222-:22,hostfwd=tcp::5901-:5900 \ | ||
34 | -device virtio-net-pci,netdev=net0 | ||
35 | |||
36 | diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/hw/core/qdev-properties-system.c | ||
39 | +++ b/hw/core/qdev-properties-system.c | ||
40 | @@ -XXX,XX +XXX,XX @@ const PropertyInfo qdev_prop_iothread_vq_mapping_list = { | ||
41 | .set = set_iothread_vq_mapping_list, | ||
42 | .release = release_iothread_vq_mapping_list, | ||
43 | }; | ||
44 | + | ||
45 | +const PropertyInfo qdev_prop_vmapple_virtio_blk_variant = { | ||
46 | + .name = "VMAppleVirtioBlkVariant", | ||
47 | + .enum_table = &VMAppleVirtioBlkVariant_lookup, | ||
48 | + .get = qdev_propinfo_get_enum, | ||
49 | + .set = qdev_propinfo_set_enum, | ||
50 | + .set_default_value = qdev_propinfo_set_default_value_enum, | ||
51 | +}; | ||
52 | diff --git a/hw/vmapple/virtio-blk.c b/hw/vmapple/virtio-blk.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/hw/vmapple/virtio-blk.c | ||
55 | +++ b/hw/vmapple/virtio-blk.c | ||
56 | @@ -XXX,XX +XXX,XX @@ | ||
57 | #include "qemu/module.h" | ||
58 | #include "qapi/error.h" | ||
59 | |||
60 | +#define TYPE_VMAPPLE_VIRTIO_BLK "vmapple-virtio-blk" | ||
61 | OBJECT_DECLARE_TYPE(VMAppleVirtIOBlk, VMAppleVirtIOBlkClass, VMAPPLE_VIRTIO_BLK) | ||
62 | |||
63 | typedef struct VMAppleVirtIOBlkClass { | ||
64 | @@ -XXX,XX +XXX,XX @@ typedef struct VMAppleVirtIOBlk { | ||
65 | /* | ||
66 | * vmapple-virtio-blk-pci: This extends VirtioPCIProxy. | ||
67 | */ | ||
68 | -#define TYPE_VMAPPLE_VIRTIO_BLK_PCI "vmapple-virtio-blk-pci-base" | ||
69 | OBJECT_DECLARE_SIMPLE_TYPE(VMAppleVirtIOBlkPCI, VMAPPLE_VIRTIO_BLK_PCI) | ||
70 | |||
71 | #define VIRTIO_BLK_T_APPLE_BARRIER 0x10000 | ||
72 | |||
73 | -#define VIRTIO_APPLE_TYPE_ROOT 1 | ||
74 | -#define VIRTIO_APPLE_TYPE_AUX 2 | ||
75 | - | ||
76 | static bool vmapple_virtio_blk_handle_unknown_request(VirtIOBlockReq *req, | ||
77 | MultiReqBuffer *mrb, | ||
78 | uint32_t type) | ||
79 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo vmapple_virtio_blk_info = { | ||
80 | struct VMAppleVirtIOBlkPCI { | ||
81 | VirtIOPCIProxy parent_obj; | ||
82 | VMAppleVirtIOBlk vdev; | ||
83 | - uint32_t apple_type; | ||
84 | + VMAppleVirtioBlkVariant variant; | ||
85 | }; | ||
86 | |||
87 | |||
88 | @@ -XXX,XX +XXX,XX @@ static Property vmapple_virtio_blk_pci_properties[] = { | ||
89 | VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), | ||
90 | DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, | ||
91 | DEV_NVECTORS_UNSPECIFIED), | ||
92 | + DEFINE_PROP_VMAPPLE_VIRTIO_BLK_VARIANT("variant", VMAppleVirtIOBlkPCI, variant, | ||
93 | + VM_APPLE_VIRTIO_BLK_VARIANT_UNSPECIFIED), | ||
94 | DEFINE_PROP_END_OF_LIST(), | ||
95 | }; | ||
96 | |||
97 | @@ -XXX,XX +XXX,XX @@ static void vmapple_virtio_blk_pci_realize(VirtIOPCIProxy *vpci_dev, Error **err | ||
98 | DeviceState *vdev = DEVICE(&dev->vdev); | ||
99 | VirtIOBlkConf *conf = &dev->vdev.parent_obj.conf; | ||
100 | |||
101 | + if (dev->variant == VM_APPLE_VIRTIO_BLK_VARIANT_UNSPECIFIED) { | ||
102 | + error_setg(errp, "Device " TYPE_VMAPPLE_VIRTIO_BLK_PCI ": must specify " | ||
103 | + "a variant, 'aux' or 'root'"); | ||
104 | + return; | ||
105 | + } | ||
106 | + | ||
107 | if (conf->num_queues == VIRTIO_BLK_AUTO_NUM_QUEUES) { | ||
108 | conf->num_queues = virtio_pci_optimal_num_queues(0); | ||
109 | } | ||
110 | @@ -XXX,XX +XXX,XX @@ static void vmapple_virtio_blk_pci_realize(VirtIOPCIProxy *vpci_dev, Error **err | ||
111 | */ | ||
112 | virtio_add_feature(&dev->vdev.parent_obj.host_features, VIRTIO_BLK_F_ZONED); | ||
113 | /* Propagate the apple type down to the virtio-blk device */ | ||
114 | - dev->vdev.apple_type = dev->apple_type; | ||
115 | + dev->vdev.apple_type = dev->variant; | ||
116 | /* and spawn the virtio-blk device */ | ||
117 | qdev_realize(vdev, BUS(&vpci_dev->bus), errp); | ||
118 | |||
119 | @@ -XXX,XX +XXX,XX @@ static void vmapple_virtio_blk_pci_instance_init(Object *obj) | ||
120 | } | ||
121 | |||
122 | static const VirtioPCIDeviceTypeInfo vmapple_virtio_blk_pci_info = { | ||
123 | - .base_name = TYPE_VMAPPLE_VIRTIO_BLK_PCI, | ||
124 | - .generic_name = "vmapple-virtio-blk-pci", | ||
125 | + .generic_name = TYPE_VMAPPLE_VIRTIO_BLK_PCI, | ||
126 | .instance_size = sizeof(VMAppleVirtIOBlkPCI), | ||
127 | .instance_init = vmapple_virtio_blk_pci_instance_init, | ||
128 | .class_init = vmapple_virtio_blk_pci_class_init, | ||
129 | }; | ||
130 | |||
131 | -static void vmapple_virtio_root_instance_init(Object *obj) | ||
132 | -{ | ||
133 | - VMAppleVirtIOBlkPCI *dev = VMAPPLE_VIRTIO_BLK_PCI(obj); | ||
134 | - | ||
135 | - dev->apple_type = VIRTIO_APPLE_TYPE_ROOT; | ||
136 | -} | ||
137 | - | ||
138 | -static const TypeInfo vmapple_virtio_root_info = { | ||
139 | - .name = TYPE_VMAPPLE_VIRTIO_ROOT, | ||
140 | - .parent = "vmapple-virtio-blk-pci", | ||
141 | - .instance_size = sizeof(VMAppleVirtIOBlkPCI), | ||
142 | - .instance_init = vmapple_virtio_root_instance_init, | ||
143 | -}; | ||
144 | - | ||
145 | -static void vmapple_virtio_aux_instance_init(Object *obj) | ||
146 | -{ | ||
147 | - VMAppleVirtIOBlkPCI *dev = VMAPPLE_VIRTIO_BLK_PCI(obj); | ||
148 | - | ||
149 | - dev->apple_type = VIRTIO_APPLE_TYPE_AUX; | ||
150 | -} | ||
151 | - | ||
152 | -static const TypeInfo vmapple_virtio_aux_info = { | ||
153 | - .name = TYPE_VMAPPLE_VIRTIO_AUX, | ||
154 | - .parent = "vmapple-virtio-blk-pci", | ||
155 | - .instance_size = sizeof(VMAppleVirtIOBlkPCI), | ||
156 | - .instance_init = vmapple_virtio_aux_instance_init, | ||
157 | -}; | ||
158 | - | ||
159 | static void vmapple_virtio_blk_register_types(void) | ||
160 | { | ||
161 | type_register_static(&vmapple_virtio_blk_info); | ||
162 | virtio_pci_types_register(&vmapple_virtio_blk_pci_info); | ||
163 | - type_register_static(&vmapple_virtio_root_info); | ||
164 | - type_register_static(&vmapple_virtio_aux_info); | ||
165 | } | ||
166 | |||
167 | type_init(vmapple_virtio_blk_register_types) | ||
168 | diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properties-system.h | ||
169 | index XXXXXXX..XXXXXXX 100644 | ||
170 | --- a/include/hw/qdev-properties-system.h | ||
171 | +++ b/include/hw/qdev-properties-system.h | ||
172 | @@ -XXX,XX +XXX,XX @@ extern const PropertyInfo qdev_prop_pcie_link_speed; | ||
173 | extern const PropertyInfo qdev_prop_pcie_link_width; | ||
174 | extern const PropertyInfo qdev_prop_cpus390entitlement; | ||
175 | extern const PropertyInfo qdev_prop_iothread_vq_mapping_list; | ||
176 | +extern const PropertyInfo qdev_prop_vmapple_virtio_blk_variant; | ||
177 | + | ||
178 | |||
179 | #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \ | ||
180 | DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t) | ||
181 | @@ -XXX,XX +XXX,XX @@ extern const PropertyInfo qdev_prop_iothread_vq_mapping_list; | ||
182 | DEFINE_PROP(_name, _state, _field, qdev_prop_iothread_vq_mapping_list, \ | ||
183 | IOThreadVirtQueueMappingList *) | ||
184 | |||
185 | +#define DEFINE_PROP_VMAPPLE_VIRTIO_BLK_VARIANT(_n, _s, _f, _d) \ | ||
186 | + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_vmapple_virtio_blk_variant, \ | ||
187 | + VMAppleVirtioBlkVariant) | ||
188 | + | ||
189 | #endif | ||
190 | diff --git a/include/hw/vmapple/vmapple.h b/include/hw/vmapple/vmapple.h | ||
191 | index XXXXXXX..XXXXXXX 100644 | ||
192 | --- a/include/hw/vmapple/vmapple.h | ||
193 | +++ b/include/hw/vmapple/vmapple.h | ||
194 | @@ -XXX,XX +XXX,XX @@ | ||
195 | |||
196 | #define TYPE_VMAPPLE_CFG "vmapple-cfg" | ||
197 | |||
198 | -#define TYPE_VMAPPLE_VIRTIO_BLK "vmapple-virtio-blk" | ||
199 | -#define TYPE_VMAPPLE_VIRTIO_ROOT "vmapple-virtio-root" | ||
200 | -#define TYPE_VMAPPLE_VIRTIO_AUX "vmapple-virtio-aux" | ||
201 | +#define TYPE_VMAPPLE_VIRTIO_BLK_PCI "vmapple-virtio-blk-pci" | ||
202 | |||
203 | #endif /* HW_VMAPPLE_VMAPPLE_H */ | ||
204 | diff --git a/qapi/virtio.json b/qapi/virtio.json | ||
205 | index XXXXXXX..XXXXXXX 100644 | ||
206 | --- a/qapi/virtio.json | ||
207 | +++ b/qapi/virtio.json | ||
208 | @@ -XXX,XX +XXX,XX @@ | ||
209 | ## | ||
210 | { 'enum': 'GranuleMode', | ||
211 | 'data': [ '4k', '8k', '16k', '64k', 'host' ] } | ||
212 | + | ||
213 | +## | ||
214 | +# @VMAppleVirtioBlkVariant: | ||
215 | +# | ||
216 | +# @unspecified: The default, not a valid setting. | ||
217 | +# | ||
218 | +# @root: Block device holding the root volume | ||
219 | +# | ||
220 | +# @aux: Block device holding auxiliary data required for boot | ||
221 | +# | ||
222 | +# Since: 9.2 | ||
223 | +## | ||
224 | +{ 'enum': 'VMAppleVirtioBlkVariant', | ||
225 | + 'data': [ 'unspecified', 'root', 'aux' ] } | ||
226 | -- | ||
227 | 2.39.3 (Apple Git-145) | diff view generated by jsdifflib |