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

Re: [PATCH v2 1/1] vpci: Add resizable bar support


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Date: Wed, 11 Dec 2024 06:20:45 +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=tVLQK9Pf9WHFE7oiO52yZyICFfodqAd77gyssO5JpEU=; b=ygpx+K+ZNhyv0rX8yJdrrXdrgAyYPknQDMwyPgPNP4sHcMC++eqd7F5c9hSu+0B1Q760668xgK3+DRLuKOJEVUp3Od1Ubj3z9aHtpv29W539BwmJUVkiS4nFjlGeLz0IESudgDOIujbwpGRhStnQfK1tscmafcyopLX+rZl5SVJVqV9lSB1NK8+zBsBeCJ1zQciCgXjaq7Li9CRwUhe1tey2jhSRRDCa/idBQ/SDeixcVcdyvFbHb/1jnniYP4QKZ8UiGDqW1PwsGHd3K1KiIN2udfkm2P7a0NVGthiXg1fxqsNmY41ckf59G90q+bfnexAtAcgP0vCyxghFfdUd1w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QiNn6XWwFs4K5WNOKXIfvIn64ARBbRLHAOGvNEp9BAN7+I8PHUJUOaopDRzs76l5dn6RIPG9XjqnllwziHzBWKvfbhi3e8djh61M6T9+hR92aq3RzcybNZDYwamA0a35zKcGdqpX4Yxk86VnHudC+Lana1nB+eURCWwJuhpc1UzRvgGbzNrwuAxTWizBNjy+icySO4sCa72YvpnZEq2y76gNzKrXvVLSabRiMRflZE7C8ogyl8rdUyTxgHy0UFOl2tKZ9WvSxuE0zrYtORYTFnQg0P1FhIWy2UIl7xiSa5C5yywenrQ2OkmiPKfS75iaP2OzrEiJmSmhCqlN7KRwZw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Huang, Ray" <Ray.Huang@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 11 Dec 2024 06:20:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHbRIDgGHZ3ofHO0UuqqXvn+EZCabLd/CGAgAFgZ4CAAcmtAA==
  • Thread-topic: [PATCH v2 1/1] vpci: Add resizable bar support

On 2024/12/10 19:00, Roger Pau Monné wrote:
> On Mon, Dec 09, 2024 at 02:59:31PM +0100, Jan Beulich wrote:
>> On 02.12.2024 07:09, Jiqian Chen wrote:
>>> +static int cf_check init_rebar(struct pci_dev *pdev)
>>> +{
>>> +    uint32_t ctrl;
>>> +    unsigned int rebar_offset, nbars;
>>> +
>>> +    rebar_offset = pci_find_ext_capability(pdev->sbdf, 
>>> PCI_EXT_CAP_ID_REBAR);
>>> +
>>> +    if ( !rebar_offset )
>>> +        return 0;
>>> +
>>> +    ctrl = pci_conf_read32(pdev->sbdf, rebar_offset + PCI_REBAR_CTRL);
>>> +    nbars = MASK_EXTR(ctrl, PCI_REBAR_CTRL_NBAR_MASK);
>>> +
>>> +    for ( unsigned int i = 0; i < nbars; i++, rebar_offset += 
>>> PCI_REBAR_CTRL )
>>> +    {
>>> +        int rc;
>>> +
>>> +        rc = vpci_add_register(pdev->vpci, vpci_hw_read32, vpci_hw_write32,
>>> +                               rebar_offset + PCI_REBAR_CAP, 4, NULL);
>>
>> The capability register is r/o aiui. While permitting hwdom to write it is
>> fine, DomU-s shouldn't be permitted doing so, just in case. (An alternative
>> to making handler selection conditional here would be to bail early for the
>> !hwdom case, accompanied by a TODO comment. This would then also address
>> the lack of virtualization of the extended capability chain, as we may not
>> blindly expose all capabilities to DomU-s.)
> 
> I don't think we can safely expose this capability to domUs by
> default, so my preference would be a returning an error in that case
> (and printing a log message indicating ReBAR is not supported for
> domUs).

If I understand correctly.
I need to add below check in init_rebar():
    /* TODO */
    if ( !is_hardware_domain(pdev->domain) )
    {
        printk("ReBar is not supported for domUs\n");
        return -EOPNOTSUPP;
    }

> 
> Note it's already not exposed to domUs by not being part of
> supported_caps in init_header().
> 
> Regards, Roger

-- 
Best regards,
Jiqian Chen.

 


Rackspace

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