On 17.03.2023 09:43, Roger Pau Monné wrote: > On Tue, Mar 14, 2023 at 08:56:30PM +0000, Volodymyr Babchuk wrote: >> vPCI MMIO handlers are accessing pdevs without protecting this >> access with pcidevs_{lock|unlock}. This is not a problem as of now >> as these are only used by Dom0. But, towards vPCI is used also for >> guests, we need to properly protect pdev and pdev->vpci from being >> removed while still in use. >> >> For that use pdev reference counting. > > I wonder whether vPCI does need to take another reference to the > device. This all stems from me not having it fully clear how the > reference counting is supposed to be used for pdevs. > > As mentioned in a previous patch, I would expect device assignation to > take a reference, and hence vPCI won't need to take an extra refcount > since vPCI can only be used once the device has been assigned to a > domain, and hence already has at least an extra reference taken from > the fact it's assigned to a domain. > > If anything I would add an ASSERT(pdev->refcount > 1) or equivalent.
FWIW: +1 Jan