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

Re: [PATCH v12 01/15] vpci: use per-domain PCI lock to protect vpci structure


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Mon, 15 Jan 2024 10:08:35 -0500
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=citrix.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=XoCIHXPvOf+Un7JWgo3DW3wxXw+wXGd2XDSFARUz5lc=; b=Vczfm6hygBoZTKVtvFXOLyYVrklrDWhyqgXgHB7K0Kr1u4T5Q9R4GjjOBv1o8Zbd1FAaw+lsvdRtk8Rs1Q9AScMbcopZYygZ9oP9Ufj9zJ8iSBdrQOhCytZIdPX3m+4BC1vHkMkPWkI0e63eEr+1dWgNuzQ9JWfOtOhXeOrcW6orc3K5f+EWmXaeTrjjgH3CA1OVjKDOlHrHpslGPmVWYlAqHztuOZ/nXzzA1w2bwADbFLXSBPv4n2LMDXVXKcf0RKzwQzHSp8qqRJwrCous/VoJasRMpelJGziS8vPb2Dt/Ak9AzA+oDGhwVqi8+Px36bIWrRKflmN3OrFX+s+Cbg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HtmOfqgveubEkFKU9zXUYLmd+RkiCSxdT+e9cUigOYkTYfVsKJaMWbvYfT7m2NSYVRFwYQ93c6wlOfIIfk32a9UNRXXWsOwhSuDubhkW564iyC7iyxDH2ErwoSH/BVhH54OISxJLgYdsp9eIrUTWaHfvu1DHqBRrIOx/62RartxYJecZqavQbBBVONdkAH2lA+6+tPWjglpTeWBeHLKutPnhxCwiV5OOBoK9yONn82YHG1jXjVAGX1U1hS9+6SdLKZiFUZZ5ecHFvZX+FfNCOnXAZGE9Z9MwRTvXLkmsGn4vd9UDtaELpMkpGhCWCVTlot2oLN41Jnm1mVqV4Y5CCw==
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, "Andrew Cooper" <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
  • Delivery-date: Mon, 15 Jan 2024 15:08:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 1/15/24 03:53, Roger Pau Monné wrote:
> On Fri, Jan 12, 2024 at 12:54:56PM -0500, Stewart Hildebrand wrote:
>> On 1/12/24 08:48, Roger Pau Monné wrote:
>>> On Tue, Jan 09, 2024 at 04:51:16PM -0500, Stewart Hildebrand wrote:
>>>> @@ -202,8 +204,20 @@ static int __init apply_map(struct domain *d, const 
>>>> struct pci_dev *pdev,
>>>>      struct map_data data = { .d = d, .map = true };
>>>>      int rc;
>>>>  
>>>> +    ASSERT(rw_is_write_locked(&d->pci_lock));
>>>> +
>>>>      while ( (rc = rangeset_consume_ranges(mem, map_range, &data)) == 
>>>> -ERESTART )
>>>> +    {
>>>> +        /*
>>>> +         * It's safe to drop and reacquire the lock in this context
>>>> +         * without risking pdev disappearing because devices cannot be
>>>> +         * removed until the initial domain has been started.
>>>> +         */
>>>> +        write_unlock(&d->pci_lock);
>>>>          process_pending_softirqs();
>>>> +        write_lock(&d->pci_lock);
>>>
>>> Hm, I should have noticed before, but we already call
>>> process_pending_softirqs() with the pdev->vpci->lock held here, so it
>>> would make sense to drop it also.
>>
>> I don't quite understand this, maybe I'm missing something. I don't see 
>> where we acquire pdev->vpci->lock before calling process_pending_softirqs()?
>>
>> Also, I tried adding
>>
>>     ASSERT(!spin_is_locked(&pdev->vpci->lock));
>>
>> both here in apply_map() and in vpci_process_pending(), and they haven't 
>> triggered in either dom0 or domU test cases, tested on both arm and x86.
> 
> I think I was confused.  Are you sure that pdev->vpci->lock is taken
> in the apply_map() call?

I'm sure that it's NOT taken in apply_map(). See the ! in the test ASSERT above.

> I was mistakenly assuming that
> vpci_add_handlers() called the init function with the vpci->lock
> taken, but that doesn't seem to be case with the current code.  That
> leads to apply_map() also being called without the vpci->lock taken.

Right.

> 
> I was wrongly assuming that apply_map() was called with the vpci->lock
> lock taken, and that would need dropping around the
> process_pending_softirqs() call.
> 
> Thanks, Roger.



 


Rackspace

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