[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v10 2/4] vpci/rebar: Free Rebar resources when init_rebar() fails
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
- Date: Wed, 6 Aug 2025 03:39:14 +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=pLkmqVTfKVZJZB5yp+5RloWood+UEHnFL3yzWi//LvM=; b=gzI+djsJjn/tKxlvtt+PlqWUcXwHaBepo6Ehhv1/HuWIaDKlHz25d+KNOyLftafFEB/tWjFsLbEOsUH3aqLKnTzDhLAsO7DbZ/iyh7kiEgPxK/CB/PqmgQgwK451slFD1prwJkIguaCvGWVSLGeJf8Xb85I0xGgdkgnnqFvzj5eettMDjmAxMNoJ62NahBuGxPv0GdEIlY1L2sag9iUdiCDUxTH7uf4MmkNNw3shuO3Ws/ypgmo6BQ15R1PVAHC4FlC2GcQlGTwy/VmqNQA17kCuamggPT2PcRXy0EGpPFUC27QbuzOG+LdRtSDRMVKkBHgsJNzF8GvlvRLDnUFpbQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RmwgJq/XI6qKJbaZ0kP7iZ/dQfLg476lisouKHRSkHN6jrHP1kMOFIegb8bYuqtXW03BZ5ro5mbZKSFpEdXKlSLJrA/nNwxGEN2qpW6j8Cyk6zmQkLbTCjWLLwaiEM7rBZmbSic9aOXD0dRxM3VhE+Tmh5wMgQmHtSOO+hvbpniqGYqJFW9TdH7Ft2fL7vx0ZkutQOOfddY/PXawL5foinrZI6mpgWEZ1l0MTd/2S/UkLyUL0NCq3VRnfOP24tq0iqiuOTIrl0M3FkqoVFe8d6AVACaGAVlZnwjUHroxIkmnsLV0Zr8VJeWmBfx6sKLEt1CqLDBGaPlujGbNfFDIWQ==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
- Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Huang, Ray" <Ray.Huang@xxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
- Delivery-date: Wed, 06 Aug 2025 03:39:26 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHcBbvxdj1/OHisv0yt2jqXoA238rRTv+0AgAHBO4A=
- Thread-topic: [PATCH v10 2/4] vpci/rebar: Free Rebar resources when init_rebar() fails
On 2025/8/5 16:48, Jan Beulich wrote:
> On 05.08.2025 05:49, Jiqian Chen wrote:
>> --- a/xen/drivers/vpci/rebar.c
>> +++ b/xen/drivers/vpci/rebar.c
>> @@ -49,6 +49,32 @@ static void cf_check rebar_ctrl_write(const struct
>> pci_dev *pdev,
>> bar->guest_addr = bar->addr;
>> }
>>
>> +static int cf_check cleanup_rebar(const struct pci_dev *pdev)
>> +{
>> + int rc;
>> + uint32_t ctrl;
>> + unsigned int nbars;
>> + unsigned int rebar_offset = pci_find_ext_capability(pdev->sbdf,
>> +
>> PCI_EXT_CAP_ID_REBAR);
>> +
>> + if ( !rebar_offset || !is_hardware_domain(pdev->domain) )
>> + {
>> + ASSERT_UNREACHABLE();
>> + return 0;
>> + }
>> +
>> + ctrl = pci_conf_read32(pdev->sbdf, rebar_offset + PCI_REBAR_CTRL(0));
>> + nbars = MASK_EXTR(ctrl, PCI_REBAR_CTRL_NBAR_MASK);
>> +
>> + rc = vpci_remove_registers(pdev->vpci, rebar_offset + PCI_REBAR_CAP(0),
>> + PCI_REBAR_CTRL(nbars - 1));
>> + if ( rc )
>> + printk(XENLOG_ERR "%pd %pp: fail to remove Rebar handlers rc=%d\n",
>> + pdev->domain, &pdev->sbdf, rc);
>
> MSI and MSI-X (now) have ASSERT_UNREACHABLE() on their respective paths. Is
> there a reason this shouldn't be done here as well?
Will add.
>
> MSI and MSI-X further have another add-register below here, to ensure the
> control register cannot be written. Again - is there a reason the same
> shouldn't be done here? (If so, I think this may want putting in a comment.)
Since extended capabilities are only exposed to dom0, and dom0 has no
limitations to access devices.
It since there is not much point in adding such a handler for rebar.
>
> Jan
--
Best regards,
Jiqian Chen.
|