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

Re: [RFC PATCH 1/2] pci: Allow platforms to modify BAR adresses


  • To: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 24 Apr 2026 10:58:21 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=q30Qn+m5GPX6SjHc9+OHy2BFyepqWpqFl8i0NVVPmiM=; b=JxSbvqO43Fj2+gVUMRDgq9si4X0njwLnuUCx0xJeY9aKPLvkEUM/yugX5FSWtWewW4p4/KEhE3XiZoRB5T4Zi1ll6nrFYiCQ7hmCN3trVHmRDuU/bc8K8jYZUlSkfjrqQwG1wGZa5Q6hjTKvUUxGk+eMLj11FtJEvLj/XXSALPlMs2iihD6o577oOgvEgs44muIHmvnGG71cMH7t034cAocMUxIyMFWG11Q647wsQiTjRYs/ubMhOz3Srb7QQzuIR3u6gKP9zD6vWFrGWLOkA3jZWBRxu+O97EfPRAUIOM91qIy+0jnsbsD86QmdJGrouVcYACmA2itqDGmwa2fdfg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mbeiUwyO1E4oQZDP6OqEQ/7ja59QuHZhBdziKRemxq8UCdxJ8FIz6vQwSx2yWZbqMzH7vDLD5ZhTcHA0VKJGQDW4uYOKjQwHgUcTRfW1r+r/9jul/Uy5QD3QSraF3uyzTvNzD4drodLXqEJyDzB7mP7YeZ0x8oUkv3yCZdZOjl11HI2MZ7psU9vnnuD4feZaZgEtkaV2tKNO4Xkl1Deht2nzirLZulMXQlBEcvbpIgxoD5A75cry/01k1BlsKCl3PWu+Qu7F30X7PwdVEzan2lDhu96w56/tz4o0MtRL0FF1t+fK/jB4zZxQ4Z1GThhFMOoXNoOXxuM3YID8i/aBqg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Delivery-date: Fri, 24 Apr 2026 08:58:37 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Apr 21, 2026 at 07:57:14AM +0000, Mykyta Poturai wrote:
> This patch is a preparatory work for adding Region ID support on Renesas
> R-Car series boards. Add new host bridge op "fixup_bar" that allows
> platforms to modify BAR addresses before they are mapped.
> 
> Because x86 don't have support for PCI Host Bridge drivers, add another
> level of indirection in form of platform_pci_fixup_bar() function, that
> will call host bridge op on ARM and do nothing on x86.
> 
> Signed-off-by: Mykyta Poturai <mykyta_poturai@xxxxxxxx>
> ---
>  xen/arch/arm/include/asm/pci.h  |  3 +++
>  xen/arch/arm/include/asm/vpci.h |  9 +++++++++
>  xen/arch/arm/vpci.c             | 12 ++++++++++++
>  xen/arch/x86/include/asm/vpci.h |  6 ++++++
>  xen/drivers/vpci/header.c       |  2 ++
>  5 files changed, 32 insertions(+)
> 
> diff --git a/xen/arch/arm/include/asm/pci.h b/xen/arch/arm/include/asm/pci.h
> index 7c3211823f..398a4eb746 100644
> --- a/xen/arch/arm/include/asm/pci.h
> +++ b/xen/arch/arm/include/asm/pci.h
> @@ -80,6 +80,9 @@ struct pci_ops {
>      void (*init_bus_range)(struct dt_device_node *dev,
>                             struct pci_host_bridge *bridge,
>                             struct pci_config_window *cfg);
> +    void (*fixup_bar)(struct pci_host_bridge *bridge,
> +                      unsigned int bar_num,
> +                      paddr_t *addr);
>  };
>  
>  /*
> diff --git a/xen/arch/arm/include/asm/vpci.h b/xen/arch/arm/include/asm/vpci.h
> index 0cc6f5a105..f5c817a51c 100644
> --- a/xen/arch/arm/include/asm/vpci.h
> +++ b/xen/arch/arm/include/asm/vpci.h
> @@ -16,6 +16,10 @@ struct vpci_arch_msix_entry {
>  
>  int domain_vpci_init(struct domain *d);
>  unsigned int domain_vpci_get_num_mmio_handlers(struct domain *d);
> +
> +void platform_pci_fixup_bar(const struct pci_dev *pdev, unsigned int bar_num,
> +                            paddr_t *addr);
> +
>  #else
>  static inline int domain_vpci_init(struct domain *d)
>  {
> @@ -26,6 +30,11 @@ static inline unsigned int 
> domain_vpci_get_num_mmio_handlers(struct domain *d)
>  {
>      return 0;
>  }
> +
> +static inline void platform_pci_fixup_bar(const struct pci_dev *pdev,
> +                                          unsigned int bar_num,
> +                                          paddr_t *addr)
> +{}
>  #endif /* CONFIG_HAS_VPCI */
>  
>  #endif /* ARM_VPCI_H */
> diff --git a/xen/arch/arm/vpci.c b/xen/arch/arm/vpci.c
> index d41aa383a8..ec6efec22e 100644
> --- a/xen/arch/arm/vpci.c
> +++ b/xen/arch/arm/vpci.c
> @@ -189,6 +189,18 @@ unsigned int domain_vpci_get_num_mmio_handlers(struct 
> domain *d)
>      return 1;
>  }
>  
> +void platform_pci_fixup_bar(const struct pci_dev *pdev,
> +                                          unsigned int bar_num,
> +                                          paddr_t *addr)
> +{
> +    struct pci_host_bridge *bridge = pci_find_host_bridge(pdev->sbdf.seg, 
> pdev->sbdf.bus);
> +
> +    if ( bridge->ops->fixup_bar )
> +    {
> +        bridge->ops->fixup_bar(bridge, bar_num, addr);
> +    }
> +}
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/xen/arch/x86/include/asm/vpci.h b/xen/arch/x86/include/asm/vpci.h
> index c501ff1709..a05b70abbf 100644
> --- a/xen/arch/x86/include/asm/vpci.h
> +++ b/xen/arch/x86/include/asm/vpci.h
> @@ -16,6 +16,12 @@ struct vpci_arch_msix_entry {
>      int pirq;
>  };
>  
> +/* X86 does not require PCI BAR modifications */
> +static inline void platform_pci_fixup_bar(const struct pci_dev *pdev,
> +                                          unsigned int bar_num,
> +                                          paddr_t *addr)
> +{}
> +
>  #endif /* X86_VPCI_H */
>  
>  /*
> diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
> index a760d8c32f..d89e43354c 100644
> --- a/xen/drivers/vpci/header.c
> +++ b/xen/drivers/vpci/header.c
> @@ -882,6 +882,8 @@ int vpci_init_header(struct pci_dev *pdev)
>          bars[i].size = size;
>          bars[i].prefetchable = val & PCI_BASE_ADDRESS_MEM_PREFETCH;
>  
> +        platform_pci_fixup_bar(pdev, i, &bars[i].addr);

You do this for vpci_init_header(), but don't you also need to do it
for bar_write(), in case dom0 decides to relocate the BAR?

Also - I would assume that both the firmware and dom0 are aware of
this limitation, and hence wonder why you need this fixup in Xen?

Thanks, Roger.



 


Rackspace

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