On 21/08/2025 11:15 am, Mykyta Poturai wrote:
> diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c
> b/xen/drivers/passthrough/arm/ipmmu-vmsa.c
> index dac0dd6d46..49f149e222 100644
> --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c
> +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c
> @@ -1138,8 +1155,38 @@ static int ipmmu_assign_device(struct domain *d, u8
> devfn, struct device *dev,
> if ( !to_ipmmu(dev) )
> return -ENODEV;
>
> - spin_lock(&xen_domain->lock);
> +#ifdef CONFIG_HAS_PCI
> + if ( dev_is_pci(dev) )
> + {
> + struct pci_dev *pdev = dev_to_pci(dev);
> + struct domain *old_d = pdev->domain;
> +
> + /* Ignore calls for phantom functions */
> + if ( devfn != pdev->devfn )
> + return 0;
> +
> + write_lock(&d->pci_lock);
> + list_move(&pdev->domain_list, &d->pdev_list);
> + write_unlock(&d->pci_lock);
> + pdev->domain = d;
> +
> + /* dom_io is used as a sentinel for quarantined devices */
> + if ( d == dom_io )
> + {
> + int ret;
> +
> + /*
> + * Try to de-assign: do not return error if it was already
> + * de-assigned.
> + */
> + ret = ipmmu_deassign_device(old_d, dev);
> +
> + return ret == -ESRCH ? 0 : ret;
> + }
> + }
> +#endif
>
> + spin_lock(&xen_domain->lock);
Minor point. You've removed a newline here, which is why the hunk is
not cleanly ahead of the spin_lock() call.
~Andrew