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

Re: [PATCH v2 10/11] vpci: Add initial support for virtual PCI bus topology


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Date: Wed, 29 Sep 2021 09:03:00 +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; bh=THBeAc5jY29gXIe48ZUd/K3VVnp852+rISS9da95/mo=; b=kX8Oq8+tmd3RMbD7KFkWIYExALk050C32M6Zims69o/SugRrbS1whlPw+Yk4rbk0CZu0FT5frckIvPJy4swRfWV/5mwdd9XWYwtOdhR1H4HeQqWdsUuElnpw2JtBTH5B1l6T88+AN9JszuXbDeCJlbKvwPV8CpkUPkUxmHKAYL9R//8jrCwUjvw31aeHcWy3FByi9eqw2pJ+izDjmnzib5MrvI5cYJOiNdFqOklvNkpNTcH0YvCMTZ/8Fz/MxD0LkFJfcpA0hU2LwvdZynJTQ8FxdJMcbg8+lfBnEm7X/gWCbrrnEQG+cDE/ntgVcq0HX6Lo1+LVzwjO4N2LIoJ8mQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dtALfyxxNmaU/48YZTJxNw6Ysoaj2QQdD3N0nwL4l+r/7H03WATekiGlujRT0fDyoRF0scVV3mJFma2MVArkeGMokS8L3SPdglXzE1OXKfAR+HDpX0J055e/WAJqXxC+EFUZeiJ3MKQyR0aa8HT8HoIryk72XQphdA8P8Y2W6oB/VGz/K1jwDTsAifAWR6tMh0FmRWb5o/W5UVX/2M+zPmbsKbIpWO5XVn0w6hbHQEcCDkr0szc9qHbXF9G0oq47tft0qFSkIslTHNigQGNab7Oi7sNcCTxzzKYPvnnQPbl+P48lIZc+2Kj3ozvbtyglWqOIcvkBZ1YC0Z9Ykk2+LQ==
  • Authentication-results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=epam.com;
  • Cc: "julien@xxxxxxx" <julien@xxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>, "roger.pau@xxxxxxxxxx" <roger.pau@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Delivery-date: Wed, 29 Sep 2021 09:03:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXsHpEaYKJY1uGNUmlwbBKeBrI6Ku5GYwAgAAC+oCAAAUNAIAATmyAgAFQpAA=
  • Thread-topic: [PATCH v2 10/11] vpci: Add initial support for virtual PCI bus topology

Hi, Jan!

Sorry for top posting, but this is a general question on this 
patch/functionality.

Do you see we need to gate all this with CONFIG_HAS_VPCI_GUEST_SUPPORT

as this renders in somewhat dead code for x86 for now? I do think this still

needs to be in the common code though.

Thank you in advance,

Oleksandr

On 28.09.21 15:58, Oleksandr Andrushchenko wrote:
> On 28.09.21 11:17, Michal Orzel wrote:
>> On 28.09.2021 09:59, Jan Beulich wrote:
>>> On 28.09.2021 09:48, Michal Orzel wrote:
>>>> On 23.09.2021 14:55, Oleksandr Andrushchenko wrote:
>>>>> --- a/xen/drivers/passthrough/pci.c
>>>>> +++ b/xen/drivers/passthrough/pci.c
>>>>> @@ -833,6 +833,63 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn)
>>>>>        return ret;
>>>>>    }
>>>>>    
>>>>> +static struct vpci_dev *pci_find_virtual_device(const struct domain *d,
>>>>> +                                                const struct pci_dev 
>>>>> *pdev)
>>>>> +{
>>>>> +    struct vpci_dev *vdev;
>>>>> +
>>>>> +    list_for_each_entry ( vdev, &d->vdev_list, list )
>>>>> +        if ( vdev->pdev == pdev )
>>>>> +            return vdev;
>>>>> +    return NULL;
>>>>> +}
>>>>> +
>>>>> +int pci_add_virtual_device(struct domain *d, const struct pci_dev *pdev)
>>>>> +{
>>>>> +    struct vpci_dev *vdev;
>>>>> +
>>>>> +    ASSERT(!pci_find_virtual_device(d, pdev));
>>>>> +
>>>>> +    /* Each PCI bus supports 32 devices/slots at max. */
>>>>> +    if ( d->vpci_dev_next > 31 )
>>>>> +        return -ENOSPC;
>>>>> +
>>>>> +    vdev = xzalloc(struct vpci_dev);
>>>>> +    if ( !vdev )
>>>>> +        return -ENOMEM;
>>>>> +
>>>>> +    /* We emulate a single host bridge for the guest, so segment is 
>>>>> always 0. */
>>>>> +    *(u16*) &vdev->seg = 0;
>>>> Empty line hear would improve readability due to the asterisks being so 
>>>> close to each other.
> Will add
>>>> Apart from that:
>>>> Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
>>>>> +    /*
>>>>> +     * The bus number is set to 0, so virtual devices are seen
>>>>> +     * as embedded endpoints behind the root complex.
>>>>> +     */
>>>>> +    *((u8*) &vdev->bus) = 0;
>>>>> +    *((u8*) &vdev->devfn) = PCI_DEVFN(d->vpci_dev_next++, 0);
>>> All of these casts are (a) malformed and (b) unnecessary in the first
>>> place, afaics at least.
>>>
>> Agree.
>> *((u8*) &vdev->bus) = 0;
>> is the same as:
>> vdev->bus = 0;
> Overengineering at its best ;)
>
> Will fix that
>
>>> Jan
>>>
> Thank you,
>
> Oleksandr

 


Rackspace

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