Skip to content

deadlock between pci_resources and move_bar #6775

@alex-matei

Description

@alex-matei

Describe the bug
AddressManager::move_bar() acquires the device_tree mutex. The function is called from PciConfigIo::config_space_write()/PciConfigMmio::config_space_write() while the pci_bus mutex is acquired.
The functions DeviceManager::pci_resources()/eject_device() acquire these mutexes in reverse order, which leads to a deadlock.

To Reproduce
Create a new VM and do a snapshot of it. Create a new VM from snapshot and add a disk. pci_resources() is called when adding the disk. move_bar() is called from config_space_write() at the same time. Cloud-hypervisor hangs while processing "/vm.add-disk" command because of the deadlock between these two functions. I reproduced this issue with kata-containers, it issues multiple add commands and cloud-hypervisor freezes on one of them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions