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

Re: [PATCH v4 11/11] xen/arm: translate virtual PCI bus topology for guests


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Date: Wed, 24 Nov 2021 11:31:27 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • 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=l5uMs6GCdNNkPlVD5LpM0ZDDauleikCEj8IUXuw5cNc=; b=AYAy5WS69meph165q5iLo6d+D52Scj6pszMpoRch3SjoF2p22+Y0gM8+oRT876YOWMQLjUIDTguAo1Q7g8kxqi57uRLdcD9IaYYC8o7egO1i2BG+JF1jKNCACrHU9ShVvw9cBjX9J+RAY4y6AMFdvr/oCnl8opHvr82Xlx+CtgLi6Ywn2Kky0/GmtKBtvMQFWryG16AJT+1tcRTtEtsB/aqcwDNXg/QLS4dFl785kDZX+Gn5nad9je0GbT/qeKAetIr9xh9wFbQnezYPOZyLs13U5cBx4W6mBWIUeJPaIf7gdYCnj7XRPYKmmLoDPTWjBBGTxLdhECAPXQxADC/Ybw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZzJ6FfXaj7CR46+v3fMnG6+gu6gCfz7F1BO9Hy0Pf2ySC5rmDlG/Evgj0nQaYPEzPtRduV9Zefa6besEgcv1MBWMjJCpUs6BFsgZkR/VcUnVnfH5qhexyWIAe4erC8iaEIScuqxha1pp7lWvjFmjUSiLn7crue7tsDx5Ssl8fvJZIMo5th1qENcDOHxhL4WgzZPrnET46KDthZo61M0bnNtCfMy+3bEhbD4/kJigkBYrTd0+5iB6M0Cuz8b6aeeWhuTWNzya4LopvKHvaynIgXFcDY44aAP+0Ke0vxjt7MSVFn66omJOcYMLsBfhFy58G74Oe3rEoaZ8TtS1Q+QCqw==
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>, "andrew.cooper3@xxxxxxxxxx" <andrew.cooper3@xxxxxxxxxx>, "george.dunlap@xxxxxxxxxx" <george.dunlap@xxxxxxxxxx>, "paul@xxxxxxx" <paul@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 24 Nov 2021 11:31:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHX0hJP4tGfmNyDbEa0m8z5ITSeMav5fmGAgAABr4CAADRIAIAAEgeAgBjjHgA=
  • Thread-topic: [PATCH v4 11/11] xen/arm: translate virtual PCI bus topology for guests


On 08.11.21 17:28, Oleksandr Andrushchenko wrote:
>
> On 08.11.21 16:23, Roger Pau Monné wrote:
>> On Mon, Nov 08, 2021 at 11:16:42AM +0000, Oleksandr Andrushchenko wrote:
>>> On 08.11.21 13:10, Jan Beulich wrote:
>>>> On 05.11.2021 07:56, Oleksandr Andrushchenko wrote:
>>>>> --- a/xen/arch/arm/vpci.c
>>>>> +++ b/xen/arch/arm/vpci.c
>>>>> @@ -41,6 +41,15 @@ static int vpci_mmio_read(struct vcpu *v, mmio_info_t 
>>>>> *info,
>>>>>         /* data is needed to prevent a pointer cast on 32bit */
>>>>>         unsigned long data;
>>>>>     
>>>>> +#ifdef CONFIG_HAS_VPCI_GUEST_SUPPORT
>>>>> +    /*
>>>>> +     * For the passed through devices we need to map their virtual SBDF
>>>>> +     * to the physical PCI device being passed through.
>>>>> +     */
>>>>> +    if ( !bridge && !vpci_translate_virtual_device(v->domain, &sbdf) )
>>>>> +            return 1;
>>>> Nit: Indentation.
>>> Ouch, sure
>>>>> @@ -59,6 +68,15 @@ static int vpci_mmio_write(struct vcpu *v, mmio_info_t 
>>>>> *info,
>>>>>         struct pci_host_bridge *bridge = p;
>>>>>         pci_sbdf_t sbdf = vpci_sbdf_from_gpa(bridge, info->gpa);
>>>>>     
>>>>> +#ifdef CONFIG_HAS_VPCI_GUEST_SUPPORT
>>>>> +    /*
>>>>> +     * For the passed through devices we need to map their virtual SBDF
>>>>> +     * to the physical PCI device being passed through.
>>>>> +     */
>>>>> +    if ( !bridge && !vpci_translate_virtual_device(v->domain, &sbdf) )
>>>>> +            return 1;
>>>> Again.
>>> Will fix
>>>>> @@ -172,10 +175,37 @@ REGISTER_VPCI_INIT(vpci_add_virtual_device, 
>>>>> VPCI_PRIORITY_MIDDLE);
>>>>>     static void vpci_remove_virtual_device(struct domain *d,
>>>>>                                            const struct pci_dev *pdev)
>>>>>     {
>>>>> +    ASSERT(pcidevs_locked());
>>>>> +
>>>>>         clear_bit(pdev->vpci->guest_sbdf.dev, &d->vpci_dev_assigned_map);
>>>>>         pdev->vpci->guest_sbdf.sbdf = ~0;
>>>>>     }
>>>>>     
>>>>> +/*
>>>>> + * Find the physical device which is mapped to the virtual device
>>>>> + * and translate virtual SBDF to the physical one.
>>>>> + */
>>>>> +bool vpci_translate_virtual_device(struct domain *d, pci_sbdf_t *sbdf)
>>>> const struct domain *d ?
>>> Will change
>>>>> +{
>>>>> +    const struct pci_dev *pdev;
>>>>> +    bool found = false;
>>>>> +
>>>>> +    pcidevs_lock();
>>>>> +    for_each_pdev( d, pdev )
>>>>> +    {
>>>>> +        if ( pdev->vpci->guest_sbdf.sbdf == sbdf->sbdf )
>>>>> +        {
>>>>> +            /* Replace virtual SBDF with the physical one. */
>>>>> +            *sbdf = pdev->sbdf;
>>>>> +            found = true;
>>>>> +            break;
>>>>> +        }
>>>>> +    }
>>>>> +    pcidevs_unlock();
>>>> I think the description wants to at least mention that in principle
>>>> this is too coarse grained a lock, providing justification for why
>>>> it is deemed good enough nevertheless. (Personally, as expressed
>>>> before, I don't think the lock should be used here, but as long as
>>>> Roger agrees with you, you're fine.)
>>> Yes, makes sense
>> Seeing as we don't take the lock in vpci_{read,write} I'm not sure we
>> need it here either then.
> Yes, I was not feeling confident while adding locking
>> Since on Arm you will add devices to the guest at runtime (ie: while
>> there could already be PCI accesses), have you seen issues with not
>> taking the lock here?
> No, I didn't. Neither I am aware of Arm had problems
> But this could just mean that we were lucky not to step on it
>> I think the whole pcidevs locking needs to be clarified, as it's
>> currently a mess.
> Agree
>>    If you want to take it here that's fine, but overall
>> there are issues in other places that would make removing a device at
>> runtime not reliable.
> So, what's the decision? I would leave the locks where I put them,
> so at least this part won't need fixes.
As I am about to use the lock outside vpci struct in v5 all these go away
>> Thanks, Roger.
>>
> Thank you,
> Oleksandr

 


Rackspace

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