• Dexuan Cui's avatar
    PCI: hv: Add pci_destroy_slot() in pci_devices_present_work(), if necessary · 340d4556
    Dexuan Cui authored
    When we hot-remove a device, usually the host sends us a PCI_EJECT message,
    and a PCI_BUS_RELATIONS message with bus_rel->device_count == 0.
    
    When we execute the quick hot-add/hot-remove test, the host may not send
    us the PCI_EJECT message if the guest has not fully finished the
    initialization by sending the PCI_RESOURCES_ASSIGNED* message to the
    host, so it's potentially unsafe to only depend on the
    pci_destroy_slot() in hv_eject_device_work() because the code path
    
    create_root_hv_pci_bus()
     -> hv_pci_assign_slots()
    
    is not called in this case. Note: in this case, the host still sends the
    guest a PCI_BUS_RELATIONS message with bus_rel->device_count == 0.
    
    In the quick hot-add/hot-remove test, we can have such a race before
    the code path
    
    pci_devices_present_work()
     -> new_pcichild_device()
    
    adds the new device into the hbus->children list, we may have already
    received the PCI_EJECT message, and since the tasklet handler
    
    hv_pci_o...
    340d4556
pci-hyperv.c 74.5 KB