Skip to content

virt_kvm: Validate MSR accesses#4015

Open
smalis-msft wants to merge 1 commit into
microsoft:mainfrom
smalis-msft:virt-kvm-msrs
Open

virt_kvm: Validate MSR accesses#4015
smalis-msft wants to merge 1 commit into
microsoft:mainfrom
smalis-msft:virt-kvm-msrs

Conversation

@smalis-msft

Copy link
Copy Markdown
Contributor

kvm_get/set_msrs return the number of MSRs they were able to process. We should be validating that all of our requested MSRs do in fact get processed.

Copilot AI review requested due to automatic review settings July 23, 2026 19:43
@smalis-msft
smalis-msft requested a review from a team as a code owner July 23, 2026 19:43
@github-actions github-actions Bot added the unsafe Related to unsafe code label Jul 23, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the KVM MSR read/write paths by validating that KVM_GET_MSRS / KVM_SET_MSRS actually process the full set of requested MSR entries, rather than silently accepting partial completion.

Changes:

  • Add a new Error::IncompleteMsrs { ... } variant that reports partial MSR processing (including the first unprocessed MSR and whether the operation was a write).
  • Update Processor::get_msrs to check the returned “completed” count and error out if it’s less than requested.
  • Update Processor::set_msrs to check the returned “completed” count and error out if it’s less than requested.

@smalis-msft smalis-msft added the backport_1.8.2607 Change should be backported to the release/1.8.2607 branch label Jul 23, 2026
@github-actions

Copy link
Copy Markdown

@jstarks

jstarks commented Jul 24, 2026

Copy link
Copy Markdown
Member

Do we think this is hitting somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport_1.8.2607 Change should be backported to the release/1.8.2607 branch unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants