Skip to content

Conversation

@bchalios
Copy link
Contributor

@bchalios bchalios commented Aug 11, 2025

Changes

Validate the interrupt vectors that guest selects for VirtIO queues and configuration interrupts. Also, make sure that the MSI implementation of VirtioInterrupt checks that the interrupt index corresponds to a valid interrupt vector.

Reason

If the guest sets an invalid vector for a VirtIO queue and/or configuration, we might end up doing an out-of-bounds access to the table that holds the MSI vectors and cause a panic at runtime.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • I have read and understand CONTRIBUTING.md.
  • I have run tools/devtool checkbuild --all to verify that the PR passes
    build checks on all supported architectures.
  • I have run tools/devtool checkstyle to verify that the PR passes the
    automated style checks.
  • I have described what is done in these changes, why they are needed, and
    how they are solving the problem in a clear and encompassing way.
  • I have updated any relevant documentation (both in code and in the docs)
    in the PR.
  • I have mentioned all user-facing changes in CHANGELOG.md.
  • If a specific issue led to this PR, this PR closes the issue.
  • When making API changes, I have followed the
    Runbook for Firecracker API changes.
  • I have tested all new and changed functionalities in unit tests and/or
    integration tests.
  • I have linked an issue to every new TODO.

  • This functionality cannot be added in rust-vmm.

@bchalios bchalios added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Aug 11, 2025
@bchalios bchalios changed the base branch from main to feature/pcie August 11, 2025 13:37
@bchalios bchalios enabled auto-merge (rebase) August 11, 2025 13:40
Manciukic
Manciukic previously approved these changes Aug 11, 2025
roypat
roypat previously approved these changes Aug 11, 2025
Copy link
Contributor

@roypat roypat left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me

@bchalios bchalios dismissed roypat’s stale review August 12, 2025 06:20

The merge-base changed after approval.

@bchalios bchalios force-pushed the fix_msix_interrupts branch from 8c23ce6 to 1268508 Compare August 12, 2025 06:23
roypat
roypat previously approved these changes Aug 12, 2025
We should check that the MSI-X vector that a guest assigns to a VirtIO
queue or configuration is a valid one. If it is a value bigger than the
available vectors allocated for the device, it should not update the
vector field and mark the corresponding vector to the NO_VECTOR value.

Also, add checks in the MSI implementation for VirtioInterrupt trait,
for making sure that we don't try to interact with out-of-range
interrupt vectors.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
@codecov
Copy link

codecov bot commented Aug 12, 2025

Codecov Report

❌ Patch coverage is 24.13793% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.59%. Comparing base (8073b33) to head (af5c750).
⚠️ Report is 1 commits behind head on feature/pcie.

Files with missing lines Patch % Lines
.../src/devices/virtio/transport/pci/common_config.rs 38.88% 11 Missing ⚠️
src/vmm/src/devices/virtio/transport/pci/device.rs 0.00% 11 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           feature/pcie    #5353      +/-   ##
================================================
- Coverage         80.64%   80.59%   -0.05%     
================================================
  Files               265      265              
  Lines             30674    30690      +16     
================================================
- Hits              24737    24736       -1     
- Misses             5937     5954      +17     
Flag Coverage Δ
5.10-c5n.metal 80.38% <24.13%> (-0.06%) ⬇️
5.10-m5n.metal 80.38% <24.13%> (-0.06%) ⬇️
5.10-m6a.metal 79.59% <24.13%> (-0.06%) ⬇️
5.10-m6g.metal 76.89% <24.13%> (-0.06%) ⬇️
5.10-m6i.metal 80.37% <24.13%> (-0.06%) ⬇️
5.10-m7a.metal-48xl 79.57% <24.13%> (-0.07%) ⬇️
5.10-m7g.metal 76.89% <24.13%> (-0.06%) ⬇️
5.10-m7i.metal-24xl 80.35% <24.13%> (-0.06%) ⬇️
5.10-m7i.metal-48xl 80.34% <24.13%> (-0.06%) ⬇️
5.10-m8g.metal-24xl 76.88% <24.13%> (-0.06%) ⬇️
5.10-m8g.metal-48xl 76.88% <24.13%> (-0.06%) ⬇️
6.1-c5n.metal 80.41% <24.13%> (-0.06%) ⬇️
6.1-m5n.metal 80.42% <24.13%> (-0.05%) ⬇️
6.1-m6a.metal 79.63% <24.13%> (-0.06%) ⬇️
6.1-m6g.metal 76.89% <24.13%> (-0.06%) ⬇️
6.1-m6i.metal 80.42% <24.13%> (-0.05%) ⬇️
6.1-m7a.metal-48xl 79.62% <24.13%> (-0.06%) ⬇️
6.1-m7g.metal 76.89% <24.13%> (-0.06%) ⬇️
6.1-m7i.metal-24xl 80.43% <24.13%> (-0.05%) ⬇️
6.1-m7i.metal-48xl 80.43% <24.13%> (-0.06%) ⬇️
6.1-m8g.metal-24xl 76.89% <24.13%> (-0.06%) ⬇️
6.1-m8g.metal-48xl 76.89% <24.13%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bchalios bchalios merged commit 1e675c2 into firecracker-microvm:feature/pcie Aug 12, 2025
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Awaiting review Indicates that a pull request is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants