Both attach shims now apply cursor position and glyph actions through the bus-independent shim. Cursor glyph validation, ABI calls, allocation, and console installation therefore have one implementation for PCI and MMIO.
Remove the reims_vgpu_backend Meson option and the Metal feature branch from the QEMU device build. Both PCI and MMIO devices now link the same backend-vulkan,host-window Rust staticlib; platform-specific framework linkage remains only where the macOS Vulkan window stack requires it.
Also update the device comments and Kconfig text so they describe the Vulkan product path rather than deleted Metal stubs or presentation behavior.
Verified by configuring and building qemu-system-x86_64 through scripts/qemu-build/qemu-build.sh, including the reims-vgpu Rust staticlib and both product device types. The macOS aarch64 QEMU link and a live VM boot were not run on this Linux host.
Build stable MAP_SHARED views over file-backed guest pages when a GVA window is not physically contiguous. Hold those aliases for the device lifetime so imported GPU reads retain a valid address, then release them after backend teardown.
Component: `vendor/qemu` — `hw/display/reims-vgpu-pci.c`. Comment only; no
behaviour changes. Pathway: x86 macOS / Linux Vulkan. Rail: `macos-26`.
## What this records
Three guest processes crash-loop on macOS 26 — the icon-services agent, the
dock's tile-plugin XPC service, and Spotlight. All three have a byte-identical
top-of-stack and all three die on the same assertion inside Metal's
binary-archive loader:
failed assertion `Target device architecture is nil'
232 crash reports of those three processes were harvested across previous boots.
The assertion text itself had never been read; it was recovered from the guest's
own log this session, and it changes the diagnosis. This is a **missing
property**, not a slice mismatch and not a driver-version mismatch, and those
lead to opposite repairs.
## Why it is not ours to fix, established rather than assumed
The guest ships two IOKit personalities for one paravirt GPU. One matches an
`IOPCIDevice` on exactly the two IDs this file defines; the other matches a
device-tree node by name on an ARM platform provider. Each names a different
Metal plugin, and the two plugins are different drivers, not two builds of one —
different superclasses, different instance sizes, and one hard-codes
binary-archive support off.
The device-architecture property the assert names is implemented in **only** the
second plugin. In the one this pathway loads it is a protocol declaration with a
null implementation pointer, on both of its architecture slices. That was checked
directly against the plugin's method tables and independently corroborated by
disassembling the sibling's implementation; the two agree. The property strings
are present in both, which is the trap — a string search finds the property and
makes it look implemented.
The second personality cannot be reached from here at any PCI identity: it
requires an ARM platform provider that does not exist on an x86_64 guest, and
its kext declares a dependency on the ARM platform driver. The guest's
accelerator node publishes no architecture-related property at all, so there is
nothing on the IORegistry side to fill either.
Hence the comment's instruction: the capability table is not in that code path,
so do not spend a boot probing device-info keys for this.
## Why it belongs here
The two IDs read as arbitrary identifiers. They are in fact the input to a match
that selects the guest's entire Metal driver, and the consequence lands three
subsystems away in a crash loop. A future session changing them to dodge some
other problem would have no way to know that from this file.
## Tests
None, and none is possible. The fact is about the guest's matching tables, which
nothing in this repository executes or can assert against. It is recorded where
the input to that match is defined, which is what `AGENTS.md` prescribes when an
invariant cannot be reached by a test.
## Verified
QEMU rebuilt for x86_64/vulkan: both devices present, staticlib linked, build
clean. Guest-side facts read off a live `macos-26` boot (verdict `ok`) via a new
read-only probe — loaded kext list, both personality dictionaries, and the
accelerator node's full property list.
## Not verified
Whether the arm64 pathway loads the other personality and therefore renders
Tahoe icons correctly. That is the implication of the matching rules and it is
untested — no arm64 host is available here, and the rule against generalising
across pathways applies to this prediction as much as to any other.
Co-Authored-By: Claude <noreply@anthropic.com>
Component: `vendor/qemu/hw/display` — both device shims and the build wiring.
Only `hw/display/reims-vgpu-*` is touched; upstream QEMU's own dma-buf users
(virtio-gpu, ui/, vfio) are unrelated and out of scope.
Deletes `reims-vgpu-dmabuf.{c,h}` — the `/dev/udmabuf` handle, the
`UDMABUF_CREATE_LIST` call and the run coalescer — the PCI shim's
`dmabuf_for_pages` forwarder and its HostOps entry, and the meson translation
unit.
ABI v17's `guest_ram_regions` replaced the mechanism outright rather than
alongside it: guest pages now reach the host GPU by importing the mapping QEMU
already holds over a RAMBlock, which works on Linux, Windows and macOS, where
udmabuf is a Linux kernel object with no equivalent on either of the other two.
Removed rather than left in place, because a half-retired rail with two
spellings is the divergence class AGENTS.md warns about and a caller that can
still ask for an fd eventually will.
Two comments corrected rather than deleted, both about `map_pages_stable`: it
was documented as the flag the GPU rail read, and the GPU rail no longer exists
on that path. It is a claim about a CPU-side view only. The MMIO shim's copy
also now says why the import does not re-open the device-lifetime retention
that `reims-vgpu-mmio.c:208` records dropping — an import is over the span,
never over a packed `mach_vm_remap` view.
Verified: `ninja qemu-system-x86_64` builds and links clean against the v18
staticlib; all three reims TUs compile under QEMU's `-Werror` set. Not
verified: no live boot, and the MMIO shim was compiled on Linux but not built
into an Apple-host binary.
Co-Authored-By: Claude <noreply@anthropic.com>
Component: `vendor/qemu/hw/display` — the shared shim plus both device shims.
No behavior change on either pathway: nothing calls the new entry point yet.
`guest_ram_regions` enumerates guest RAM as stable (gpa_base, host_va, len)
spans that hold for the VM's lifetime. Guest pages are about to reach the host
GPU by importing the mapping QEMU already holds over a RAMBlock, once, after
which a resource is an (offset, len) inside that import rather than a page
list somebody has to export.
It is deliberately not `map_pages` with a different return type. `map_pages`
answers "give me a view of these specific pages" and on the sysbus shim builds
a packed `mach_vm_remap` view the caller must release; this never allocates,
never releases, and never changes its answer. That is also why it does not
re-open the device-lifetime retention `reims-vgpu-mmio.c:208` records dropping
— an import is over the span, never over a remap view, and a fragmented
surface becomes several offsets inside one span.
One implementation in `reims-vgpu-shim.c`, which both shims point their table
entry straight at. It walks the system address space's flat view, skips ROM,
ROMD and ram_device ranges (RAM-backed, but the guest either cannot store into
them or does not own them), and coalesces adjacent ranges only when they
continue in *both* address spaces — two blocks that abut in GPA but not in
host VA stay separate, because merging those would make an offset inside the
span name the wrong host bytes.
The shim exports the spans and nothing else: not whether this host can import
them, not which primitive the backend would use, not how the ranges coalesced.
A shim holding those three can rebuild the rule, and per AGENTS.md it will.
Truncation is reported rather than silent: the call returns its true total
even when that exceeds the caller's array, so a short array is a fact the
caller learns instead of a part of guest RAM the GPU silently cannot reach.
Verified: `ninja qemu-system-x86_64` builds and links clean with the v17
staticlib. Both device shims and the shared shim compile with QEMU's `-Werror`
set. Not verified: no live boot, and the MMIO shim was compiled on Linux but
not built into an Apple-host binary.
Co-Authored-By: Claude <noreply@anthropic.com>
`hw/display/reims-vgpu-pci.c`, x86 PCI pathway.
`fb_update` asks Rust who owns the host console and branches on the kind it
names. The `_FIRMWARE` arm returns either way and says why: a failed copy must
not fall through to the re-push at the bottom of the function, whose pending
frame is a *product* one, and pushing that while Rust says the firmware console
owns the screen is the pre-boundary steal the feed exists to prevent.
The `_EARLY` arm right above it returned only when its paint succeeded. A failed
early paint fell through and pushed the product frame — the same steal, with the
same reasoning against it written eight lines below, unapplied. The arm64 shim
returns either way on this arm, so the two shims disagreed and each host builds
only one of them.
Now returns unconditionally. No console update added beside it: unlike the arm64
shim's, this `paint_scanout` already calls `qemu_console_update_full` and clears
`new_frame_ready` itself on the path that returns true, so calling it here would
be the second call.
Verified: QEMU builds; both device shims present. The Rust-side gate is
`a_console_feed_arm_never_falls_through_to_the_product_re_push` in
`crates/reims-vgpu/tests/qemu_shims_agree.rs`, which fails on this file with the
old arm restored and passes with it fixed.
Not verified: arm64, whose shim already had the behavior this brings x86 to.
Co-Authored-By: Claude <noreply@anthropic.com>
`reims-vgpu-mmio.c` sized its `mach_vm_remap` view, its host-VA alignment mask
and its packed-contiguity stride from `REIMS_VGPU_GUEST_PAGE_SIZE`, eight uses in
`map_pages`. That name has no architecture in it and the value is 16384 — arm64e's
page, not "the guest's".
Its three siblings in the same block of the shared header are all arch-qualified
(`..._SHIFT_ARM64E`, `..._SHIFT_X86_64`, `..._SIZE_X86_64`), and the Rust side
adopted exactly this prohibition after being bitten by it: `model::regs` carries
a comment saying there is no bare `PAGE_SIZE` / `PAGE_SHIFT` because those names
"defaulted to arm16K and caused x86 wild writes (stamp slots)". The rule was
never carried across the boundary, where the header is the only copy and nothing
compares the two.
Renamed to `REIMS_VGPU_GUEST_PAGE_SIZE_ARM64E`, so the four constants read alike
and a use of the arm64e page on an x86 path has to say so. No live bug: all eight
uses are in the arm64 shim, where 16 KiB is the right number. This is the spelling
that makes the next one visible.
Not verified by compilation on this host: every one of the eight sits inside
`#if defined(CONFIG_DARWIN)` and is preprocessed away on Linux. `qemu-build.sh`
succeeds and both devices register, which proves the file parses and the header
change is consistent, not that the Darwin arm compiles. It is a textual rename of
one `#define` and all of its uses, and a grep confirms no unqualified spelling
survives anywhere in the tree.
The parent repo adds `the_abi_header_is_pinned_to_the_rust_page_geometry`, which
fails if any of the four drifts from `contract::gva`.
QEMU shims, both pathways. `device_console_feed` is the single owner of
host-console ownership; its doc records that the shims used to assemble the
three-way themselves and that neither may re-derive it. The PCI shim had been
brought onto that contract. The MMIO shim had not, and `gfx_update` held three
copies of a rule that is not C's to hold:
- It called `reims_vgpu_qemu_console_feed` raw and tested
`rc == OK && kind == EARLY`, so a failed call fell through to the
post-boundary re-push. That is the shim inventing a policy for "no answer",
which `device_console_feed`'s own doc names as the thing being removed. The
PCI shim already read a failed call as _FIRMWARE — fail closed, because the
firmware console owns the screen until Rust says otherwise.
- On _EARLY it bailed whenever the surface size differed from the geometry
Rust named ("never resize from the refresh path"), and otherwise overwrote
that geometry with `surface_width`/`surface_height` before copying. So an
early front at a new size repainted nothing on arm64, forever, while x86
resized and painted it. `device_console_feed` states that _EARLY guarantees a
paintable target and that the shims therefore do not re-test the geometry.
- It had no _FIRMWARE arm at all: that kind fell into the re-push, which is the
pre-boundary steal the PCI shim's comment names. The `may_paint` gate on
`apply_scanout` means no product frame can be pending pre-boundary today, so
this arm is a closed door rather than a live loss — but it is the door.
Changes:
- `reims-vgpu-shim.{c,h}` gains `reims_vgpu_shim_console_feed`, which forwards
the kind and answers _FIRMWARE for a device with no handle or no answer. Both
shims call it; the PCI-private copy is deleted.
- `reims-vgpu-mmio.c` gains `paint_scanout`, factored out of `apply_scanout`
and now also used by `gfx_update`'s _EARLY arm, so both paint at the geometry
they were handed. It deliberately does *not* push the console the way the PCI
twin does: that shim's immediate push and this one's coalescing are each a
measurement of their own pathway, recorded next to each, and unifying them
would generalize one host's finding onto the other.
- Comments naming an "archive" implementation that no longer exists are gone.
Verification: x86_64 QEMU builds warning-free with all three shim files forced
to recompile. Driven boot, `window-drag-probe --seconds 25 --app Safari`:
desktop up at 1921x1079 / 138742 colors, window moved (320,180) -> (724,222),
fail-channel classes unchanged from baseline (gva_zero_pfn,
buffer_import_bind_offset_alignment, mem_qemu_read_gpa_callback_failed,
llvm_vector_alloc_stride) with no new reason.
Not verified: the arm64 MMIO pathway cannot be booted from this host, so the
three fixes above are argued from `device_console_feed`'s stated contract and
from the PCI shim that already honours it, not from a boot. The Darwin-only
arms of reims-vgpu-mmio.c are untouched and were not compiled.
Co-Authored-By: Claude <noreply@anthropic.com>
`hw/display/reims-vgpu-{mmio,pci}.c`, both pathways.
Three constants that cross the Rust/C boundary existed as three copies each with
nothing comparing them:
- the EFI pre-boot mode, `1920u`/`1080u`, once per shim and once in Rust as
`model::regs::EFI_BOOT_{WIDTH,HEIGHT}`;
- the gfx MMIO window size, `0x4000`, as `REIMS_VGPU_MMIO_GFX_MMIO_SIZE`, as
`REIMS_VGPU_PCI_BAR_SIZE`, and in Rust as `model::regs::GFX_MMIO_SIZE`.
Both now come from `include/reims_vgpu_qemu_abi.h`, which is the file the
project's rule already names for anything crossing the boundary, and the local
defines are gone.
The EFI pair is the one that bites. The shim sizes the `DisplaySurface` the
pre-boot console is painted into, and `scanout::paint_efi_console` refuses a
paint whose width is not the mode this device advertised to the firmware. A
drift does not degrade — it makes the refusal fire on every early console paint,
into a surface the shim itself just created at the other size, with the two
numbers living in different files and different languages. The window size is
the same shape one level down: a region larger than the bound Rust indexes is
guest-addressable space whose accesses reach a register store with no slot for
them.
Kept local on purpose: `REIMS_VGPU_MMIO_IOSFC_MMIO_SIZE`, because Rust keeps no
per-offset state for that rail and a mirror would be a source of truth nothing
checks; and `REIMS_VGPU_PCI_EFI_BPP`, which describes this shim's own BAR1 GOP
layout rather than anything Rust reads — Rust reaches those bytes only through
`efi_console_copy`'s explicit stride argument.
No ABI version bump: these are compile-time constants, not a change to the
`HostOps` table or any struct layout the version guards.
Verification: `scripts/qemu-build/qemu-build.sh` — both shim objects rebuild and
`qemu-system-x86_64` links, with both devices present. The Rust side of this
change carries the two drift tests.
`hw/display/reims-vgpu-dirty.c` — the guest-write witness, shared by both shims
and every pathway.
The flat view walk that replaced the monotone hull recorded guest-RAM ranges
into a fixed 64-entry array and stopped when it filled. That bound is not a
budget. A range it dropped is a range no tracked page can resolve into, and an
unresolvable page reads as written — for every page in the range, on every
harvest, for the life of the VM, with no counter naming it. That is the same
latch the hull produced, reached by a smaller door, and nothing about it is
recoverable or observable from the guest side. So the table now grows to
whatever the flat view reports and the bound is gone with the magic number that
carried it.
Measured before changing it, because a table should be banded before it is
widened: 5 ranges on x86 q35 with this device, unchanged across a driven boot
including the load phase. 64 therefore had ample headroom and was never close to
binding — this removes a failure mode, not a live fault, and the comment now
says so rather than implying the reach was under pressure.
Two smaller things fall out. The per-range `logged`/`needs_log` state moves from
parallel stack arrays into the slice itself, which is where the page loop reads
it. And the logging pass now lets `g_hash_table_add` decide, rather than the
flag: one MemoryRegion can supply several ranges — on q35 guest RAM is one
region aliased below and above the PCI hole — so a region whose ranges both
asked for logging took `memory_region_ref` twice against a single table entry,
and the extra reference was never dropped.
Verified: builds warning-free. A driven boot on this binary
(vibrancy-latch-probe, 150 s load) reads `gw_refused_guest_store` 165 and
`deferred_flush_clobber` 0 — inside the clean band of 145-186 and 0, against a
degraded cluster of 20122-34772 and 29-69 — with `t11rung_resident_refused` 30
against 27780 latched, and the two controls `t11_gw_armed` (75283) and
`gw_vouched` (43484) at their usual magnitudes, so the witness is still armed
and answering rather than silenced. The temporary probe that produced the range
count was removed before this build.
Not verified: the pane gate refused a verdict on that boot rather than scoring
it — its control region moved, so the two shots are not the same scene. The
mechanism counters above are the reading. arm64/MMIO is the same file and was
not booted; it presents guest RAM as one range, so it exercised neither the old
bound nor the aliasing that double-referenced.
Co-Authored-By: Claude <noreply@anthropic.com>
Follow-up to the FlatView slice cut in the previous commit. Enabling region
logging moved to the tail of the harvest, because `memory_region_set_log`
rebuilds the flat view the slice table describes — but the arming push that
protects a set from that harvest still ran where it always had, which is now
*after* the generation update it was meant to gate. A set created one harvest
earlier therefore reached `s->gen = 1` on a harvest whose sync was taken before
its region started recording, and its first readable generation rested on an
absence of reports that was never evidence.
Wrong direction to leave open even though it cannot produce the latch this
series is about: it reports a written surface as clean, not a clean one as
written.
Make the wait per set rather than global. A set that met an unrecorded region
while reading its own pages pushes its own `arm_at`, in the same locked pass that
found it and before the generation moves. That is strictly narrower than the
global push it replaces — a set whose pages all sat in recorded regions no longer
waits for one that did not — and it keeps the documented window exactly: two
harvests for the first surface of a boot, one for every surface after it.
The test stays `s->gen == 0`. An already armed set must not be sent back through
its startup window; its pages read as written for that harvest, which is the
conservative answer and needs no help.
Verified: builds warning-free. Boot sweep pending, same as the previous commit.
The guest-write witness (`hw/display/reims-vgpu-dirty.c`, both shims, every
pathway) cut its tracked window by walking a monotone hull of every GPA ever
tracked with `address_space_translate`. That walk cannot be made correct.
`address_space_translate_internal` clamps `plen` to the section **only when the
section is RAM** (`system/physmem.c`); for anything else it hands back the whole
requested length. So the first non-RAM byte in the hull produced one `mr == NULL`
slice covering every guest page above it, and the walk stopped there.
On x86 q35 low RAM ends below the PCI hole and high RAM begins at 4 GiB, with 37
device ranges in between. One tracked page landing in low RAM while others sat
above the hole was enough: every page in high RAM then resolved to that slice.
`reims_vgpu_dirty_harvest` reads a page it cannot resolve as written — the
conservative answer, and the right one for a page that is genuinely gone — so
every tracked surface reported itself permanently overwritten by the guest. The
hull never shrank and the clear pass skipped unresolved pages, so nothing could
undo it for the life of the VM.
Downstream that is a guest-visible latch rather than a slow path. Every
host-side copy of a surface is declared stale, the type-11 sampled rung refuses
its resident and merges guest pages that never held the composite, and deferred
render windows report `deferred_flush_clobber`. It reads as vibrancy backdrops
going transparent and popover geometry breaking, and it does not recover.
Ask the FlatView for the guest-RAM ranges instead of reconstructing them.
`flatview_for_each_range` reports every range with exact bounds; guest RAM is a
handful of them, so the slice bound now describes RAM regions rather than a hull
that crosses MMIO, and no reachable input makes it lie. The hull is deleted with
the walk that needed it.
Logging is now enabled for the regions a tracked page actually resolved into,
discovered in the read pass and applied after the clear pass, because
`memory_region_set_log` rebuilds the flat view the slice table describes. A
region not yet logged reads as written for that harvest, which is what a region
with no recorded history has to say, and the arming push that follows keeps the
documented one-harvest/two-harvest window exactly as it was.
Measured: `gw_refused_guest_store` separates clean from degraded boots with no
overlap over twelve recorded boots on two binaries — 155-186 on the seven clean
ones, 20 122-34 772 on the five degraded ones — and steps between the two inside
a single second, never returning. That counter is the gate for this change.
Not verified: this commit is the build and the reasoning; the post-fix boot
sweep that scores it has not run yet. arm64/MMIO is the same code but was not
booted.
Component: `hw/display/meson.build`, `meson_options.txt`.
`reims_vgpu_backend_kind` was read from `REIMS_VGPU_BACKEND` in the environment.
That is correct exactly once, at configure. Meson also re-runs its build files
whenever ninja finds them out of date, and *that* run inherits ninja's
environment — which for any plain `ninja`, any IDE, and any script that did not
export the variable is an environment where it is unset. The default is `metal`,
so a tree configured for Vulkan quietly became a Metal one the first time
anything under `hw/display` changed.
On a Linux host the result is not subtle — `backend-metal` is Apple-only and the
staticlib fails with twenty-odd Rust errors — but it arrives at the next *boot*
rather than at the change, and the caller's own stamp still says `vulkan`,
because the script wrote what it intended rather than what meson resolved.
The backend is now a meson option, which is stored in the build directory and
survives regeneration. `env` stays the default so a caller that has not been
taught the option keeps its old behaviour, and it is read only on a real
configure.
Verified: reconfigured x86_64/vulkan from scratch, then `touch
hw/display/meson.build` and `env -u REIMS_VGPU_BACKEND ninja` — build.ninja
still names `--no-default-features --features backend-vulkan,host-window` and
nothing names `backend-metal`. Before this change that sequence rewrote the rule
to `--features backend-metal`.
Co-Authored-By: Claude <noreply@anthropic.com>
Component: Reims VGPU QEMU shim, x86 PCI attach.
`reims_vgpu_dmabuf_for_pages` turns page-aligned guest GPAs into one dma-buf fd
via `UDMABUF_CREATE_LIST`, so the host GPU can read and write those pages in
place instead of the device staging every byte through the CPU in both
directions.
The shim answers with the fd or with a named `REIMS_VGPU_DMABUF_ERR_*` code from
the shared ABI header. It exports no inputs: whether this host has
`/dev/udmabuf`, whether guest RAM is fd-backed, and whether the run list fits
the kernel's bound are questions only QEMU can answer, and a caller holding all
three would reconstruct the rule.
Two things that are derived rather than guessed:
- The run offset is `qemu_ram_get_fd_offset(rb) + offset`. A RAMBlock may sit at
a non-zero offset inside its backing file, and dropping the block's own offset
builds a dma-buf over the wrong bytes of the right file — corruption, not a
failure. QEMU's own `virtio-gpu-udmabuf.c` omits this term.
- `REIMS_VGPU_DMABUF_MAX_RUNS` is the udmabuf driver's `list_limit` default.
Adjacent pages coalesce first, so it bounds runs and not pages: a contiguous
surface of any size is one run, and a scattered one is refused by name rather
than as an opaque ioctl error.
`/dev/udmabuf` is opened once. Opening it is a permission check as much as an
acquisition and the answer cannot change while the process runs, so a host
without the node does not retry the open per resource.
The non-Linux arm answers `UNSUPPORTED` in C rather than being absent, so the
Rust side sees one named refusal instead of a link error. The sysbus/MMIO attach
leaves the callback NULL, which reads the same way.
Verified: `ninja libsystem.a.p/hw_display_reims-vgpu-dmabuf.c.o
libsystem.a.p/hw_display_reims-vgpu-pci.c.o` compiles clean, and `nm` shows
`reims_vgpu_dmabuf_for_pages` as a defined text symbol.
Not verified: no live boot — nothing has called this against real guest pages,
and the full QEMU link was not run (this build directory's staticlib target is
configured for `backend-metal`, which does not build on a Linux host).
QEMU built against a -C instrument-coverage staticlib writes default_*.profraw
into its working directory when LLVM_PROFILE_FILE is unset. scripts/runtime-dead
sets it, but a hand-run does not. These are build artifacts, never tracked.
vendor/qemu, x86 Vulkan link path. Opt-in and off by default.
Building crates/reims-vgpu with -C instrument-coverage produces __llvm_prf_*
sections and nothing that writes them. rustc bundles profiler_builtins into a
final artifact; this staticlib is not one, QEMU links it. So the profile runtime
has to be named at the QEMU link instead, and named --whole-archive: no
instrumented object references it, so the linker drops every member otherwise.
REIMS_VGPU_COVERAGE carries the path to libclang_rt.profile-<arch>.a. Unset —
the default, and every build that is not scripts/runtime-dead — changes nothing:
verified by rebuilding with the variable clear and confirming the binary carries
no __llvm_prf_cnts section.
This exists for scripts/runtime-dead, which measures which decoded paths the
guest protocol never takes. AGENTS.md names that as the one reduction lever
scripts/dead-state cannot see.
vendor/qemu thin shim, both pathways (reims-vgpu-pci, reims-vgpu-mmio).
v14 moved the console-ownership *kind* into Rust but went on exporting it as
an input, and the two shims did with it what shims do:
- reims-vgpu-pci rebuilt the paint verdict itself, out of console_feed's
out_kind and out_mapping_id:
kind == FIRMWARE || (kind == EARLY && mid != mapping_id)
- reims-vgpu-mmio rebuilt nothing and painted every present it was handed.
So a pre-boundary present naming a mapping other than the latched early front
was refused on x86 as a steal of the firmware console, and painted on arm64.
One rule, one pathway holding it — the same shape as the GPA-attrs drift, on
the question of who owns the screen.
The verdict is now exported whole as reims_vgpu_qemu_scanout_may_paint (ABI
v15) and forwarded by reims_vgpu_shim_scanout_may_paint, which both shims call.
The kind stays exported because fb_update genuinely dispatches on it — it picks
between three QEMU-side mechanisms — but no shim assembles the paint rule now.
x86 behaviour is unchanged by construction: the two branches the shim lost
(rust_handle == 0, and a console_feed that errors) both already collapsed to
FIRMWARE and therefore to "do not paint", which is what the forwarder returns
for both. arm64 changes: it gains the gate it never had.
Verified: x86 boot (vm/boot-x86.sh --device reims-vgpu-pci --testing,
REIMS_VGPU_WINDOW=0 so gfx_update and apply_scanout actually run) reaches the
macOS 13.7.8 desktop with WindowServer alive; fail-log record set unchanged
from the pre-change boot (same seven classes, no new ones).
NOT verified: the arm64 MMIO pathway. It needs an Apple host, and it is the
pathway whose behaviour this changes.
Component: QEMU device shims, both pathways (`reims-vgpu-pci` x86,
`reims-vgpu-mmio` arm64) plus the shared `reims-vgpu-shim`.
`read_gpa`/`write_gpa` were written twice, and the two copies had drifted on the
one thing that matters. The PCI shim passed `MemTxAttrs{ .memory = 1 }`; the MMIO
shim passed `MEMTXATTRS_UNSPECIFIED`.
That attribute is not cosmetic. Every GPA reaching these two functions came from
a guest-supplied page-entry list. With `.memory` set, an entry that resolves to a
device instead of RAM is rejected with MEMTX_ACCESS_ERROR; without it, the access
is performed — so a bad PFN pointing at one of our own BARs re-entered this
device's MMIO handler from inside a Rust call that already held the device lock.
The x86 shim carried a comment naming that hazard. The arm64 shim had the same
hazard and no defence.
`reims-vgpu-shim.h` states the rule this violated: a duplicated predicate is a
predicate that can drift, and a drift between the two shims is a bug the guest
sees on exactly one pathway. Both functions ignore the HostOps `ctx` entirely,
which is that header's own test for belonging in the shared file, so they move
there with the attrs and their basis recorded once.
Net -4 lines of C; the point is the drift, not the count.
Verified: x86_64 build clean, all four shim objects recompiled warning-free
(pci, mmio, dirty, shim). One driven `vm/boot-x86.sh --device reims-vgpu-pci
--testing` boot reached the guest desktop and presented guest frames through the
engine-resident zero-copy rail; against the stashed baseline log the memory-
callback failure census is identical (one pre-existing EFI-framebuffer read at
0x80000000, present on both arms) and `window_publish` reads 416 against 415.
NOT verified: the arm64/MMIO pathway, which is where the behaviour actually
changes. That needs an Apple host. The change there is strictly narrowing — RAM
accesses are unaffected; only device-targeted GPAs, which previously re-entered
MMIO, now fail closed and surface as a visible decline.
Co-Authored-By: Claude <noreply@anthropic.com>
hw/display/reims-vgpu-pci.c and hw/display/reims-vgpu-mmio.c. Needs the
matching parent commit — this is ABI v14 and will not link against v13.
Both shims called `present_boundary_seen` and `early_scanout_target` and
recombined the pair into a three-way: firmware console, early latched front, or
product present. That branch is the host-console ownership rule. It is protocol
policy, AGENTS.md says C is a thin shim, and the rule already existed a third
time in Rust — at `host_console_uses_bar1`, whose doc said in as many words
"shipped C mirrors this". Three copies of one display-ownership rule is three
chances for a pathway to disagree about who owns the screen.
Both queries are replaced by `reims_vgpu_qemu_console_feed`, which returns the
answer. `reims_vgpu_pci_present_boundary` and
`reims_vgpu_pci_early_scanout_latched` are gone; `apply_scanout` and `fb_update`
switch on the kind. The geometry validity test the shims each did on the early
target (`mid == 0 || w == 0 || h == 0`) is gone with them — that is a decode
rule, and `_EARLY` now guarantees a paintable target.
Every branch is a semantic identity with what it replaced:
boundary -> _PRODUCT paint
!boundary, no early latch -> _FIRMWARE do not paint
!boundary, latched, mid != id -> _EARLY do not paint
!boundary, latched, mid == id -> _EARLY paint
rust_handle == 0 -> _FIRMWARE do not paint
`fb_update`'s `_FIRMWARE` arm returns unconditionally, including when the
firmware copy fails, exactly as the old code did. Falling through to the
pending-frame re-push there would push a product frame while Rust says the
firmware console owns the screen, which is the pre-boundary steal this feed
exists to prevent.
Verified by A/B on a live x86 guest, both boots `REIMS_VGPU_WINDOW=0` so QEMU
owns the console with `-display gtk` and `fb_update` actually ticks (the default
host-window config uses `-display none` and never calls it, so it does not
exercise this code at all):
- this commit, and the same boot with both repos stashed to baseline
- screenshots at the same boot stage are **byte-identical**, 4174 bytes each,
ImageMagick RMSE 0 (0)
That console renders black on both arms. It is black at baseline, so this change
did not cause it; the boot script and AGENTS.md both record the QEMU display
path as deprecated for product work, kept for archaeology and A/B. The supported
host-window path booted to a full macOS desktop on this staticlib.
Also verified: both shim objects deleted and recompiled explicitly, no
diagnostics; `qemu-system-x86_64` links.
Not verified: the Darwin arm of `reims-vgpu-mmio.c` (`#if defined(CONFIG_DARWIN)`)
is not covered by a Linux compile, and arm64 was not booted. The mmio change is
outside that guard.
hw/display/reims-vgpu-pci.c and hw/display/reims-vgpu-mmio.c.
`REIMS_VGPU_PCI_MAX_DIM` and `REIMS_VGPU_MMIO_MAX_DIM` were each `8192u`, each
declared in its own shim, each with no stated basis, and each used for exactly
one thing: the geometry guard in that shim's `set_mode`. That is two copies of a
product policy bound sitting in the thin C layer, which is the shape
`reims-vgpu-shim.h` already warns about in its own header comment — a duplicated
table is a table that can drift, and a drift between the two shims is a bug the
guest sees on exactly one pathway. Here it would be a geometry that one attach
accepts and the other silently drops.
Both now use `REIMS_VGPU_MAX_SCANOUT_DIM` from the shared ABI header, which both
files already include. The bound's owner is Rust `model::MAX_SCANOUT_DIM`, where
the basis is now recorded: it is derived from the allocation it bounds, not from
a device capability — tightly packed BGRA8 at 8192 squared is a 256 MiB single
surface, the figure `surface_cache`'s GVA cache cap is reasoned against, and the
16-bit wire fields would otherwise admit a 16 GiB surface from one corrupt guest
word.
No behaviour change: same value, same guard, same two call sites.
Verified: `scripts/qemu-build/qemu-build.sh --backend vulkan --target x86_64`
links `qemu-system-x86_64` clean, and both shim objects were deleted and
recompiled explicitly so this is not a stale-object pass —
`hw_display_reims-vgpu-mmio.c.o` and `hw_display_reims-vgpu-pci.c.o` both build
with no diagnostics.
Not verified: no guest was booted, and the Darwin arm of `mmio.c` is guarded by
`#if defined(CONFIG_DARWIN)`, so the Linux compile above does not cover it. The
lines changed here are outside that guard.
Component: QEMU x86 PCI shim (`reims-vgpu-pci.c`), the `efi_console_copy` half
of the pre-boundary host-console feed.
`reims_vgpu_pci_copy_early_console` declared `gpa` and `fb_stride`, passed
their addresses to `reims_vgpu_qemu_efi_console_copy`, and then read neither.
The call's only decision is `rc == REIMS_VGPU_QEMU_OK`. Both locals are gone
and the call now passes the five arguments it actually uses.
The staticlib side drops the matching outs in the same changeset, so the ABI
header, the `extern "C"` shim and this caller move together.
Verified: `scripts/qemu-build/qemu-build.sh --backend vulkan --target x86_64`
builds clean from a fresh configure (the pre-existing build dir was stale — its
stamp read `x86_64:vulkan` while `build.ninja` still baked `backend-metal`, so
it was removed and reconfigured). `qemu-system-x86_64` reports both devices
present with the vulkan-linked staticlib.
Not verified: no live x86 guest boot. This removes only discarded out-params;
the copy path and its OK/EMPTY contract are unchanged.
Component: QEMU C shim (hw/display), both pathways -- reims-vgpu-pci
(x86 PCI) and reims-vgpu-mmio (arm64 sysbus).
reims-vgpu-pci.c and reims-vgpu-mmio.c each carried their own copy of
seven functions whose bodies were byte-identical once the pci_/mmio_
name prefix was normalised away:
mono_ns, is_ram_gpa, read_kva -- ignore the HostOps ctx entirely
button -- a 27-line REIMS_VGPU_BUTTON_* table
input_key, input_pointer_move, input_button -- read only s->con
None of them read anything from the device state, so neither copy was
earning its bus-specific home. The cost was not the 222 duplicated
lines; it was that a change to the button table or the is_ram_gpa
predicate had to be made twice, and a miss would produce a bug visible
on exactly one of the two pathways. That is the failure mode the split
invites and nothing prevented it.
They now live in reims-vgpu-shim.{c,h}, following the precedent
reims-vgpu-dirty.{c,h} already set as code "shared by both shims". The
three with HostOps-compatible signatures are pointed at directly from
both host_ops tables; the three input helpers take a QemuConsole* so the
caller supplies the one field they needed. `button` is now static inside
the shared file, since it has no caller outside it. Every comment that
explained a removed body was carried across -- notably the read_kva
"never fall back to first_cpu" AB-BA deadlock note, which had existed
only in the mmio copy even though both copies had the hazard.
Dropping the bodies left includes with no remaining user: ui/input.h,
system/hw_accel.h, exec/cpu-common.h, hw/core/cpu.h and qemu/timer.h in
the PCI shim, and ui/input.h plus exec/cpu-common.h in the MMIO shim.
Removed, and the surviving uses re-checked by rebuild rather than by
grep, since QEMU headers include each other freely.
C shim total 3,206 -> 3,170 lines. The net is small because the shared
file carries the contract comments; the duplication itself went from 222
lines to 116.
Verified: all three objects compile warning-free on Linux/x86_64 via
`ninja libsystem.a.p/hw_display_reims-vgpu-{pci,mmio,shim}.c.o`, and no
reference to any removed symbol remains.
Not verified: no live VM boot on either pathway, and the Apple-host
build of these files was not exercised -- the code is bus-independent
and host-independent, but the arm64/HVF compile was not run here.
Component: QEMU C shim, hw/display/reims-vgpu-pci.c (x86 PCI pathway).
Deletes `reims_vgpu_pci_gop_console_proxy()` and the
`reims_vgpu_pci_bar1_fingerprint()` it drove, the seven `gop_proxy_*` fields
of device state they carried, their reset block, and the three call sites in
`reims_vgpu_pci_fb_update()`.
What it was: on every display refresh tick it FNV-1a'd a 1/64 sample of the
1920x1080 BAR1 framebuffer, compared the digest against the previous tick, and
`fopen`/`fprintf`/`fclose`'d a line into a hardcoded `/tmp/reims-vgpu-gop-console.log`
on change or every 250 ms.
Why it goes:
- Its own comment declares it a probe, not a feature: "Freeze class under test",
"Correlate this log with serial milestones", "do NOT use content as product
cutover". AGENTS.md says temporary probes are fine to collect evidence and
must be removed before claiming the fix. The freeze it was built to chase is
not referenced by any remaining code, script, or doc.
- It costs a strided read of ~32k framebuffer pixels plus an open/write/close
syscall trio on the display refresh path, per tick, always on. That is real
per-frame work for a diagnostic no one reads.
- The hardcoded `/tmp` path is not a product artifact. The device already has an
always-on fail log with a real sink behind it; a second, separate, unbuffered
log file bypasses it.
`reims_vgpu_pci_copy_gop_fb()` is untouched — that is the product early-boot
GOP framebuffer copy, not the probe. The console-ownership contract in
`fb_update()` (boundary, early latch, product present) is unchanged; only the
proxy calls sitting beside it are gone. `REIMS_VGPU_PCI_EFI_W/H/BPP` remain in
use by the real copy paths.
Verified: `ninja libsystem.a.p/hw_display_reims-vgpu-pci.c.o` in the existing
build tree compiles clean.
Not verified: no live x86 VM boot in this change — the removal deletes an
observer with no control edge into `fb_update`'s return value or the surface.
Co-Authored-By: Claude <noreply@anthropic.com>
Component: hw/display/reims-vgpu-dirty.{c,h}. Paired with the parent repo's
d7f151b, which carried the Rust-side counter and the corrected docs and left
this half uncommitted in a detached submodule.
`reims_vgpu_dirty_track` pinned a new set's generation at 0 for two harvests,
reasoning that the first harvest after the call may still be turning dirty
logging on for the pages' regions, so writes older than it were never recorded.
That reason is right and it is a reason about the *first* set to name a region.
Guest RAM is one MemoryRegion, so after the first tracked surface of a boot no
harvest enables anything and the second harvest waited for an event that could
no longer occur.
Waiting is not free. An unarmed set reads back generation 0, the Rust side's
`guest_write_gen` maps that to "cannot tell", the type-11 LOAD elision refuses
with `t11_gw_ref_no_stamp`, and the draw pays a whole-frame seed read out of
guest pages plus a whole-frame staging upload. The window is counted in harvests
and harvests are driven by guest doorbells, so it lasts as long as the guest
stays quiet — which is exactly when a draw arriving into it is a visible hitch.
`arm_at` is now `harvests + 1`, and `reims_vgpu_dirty_harvest` pushes every
never-armed set to the next harvest when that harvest had to enable logging, so
a set created before its region was logged arms exactly as late as before. The
push tests `s->gen == 0` rather than `d->harvests < s->arm_at`: a set created at
harvest H carries `arm_at = H + 1` and `d->harvests` is already H + 1 at that
point, so the arithmetic test is false for precisely the set that needs pushing.
Soundness: with logging already on, every guest write to the pages since the
last sync is already in KVM's bitmap, so the first sync after `track` reports
all of them. A write predating `track` is also reported, which refuses an
elision that could have been taken — conservative in the safe direction. A page
reported unwritten was genuinely unwritten, because logging was on for the whole
interval.
Measured, two boots running the same sequence, normalised: unarmed stamps
99/7577 = 1.31 % before against 162/14257 = 1.14 % after, and full-frame seed
uploads 1.56 % against 1.40 %. Real, small, and not the hitch fix — most sets
were already arming within about one Store either way.
Verified: QEMU rebuilt and booted (x86/PCI, reims-vgpu-pci), guest reached the
desktop and Safari probes returned; parent-repo tests and clippy in d7f151b. Not
verified: `FakeHost` does not model the arming window, so there is no unit test
for this and the proxy is the live counter pair above; the arm64/MMIO pathway
shares this file and was not booted.
Component: vendor/qemu thin shim (x86 PCI + arm MMIO), guest-write tracking.
reims_vgpu_dirty_harvest already reads the hypervisor bitmap one guest page at
a time. It folded that into a per-set boolean and threw the rest away, so the
only question the device could ask was "did anything in this surface move".
That is the right question for a reader deciding whether to reuse a host-side
copy: one moved page makes the copy wrong. It is the wrong question for a
writer. A deferred writeback holds a frame the device rendered and lands it in
the guest's pages later; if the guest wrote some of those pages in between,
writing the whole frame loses the guest's stores and dropping the frame loses
the device's. Neither is correct and the difference between them is exactly
the per-page list this discards.
Adds reims_vgpu_dirty_written_since: the page-aligned GPAs of a token's set
whose last observed write is newer than a generation the caller previously
recorded. Backed by a page_gen array parallel to pages, stamped in the harvest
that already computes the answer -- so this costs one u64 per tracked page and
no extra bitmap work.
Stamped after the generation update rather than during the page walk, because
the value to stamp with is the generation this harvest produces, and that is
not known until every page has been read. Not stamped at all while the set is
inside its two-harvest startup window: a page stamped there would carry a
generation no reader can have recorded and would read as written forever.
Returns -1 -- "assume the whole set was written" -- for an unknown token, an
unreadable generation, a since_gen of 0, and a set with more written pages
than the caller's buffer. It refuses rather than truncating: a short list says
"these pages and no others", which is the one answer that turns a
conservative caller into a wrong one.
Also plumbs guest_written_pages through both shims' HostOps tables. Pages that
this harvest could not cut a slice for, or that are not RAM, are recorded as
written per page as well as for the set, so the per-page reader is never less
conservative than the generation.
Verified: qemu-system-x86_64 builds and links clean with the reims-vgpu
vulkan staticlib. Not verified: the arm MMIO shim is compiled but not booted
from this host.
`reims-vgpu-mmio` exposes both a gfx and an iosfc MMIO region, and either can
carry the write that hands the device work. The harvest sat on the gfx path
only, so on whichever rail the arm64 guest actually uses for a submission the
guest-write witness could be a whole submission stale — the elision would
answer with a generation harvested before the guest's last store instead of
after it.
Both paths now harvest. Neither is a new cost: the harvest returns immediately
unless a generation has been read since the last one, so covering the second
window costs a predicate rather than a sync. `reims-vgpu-pci` has no second
window and is unchanged.
Verified: `ninja libsystem.a.p/hw_display_reims-vgpu-mmio.c.o` warning-free on
Linux.
Not verified: no arm64 host available here, so the ordering this restores has
not been exercised on the pathway it exists for.
Co-Authored-By: Claude <noreply@anthropic.com>
Implements the reims-vgpu ABI v12 guest-write tracking triple in both shims
over the hypervisor's dirty bitmap.
A paravirtual surface's storage is plain guest RAM. The guest CPU stores into
it with no device operation at all, so nothing the Rust device counts can
witness such a store, and every host-side copy of those pages (an engine
resident, a cache entry) is stale from that instant with nothing to say so.
The hypervisor's dirty bitmap is the only witness; this is the adapter.
New `hw/display/reims-vgpu-dirty.{c,h}`, shared by both shims:
- `track` registers a mapping incarnation's page list, `gen` reads a monotonic
count of harvests that saw some page of it written, `untrack` releases it.
`gen` is safe from any thread; `harvest` is BQL-only.
- The harvest runs in `gfx_write`, **before** the register write reaches Rust.
That is the guest handing the device work, so every guest store ordered
before the handoff is observed before the work that could reuse a host-side
copy of those pages runs. It is also the only place it can run: the
accelerator's dirty-log sync needs the BQL, which a vCPU MMIO write holds and
the drain thread must never take — taking it there inverts against
`gfx_write`, which already calls into Rust with the BQL held.
- Read and clear are separate passes. Reads are pure
(`physical_memory_get_dirty_flag`), so every set holding a page sees the same
answer; a snapshot-and-clear per set would let the first set harvested
consume the reports of every set sharing its region — and its bitmap-long
rounding would take up to 63 neighbouring pages with it.
- Only pages that came back written are cleared. Clearing re-protects, so
clearing the whole tracked window would make every page the guest has mapped
refault after every harvest; this costs one refault per page the guest
writes again. Exactly-adjacent pages merge into one hypervisor round trip and
no range is widened past a page that was written.
- A set's generation reads back 0 ("cannot tell") for its first two harvests,
because writes older than the harvest that turned logging on for its regions
were never recorded, and their absence would otherwise look like the guest
not having written.
- A window that will not cut, a page outside it, or a page that is not RAM all
read as written — the conservative answer, which costs a reuse and never a
wrong frame.
- Region logging goes on once and stays on for the device life (refcounted via
`memory_region_set_log`, released in `reims_vgpu_dirty_free`): toggling per
surface re-protects the whole region each time.
- A harvest nothing has consumed since the previous one is skipped, so a burst
of register writes costs one sync.
- `page_size` below the target page is refused rather than answered at a
granularity the bitmap does not have. Both pathways are the other way round
(4 KiB x86 == target, 16 KiB arm64e > target, checked per target page).
Both shims gain the three callbacks, a `ReimsVgpuDirty *` created at realize
and freed after the Rust device is destroyed, and the harvest call in
`gfx_write`.
Verified: all three objects compile warning-free
(`ninja libsystem.a.p/hw_display_reims-vgpu-{dirty,pci,mmio}.c.o`), including
the MMIO shim built on Linux.
Not verified: no live VM boot yet. Nothing in Rust consumes the generation
yet, so no set is ever tracked and the harvest returns immediately.
Co-Authored-By: Claude <noreply@anthropic.com>
Component: QEMU shims (hw/display/reims-vgpu-mmio.c, hw/display/reims-vgpu-pci.c).
`map_pages` on the MMIO shim returns a direct RAMBlock HVA for a host-contiguous
run and a packed `mach_vm_remap` view for a fragmented one. `unmap_pages` was
`(void)ptr; (void)len;` and the views were held in `stable_aliases` until device
teardown, so every fragmented map leaked a VA reservation for the VM's lifetime.
That retention existed for one reason: Rust cached `VK_EXT_external_memory_host`
imports over those views and could re-read the pages at any later point, so the
address had to stay valid forever. Nothing imports guest pages any more, so the
retention buys nothing and the leak is pure cost.
`unmap_pages` now releases. The array survives as `page_views` but its job is
inverted — it is a *lookup*, not a retention list. It has to exist: a view and a
direct RAMBlock HVA are indistinguishable as bare pointers, and
`mach_vm_deallocate` on the latter would unmap the guest's own memory. A pointer
not found in it is guest RAM and is left alone. The recorded allocation length
is used rather than the caller's `len`, because a run entered at a page offset
asks to release fewer bytes than its view spans.
`reims_vgpu_mmio_free_page_views` stays as a teardown backstop but now logs
anything still mapped. A silent reclaim there is exactly what hid this leak.
`map_pages_stable` splits, and the split is the honest reading:
- MMIO -> 0. It can hand out a view whose lifetime the caller owns, and the flag
cannot be conditioned on whether a particular run turned out contiguous.
- PCI -> 1, unchanged, with the claim narrowed in its comment. That shim never
allocates: it refuses any list that is not a packed host-contiguous run and
otherwise returns `memory_region_get_ram_ptr() + xlat`, which is guest RAM
itself. No release is owed and none is possible to get wrong.
The flag used to mean "you may retain this inside a cached host-pointer import".
It now means only "no release is owed", which is why the two shims can disagree.
Not verified: QEMU is not configured or built on this host — the edits are
brace/paren balanced and `qemu/log.h` is already included for the new
`qemu_log_mask`, but nothing compiled them and no VM was booted.
Component: QEMU MMIO shim (hw/display/reims-vgpu-mmio.c).
`reims_vgpu_mmio_set_gpu_mode` allocated a display buffer at an alignment it
negotiated with Rust, attached it as the DisplaySurface backing, and handed it
to `reims_vgpu_qemu_scanout_gpu_copy` so the engine could DMA a finished present
into it — no framebuffer bytes across the CPU.
The alignment came from `VK_EXT_external_memory_host` and the buffers had to be
retained in `scanout_buffers` until teardown, because the engine cached their
imports. That extension is no longer requested, so the alignment query now fails
and the branch is dead. Removed the function, `surface_gpu_direct`,
`surface_buffer_len`, and the whole `scanout_buffers` retention array, leaving
`reims_vgpu_mmio_set_mode` and the CPU `scanout_copy` as the single path — which
is what every frame already took whenever the direct arm declined.
Not verified: QEMU is not built on this host and no VM was booted. The
corresponding Rust ABI exports and header declarations go in the same
superproject commit, so a build sees both sides or neither.
`reims_vgpu_pci_scanout_gl` imported an exported present dmabuf into QEMU's
console GL context. Its own comment named it "Deprecated pre-host-window
GL/dmabuf bridge" and said "The supported product path is the Rust host
window/direct-present route; keep this shim thin and do not extend it for fps
work unless explicitly doing historical investigation."
The Rust side only ever enqueued this action behind `REIMS_VGPU_SCANOUT_GL=1`, so it
was dead on every normal boot, and it is a second display path competing with
the real one. Removed there in the same change; this drops the handler and its
`REIMS_VGPU_HOST_ACTION_SCANOUT_GL` dispatch arm.
Wire value 7 is retired rather than reused: the surrounding action numbers are
unchanged (6 then 8), so nothing else on the ABI moves.
Not built — QEMU was not compiled for this change; verified by grep that no
reference to the removed symbols remains under hw/display/.
Co-Authored-By: Claude <noreply@anthropic.com>
Component: QEMU display build integration.
Update the Reims vGPU Meson integration for the repository layout where QEMU lives under vendor/qemu and the Rust host crate lives under crates/reims-vgpu. The C shim still links the same staticlib and includes the same C ABI header; only the source-root-relative paths change.
Verification: ran git diff --check in the QEMU submodule before committing.
Component: QEMU display/vmapple integration.
Add thin sysbus MMIO and PCI Reims vGPU devices that hand device behavior to the host Rust backend through the C ABI. Wire the devices into hw/display build configuration, trace events, and vmapple's gfx-device selection while keeping protocol and backend logic outside QEMU.
Verification: reconstructed from base b83371668192a705b878e909c5ae9c1233cbd5fb; applied host/qemu-patches/0001-0005 with git am --3way; staged the exact tree from current host/qemu tip ab8fc79abf9a366e6b6effc258c9c53b188f6753; final tree compared against that tip before push.
Select the paravirt GPU backing REIMS_VGPU_GFX/REIMS_VGPU_IOSFC via a machine property
(default apple-gfx-mmio). Product-device alternatives were removed; only
Apple's ParavirtualizedGraphics path remains valid.
hvf_arch_vm_create() hardcoded the hv_gic distributor/redistributor GPAs
to hw/arm/virt.c's base_memmap (0x08000000/0x080A0000). On any machine
whose GICv3 lives elsewhere — vmapple puts it at 0x10000000/0x10010000 —
kernel-irqchip=on placed the in-kernel vGIC at addresses the guest never
touches, while the guest's dist/redist accesses landed on the GIC
device's ops-less MemoryRegions (reads-as-zero, writes ignored). A
vmapple macOS guest wedges in iBootStage2 that way (no timer PPI ever
enabled, one vCPU spins at 100%).
Add a MachineClass::get_vgic_bases hook (mirroring
get_kernel_irqchip_default), implement it for vmapple from its memmap,
and fall back to the virt values when a board does not provide it.
With this, vmapple boots macOS to the desktop under kernel-irqchip=on:
render oracle clean (1440x1080 screendump, desktop content), ssh up,
in-guest top idle. Verified on macOS 26.5 host, Monterey vmapple guest.
macOS 13+ guest kernels access MMIO with instructions the CPU reports with
ISV=0 (no instruction syndrome) during early boot — load/store pair, SIMD&FP
single-register, and pre/post-indexed GPR loads/stores. macOS 12 did not, so
the vmapple bring-up never hit this. QEMU's hvf arm data-abort handler had a
bare assert(isv), so any such access aborted QEMU (observed:
insn=0xb8080d09 'str w9,[x8,#128]!' at ipa=0x10020080).
Decode the faulting instruction from guest memory and perform the access at
the already-translated fault IPA, covering exactly the A64 classes that report
ISV=0 and can target MMIO. Refuse SP-based writeback and anything unrecognized
(abort with pc/insn/va/ipa context) rather than silently mis-emulating.
hvf_arch_init_vcpu() asserts !(ri->type & ARM_CP_NO_RAW) while building the
cpreg sync list. Some ID registers (e.g. ID_AA64ISAR0_EL1) became
ARM_CP_NO_RAW in system emulation because a field is computed at read time
via a readfn (RNDR depends on SCR_EL3.TRNDR under FEAT_RNG_TRAP). Such regs
have no raw backing store to sync with HVF and must not be added to the sync
list. Without this, the assert aborts on a macOS 26 host and no aarch64 HVF
guest (incl. vmapple) can start. Verified live: the vmapple guest gets past
HVF vCPU init to iBootStage2 with this change.
Applies the QEMU-devel RFC v7 series "vmapple: make it work on the latest
macOS release" (Mohamed Mediouni), patches 1-6, rebased onto this base:
1. apple-gfx: use the macOS 15.4+ PGMemoryMapDescriptor interface
(+ argument buffers / process isolation)
2. hw/vmapple/aes: convert MAX_LEN to a #define
3. vmapple: declare it AArch64-compatible (visible to -M vmapple)
4. build the VMapple machine by default (CONFIG_VMAPPLE=y)
5. vmapple: add the arm-gicv2m MSI controller
6. vmapple, gicv2m: macOS compat quirk (V2M_MSI_TYPER bit 31)
Patch 7 (private ISA / Tahoe) is deliberately excluded: it requires SIP
disabled + AMFI bypass, which this project does not do. This boots an arm
macOS Monterey guest under -M vmapple with HVF on a macOS 26 host.
2026-07-26 14:23:54 +03:00
18 changed files with 3282 additions and 26 deletions
@@ -2432,11 +2689,24 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcpu_exit_exception_t *excp)
*/
assert(!s1ptw);
/*
* TODO: ISV will be 0 for SIMD or SVE accesses.
* Inject the exception into the guest.
*/
assert(isv);
if(!isv){
/*
* No instruction syndrome (LDP/STP, SIMD&FP, ...): decode and
* emulate the faulting instruction. macOS 13+ guests do such
* accesses against MMIO in early boot.
*/
uint32_tinsn=0;
if(!hvf_emulate_isv0_mmio(cpu,ipa,&insn)){
error_report("hvf: unhandled ISV=0 data abort: pc=0x%"PRIx64
" insn=0x%08x va=0x%llx ipa=0x%llx wnr=%d",
env->pc,insn,excp->virtual_address,
excp->physical_address,iswrite);
abort();
}
/* Emulation advanced env->pc itself; flushed at handler tail. */
break;
}
/*
* Emulate MMIO.
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.