Repository navigation
[DO NOT REVIEW] chipset: zero-extend wide IOAPIC MMIO reads - #5084
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoNov 13, 2026
Merged
Pedro Henrique Penna (ppenna) merged 1 commit into
Pedro Henrique Penna (ppenna) merged 1 commit into
Conversation
A guest read of the IOAPIC's index or data register wider than 4 bytes, such as a 64-bit mov from 0xfec00000, panicked the VP thread with "copy_from_slice: source slice length (4) does not match destination slice length (8)", which ended OpenVMM and the VM. IoApicDevice::mmio_read means to accept a read of any size, but it copied the register's min(len, 4) low bytes into the whole buffer, so only reads of at most 4 bytes matched the slice lengths. mmio_read now copies those low bytes into the start of the buffer and zeroes the rest, so a wider read returns the 32-bit register zero-extended, as the RTC already does for a wide read of its ports, and a narrower one still returns the register's low bytes. Tests: the new test ioapic::tests:: mmio_reads_of_any_size_are_zero_extended reads the index and data registers, for the ID, the version, and both halves of a redirection entry, with every length from 1 to 8 bytes into a buffer of stale bytes. At feature/microvm/dev 09cd771, it fails with the panic above at vm/devices/chipset/src/ioapic/mod.rs:724:14. NVX f02bdcd53 pins 09cd771; there, an Alpine guest on 1 processor that maps /dev/mem at 0xfec00000 and reads both registers with 32-bit and then 64-bit loads panics OpenVMM at the same line on its first 64-bit read, on KVM, MSHV, and WHP. With this change, the same guest reads the registers' 32-bit values zero-extended on all three, on 1 and 2 processors, and the 132 chipset tests pass with cargo nextest on Windows x64 and Linux x64. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
requested a review
from a team
as a code owner
November 13, 2026 21:30
Pedro Henrique Penna (ppenna)
merged commit Nov 13, 2026
e2458a6
into
feature/microvm/dev
104 of 108 checks passed
syeedali
pushed a commit
to syeedali/nvx
that referenced
this pull request
Nov 14, 2026
A guest read of the emulated IOAPIC's index or data register wider than 4 bytes, such as a 64-bit mov from 0xfec00000, panicked OpenVMM's VP thread with "copy_from_slice: source slice length (4) does not match destination slice length (8)" in IoApicDevice::mmio_read, which ended the VM (microsoft#1140). Pin e2458a6cef958c3ac2d710e13a6ba490a9911b88, the head of microsoft/openvmm#5084, one commit on 09cd771c0, the head of feature/microvm/dev: - e2458a6ce chipset: zero-extend wide IOAPIC MMIO reads mmio_read copied the 32-bit register's min(len, 4) low bytes into the whole buffer, so only reads of at most 4 bytes matched the slice lengths. It now copies those bytes into the start of the buffer and zeroes the rest, so a wider read returns the register zero-extended, as the CMOS RTC does for a wide read of its ports, and a narrower one still returns the register's low bytes. Evidence: with OpenVMM built from 09cd771c0, the previous pin, an Alpine guest on 1 processor that maps /dev/mem at 0xfec00000 and reads the index and data registers with 32-bit and then 64-bit loads panicked OpenVMM at vm/devices/chipset/src/ioapic/mod.rs:724:14 on its first 64-bit load, on nvx-kvm-test, nvx-mshv-test, and nvx-whp-test. At the pin, its 64-bit loads read the values of its 32-bit loads, zero-extended, on all three hosts, on 1 and 2 processors. Tests: with OpenVMM built from the pin, the microVM scenarios smp, on 1 and 2 processors, and interrupt-map pass on nvx-kvm-test, nvx-mshv-test, and nvx-whp-test. The revision's new chipset test, mmio_reads_of_any_size_are_zero_extended, fails at 09cd771c0 with the panic above, and its 132 chipset tests pass on Windows and on Linux, on nvx-kvm-test. NVX needs no coordinated change: the control-session vectors, the source excerpts, the contract versions, the activation bound, and the CPU profiles that nvx-rs copies from OpenVMM match the revision's. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
syeedali
pushed a commit
to syeedali/nvx
that referenced
this pull request
Nov 14, 2026
The NVX pin moves to e2458a6ce, position 274, 150 commits past the mapped tip. Position 274, the one commit of microsoft/openvmm#5084 on 09cd771c0, the head of feature/microvm/dev, is not yet assigned to a PR. Position 274 makes the IOAPIC's mmio_read zero-extend a read of its index or data register wider than 4 bytes, which panicked the vCPU thread, and so OpenVMM, because it copied the register's low bytes into the whole buffer. The code is upstream main's, and the commit adds a test to the device's tests, in a file whose saved-state tests position 183 also changes; it changes none of position 183's code and nothing that a mapped PR adds. Replaying it on upstream main, 7d90c4104, applies without conflicts, and chipset type-checks there with its tests, which pass, so it can go upstream on its own. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the emulated IOAPIC return a read of its index or data register that is wider than 4 bytes zero-extended, instead of panicking, for microsoft/nvx#1140.
IoApicDevice::mmio_readcopied the register'smin(len, 4)low bytes into the whole read buffer, so a 64-bit read panicked the VP thread and ended OpenVMM and the VM.One commit on
09cd771c0, the head offeature/microvm/dev. microsoft/nvx#1570 pins it; this pull request lands first, by fast-forwardingfeature/microvm/devtoe2458a6ce.Zero-extend wide IOAPIC MMIO reads (
e2458a6ce)mmio_readcomputedn = data.len().min(size_of_val(&v)), 4 at most, and then calleddata.copy_from_slice(&v.to_ne_bytes()[..n]), which requires both slices to have the same length. Reads of 1 to 4 bytes worked; a 5- to 8-byte read, such as a 64-bitmovfrom0xfec00000or0xfec00010, panicked with "copy_from_slice: source slice length (4) does not match destination slice length (8)" atvm/devices/chipset/src/ioapic/mod.rs:724. The IOAPIC is OpenVMM's own on every backend, since KVM runs with a split irqchip, so the guest's MMIO reachesIoApicDeviceon KVM, MSHV, and WHP alike.mmio_readcopies thenlow bytes intodata[..n]and zeroesdata[n..], so a wider read returns the 32-bit register zero-extended, asRtc::io_readdoes for a wide read of its ports since [DO NOT REVIEW] chipset: zero-extend wide reads of the RTC's ports #5072, and a narrower one still returns the register's low bytes. A read of another offset still fails withInvalidRegisterand leaves the buffer as it was. The patch attached to openvmm: 64-bit IOAPIC MMIO reads panic in IoApicDevice::mmio_read nvx#1140 makes the same change.mmio_reads_of_any_size_are_zero_extendedsets the IOAPIC's ID and redirection entry 5, then reads the index and data registers with the ID, the version, and both halves of entry 5 selected, with every length from 1 to 8 bytes into a buffer of0xa5bytes, and requires the register's low bytes followed by zeros. At09cd771c0, it fails at its first 5-byte read with the panic above, atmod.rs:724:14.Validation
With Rust 1.97.1 and cargo-nextest 0.9.133, for
chipset, with this change: on Windows x64,cargo check,cargo clippy --all-targets,cargo doc --no-deps, andcargo nextest run --profile agent(132 passed), thencargo xtask fmt --fix(no changes); on Linux x64, on the Azure Linux 3 KVM test VM,cargo check,cargo clippy --all-targets,cargo doc --no-deps, andcargo nextest run --profile agent(132 passed).In NVX's Alpine microVM, at NVX
f02bdcd53, which pins09cd771c0, a static guest program mapped/dev/memat0xfec00000and read the index (+0x00) and data (+0x10) registers with 32-bit and then 64-bit loads:09cd771c00x34,0x21; the first 64-bit read panics atmod.rs:724:140x34,0x210x34,0x200x34,0x21; the first 64-bit read panics atmod.rs:724:140x34,0x210x34,0x200x34,0x21; the first 64-bit read panics atmod.rs:724:140x34,0x210x34,0x20With this change, each 64-bit read returned the 32-bit read's value with zero upper bits, and the guest exited cleanly.
In this pull request's CI, run 43511358061:
run vmm-tests [x64-windows-intel-tdx]timed out in one test of 119, a Windows OpenHCL guest'smemstatmemory test (770 s). It passed on its one rerun, and so didopenvmm checkin gates.run vmm-tests [x64-windows-amd-snp]fails at09cd771c0too (run 43489085265), mostly with "VM did not start after reset in the required time": 19 of 86 tests failed there and 16 here, 11 of them in both runs.