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

Re: [PATCH v3 04/11] vpci/header: Emulate extended capability list for dom0


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Date: Wed, 7 May 2025 03:32:47 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=R0klfDFk0oD1mNFMFmYWfGLUMNDOrYjQgES5nwI92hA=; b=hs1cmZ/Fqs/yZummmnAcpHjqIcdNFRvAYN6OiEzSQZSW2dDGvalxr840gLV/Pk/WLQ/SrYArJINOxii8d7Q8Yzp+nIgPJ6JL6QgHt6R4UdvC41XlfD+zc3Do1VYePVrIQHheyguojjYr0W/V2NDC5wlvO/8754ewwB47PbPK95h/pyBRixestS+S6REm+9yud7duyKDifUXgktFBRG2+6WojeQ5y0CQ2Dr84arQ32WKQ6/jEl9nylx3dW8jfZIh4fDtNDDOaLGWLcwxLKAM60Zfh/J80zeItQkvuzQbKqX89ZwtqzQKlT5wxbPul1Hg1Ia1IzU3E+O8smFe9cDp0fw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gRT3TmSQ6i5Vh81fY6tQ0qWcS5bYCIk+lgnuIB+7KBikNcyjCqPRqS7LBS19q58EX7QJz7xaXtwwPUuKP99vbfDc8ozDGa3W7+vZTOw1FsnJLtJbDtOZNmjMKQRW4QZI/GbXfl81W4lkjffqM1h3jYCmyyCRhUtXYahm0217NFjQQ7Cw7c5H5ALQjPlp4FiXX72/q0EPVEebiRhv7ram9oHJ35TZTDBjBTAoXdj+mP+M/2WL5K/ar7yITGNtG5dQWWNxtMv2Rft7WgVgzBeS5nxuaN9m5Nd5LL/GGe5z6NDRrO1VRE6XREyhVpyPmhGhp13xmYZNLxkg99Zm+M5fPQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Huang, Ray" <Ray.Huang@xxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Wed, 07 May 2025 03:33:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHbsoVY5fFyP0iPLUqWwUIzQgdm1rPFvVIAgAFjzIA=
  • Thread-topic: [PATCH v3 04/11] vpci/header: Emulate extended capability list for dom0

On 2025/5/6 22:14, Roger Pau Monné wrote:
> On Mon, Apr 21, 2025 at 02:18:56PM +0800, Jiqian Chen wrote:
>> Add a new function to emulate extended capability list for dom0,
>> and call it in init_header(). So that it will be easy to hide a
>> extended capability whose initialization fails.
>>
>> As for the extended capability list of domU, just move the logic
>> into above function and keep hiding it for domU.
>>
>> Signed-off-by: Jiqian Chen <Jiqian.Chen@xxxxxxx>
>> ---
>> cc: "Roger Pau Monné" <roger.pau@xxxxxxxxxx>
>> ---
>> v2->v3 changes:
>> * In vpci_init_ext_capability_list(), when domain is domU, directly return 
>> after adding a handler(hiding all extended capability for domU).
>> * In vpci_init_ext_capability_list(), change condition to be "while ( pos >= 
>> 0x100U && ttl-- )" instead of "while ( pos && ttl-- )".
>> * Add new function vpci_hw_write32, and pass it to extended capability 
>> handler for dom0.
>>
>> v1->v2 changes:
>> new patch
>>
>> Best regards,
>> Jiqian Chen.
>> ---
>>  xen/drivers/vpci/header.c | 36 ++++++++++++++++++++++++++++--------
>>  xen/drivers/vpci/vpci.c   |  6 ++++++
>>  xen/include/xen/vpci.h    |  2 ++
>>  3 files changed, 36 insertions(+), 8 deletions(-)
>>
>> diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
>> index c98cd211d9d7..ee94ad8e5037 100644
>> --- a/xen/drivers/vpci/header.c
>> +++ b/xen/drivers/vpci/header.c
>> @@ -817,6 +817,31 @@ static int vpci_init_capability_list(struct pci_dev 
>> *pdev)
>>                                    PCI_STATUS_RSVDZ_MASK);
>>  }
>>  
>> +static int vpci_init_ext_capability_list(struct pci_dev *pdev)
>> +{
>> +    unsigned int pos = PCI_CFG_SPACE_SIZE, ttl = 480;
>> +
>> +    if ( !is_hardware_domain(pdev->domain) )
>> +        /* Extended capabilities read as zero, write ignore for guest */
>> +        return vpci_add_register(pdev->vpci, vpci_read_val, NULL,
>> +                                 pos, 4, (void *)0);
>> +
>> +    while ( pos >= PCI_CFG_SPACE_SIZE && ttl-- )
>> +    {
>> +        uint32_t header = pci_conf_read32(pdev->sbdf, pos);
>> +        int rc;
> 
> I'm thinking it might be helpful to avoid setting the handler for the
> last capability on the list, or simply for devices that have no
> extended capabilities at all:
> 
> if ( PCI_EXT_CAP_NEXT(header) >= PCI_CFG_SPACE_SIZE )
> {
>     int rc = vpci_add_register(pdev->vpci, vpci_read_val, vpci_hw_write32,
>                                pos, 4, (void *)(uintptr_t)header);
> 
>     if ( rc )
>         return rc;
> }
But if adding this check, there is a problem, think about this situation:
a device only has one extended capability, then under your check, it does not 
add handler for it,
if the initialization of that extended capability fails, we can't hide it by 
removing handler from vpci.
If you want to avoid adding handler for devices that have no extended 
capabilities.
I think adding check
If ( header == 0 )
    return 0;
is enough.

> 
> Otherwise on systems with a lot of devices it can be quite wasteful to
> set a handler to just return the next capability as 0.
> 
> Thanks, Roger.

-- 
Best regards,
Jiqian Chen.

 


Rackspace

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