Skip to content

Conversation

@shenw0000
Copy link
Contributor

@shenw0000 shenw0000 commented Oct 30, 2025

  • Refactors the PCI config space emulator to pull common code between the type-0 and type-1 into a common emulator
  • Bridges now properly supports BAR
  • Adding MSI capability
  • Properly implement slot and link capabilities
  • Add CLI arguments to specify that a port is hotplug capable
  • Add unit tests

@github-actions github-actions bot added the unsafe Related to unsafe code label Oct 31, 2025
@github-actions
Copy link

⚠️ 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

@shenw0000 shenw0000 changed the title Pcie hotplug openvmm/pcie: refactor pcie config space emulator, properly implement slot and link capabilities, add MSI capability Nov 4, 2025
@shenw0000 shenw0000 marked this pull request as ready for review November 4, 2025 00:52
@shenw0000 shenw0000 requested a review from a team as a code owner November 4, 2025 00:52
Copilot AI review requested due to automatic review settings November 4, 2025 00:52
Copy link
Contributor

Copilot AI left a comment

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 adds PCIe hotplug support to OpenVMM's PCIe infrastructure, enabling dynamic device attachment and removal. The key changes include:

  • Adding MSI capability support for interrupts
  • Implementing PCIe hotplug slot capabilities and presence detection
  • Refactoring configuration space emulators to share common functionality
  • Adding CLI options for enabling hotplug on root ports and switches

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
vm/devices/pci/pcie/src/switch.rs Updated downstream switch port to support hotplug parameters
vm/devices/pci/pcie/src/root.rs Added hotplug support and extensive tracing to root complex
vm/devices/pci/pcie/src/port.rs Added hotplug and MSI capability, plus presence detect handling
vm/devices/pci/pci_core/src/spec.rs Added MSI capability structures and PCIe link speed/width enums
vm/devices/pci/pci_core/src/msi.rs Added Debug and Inspect derives for MSI types
vm/devices/pci/pci_core/src/cfg_space_emu.rs Major refactoring to extract common header emulator, added presence detect support
vm/devices/pci/pci_core/src/capabilities/read_only.rs Added capability_id support and as_any methods
vm/devices/pci/pci_core/src/capabilities/pci_express.rs Implemented hotplug support with slot capabilities and link speed management
vm/devices/pci/pci_core/src/capabilities/msix.rs Added capability_id and as_any methods
vm/devices/pci/pci_core/src/capabilities/msi_cap.rs New file implementing MSI capability
vm/devices/pci/pci_core/src/capabilities/mod.rs Added capability_id and as_any methods to trait
openvmm/openvmm_entry/src/lib.rs Wired hotplug config through entry point
openvmm/openvmm_entry/src/cli_args.rs Added CLI parsing for hotplug options
openvmm/hvlite_defs/src/config.rs Added hotplug fields to config structs
openvmm/hvlite_core/src/worker/dispatch.rs Wired hotplug config through worker dispatch
Comments suppressed due to low confidence (3)

vm/devices/pci/pci_core/src/capabilities/pci_express.rs:1

  • Using unreachable!() with user/guest-provided data violates the trust boundary principle. If a guest provides an invalid link speed value that doesn't match any of the defined encodings, this will panic. Replace with a safe default or error handling to prevent guest-triggered panics.
// Copyright (c) Microsoft Corporation.

vm/devices/pci/pci_core/src/capabilities/pci_express.rs:1

  • Similar issue as previous comment - using unreachable!() in from_bits methods for SupportedLinkSpeedsVector and LinkWidth. Guest-provided values could trigger panics. These should return safe defaults or use Result types instead.
// Copyright (c) Microsoft Corporation.

vm/devices/pci/pci_core/src/capabilities/pci_express.rs:1

  • Similar issue as previous comment - using unreachable!() in from_bits methods for SupportedLinkSpeedsVector and LinkWidth. Guest-provided values could trigger panics. These should return safe defaults or use Result types instead.
// Copyright (c) Microsoft Corporation.

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

Labels

unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants