Skip to content

virtualbox: VBoxVMI register read and write - #306

Merged
Wenzel merged 2 commits into
devfrom
vbox/vboxvmi-registers
Oct 12, 2026
Merged

Wenzel merged 2 commits into
devfrom
vbox/vboxvmi-registers

Conversation

@Wenzel

@Wenzel Wenzel commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Closes #284.

  • VBoxVMI driver implements read_registers/write_registers: one round trip each, via rs-vboxvmi 5452496. Writes are all or nothing; values the CPU would refuse return InvalidRegisters.
  • Both VirtualBox methods now refuse efer != msr_efer with a shared EferMismatch error (VirtualBox has one EFER register); documented on the driver page and X86Registers::efer.
  • Tests: the VirtualBox register tests run under both methods; invalid-RFLAGS check goes through the driver; new virtualbox_write_registers_survive_resume (SYSENTER MSRs written while paused survive 1 s of guest execution; restores only those MSRs afterwards).
  • Docs: VBoxVMI supports registers; test filter guidance updated (only physical write stays MachineDebugger-only until VBox 7c: VBoxVMI: physical write #285).

Server: Wenzel/virtualbox#7 (merged into vmi/vboxvmi).

Verified live with 1 and 2 vCPUs: full VBoxVMI suite (init, pause, vCPU, registers, page walk + banner, register writes, survive_resume, reads) and MachineDebugger register tests. fmt, clippy -D warnings (virtualbox-api, virtualbox-vmi, both with --tests), virtualbox_errors pass.

Wenzel and others added 2 commits October 12, 2026 08:26
read_registers and write_registers go through the VBoxVMI REGS_READ and
REGS_WRITE commands: the full X86Registers set of one vCPU, MSRs
included, in one round trip, served by the vCPU's EMT between two of its
instructions (a consistent snapshot, an atomic write, also on a running
VM). A write is all or nothing: a value the CPU would not load (e.g.
RFLAGS bit 1 clear) fails it without writing anything. efer and msr_efer
are both EFER and must be equal in a write. rs-vboxvmi is bumped to
5452496 for the new commands.

The register tests run under both methods: the invalid RFLAGS check
goes through the driver instead of VBoxManage setregisters (which needs
the MachineDebugger patch), registers_unchanged_while_paused checks that
an unknown vCPU is an error, and the new
virtualbox_write_registers_survive_resume checks that written registers
are still there after the guest ran. The driver and test docs list
registers as supported by VBoxVMI, with filters running every VBoxVMI
test once, for 1 and 2 vCPUs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VirtualBox has one EFER register, which X86Registers::efer and msr_efer
both are. A register write giving them different values now fails with
the shared EferMismatch error before anything is written, also with the
MachineDebugger method, which wrote both to the same DBGF register and
let the last one win. Documented on the driver page and the efer field.

virtualbox_write_registers_survive_resume waits until a cold-booted
guest has set SYSENTER_EIP on the vCPU it writes, and restores only the
two MSRs it changed: the other registers moved on while the guest ran.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Wenzel
Wenzel merged commit 9bc5c0e into dev Oct 12, 2026
22 checks passed
@Wenzel Wenzel mentioned this pull request Oct 12, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant