[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] pci: fix locking around vPCI removal in pci_remove_device()


  • To: Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Thu, 29 Feb 2024 09:03:33 -0500
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/4J5McUmXEV6SeAVg8/yzDPAv8aLMQpiOom1ClSKdag=; b=YxMY7tSbl7bmedebburTNXmjjKPnl6Wmsr6Zx5oI8mUL8ia5WZjpdvHGF3JiOCPtrB/Inh3mW7V49oszazLOHXEpdwt6VkvAzF8ocszEhpbTOpkq/cWKGeLdHQ0QGBoolO4d/xwoh0+sXz2S5+E27mcrue4hFLdXcI+DH/4o6iIqewCzGkDFDakG8sOYPv0z9cSPJMFHP37f0f5RmwDN0Xu1VIulzm7vUFn3T8U2gEEbPjezxHjbAgizSmLMDxjr/+4NiJZ4FzzqfmK4IVPJUg45CbBeaGPo5cM0bSYQyBRLHCO8Ptd/7CfE8BmY3XoAyq8DcOOqALi3XGl6A6i+LA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FRmk7iOfuR2wDiQuGeGvxtgSHJ4JxVRhW47EL6bgvciIDwXC4Hxy7Wip9Q+GJu83mwiD32VkuYetesYs04Xkdy9pDh28GYkXK2Q/B0j6XUZ0pwXnoyI0PYFGAA1JytmzGOXty6g5uxAvCZxcJOdW9ibnKrSy1qGFsOG6n/VVsgqdBZCTze1x/wTdUex8YnlrDuMAOXxKXA+WI+61LIn/c70xcpGo/8McPIlbCNfeNHNCCnhMQEShZ5He9Nfi+DKYUtPmnzqNzSlI6jb8VLbja8LjOFwPhUWL/bnF+hR3syXPt1aqMMkkr2UvKurkqERneDYQuXEGb1VkGCYZ8GH+Fg==
  • Cc: Paul Durrant <paul@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 29 Feb 2024 14:03:46 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2/29/24 08:23, Jan Beulich wrote:
> On 29.02.2024 14:15, Roger Pau Monne wrote:
>> Currently vpci_deassign_device() is called without holding the per-domain
>> pci_lock in pci_remove_device(), which leads to:
>>
>> Assertion 'rw_is_write_locked(&pdev->domain->pci_lock)' failed at 
>> ../drivers/vpci/vpci.c:47
>> [...]
>> Xen call trace:
>>    [<ffff82d040260eac>] R vpci_deassign_device+0x10d/0x1b9
>>    [<ffff82d04027932f>] S pci_remove_device+0x2b1/0x380
>>    [<ffff82d040260bd0>] F pci_physdev_op+0x197/0x19e
>>    [<ffff82d04032272d>] F do_physdev_op+0x342/0x12aa
>>    [<ffff82d0402f067a>] F pv_hypercall+0x58e/0x62b
>>    [<ffff82d0402012ba>] F lstar_enter+0x13a/0x140
>>
>> Move the existing block that removes the device from the domain pdev_list 
>> ahead
>> and also issue the call to vpci_deassign_device() there.  It's fine to remove
>> the device from the domain list of assigned devices, as further functions 
>> only
>> care that the pdev domain field is correctly set to the owner of the device
>> about to be removed.
>>
>> Moving the vpci_deassign_device() past the pci_cleanup_msi() call can be
>> dangerous, as doing the MSI cleanup ahead of having removed the vPCI handlers
>> could lead to stale data in vPCI MSI(-X) internal structures.
>>
>> Fixes: 4f78438b45e2 ('vpci: use per-domain PCI lock to protect vpci 
>> structure')
>> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> 
> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

Reviewed-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>

Thanks



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.