AppleSilicon/qemu/replay/stubs-system.c
Youssef 26710d37c7 orchard: macOS on QEMU, on a Linux host
Boots an arm64 macOS guest on QEMU/TCG on Linux through the genuine Apple
chain -- AVPBooter -> iBootStage1 -> iBootStage2 -> stock XNU -- and renders
its desktop on the host's Vulkan.

QEMU (1044 lines over 18 files, 8 new):

  * the `apple-vm` machine: Apple-style timer-on-FIQ wiring, the paravirtual
    GPU device, a PAC master key installed across CPUs, and GICv2m's
    `macos-compat` bit, without which macOS will not use the MSI frame;
  * `bdif` NVRAM block writes. Upstream drops them, so a guest could never
    persist a boot variable and every install phase repeated forever;
  * `cfg`'s guest-visible random seed at its fixed offset;
  * Apple pointer authentication under TCG: the register definitions come
    from ChefKissInc/Inferno, the per-core key snapshot and the PSCI CPU_ON
    key inheritance (restricted to a kernel caller by testing that its pc is
    in the TTBR1 half) are ours. Without them secondaries run keyless and the
    first cross-core authentication recurses through its own panic path;
  * portability work upstream has not needed before: CONFIG_VMAPPLE was gated
    on HVF and shipped off, hw/vmapple/aes.c has a VLA that only compiled
    under clang, and the architectural op1-to-minimum-EL assertion rejects
    Apple's IMPDEF registers.

The GPU is steelbrain/reims-vgpu, carried as a submodule pinned to the commit
this was tested against; the two changes it needs are in patches/reims-vgpu/.
The AVPBooter patch is NyanSatan's, from Virtual-iBoot-Fun.

Nothing Apple ships is in this repository. The macOS image is fetched from a
public tart image, and Apple's VM firmware is extracted from that image, where
Virtualization.framework carries it -- so no Mac is involved in the setup.

Measured on the reference host: desktop in 75 s at 12 vCPUs and 10 GB.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Youssef <soosef.youssef@gmail.com>
2026-09-20 00:53:26 +03:00

108 lines
2.1 KiB
C

#include "qemu/osdep.h"
#include "system/replay.h"
#include "ui/input.h"
void replay_input_event(QemuConsole *src, QemuInputEvent *evt)
{
qemu_input_event_send_impl(src, evt);
}
void replay_input_sync_event(void)
{
qemu_input_event_sync_impl();
}
void replay_add_blocker(const char *feature)
{
}
void replay_audio_in_start(size_t *nsamples)
{
}
void replay_audio_in_sample_lr(uint64_t *left, uint64_t *right)
{
}
void replay_audio_in_finish(void)
{
}
void replay_audio_out(size_t *played)
{
}
void replay_breakpoint(void)
{
}
bool replay_can_snapshot(void)
{
return true;
}
void replay_configure(struct QemuOpts *opts)
{
}
void replay_flush_events(void)
{
}
void replay_gdb_attached(void)
{
}
bool replay_running_debug(void)
{
return false;
}
void replay_shutdown_request(ShutdownCause cause)
{
}
void replay_start(void)
{
}
void replay_vmstate_init(void)
{
}
#include "monitor/monitor.h"
#include "monitor/hmp.h"
#include "qapi/qapi-commands-replay.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#ifdef CONFIG_HMP
void hmp_info_replay(MonitorHMP *hmp, const QDict *qdict)
{
error_report("replay support not available");
}
void hmp_replay_break(MonitorHMP *hmp, const QDict *qdict)
{
error_report("replay support not available");
}
void hmp_replay_delete_break(MonitorHMP *hmp, const QDict *qdict)
{
error_report("replay support not available");
}
void hmp_replay_seek(MonitorHMP *hmp, const QDict *qdict)
{
error_report("replay support not available");
}
#endif
ReplayInfo *qmp_query_replay(Error **errp)
{
error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
"replay support not available");
return NULL;
}
void qmp_replay_break(int64_t icount, Error **errp)
{
error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
"replay support not available");
}
void qmp_replay_delete_break(Error **errp)
{
error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
"replay support not available");
}
void qmp_replay_seek(int64_t icount, Error **errp)
{
error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
"replay support not available");
}