rust-vmm / kvm-ioctls

Apache License 2.0
255 stars 103 forks source link

Add support for userspace MSR handling #241

Closed 00xc closed 7 months ago

00xc commented 7 months ago

Summary of the PR

Add support for userspace MSR handling. This is done by enabling the KVM_CAP_X86_USER_SPACE_MSR capability, which enables two new exits, KVM_EXIT_X86_RDMSR and KVM_EXIT_X86_WRMSR. This allows a VMM to intercept reads and writes to invalid MSRs instead of having KVM automatically inject a #GP into the guest.

This PR adds safe wrappers around KVM_CAP_X86_USER_SPACE_MSR, KVM_EXIT_X86_RDMSR and KVM_EXIT_X86_WRMSR, some helper types and 2 relevant tests.

Requirements

00xc commented 7 months ago

Reordered Cap::X86UserSpaceMsr to keep a consistent ordering.

00xc commented 7 months ago

Rebased on main, fixed conflicts and updated coverage.

00xc commented 7 months ago

Rebased on main and fixed conflicts.

00xc commented 7 months ago

Gentle ping for reviewers