Closed 00xc closed 9 months ago
@JonathanWoollett-Light addressed your suggestions in the newer version, except the ones about using function mnemonics. Regarding that, isn't that change out of scope for this PR? It would add a new dependency and we would still have a bunch of tests which use raw bytes as assembly code. I'd rather work on that change in a separate PR.
By the way the code can also properly be assembled with that crate's CodeAssembler
, e.g.
let mut asm = CodeAssembler::new(16).unwrap();
asm.out(0x2c, al).unwrap();
asm.hlt().unwrap();
asm.out(0x2c, al).unwrap();
asm.hlt().unwrap();
let code = asm.assemble(base_addr).unwrap();
@JonathanWoollett-Light addressed your suggestions in the newer version, except the ones about using function mnemonics. Regarding that, isn't that change out of scope for this PR? It would add a new dependency and we would still have a bunch of tests which use raw bytes as assembly code. I'd rather work on that change in a separate PR.
Yeah this makes sense.
Rebased on main and fixed conflicts
Gentle ping for reviewers :)
@00xc Can you please resolve the merge conflicts, after this LGTM.
Rebased on main and fixed conflicts
Summary of the PR
Add support for coalesced MMIO. This performance feature allows guest writes to port and memory space to not trigger VM exits. Instead, the kernel will write an entry into a shared ring buffer for each access, which userspace must consume. The ring buffer is mapped at a certain offset in the vcpu's file descriptor.
In order to enable this capability, introduce the
KvmCoalescedIoRing
struct, which will act as a safe wrapper around the raw mapping of the ring buffer. Since users may not want to use coalesced MMIO, or it might not be available, store it as anOption
in theVcpuFd
struct.Add two tests as well for the newly added code.
The public API consists of:
Cap::CoalescedMmio
(KVM_CAP_COALESCED_MMIO
)Cap::CoalescedPio
(KVM_CAP_COALESCED_PIO
).VmFd::register_coalesced_mmio()
(KVM_REGISTER_COALESCED_MMIO
ioctl).VmFd::unregister_coalesced_mmio()
(KVM_UNREGISTER_COALESCED_MMIO
ioctl).VcpuFd::map_coalesced_mmio_ring()
).VcpuFd::read_coalesced_mmio()
).Requirements
Before submitting your PR, please make sure you addressed the following requirements:
git commit -s
), and the commit message has max 60 characters for the summary and max 75 characters for each description line.unsafe
code is properly documented.