On 16.12.2024 11:24, Roger Pau Monné wrote:
> On Fri, Dec 13, 2024 at 01:42:32PM +0800, 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);
>
> You can do the init at definition:
>
> uint32_t ctrl;
> unsigned int nbars;
> unsigned int rebar_offset = pci_find_ext_capability(pdev->sbdf,
> PCI_EXT_CAP_ID_REBAR);
>
>
>> +
>> + if ( !rebar_offset )
>> + return 0;
>> +
>> + if ( !is_hardware_domain(pdev->domain) )
>> + {
>> + printk("ReBar is not supported for domUs\n");
>
> This needs a bit more information IMO:
>
> printk(XENLOG_ERR
> "%pd %pp: resizable BAR capability not supported for unprivileged
> domains\n",
> pdev->domain, &pdev->sbdf);
>
> I wonder if this should instead be an XSM check, but that would
> require a new XSM hook to process permissions for PCI capabilities.
Ultimately perhaps, but right now we need to bail here irrespective of
XSM policy, as the DomU side simply is unimplemented.
Jan