[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v6 4/8] vpci: Hide extended capability when it fails to initialize
- To: Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
- From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
- Date: Tue, 24 Jun 2025 09:37:13 +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=fptTgdbhLrjlnkw5z6nGSycRPV02lARyQEKGVV1iGs8=; b=NpZZFk+Kmpwri3cjED5VAqTrWyHxwT0KuECUnCthSoaBCcOuqHZWR1CsN5pIwNYduD9Z6zTO0EqRY4yIbBJ5R9rl+7SrldaqVwMAlbAYyGQypiq3arwKBcmF1XxpioVf2aa2JItoQXCUBOKMZXeTyXtChm+Wpj2mcjdJrXLk5+OkQt2LvZoogzi+qR0B96JdkM7Pq9tLzjyiIF/+5Io0foh1SHxR8mLhbAE3E44F3jyaUhWQAN6s4OGavZ6PT3SeZECWfmOcSHkItfagfkpc6Zg3WHvyGXGNtDq/tWDCNPO9Onm/8QeRZyjp6eavSRTtAULyj+gbnrDvf5LDLT2Z3g==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JcE9haBs2am8ni3f7+9r1kBICDBXsC0FiaurQduXbvxcQMH37Rc752oZGPxvU7kBcYKp6hjH3tBL43d75I7MY/ylhT5KWAXcxyOGcl3yp3hf/H29kvXRVHEAY82Qbm30LRLO+NiZ/zkPOy0OPqUtFpiyyuhanUha9SiK6vWmaRksSQI5eKZatfE16lA7m99pw2i1xMnGn+sqdqD1LrH982B2OwxjMiXgDNfGQb65qRvNRxNmM9W1v8vEl0Szi5N0GyZz3S+dx3fsKZXpugjgUker1/aRSO5sS5/zmBeF7kEqwfDQ4OkqsR2PDGEnFO4AtnzUx0QrHqMAD/8Nbr55wg==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
- Cc: "Huang, Ray" <Ray.Huang@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, "Orzel, Michal" <Michal.Orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
- Delivery-date: Tue, 24 Jun 2025 09:37:30 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHb23ycT0X2vA9tYE2cHa4M+crvOLQJAzsAgAmiH4A=
- Thread-topic: [PATCH v6 4/8] vpci: Hide extended capability when it fails to initialize
On 2025/6/18 22:27, Jan Beulich wrote:
> On 12.06.2025 11:29, Jiqian Chen wrote:
>> +static int vpci_ext_capability_hide(struct pci_dev *pdev, unsigned int cap)
>> +{
>> + const unsigned int offset = pci_find_ext_capability(pdev->sbdf, cap);
>> + struct vpci_register *r, *prev_r;
>> + struct vpci *vpci = pdev->vpci;
>> + uint32_t header, pre_header;
>> +
>> + if ( offset < PCI_CFG_SPACE_SIZE )
>> + {
>> + ASSERT_UNREACHABLE();
>> + return 0;
>> + }
>> +
>> + spin_lock(&vpci->lock);
>> + r = vpci_get_register(vpci, offset, 4);
>> + if ( !r )
>> + {
>> + spin_unlock(&vpci->lock);
>> + return -ENODEV;
>> + }
>> +
>> + header = (uint32_t)(uintptr_t)r->private;
>> + if ( offset == PCI_CFG_SPACE_SIZE )
>> + {
>> + if ( PCI_EXT_CAP_NEXT(header) <= PCI_CFG_SPACE_SIZE )
>> + r->private = (void *)(uintptr_t)0;
>> + else
>> + /*
>> + * The first extended capability (0x100) can not be removed from
>> + * the linked list, so instead mask its capability ID to return >> 0
>> + * and force OSes to skip it.
>> + */
>> + r->private = (void *)(uintptr_t)(header &
>> ~PCI_EXT_CAP_ID(header));
>
> Can we rely on OSes recognizing ID 0 as "just skip"? Since the size isn't
> encoded
> in the header, there might be issues lurking here.
I was not very confident about how to handle this situation.
This version was modified according to Roger's suggestions.
Maybe Roger can give you more explanation.
>
> Jan
--
Best regards,
Jiqian Chen.
|