xen-pciback: allow compiling on other archs than x86
Subsystems (5)
PATCH 1/1 xen-pciback: allow compiling on other archs than x86
From: Oleksandr Andrushchenko <[email protected]>
Xen-pciback driver was designed to be built for x86 only. But it can also be used by other architectures, e.g. Arm. Re-structure the driver in a way that it can be built for other platforms as well.
---
Tested on Arm and x86.
--- arch/x86/include/asm/xen/pci.h | 24 ---------- arch/x86/pci/xen.c | 74 +---------------------------- drivers/xen/Kconfig | 2 +- drivers/xen/events/events_base.c | 1 + drivers/xen/pci.c | 75 ++++++++++++++++++++++++++++++ drivers/xen/xen-pciback/pci_stub.c | 3 +- drivers/xen/xen-pciback/xenbus.c | 2 +- include/xen/pci.h | 34 ++++++++++++++ 8 files changed, 115 insertions(+), 100 deletions(-) create mode 100644 include/xen/pci.h
arch/x86/include/asm/xen/pci.h +0 -24
@@ -14,30 +14,6 @@ static inline int pci_xen_hvm_init(void) return -1; }#endif -#if defined(CONFIG_XEN_DOM0 ) -int __init pci_xen_initial_domain (void ); -int xen_find_device_domain_owner (struct pci_dev *dev); -int xen_register_device_domain_owner (struct pci_dev *dev,uint16_t domain); -int xen_unregister_device_domain_owner (struct pci_dev *dev); -#else -static inline int __init pci_xen_initial_domain (void ) -{ -return -1 ; -} -static inline int xen_find_device_domain_owner (struct pci_dev *dev) -{ -return -1 ; -} -static inline int xen_register_device_domain_owner (struct pci_dev *dev, -uint16_t domain) -{ -return -1 ; -} -static inline int xen_unregister_device_domain_owner (struct pci_dev *dev) -{ -return -1 ; -} -#endif #if defined(CONFIG_PCI_MSI )#if defined(CONFIG_PCI_XEN )
arch/x86/pci/xen.c +1 -73
84 lines not on this page · raw message
drivers/xen/Kconfig +1 -1
@@ -182,7 +182,7 @@ config SWIOTLB_XEN config XEN_PCIDEV_BACKEND tristate "Xen PCI-device backend driver" - depends on PCI && X86 && XEN + depends on PCI && XEN depends on XEN_BACKEND default m help
drivers/xen/events/events_base.c +1 -0
@@ -65,6 +65,7 @@#include <xen/interface/vcpu.h> #include <xen/xenbus.h> #include <asm/hw_irq.h> +#include <xen/pci.h> #include "events_internal.h"
drivers/xen/pci.c +75 -0
78 lines not on this page · raw message
drivers/xen/xen-pciback/pci_stub.c +2 -1
@@ -19,7 +19,8 @@#include <linux/sched.h> #include <linux/atomic.h> #include <xen/events.h> -#include <asm/xen/pci.h> +#include <xen/pci.h> +#include <xen/xen.h> #include <asm/xen/hypervisor.h> #include <xen/interface/physdev.h> #include "pciback.h"
drivers/xen/xen-pciback/xenbus.c +1 -1
@@ -14,7 +14,7 @@#include <linux/workqueue.h> #include <xen/xenbus.h> #include <xen/events.h> -#include <asm/xen/pci.h> +#include <xen/pci.h> #include "pciback.h" #define INVALID_EVTCHN_IRQ (-1)
include/xen/pci.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __XEN_PCI_H__ +#define __XEN_PCI_H__ + +#if defined(CONFIG_XEN_DOM0 ) +int __init pci_xen_initial_domain (void ); +int xen_find_device_domain_owner (struct pci_dev *dev); +int xen_register_device_domain_owner (struct pci_dev *dev,uint16_t domain); +int xen_unregister_device_domain_owner (struct pci_dev *dev); +#else +static inline int __init pci_xen_initial_domain (void ) +{ +return -1 ; +} + +static inline int xen_find_device_domain_owner (struct pci_dev *dev) +{ +return -1 ; +} + +static inline int xen_register_device_domain_owner (struct pci_dev *dev, +uint16_t domain) +{ +return -1 ; +} + +static inline int xen_unregister_device_domain_owner (struct pci_dev *dev) +{ +return -1 ; +} +#endif + +#endif
Signature · 1 line
2.25.1
Stefano Stabellini
maintainerHi Oleksandr,
Why do you want to enable pciback on ARM? Is it only to "disable" a PCI device in Dom0 so that it can be safely assigned to a DomU?
I am asking because actually I don't think we want to enable the PV PCI backend feature of pciback on ARM, right? That would clash with the PCI assignment work you have been doing in Xen. They couldn't both work at the same time.
If we only need pciback to "park" a device in Dom0, wouldn't it be possible and better to use pci-stub instead?
Quoted 327 lines · Oleksandr Andrushchenko
From: Oleksandr Andrushchenko <[email protected]>
Xen-pciback driver was designed to be built for x86 only. But it can also be used by other architectures, e.g. Arm. Re-structure the driver in a way that it can be built for other platforms as well.
Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>---
Tested on Arm and x86.--- arch/x86/include/asm/xen/pci.h | 24 ---------- arch/x86/pci/xen.c | 74 +---------------------------- drivers/xen/Kconfig | 2 +- drivers/xen/events/events_base.c | 1 + drivers/xen/pci.c | 75 ++++++++++++++++++++++++++++++ drivers/xen/xen-pciback/pci_stub.c | 3 +- drivers/xen/xen-pciback/xenbus.c | 2 +- include/xen/pci.h | 34 ++++++++++++++ 8 files changed, 115 insertions(+), 100 deletions(-) create mode 100644 include/xen/pci.harch/x86/include/asm/xen/pci.h +0
-24@@ -14,30 +14,6 @@ static inline int pci_xen_hvm_init(void) return -1; }#endif -#if defined(CONFIG_XEN_DOM0 ) -int __init pci_xen_initial_domain (void ); -int xen_find_device_domain_owner (struct pci_dev *dev); -int xen_register_device_domain_owner (struct pci_dev *dev,uint16_t domain); -int xen_unregister_device_domain_owner (struct pci_dev *dev); -#else -static inline int __init pci_xen_initial_domain (void ) -{ -return -1 ; -} -static inline int xen_find_device_domain_owner (struct pci_dev *dev) -{ -return -1 ; -} -static inline int xen_register_device_domain_owner (struct pci_dev *dev, -uint16_t domain) -{ -return -1 ; -} -static inline int xen_unregister_device_domain_owner (struct pci_dev *dev) -{ -return -1 ; -} -#endif #if defined(CONFIG_PCI_MSI )#if defined(CONFIG_PCI_XEN )arch/x86/pci/xen.c +1
-73@@ -23,6 +23,7 @@#include <xen/features.h> #include <xen/events.h> +#include <xen/pci.h> #include <asm/xen/pci.h> #include <asm/xen/cpuid.h> #include <asm/apic.h> @@ -583,77 +584,4 @@ int __init pci_xen_initial_domain(void) }return 0 ; } - -struct xen_device_domain_owner { -domid_t domain; -struct pci_dev *dev; -struct list_head list; -}; - -static DEFINE_SPINLOCK (dev_domain_list_spinlock); -static struct list_head dev_domain_list =LIST_HEAD_INIT (dev_domain_list); - -static struct xen_device_domain_owner *find_device (struct pci_dev *dev) -{ -struct xen_device_domain_owner *owner; - -list_for_each_entry (owner, &dev_domain_list, list) { -if (owner->dev == dev) -return owner; - } -return NULL ; -} - -int xen_find_device_domain_owner (struct pci_dev *dev) -{ -struct xen_device_domain_owner *owner; -int domain = -ENODEV ; - -spin_lock (&dev_domain_list_spinlock); - owner =find_device (dev); -if (owner) - domain = owner->domain; -spin_unlock (&dev_domain_list_spinlock); -return domain; -} -EXPORT_SYMBOL_GPL (xen_find_device_domain_owner); - -int xen_register_device_domain_owner (struct pci_dev *dev,uint16_t domain) -{ -struct xen_device_domain_owner *owner; - - owner =kzalloc (sizeof (struct xen_device_domain_owner ),GFP_KERNEL ); -if (!owner) -return -ENODEV ; - -spin_lock (&dev_domain_list_spinlock); -if (find_device (dev)) { -spin_unlock (&dev_domain_list_spinlock); -kfree (owner); -return -EEXIST ; - } - owner->domain = domain; - owner->dev = dev; -list_add_tail (&owner->list, &dev_domain_list); -spin_unlock (&dev_domain_list_spinlock); -return 0 ; -} -EXPORT_SYMBOL_GPL (xen_register_device_domain_owner); - -int xen_unregister_device_domain_owner (struct pci_dev *dev) -{ -struct xen_device_domain_owner *owner; - -spin_lock (&dev_domain_list_spinlock); - owner =find_device (dev); -if (!owner) { -spin_unlock (&dev_domain_list_spinlock); -return -ENODEV ; - } -list_del (&owner->list); -spin_unlock (&dev_domain_list_spinlock); -kfree (owner); -return 0 ; -} -EXPORT_SYMBOL_GPL (xen_unregister_device_domain_owner);#endif drivers/xen/Kconfig +1
-1@@ -182,7 +182,7 @@ config SWIOTLB_XEN config XEN_PCIDEV_BACKEND tristate "Xen PCI-device backend driver" - depends on PCI && X86 && XEN + depends on PCI && XEN depends on XEN_BACKEND default m helpdrivers/xen/events/events_base.c +1
-0@@ -65,6 +65,7 @@#include <xen/interface/vcpu.h> #include <xen/xenbus.h> #include <asm/hw_irq.h> +#include <xen/pci.h> #include "events_internal.h" drivers/xen/pci.c +75
-0@@ -254,3 +254,78 @@ static int xen_mcfg_late(void)return 0 ; }#endif + +#ifdef CONFIG_XEN_DOM0 +struct xen_device_domain_owner { +domid_t domain; +struct pci_dev *dev; +struct list_head list; +}; + +static DEFINE_SPINLOCK (dev_domain_list_spinlock); +static struct list_head dev_domain_list =LIST_HEAD_INIT (dev_domain_list); + +static struct xen_device_domain_owner *find_device (struct pci_dev *dev) +{ +struct xen_device_domain_owner *owner; + +list_for_each_entry (owner, &dev_domain_list, list) { +if (owner->dev == dev) +return owner; + } +return NULL ; +} + +int xen_find_device_domain_owner (struct pci_dev *dev) +{ +struct xen_device_domain_owner *owner; +int domain = -ENODEV ; + +spin_lock (&dev_domain_list_spinlock); + owner =find_device (dev); +if (owner) + domain = owner->domain; +spin_unlock (&dev_domain_list_spinlock); +return domain; +} +EXPORT_SYMBOL_GPL (xen_find_device_domain_owner); + +int xen_register_device_domain_owner (struct pci_dev *dev,uint16_t domain) +{ +struct xen_device_domain_owner *owner; + + owner =kzalloc (sizeof (struct xen_device_domain_owner ),GFP_KERNEL ); +if (!owner) +return -ENODEV ; + +spin_lock (&dev_domain_list_spinlock); +if (find_device (dev)) { +spin_unlock (&dev_domain_list_spinlock); +kfree (owner); +return -EEXIST ; + } + owner->domain = domain; + owner->dev = dev; +list_add_tail (&owner->list, &dev_domain_list); +spin_unlock (&dev_domain_list_spinlock); +return 0 ; +} +EXPORT_SYMBOL_GPL (xen_register_device_domain_owner); + +int xen_unregister_device_domain_owner (struct pci_dev *dev) +{ +struct xen_device_domain_owner *owner; + +spin_lock (&dev_domain_list_spinlock); + owner =find_device (dev); +if (!owner) { +spin_unlock (&dev_domain_list_spinlock); +return -ENODEV ; + } +list_del (&owner->list); +spin_unlock (&dev_domain_list_spinlock); +kfree (owner); +return 0 ; +} +EXPORT_SYMBOL_GPL (xen_unregister_device_domain_owner); +#endif drivers/xen/xen-pciback/pci_stub.c +2
-1@@ -19,7 +19,8 @@#include <linux/sched.h> #include <linux/atomic.h> #include <xen/events.h> -#include <asm/xen/pci.h> +#include <xen/pci.h> +#include <xen/xen.h> #include <asm/xen/hypervisor.h> #include <xen/interface/physdev.h> #include "pciback.h" drivers/xen/xen-pciback/xenbus.c +1
-1@@ -14,7 +14,7 @@#include <linux/workqueue.h> #include <xen/xenbus.h> #include <xen/events.h> -#include <asm/xen/pci.h> +#include <xen/pci.h> #include "pciback.h" #define INVALID_EVTCHN_IRQ (-1)include/xen/pci.h new file +34
-0@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __XEN_PCI_H__ +#define __XEN_PCI_H__ + +#if defined(CONFIG_XEN_DOM0 ) +int __init pci_xen_initial_domain (void ); +int xen_find_device_domain_owner (struct pci_dev *dev); +int xen_register_device_domain_owner (struct pci_dev *dev,uint16_t domain); +int xen_unregister_device_domain_owner (struct pci_dev *dev); +#else +static inline int __init pci_xen_initial_domain (void ) +{ +return -1 ; +} + +static inline int xen_find_device_domain_owner (struct pci_dev *dev) +{ +return -1 ; +} + +static inline int xen_register_device_domain_owner (struct pci_dev *dev, +uint16_t domain) +{ +return -1 ; +} + +static inline int xen_unregister_device_domain_owner (struct pci_dev *dev) +{ +return -1 ; +} +#endif + +#endif Signature · 1 line
2.25.1
Hello, Stefano!
Quoted 4 lines · Stefano Stabellini
Hi Oleksandr,
Why do you want to enable pciback on ARM? Is it only to "disable" a PCI device in Dom0 so that it can be safely assigned to a DomU?
Not only that
Quoted 5 lines
I am asking because actually I don't think we want to enable the PV PCI backend feature of pciback on ARM, right? That would clash with the PCI assignment work you have been doing in Xen. They couldn't both work at the same time.
Correct, it is not used
Quoted 3 lines
If we only need pciback to "park" a device in Dom0, wouldn't it be possible and better to use pci-stub instead?
Not only that, so pci-stub is not enough
The functionality which is implemented by the pciback and the toolstack and which is relevant/missing/needed for ARM:
1. pciback is used as a database for assignable PCI devices, e.g. xl pci-assignable-{add|remove|list} manipulates that list. So, whenever the toolstack needs to know which PCI devices can be passed through it reads that from the relevant sysfs entries of the pciback.
2. pciback is used to hold the unbound PCI devices, e.g. when passing through a PCI device it needs to be unbound from the relevant device driver and bound to pciback (strictly speaking it is not required that the device is bound to pciback, but pciback is again used as a database of the passed through PCI devices, so we can re-bind the devices back to their original drivers when guest domain shuts down)
3. Device reset
We have previously discussed on xen-devel ML possible solutions to that as from the
above we see that pciback functionality is going to be only partially used on Arm.
Please see [1] and [2]:
1. It is not acceptable to manage the assignable list in Xen itself
2. pciback can be split into two parts: PCI assignable/bind/reset handling and
the rest like vPCI etc.
3. pcifront is not used on Arm
So, limited use of the pciback is one of the bricks used to enable PCI passthrough
on Arm. It was enough to just re-structure the driver and have it run on Arm to achieve
all the goals above.
If we still think it is desirable to break the pciback driver into "common" and "pcifront specific"
parts then it can be done, yet the patch is going to be the very first brick in that building.
So, I think this patch is still going to be needed besides which direction we take.
Hope this sheds some light,
Oleksandr
Quoted 322 lines · Oleksandr Andrushchenko
Quoted 319 lines
From: Oleksandr Andrushchenko <[email protected]>
Xen-pciback driver was designed to be built for x86 only. But it can also be used by other architectures, e.g. Arm. Re-structure the driver in a way that it can be built for other platforms as well.
Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>---
Tested on Arm and x86.--- arch/x86/include/asm/xen/pci.h | 24 ---------- arch/x86/pci/xen.c | 74 +---------------------------- drivers/xen/Kconfig | 2 +- drivers/xen/events/events_base.c | 1 + drivers/xen/pci.c | 75 ++++++++++++++++++++++++++++++ drivers/xen/xen-pciback/pci_stub.c | 3 +- drivers/xen/xen-pciback/xenbus.c | 2 +- include/xen/pci.h | 34 ++++++++++++++ 8 files changed, 115 insertions(+), 100 deletions(-)create mode 100644
include/xen/pci.harch/x86/include/asm/xen/pci.h +0
-24@@ -14,30 +14,6 @@ static inline int pci_xen_hvm_init(void) return -1; }#endif -#if defined(CONFIG_XEN_DOM0 ) -int __init pci_xen_initial_domain (void ); -int xen_find_device_domain_owner (struct pci_dev *dev); -int xen_register_device_domain_owner (struct pci_dev *dev,uint16_t domain); -int xen_unregister_device_domain_owner (struct pci_dev *dev); -#else -static inline int __init pci_xen_initial_domain (void ) -{ -return -1 ; -} -static inline int xen_find_device_domain_owner (struct pci_dev *dev) -{ -return -1 ; -} -static inline int xen_register_device_domain_owner (struct pci_dev *dev, -uint16_t domain) -{ -return -1 ; -} -static inline int xen_unregister_device_domain_owner (struct pci_dev *dev) -{ -return -1 ; -} -#endif #if defined(CONFIG_PCI_MSI )#if defined(CONFIG_PCI_XEN )arch/x86/pci/xen.c +1
-73@@ -23,6 +23,7 @@#include <xen/features.h> #include <xen/events.h> +#include <xen/pci.h> #include <asm/xen/pci.h> #include <asm/xen/cpuid.h> #include <asm/apic.h> @@ -583,77 +584,4 @@ int __init pci_xen_initial_domain(void) }return 0 ; } - -struct xen_device_domain_owner { -domid_t domain; -struct pci_dev *dev; -struct list_head list; -}; - -static DEFINE_SPINLOCK (dev_domain_list_spinlock); -static struct list_head dev_domain_list =LIST_HEAD_INIT (dev_domain_list); - -static struct xen_device_domain_owner *find_device (struct pci_dev *dev) -{ -struct xen_device_domain_owner *owner; - -list_for_each_entry (owner, &dev_domain_list, list) { -if (owner->dev == dev) -return owner; - } -return NULL ; -} - -int xen_find_device_domain_owner (struct pci_dev *dev) -{ -struct xen_device_domain_owner *owner; -int domain = -ENODEV ; - -spin_lock (&dev_domain_list_spinlock); - owner =find_device (dev); -if (owner) - domain = owner->domain; -spin_unlock (&dev_domain_list_spinlock); -return domain; -} -EXPORT_SYMBOL_GPL (xen_find_device_domain_owner); - -int xen_register_device_domain_owner (struct pci_dev *dev,uint16_t domain) -{ -struct xen_device_domain_owner *owner; - - owner =kzalloc (sizeof (struct xen_device_domain_owner ),GFP_KERNEL ); -if (!owner) -return -ENODEV ; - -spin_lock (&dev_domain_list_spinlock); -if (find_device (dev)) { -spin_unlock (&dev_domain_list_spinlock); -kfree (owner); -return -EEXIST ; - } - owner->domain = domain; - owner->dev = dev; -list_add_tail (&owner->list, &dev_domain_list); -spin_unlock (&dev_domain_list_spinlock); -return 0 ; -} -EXPORT_SYMBOL_GPL (xen_register_device_domain_owner); - -int xen_unregister_device_domain_owner (struct pci_dev *dev) -{ -struct xen_device_domain_owner *owner; - -spin_lock (&dev_domain_list_spinlock); - owner =find_device (dev); -if (!owner) { -spin_unlock (&dev_domain_list_spinlock); -return -ENODEV ; - } -list_del (&owner->list); -spin_unlock (&dev_domain_list_spinlock); -kfree (owner); -return 0 ; -} -EXPORT_SYMBOL_GPL (xen_unregister_device_domain_owner);#endif drivers/xen/Kconfig +1
-1@@ -182,7 +182,7 @@ config SWIOTLB_XEN config XEN_PCIDEV_BACKEND tristate "Xen PCI-device backend driver" - depends on PCI && X86 && XEN + depends on PCI && XEN depends on XEN_BACKEND default m helpdrivers/xen/events/events_base.c +1
-0@@ -65,6 +65,7 @@#include <xen/interface/vcpu.h> #include <xen/xenbus.h> #include <asm/hw_irq.h> +#include <xen/pci.h> #include "events_internal.h" drivers/xen/pci.c +75
-0@@ -254,3 +254,78 @@ static int xen_mcfg_late(void)return 0 ; }#endif + +#ifdef CONFIG_XEN_DOM0 +struct xen_device_domain_owner { +domid_t domain; +struct pci_dev *dev; +struct list_head list; +}; + +static DEFINE_SPINLOCK (dev_domain_list_spinlock); +static struct list_head dev_domain_list =LIST_HEAD_INIT (dev_domain_list); + +static struct xen_device_domain_owner *find_device (struct pci_dev *dev) +{ +struct xen_device_domain_owner *owner; + +list_for_each_entry (owner, &dev_domain_list, list) { +if (owner->dev == dev) +return owner; + } +return NULL ; +} + +int xen_find_device_domain_owner (struct pci_dev *dev) +{ +struct xen_device_domain_owner *owner; +int domain = -ENODEV ; + +spin_lock (&dev_domain_list_spinlock); + owner =find_device (dev); +if (owner) + domain = owner->domain; +spin_unlock (&dev_domain_list_spinlock); +return domain; +} +EXPORT_SYMBOL_GPL (xen_find_device_domain_owner); + +int xen_register_device_domain_owner (struct pci_dev *dev,uint16_t domain) +{ +struct xen_device_domain_owner *owner; + + owner =kzalloc (sizeof (struct xen_device_domain_owner ),GFP_KERNEL ); +if (!owner) +return -ENODEV ; + +spin_lock (&dev_domain_list_spinlock); +if (find_device (dev)) { +spin_unlock (&dev_domain_list_spinlock); +kfree (owner); +return -EEXIST ; + } + owner->domain = domain; + owner->dev = dev; +list_add_tail (&owner->list, &dev_domain_list); +spin_unlock (&dev_domain_list_spinlock); +return 0 ; +} +EXPORT_SYMBOL_GPL (xen_register_device_domain_owner); + +int xen_unregister_device_domain_owner (struct pci_dev *dev) +{ +struct xen_device_domain_owner *owner; + +spin_lock (&dev_domain_list_spinlock); + owner =find_device (dev); +if (!owner) { +spin_unlock (&dev_domain_list_spinlock); +return -ENODEV ; + } +list_del (&owner->list); +spin_unlock (&dev_domain_list_spinlock); +kfree (owner); +return 0 ; +} +EXPORT_SYMBOL_GPL (xen_unregister_device_domain_owner); +#endif drivers/xen/xen-pciback/pci_stub.c +2
-1@@ -19,7 +19,8 @@#include <linux/sched.h> #include <linux/atomic.h> #include <xen/events.h> -#include <asm/xen/pci.h> +#include <xen/pci.h> +#include <xen/xen.h> #include <asm/xen/hypervisor.h> #include <xen/interface/physdev.h> #include "pciback.h" drivers/xen/xen-pciback/xenbus.c +1
-1@@ -14,7 +14,7 @@#include <linux/workqueue.h> #include <xen/xenbus.h> #include <xen/events.h> -#include <asm/xen/pci.h> +#include <xen/pci.h> #include "pciback.h" #define INVALID_EVTCHN_IRQ (-1)include/xen/pci.h new file +29
-0@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __XEN_PCI_H__ +#define __XEN_PCI_H__ + +#if defined(CONFIG_XEN_DOM0) +int __init pci_xen_initial_domain(void); +int xen_find_device_domain_owner(struct pci_dev *dev); +int xen_register_device_domain_owner(struct pci_dev *dev, uint16_t domain); +int xen_unregister_device_domain_owner(struct pci_dev *dev); +#else +static inline int __init pci_xen_initial_domain(void) +{ + return -1; +} + +static inline int xen_find_device_domain_owner(struct pci_dev *dev) +{ + return -1; +} + +static inline int xen_register_device_domain_owner(struct pci_dev *dev, + uint16_t domain) +{ + return -1; +} + +static inline int xen_unregister_device_domain_owner(struct pci_dev *dev) +{
Quoted 8 lines
Quoted 8 lines
include/xen/pci.h new file +5
-0+return -1 ; +} +#endif + +#endif Signature · 1 line
2.25.1
[1] https://www.mail-archive.com/[email protected]/msg84452.html
[2] https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/
Juergen Gross
maintainerQuoted 40 lines · Oleksandr Andrushchenko
Hello, Stefano!
Quoted 4 lines · Stefano Stabellini
Hi Oleksandr,
Why do you want to enable pciback on ARM? Is it only to "disable" a PCI device in Dom0 so that it can be safely assigned to a DomU?
Not only that
Quoted 5 lines
I am asking because actually I don't think we want to enable the PV PCI backend feature of pciback on ARM, right? That would clash with the PCI assignment work you have been doing in Xen. They couldn't both work at the same time.
Correct, it is not used
Quoted 3 lines
If we only need pciback to "park" a device in Dom0, wouldn't it be possible and better to use pci-stub instead?
Not only that, so pci-stub is not enough
The functionality which is implemented by the pciback and the toolstack and which is relevant/missing/needed for ARM:
1. pciback is used as a database for assignable PCI devices, e.g. xl pci-assignable-{add|remove|list} manipulates that list. So, whenever the toolstack needs to know which PCI devices can be passed through it reads that from the relevant sysfs entries of the pciback.
2. pciback is used to hold the unbound PCI devices, e.g. when passing through a PCI device it needs to be unbound from the relevant device driver and bound to pciback (strictly speaking it is not required that the device is bound to pciback, but pciback is again used as a database of the passed through PCI devices, so we can re-bind the devices back to their original drivers when guest domain shuts down)
3. Device reset
We have previously discussed on xen-devel ML possible solutions to that as from the above we see that pciback functionality is going to be only partially used on Arm.
Quoted 8 lines
Please see [1] and [2]:
1. It is not acceptable to manage the assignable list in Xen itself
2. pciback can be split into two parts: PCI assignable/bind/reset handling and the rest like vPCI etc.
3. pcifront is not used on Arm
It is neither in x86 PVH/HVM guests.
Quoted 6 lines
So, limited use of the pciback is one of the bricks used to enable PCI passthrough on Arm. It was enough to just re-structure the driver and have it run on Arm to achieve all the goals above.
If we still think it is desirable to break the pciback driver into "common" and "pcifront specific" parts then it can be done, yet the patch is going to be the very first brick in that building.
Doing this split should be done, as the pcifront specific part could be omitted on x86, too, in case no PV guests using PCI passthrough have to be supported.
Quoted 1 line
So, I think this patch is still going to be needed besides which direction we take.
Some kind of this patch, yes. It might look different in case the split is done first.
I don't mind doing it in either sequence.
Juergen
Hello, Juergen!
Quoted 43 lines · Juergen Gross
Quoted 42 lines · Oleksandr Andrushchenko
Hello, Stefano!
Quoted 4 lines · Stefano Stabellini
Hi Oleksandr,
Why do you want to enable pciback on ARM? Is it only to "disable" a PCI device in Dom0 so that it can be safely assigned to a DomU?
Not only that
Quoted 5 lines
I am asking because actually I don't think we want to enable the PV PCI backend feature of pciback on ARM, right? That would clash with the PCI assignment work you have been doing in Xen. They couldn't both work at the same time.
Correct, it is not used
Quoted 3 lines
If we only need pciback to "park" a device in Dom0, wouldn't it be possible and better to use pci-stub instead?
Not only that, so pci-stub is not enough
The functionality which is implemented by the pciback and the toolstack and which is relevant/missing/needed for ARM:
1. pciback is used as a database for assignable PCI devices, e.g. xl pci-assignable-{add|remove|list} manipulates that list. So, whenever the toolstack needs to know which PCI devices can be passed through it reads that from the relevant sysfs entries of the pciback.
2. pciback is used to hold the unbound PCI devices, e.g. when passing through a PCI device it needs to be unbound from the relevant device driver and bound to pciback (strictly speaking it is not required that the device is bound to pciback, but pciback is again used as a database of the passed through PCI devices, so we can re-bind the devices back to their original drivers when guest domain shuts down)
3. Device reset
We have previously discussed on xen-devel ML possible solutions to that as from the above we see that pciback functionality is going to be only partially used on Arm.
Please see [1] and [2]:
Quoted 8 lines
Quoted 6 lines
1. It is not acceptable to manage the assignable list in Xen itself
2. pciback can be split into two parts: PCI assignable/bind/reset handling and the rest like vPCI etc.
3. pcifront is not used on Arm
It is neither in x86 PVH/HVM guests.
Didn't know that, thank you for pointing
Quoted 11 lines
Quoted 7 lines
So, limited use of the pciback is one of the bricks used to enable PCI passthrough on Arm. It was enough to just re-structure the driver and have it run on Arm to achieve all the goals above.
If we still think it is desirable to break the pciback driver into "common" and "pcifront specific" parts then it can be done, yet the patch is going to be the very first brick in that building.
Doing this split should be done, as the pcifront specific part could be omitted on x86, too, in case no PV guests using PCI passthrough have to be supported.
Agree, that the final solution should have the driver split
Quoted 8 lines
Quoted 2 lines
So, I think this patch is still going to be needed besides which direction we take.
Some kind of this patch, yes. It might look different in case the split is done first.
I don't mind doing it in either sequence.
With this patch we have Arm on the same page as the above mentioned x86 guests,
e.g. the driver has unused code, but yet allows Arm to function now.
At this stage of PCI passthrough on Arm it is yet enough. Long term, when
the driver gets split, Arm will benefit from that split too, but unfortunately I do not
have enough bandwidth for that piece of work at the moment.
Quoted 2 lines
Juergen
Thank you,
Oleksandr
Stefano Stabellini
maintainerQuoted 75 lines · Oleksandr Andrushchenko
Quoted 43 lines · Juergen Gross
Quoted 42 lines · Oleksandr Andrushchenko
Hello, Stefano!
Quoted 4 lines · Stefano Stabellini
Hi Oleksandr,
Why do you want to enable pciback on ARM? Is it only to "disable" a PCI device in Dom0 so that it can be safely assigned to a DomU?
Not only that
Quoted 5 lines
I am asking because actually I don't think we want to enable the PV PCI backend feature of pciback on ARM, right? That would clash with the PCI assignment work you have been doing in Xen. They couldn't both work at the same time.
Correct, it is not used
Quoted 3 lines
If we only need pciback to "park" a device in Dom0, wouldn't it be possible and better to use pci-stub instead?
Not only that, so pci-stub is not enough
The functionality which is implemented by the pciback and the toolstack and which is relevant/missing/needed for ARM:
1. pciback is used as a database for assignable PCI devices, e.g. xl pci-assignable-{add|remove|list} manipulates that list. So, whenever the toolstack needs to know which PCI devices can be passed through it reads that from the relevant sysfs entries of the pciback.
2. pciback is used to hold the unbound PCI devices, e.g. when passing through a PCI device it needs to be unbound from the relevant device driver and bound to pciback (strictly speaking it is not required that the device is bound to pciback, but pciback is again used as a database of the passed through PCI devices, so we can re-bind the devices back to their original drivers when guest domain shuts down)
3. Device reset
We have previously discussed on xen-devel ML possible solutions to that as from the above we see that pciback functionality is going to be only partially used on Arm.
Please see [1] and [2]:
Quoted 8 lines
Quoted 6 lines
1. It is not acceptable to manage the assignable list in Xen itself
2. pciback can be split into two parts: PCI assignable/bind/reset handling and the rest like vPCI etc.
3. pcifront is not used on Arm
It is neither in x86 PVH/HVM guests.
Didn't know that, thank you for pointing
Quoted 11 lines
Quoted 7 lines
So, limited use of the pciback is one of the bricks used to enable PCI passthrough on Arm. It was enough to just re-structure the driver and have it run on Arm to achieve all the goals above.
If we still think it is desirable to break the pciback driver into "common" and "pcifront specific" parts then it can be done, yet the patch is going to be the very first brick in that building.
Doing this split should be done, as the pcifront specific part could be omitted on x86, too, in case no PV guests using PCI passthrough have to be supported.
Agree, that the final solution should have the driver split
Quoted 8 lines
Quoted 2 lines
So, I think this patch is still going to be needed besides which direction we take.
Some kind of this patch, yes. It might look different in case the split is done first.
I don't mind doing it in either sequence.
With this patch we have Arm on the same page as the above mentioned x86 guests,
Quoted 7 lines
e.g. the driver has unused code, but yet allows Arm to function now.
At this stage of PCI passthrough on Arm it is yet enough. Long term, when
the driver gets split, Arm will benefit from that split too, but unfortunately I do not
have enough bandwidth for that piece of work at the moment.
That's fair and I don't want to scope-creep this simple patch asking for an enormous rework. At the same time I don't think we should enable the whole of pciback on ARM because it would be erroneous and confusing.
I am wonder if there is a simple:
if (!xen_pv_domain())
return;
That we could add in a couple of places in pciback to stop it from initializing the parts we don't care about. Something along these lines (untested and probably incomplete).
What do you guys think?
drivers/xen/xen-pciback/xenbus.c +11 -1
@@ -15,6 +15,7 @@#include <xen/xenbus.h> #include <xen/events.h> #include <xen/pci.h> +#include <xen/xen.h> #include "pciback.h" #define INVALID_EVTCHN_IRQ (-1)
@@ -685,8 +686,12 @@ static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) {int err =0 ; -struct xen_pcibk_device *pdev =alloc_pdev (dev); +struct xen_pcibk_device *pdev; + +if (!xen_pv_domain ()) +return 0 ; + pdev =alloc_pdev (dev);if (pdev ==NULL ) { err = -ENOMEM ; xenbus_dev_fatal(dev, err,
@@ -743,6 +748,9 @@ const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend;int __init xen_pcibk_xenbus_register (void ) { +if (!xen_pv_domain ()) +return 0 ; + xen_pcibk_backend = &xen_pcibk_vpci_backend;if (passthrough) xen_pcibk_backend = &xen_pcibk_passthrough_backend;
@@ -752,5 +760,7 @@ int __init xen_pcibk_xenbus_register(void) void __exit xen_pcibk_xenbus_unregister(void) { +if (!xen_pv_domain ()) +return ;xenbus_unregister_driver (&xen_pcibk_driver); }
Hi, Stefano!
Quoted 81 lines · Stefano Stabellini
Quoted 67 lines · Oleksandr Andrushchenko
Quoted 40 lines · Juergen Gross
Quoted 39 lines · Oleksandr Andrushchenko
Hello, Stefano!
Quoted 4 lines · Stefano Stabellini
Hi Oleksandr,
Why do you want to enable pciback on ARM? Is it only to "disable" a PCI device in Dom0 so that it can be safely assigned to a DomU?
Not only that
Quoted 4 lines
I am asking because actually I don't think we want to enable the PV PCI backend feature of pciback on ARM, right? That would clash with the PCI assignment work you have been doing in Xen. They couldn't both work at the same time.
Correct, it is not used
Quoted 2 lines
If we only need pciback to "park" a device in Dom0, wouldn't it be possible and better to use pci-stub instead?
Not only that, so pci-stub is not enough
The functionality which is implemented by the pciback and the toolstack and which is relevant/missing/needed for ARM:
1. pciback is used as a database for assignable PCI devices, e.g. xl pci-assignable-{add|remove|list} manipulates that list. So, whenever the toolstack needs to know which PCI devices can be passed through it reads that from the relevant sysfs entries of the pciback.
2. pciback is used to hold the unbound PCI devices, e.g. when passing through a PCI device it needs to be unbound from the relevant device driver and bound to pciback (strictly speaking it is not required that the device is bound to pciback, but pciback is again used as a database of the passed through PCI devices, so we can re-bind the devices back to their original drivers when guest domain shuts down)
3. Device reset
We have previously discussed on xen-devel ML possible solutions to that as from the above we see that pciback functionality is going to be only partially used on Arm.
Please see [1] and [2]:
Quoted 7 lines
Quoted 6 lines
1. It is not acceptable to manage the assignable list in Xen itself
2. pciback can be split into two parts: PCI assignable/bind/reset handling and the rest like vPCI etc.
3. pcifront is not used on Arm
It is neither in x86 PVH/HVM guests.
Didn't know that, thank you for pointing
Quoted 9 lines
Quoted 6 lines
So, limited use of the pciback is one of the bricks used to enable PCI passthrough on Arm. It was enough to just re-structure the driver and have it run on Arm to achieve all the goals above.
If we still think it is desirable to break the pciback driver into "common" and "pcifront specific" parts then it can be done, yet the patch is going to be the very first brick in that building.
Doing this split should be done, as the pcifront specific part could be omitted on x86, too, in case no PV guests using PCI passthrough have to be supported.
Agree, that the final solution should have the driver split
Quoted 6 lines
Quoted 1 line
So, I think this patch is still going to be needed besides which direction we take.
Some kind of this patch, yes. It might look different in case the split is done first.
I don't mind doing it in either sequence.
With this patch we have Arm on the same page as the above mentioned x86 guests,
Quoted 7 lines
e.g. the driver has unused code, but yet allows Arm to function now.
At this stage of PCI passthrough on Arm it is yet enough. Long term, when
the driver gets split, Arm will benefit from that split too, but unfortunately I do not
have enough bandwidth for that piece of work at the moment.
That's fair and I don't want to scope-creep this simple patch asking for an enormous rework. At the same time I don't think we should enable the whole of pciback on ARM because it would be erroneous and confusing.
I am wonder if there is a simple:
Quoted 8 lines
if (!xen_pv_domain())
return;That we could add in a couple of places in pciback to stop it from initializing the parts we don't care about. Something along these lines (untested and probably incomplete).
What do you guys think?
I think that it needs to be an additional patch and the PV check seems
reasonable to me. We need to check if gating only part of the initialization
with xen_pv_domain is just enough, e.g. if the rest of the code is ok that
something was not initialized and won't be touched at run-time.
Let's see what other think about the approach
Quoted 46 lines
drivers/xen/xen-pciback/xenbus.c +11
-1@@ -15,6 +15,7 @@#include <xen/xenbus.h> #include <xen/events.h> #include <xen/pci.h> +#include <xen/xen.h> #include "pciback.h" #define INVALID_EVTCHN_IRQ (-1)@@ -685,8 +686,12 @@ static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) {int err =0 ; -struct xen_pcibk_device *pdev =alloc_pdev (dev); +struct xen_pcibk_device *pdev; + +if (!xen_pv_domain ()) +return 0 ; + pdev =alloc_pdev (dev);if (pdev ==NULL ) { err = -ENOMEM ; xenbus_dev_fatal(dev, err,@@ -743,6 +748,9 @@ const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend;int __init xen_pcibk_xenbus_register (void ) { +if (!xen_pv_domain ()) +return 0 ; + xen_pcibk_backend = &xen_pcibk_vpci_backend;if (passthrough) xen_pcibk_backend = &xen_pcibk_passthrough_backend;@@ -752,5 +760,7 @@ int __init xen_pcibk_xenbus_register(void) void __exit xen_pcibk_xenbus_unregister(void) { +if (!xen_pv_domain ()) +return ;xenbus_unregister_driver (&xen_pcibk_driver); }
Juergen Gross
maintainerQuoted 90 lines · Stefano Stabellini
Quoted 75 lines · Oleksandr Andrushchenko
Quoted 43 lines · Juergen Gross
Quoted 42 lines · Oleksandr Andrushchenko
Hello, Stefano!
Quoted 4 lines · Stefano Stabellini
Hi Oleksandr,
Why do you want to enable pciback on ARM? Is it only to "disable" a PCI device in Dom0 so that it can be safely assigned to a DomU?
Not only that
Quoted 5 lines
I am asking because actually I don't think we want to enable the PV PCI backend feature of pciback on ARM, right? That would clash with the PCI assignment work you have been doing in Xen. They couldn't both work at the same time.
Correct, it is not used
Quoted 3 lines
If we only need pciback to "park" a device in Dom0, wouldn't it be possible and better to use pci-stub instead?
Not only that, so pci-stub is not enough
The functionality which is implemented by the pciback and the toolstack and which is relevant/missing/needed for ARM:
1. pciback is used as a database for assignable PCI devices, e.g. xl pci-assignable-{add|remove|list} manipulates that list. So, whenever the toolstack needs to know which PCI devices can be passed through it reads that from the relevant sysfs entries of the pciback.
2. pciback is used to hold the unbound PCI devices, e.g. when passing through a PCI device it needs to be unbound from the relevant device driver and bound to pciback (strictly speaking it is not required that the device is bound to pciback, but pciback is again used as a database of the passed through PCI devices, so we can re-bind the devices back to their original drivers when guest domain shuts down)
3. Device reset
We have previously discussed on xen-devel ML possible solutions to that as from the above we see that pciback functionality is going to be only partially used on Arm.
Please see [1] and [2]:
Quoted 8 lines
Quoted 6 lines
1. It is not acceptable to manage the assignable list in Xen itself
2. pciback can be split into two parts: PCI assignable/bind/reset handling and the rest like vPCI etc.
3. pcifront is not used on Arm
It is neither in x86 PVH/HVM guests.
Didn't know that, thank you for pointing
Quoted 11 lines
Quoted 7 lines
So, limited use of the pciback is one of the bricks used to enable PCI passthrough on Arm. It was enough to just re-structure the driver and have it run on Arm to achieve all the goals above.
If we still think it is desirable to break the pciback driver into "common" and "pcifront specific" parts then it can be done, yet the patch is going to be the very first brick in that building.
Doing this split should be done, as the pcifront specific part could be omitted on x86, too, in case no PV guests using PCI passthrough have to be supported.
Agree, that the final solution should have the driver split
Quoted 8 lines
Quoted 2 lines
So, I think this patch is still going to be needed besides which direction we take.
Some kind of this patch, yes. It might look different in case the split is done first.
I don't mind doing it in either sequence.
With this patch we have Arm on the same page as the above mentioned x86 guests,
Quoted 7 lines
e.g. the driver has unused code, but yet allows Arm to function now.
At this stage of PCI passthrough on Arm it is yet enough. Long term, when
the driver gets split, Arm will benefit from that split too, but unfortunately I do not
have enough bandwidth for that piece of work at the moment.
That's fair and I don't want to scope-creep this simple patch asking for an enormous rework. At the same time I don't think we should enable the whole of pciback on ARM because it would be erroneous and confusing.
I am wonder if there is a simple:
Quoted 8 lines
if (!xen_pv_domain())
return;That we could add in a couple of places in pciback to stop it from initializing the parts we don't care about. Something along these lines (untested and probably incomplete).
What do you guys think?
Uh no, not in this way, please. This will kill pci passthrough on x86 with dom0 running as PVH. I don't think this is working right now, but adding more code making it even harder to work should be avoided.
Quoted 13 lines
drivers/xen/xen-pciback/xenbus.c +1
-0@@ -15,6 +15,7 @@#include <xen/xenbus.h> #include <xen/events.h> #include <xen/pci.h> +#include <xen/xen.h> #include "pciback.h" #define INVALID_EVTCHN_IRQ (-1)
drivers/xen/xen-pciback/xenbus.c static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, · line 694
Quoted 10 lines
drivers/xen/xen-pciback/xenbus.c +5
-1@@ -685,8 +686,12 @@ static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) {int err =0 ; -struct xen_pcibk_device *pdev =alloc_pdev (dev); +struct xen_pcibk_device *pdev; + +if (!xen_pv_domain ()) +return 0 ; + pdev =alloc_pdev (dev);
This hunk isn't needed, as with bailing out of xen_pcibk_xenbus_register early will result in xen_pcibk_xenbus_probe never being called.
drivers/xen/xen-pciback/xenbus.c const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; · line 753
Quoted 10 lines
drivers/xen/xen-pciback/xenbus.c +3
-0if (pdev ==NULL ) { err = -ENOMEM ; xenbus_dev_fatal(dev, err,@@ -743,6 +748,9 @@ const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend;int __init xen_pcibk_xenbus_register (void ) { +if (!xen_pv_domain ()) +return 0 ; +
Use #ifdef CONFIG_X86 instead.
drivers/xen/xen-pciback/xenbus.c int __init xen_pcibk_xenbus_register(void) · line 764
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +2
-0xen_pcibk_backend = &xen_pcibk_vpci_backend;if (passthrough) xen_pcibk_backend = &xen_pcibk_passthrough_backend;@@ -752,5 +760,7 @@ int __init xen_pcibk_xenbus_register(void) void __exit xen_pcibk_xenbus_unregister(void) { +if (!xen_pv_domain ()) +return ;
#ifdef again.
drivers/xen/xen-pciback/xenbus.c int __init xen_pcibk_xenbus_register(void) · line 766
Quoted 3 lines
drivers/xen/xen-pciback/xenbus.c +0
-0xenbus_unregister_driver (&xen_pcibk_driver); }
Juergen
Quoted 81 lines · Juergen Gross
Quoted 80 lines · Stefano Stabellini
Quoted 79 lines · Oleksandr Andrushchenko
Quoted 43 lines · Juergen Gross
Quoted 42 lines · Oleksandr Andrushchenko
Hello, Stefano!
Quoted 4 lines · Stefano Stabellini
Hi Oleksandr,
Why do you want to enable pciback on ARM? Is it only to "disable" a PCI device in Dom0 so that it can be safely assigned to a DomU?
Not only that
Quoted 5 lines
I am asking because actually I don't think we want to enable the PV PCI backend feature of pciback on ARM, right? That would clash with the PCI assignment work you have been doing in Xen. They couldn't both work at the same time.
Correct, it is not used
Quoted 3 lines
If we only need pciback to "park" a device in Dom0, wouldn't it be possible and better to use pci-stub instead?
Not only that, so pci-stub is not enough
The functionality which is implemented by the pciback and the toolstack and which is relevant/missing/needed for ARM:
1. pciback is used as a database for assignable PCI devices, e.g. xl pci-assignable-{add|remove|list} manipulates that list. So, whenever the toolstack needs to know which PCI devices can be passed through it reads that from the relevant sysfs entries of the pciback.
2. pciback is used to hold the unbound PCI devices, e.g. when passing through a PCI device it needs to be unbound from the relevant device driver and bound to pciback (strictly speaking it is not required that the device is bound to pciback, but pciback is again used as a database of the passed through PCI devices, so we can re-bind the devices back to their original drivers when guest domain shuts down)
3. Device reset
We have previously discussed on xen-devel ML possible solutions to that as from the above we see that pciback functionality is going to be only partially used on Arm.
Please see [1] and [2]:
Quoted 8 lines
Quoted 6 lines
1. It is not acceptable to manage the assignable list in Xen itself
2. pciback can be split into two parts: PCI assignable/bind/reset handling and the rest like vPCI etc.
3. pcifront is not used on Arm
It is neither in x86 PVH/HVM guests.
Didn't know that, thank you for pointing
Quoted 11 lines
Quoted 7 lines
So, limited use of the pciback is one of the bricks used to enable PCI passthrough on Arm. It was enough to just re-structure the driver and have it run on Arm to achieve all the goals above.
If we still think it is desirable to break the pciback driver into "common" and "pcifront specific" parts then it can be done, yet the patch is going to be the very first brick in that building.
Doing this split should be done, as the pcifront specific part could be omitted on x86, too, in case no PV guests using PCI passthrough have to be supported.
Agree, that the final solution should have the driver split
Quoted 8 lines
Quoted 2 lines
So, I think this patch is still going to be needed besides which direction we take.
Some kind of this patch, yes. It might look different in case the split is done first.
I don't mind doing it in either sequence.
With this patch we have Arm on the same page as the above mentioned x86 guests,
e.g. the driver has unused code, but yet allows Arm to function now.
At this stage of PCI passthrough on Arm it is yet enough. Long term, when
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
the driver gets split, Arm will benefit from that split too, but unfortunately I do not
have enough bandwidth for that piece of work at the moment.
That's fair and I don't want to scope-creep this simple patch asking for an enormous rework. At the same time I don't think we should enable the whole of pciback on ARM because it would be erroneous and confusing.
As the first stage before the driver is split or ifdef's used - can we take the patch
as is now? In either way we chose this needs to be done, e.g. enable compiling
for other architectures and common code move.
Quoted 41 lines
Quoted 11 lines
I am wonder if there is a simple:
if (!xen_pv_domain())
return;That we could add in a couple of places in pciback to stop it from initializing the parts we don't care about. Something along these lines (untested and probably incomplete).
What do you guys think?
Uh no, not in this way, please. This will kill pci passthrough on x86 with dom0 running as PVH. I don't think this is working right now, but adding more code making it even harder to work should be avoided.
Quoted 12 lines
drivers/xen/xen-pciback/xenbus.c +1
-0@@ -15,6 +15,7 @@ #include <xen/xenbus.h> #include <xen/events.h> #include <xen/pci.h> +#include <xen/xen.h> #include "pciback.h" #define INVALID_EVTCHN_IRQ (-1)drivers/xen/xen-pciback/xenbus.c static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, · line 693
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +4
-1@@ -685,8 +686,12 @@ static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { int err = 0; - struct xen_pcibk_device *pdev = alloc_pdev(dev); + struct xen_pcibk_device *pdev; + + if (!xen_pv_domain()) + return 0; + pdev = alloc_pdev(dev);This hunk isn't needed, as with bailing out of
xen_pcibk_xenbus_registerearly will result inxen_pcibk_xenbus_probenever being called.
Quoted 11 lines
drivers/xen/xen-pciback/xenbus.c const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; · line 752
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +3
-0if (pdev == NULL) { err = -ENOMEM; xenbus_dev_fatal(dev, err,@@ -743,6 +748,9 @@ const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; int __init xen_pcibk_xenbus_register(void) { + if (!xen_pv_domain()) + return 0; +Use #ifdef
CONFIG_X86instead.
The title of this patch says that we want to allow this driver for other archs
and now we want to introduce "#ifdef CONFIG_X86" which doesn't sound
right with that respect. Instead, we may want having something like a
dedicated gate for this, e.g. "#ifdef CONFIG_XEN_PCIDEV_BACKEND_SUPP_PV"
or something which is architecture agnostic.
Gating also means that we are not thinking about splitting the backend driver into
two different ones, e.g. one for "common" code and one for PV stuff.
Otherwise this ifdefery won't be needed.
Quoted 18 lines
drivers/xen/xen-pciback/xenbus.c int __init xen_pcibk_xenbus_register(void) · line 763
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +2
-0xen_pcibk_backend = &xen_pcibk_vpci_backend; if (passthrough) xen_pcibk_backend = &xen_pcibk_passthrough_backend;@@ -752,5 +760,7 @@ int __init xen_pcibk_xenbus_register(void) void __exit xen_pcibk_xenbus_unregister(void) { + if (!xen_pv_domain()) + return;#ifdef again.
drivers/xen/xen-pciback/xenbus.c int __init xen_pcibk_xenbus_register(void)
Quoted 3 lines
drivers/xen/xen-pciback/xenbus.c +0
-0xenbus_unregister_driver (&xen_pcibk_driver); }Juergen
Juergen Gross
maintainerQuoted 87 lines · Oleksandr Andrushchenko
Quoted 85 lines · Juergen Gross
Quoted 84 lines · Stefano Stabellini
Quoted 82 lines · Oleksandr Andrushchenko
Quoted 43 lines · Juergen Gross
Quoted 42 lines · Oleksandr Andrushchenko
Hello, Stefano!
Quoted 4 lines · Stefano Stabellini
Hi Oleksandr,
Why do you want to enable pciback on ARM? Is it only to "disable" a PCI device in Dom0 so that it can be safely assigned to a DomU?
Not only that
Quoted 5 lines
I am asking because actually I don't think we want to enable the PV PCI backend feature of pciback on ARM, right? That would clash with the PCI assignment work you have been doing in Xen. They couldn't both work at the same time.
Correct, it is not used
Quoted 3 lines
If we only need pciback to "park" a device in Dom0, wouldn't it be possible and better to use pci-stub instead?
Not only that, so pci-stub is not enough
The functionality which is implemented by the pciback and the toolstack and which is relevant/missing/needed for ARM:
1. pciback is used as a database for assignable PCI devices, e.g. xl pci-assignable-{add|remove|list} manipulates that list. So, whenever the toolstack needs to know which PCI devices can be passed through it reads that from the relevant sysfs entries of the pciback.
2. pciback is used to hold the unbound PCI devices, e.g. when passing through a PCI device it needs to be unbound from the relevant device driver and bound to pciback (strictly speaking it is not required that the device is bound to pciback, but pciback is again used as a database of the passed through PCI devices, so we can re-bind the devices back to their original drivers when guest domain shuts down)
3. Device reset
We have previously discussed on xen-devel ML possible solutions to that as from the above we see that pciback functionality is going to be only partially used on Arm.
Please see [1] and [2]:
Quoted 8 lines
Quoted 6 lines
1. It is not acceptable to manage the assignable list in Xen itself
2. pciback can be split into two parts: PCI assignable/bind/reset handling and the rest like vPCI etc.
3. pcifront is not used on Arm
It is neither in x86 PVH/HVM guests.
Didn't know that, thank you for pointing
Quoted 11 lines
Quoted 7 lines
So, limited use of the pciback is one of the bricks used to enable PCI passthrough on Arm. It was enough to just re-structure the driver and have it run on Arm to achieve all the goals above.
If we still think it is desirable to break the pciback driver into "common" and "pcifront specific" parts then it can be done, yet the patch is going to be the very first brick in that building.
Doing this split should be done, as the pcifront specific part could be omitted on x86, too, in case no PV guests using PCI passthrough have to be supported.
Agree, that the final solution should have the driver split
Quoted 8 lines
Quoted 2 lines
So, I think this patch is still going to be needed besides which direction we take.
Some kind of this patch, yes. It might look different in case the split is done first.
I don't mind doing it in either sequence.
With this patch we have Arm on the same page as the above mentioned x86 guests,
e.g. the driver has unused code, but yet allows Arm to function now.
At this stage of PCI passthrough on Arm it is yet enough. Long term, when
the driver gets split, Arm will benefit from that split too, but unfortunately I do not
have enough bandwidth for that piece of work at the moment.
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
That's fair and I don't want to scope-creep this simple patch asking for an enormous rework. At the same time I don't think we should enable the whole of pciback on ARM because it would be erroneous and confusing.
As the first stage before the driver is split or ifdef's used - can we take the patch as is now? In either way we chose this needs to be done, e.g. enable compiling for other architectures and common code move.
Fine with me in principle. I need to take a more thorough look at the patch, though.
Quoted 54 lines
Quoted 42 lines
Quoted 4 lines
I am wonder if there is a simple:
Quoted 8 lines
if (!xen_pv_domain())
return;That we could add in a couple of places in pciback to stop it from initializing the parts we don't care about. Something along these lines (untested and probably incomplete).
What do you guys think?
Uh no, not in this way, please. This will kill pci passthrough on x86 with dom0 running as PVH. I don't think this is working right now, but adding more code making it even harder to work should be avoided.
Quoted 12 lines
drivers/xen/xen-pciback/xenbus.c +1
-0@@ -15,6 +15,7 @@ #include <xen/xenbus.h> #include <xen/events.h> #include <xen/pci.h> +#include <xen/xen.h> #include "pciback.h" #define INVALID_EVTCHN_IRQ (-1)drivers/xen/xen-pciback/xenbus.c static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, · line 693
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +4
-1@@ -685,8 +686,12 @@ static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { int err = 0; - struct xen_pcibk_device *pdev = alloc_pdev(dev); + struct xen_pcibk_device *pdev; + + if (!xen_pv_domain()) + return 0; + pdev = alloc_pdev(dev);This hunk isn't needed, as with bailing out of
xen_pcibk_xenbus_registerearly will result inxen_pcibk_xenbus_probenever being called.Quoted 11 lines
drivers/xen/xen-pciback/xenbus.c const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; · line 752
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +3
-0if (pdev == NULL) { err = -ENOMEM; xenbus_dev_fatal(dev, err,@@ -743,6 +748,9 @@ const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; int __init xen_pcibk_xenbus_register(void) { + if (!xen_pv_domain()) + return 0; +Use #ifdef
CONFIG_X86instead.
Quoted 5 lines
The title of this patch says that we want to allow this driver for other archs and now we want to introduce "#ifdef
CONFIG_X86" which doesn't sound right with that respect. Instead, we may want having something like a dedicated gate for this, e.g. "#ifdefCONFIG_XEN_PCIDEV_BACKEND_SUPP_PV" or something which is architecture agnostic.
Something like that, yes. But I'd rather use CONFIG_XEN_PCIDEV_BACKEND acting as this gate and introduce CONFIG_XEN_PCI_STUB for the stub functionality needed on Arm. XEN_PCIDEV_BACKEND would depend on X86 and select XEN_PCI_STUB, while on Arm XEN_PCI_STUB could be configured if wanted. The splitting of the driver can still be done later.
Quoted 3 lines
Gating also means that we are not thinking about splitting the backend driver into two different ones, e.g. one for "common" code and one for PV stuff. Otherwise this ifdefery won't be needed.
I just wanted to avoid the xen_pv_domain() tests creeping in, as they are wrong IMO.
Juergen
Quoted 92 lines · Juergen Gross
Quoted 91 lines · Oleksandr Andrushchenko
Quoted 88 lines · Juergen Gross
Quoted 87 lines · Stefano Stabellini
Quoted 75 lines · Oleksandr Andrushchenko
Quoted 43 lines · Juergen Gross
Quoted 42 lines · Oleksandr Andrushchenko
Hello, Stefano!
Quoted 4 lines · Stefano Stabellini
Hi Oleksandr,
Why do you want to enable pciback on ARM? Is it only to "disable" a PCI device in Dom0 so that it can be safely assigned to a DomU?
Not only that
Quoted 5 lines
I am asking because actually I don't think we want to enable the PV PCI backend feature of pciback on ARM, right? That would clash with the PCI assignment work you have been doing in Xen. They couldn't both work at the same time.
Correct, it is not used
Quoted 3 lines
If we only need pciback to "park" a device in Dom0, wouldn't it be possible and better to use pci-stub instead?
Not only that, so pci-stub is not enough
The functionality which is implemented by the pciback and the toolstack and which is relevant/missing/needed for ARM:
1. pciback is used as a database for assignable PCI devices, e.g. xl pci-assignable-{add|remove|list} manipulates that list. So, whenever the toolstack needs to know which PCI devices can be passed through it reads that from the relevant sysfs entries of the pciback.
2. pciback is used to hold the unbound PCI devices, e.g. when passing through a PCI device it needs to be unbound from the relevant device driver and bound to pciback (strictly speaking it is not required that the device is bound to pciback, but pciback is again used as a database of the passed through PCI devices, so we can re-bind the devices back to their original drivers when guest domain shuts down)
3. Device reset
We have previously discussed on xen-devel ML possible solutions to that as from the above we see that pciback functionality is going to be only partially used on Arm.
Please see [1] and [2]:
Quoted 8 lines
Quoted 6 lines
1. It is not acceptable to manage the assignable list in Xen itself
2. pciback can be split into two parts: PCI assignable/bind/reset handling and the rest like vPCI etc.
3. pcifront is not used on Arm
It is neither in x86 PVH/HVM guests.
Didn't know that, thank you for pointing
Quoted 11 lines
Quoted 7 lines
So, limited use of the pciback is one of the bricks used to enable PCI passthrough on Arm. It was enough to just re-structure the driver and have it run on Arm to achieve all the goals above.
If we still think it is desirable to break the pciback driver into "common" and "pcifront specific" parts then it can be done, yet the patch is going to be the very first brick in that building.
Doing this split should be done, as the pcifront specific part could be omitted on x86, too, in case no PV guests using PCI passthrough have to be supported.
Agree, that the final solution should have the driver split
Quoted 8 lines
Quoted 2 lines
So, I think this patch is still going to be needed besides which direction we take.
Some kind of this patch, yes. It might look different in case the split is done first.
I don't mind doing it in either sequence.
With this patch we have Arm on the same page as the above mentioned x86 guests,
Quoted 7 lines
e.g. the driver has unused code, but yet allows Arm to function now.
At this stage of PCI passthrough on Arm it is yet enough. Long term, when
the driver gets split, Arm will benefit from that split too, but unfortunately I do not
have enough bandwidth for that piece of work at the moment.
That's fair and I don't want to scope-creep this simple patch asking for an enormous rework. At the same time I don't think we should enable the whole of pciback on ARM because it would be erroneous and confusing.
Quoted 6 lines
Quoted 3 lines
As the first stage before the driver is split or ifdef's used - can we take the patch as is now? In either way we chose this needs to be done, e.g. enable compiling for other architectures and common code move.
Fine with me in principle. I need to take a more thorough look at the patch, though.
Of course
Quoted 61 lines
Quoted 55 lines
Quoted 43 lines
Quoted 5 lines
I am wonder if there is a simple:
Quoted 8 lines
if (!xen_pv_domain())
return;That we could add in a couple of places in pciback to stop it from initializing the parts we don't care about. Something along these lines (untested and probably incomplete).
What do you guys think?
Uh no, not in this way, please. This will kill pci passthrough on x86 with dom0 running as PVH. I don't think this is working right now, but adding more code making it even harder to work should be avoided.
Quoted 12 lines
drivers/xen/xen-pciback/xenbus.c +1
-0@@ -15,6 +15,7 @@ #include <xen/xenbus.h> #include <xen/events.h> #include <xen/pci.h> +#include <xen/xen.h> #include "pciback.h" #define INVALID_EVTCHN_IRQ (-1)drivers/xen/xen-pciback/xenbus.c static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, · line 693
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +4
-1@@ -685,8 +686,12 @@ static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { int err = 0; - struct xen_pcibk_device *pdev = alloc_pdev(dev); + struct xen_pcibk_device *pdev; + + if (!xen_pv_domain()) + return 0; + pdev = alloc_pdev(dev);This hunk isn't needed, as with bailing out of
xen_pcibk_xenbus_registerearly will result inxen_pcibk_xenbus_probenever being called.Quoted 11 lines
drivers/xen/xen-pciback/xenbus.c const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; · line 752
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +3
-0if (pdev == NULL) { err = -ENOMEM; xenbus_dev_fatal(dev, err,@@ -743,6 +748,9 @@ const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; int __init xen_pcibk_xenbus_register(void) { + if (!xen_pv_domain()) + return 0; +Use #ifdef
CONFIG_X86instead.Quoted 5 lines
The title of this patch says that we want to allow this driver for other archs and now we want to introduce "#ifdef
CONFIG_X86" which doesn't sound right with that respect. Instead, we may want having something like a dedicated gate for this, e.g. "#ifdefCONFIG_XEN_PCIDEV_BACKEND_SUPP_PV" or something which is architecture agnostic.
Quoted 5 lines
Something like that, yes. But I'd rather use
CONFIG_XEN_PCIDEV_BACKENDacting as this gate and introduceCONFIG_XEN_PCI_STUBfor the stub functionality needed on Arm.XEN_PCIDEV_BACKENDwould depend on X86 and selectXEN_PCI_STUB, while on ArmXEN_PCI_STUBcould be configured if wanted. The splitting of the driver can still be done later.
Hm, pciback is now compiled when CONFIG_XEN_PCIDEV_BACKEND is enabled
and we want to skip some parts of its code when CONFIG_XEN_PCI_STUB is set.
So, I imagine that for x86 we just enable CONFIG_XEN_PCIDEV_BACKEND and the
driver compiles in its current state. For Arm we enable both CONFIG_XEN_PCIDEV_BACKEND
and CONFIG_XEN_PCI_STUB, so part of the driver is not compiled.
Quoted 8 lines
Quoted 4 lines
Gating also means that we are not thinking about splitting the backend driver into two different ones, e.g. one for "common" code and one for PV stuff. Otherwise this ifdefery won't be needed.
I just wanted to avoid the
xen_pv_domain()tests creeping in, as they are wrong IMO.
I understand that
Quoted 2 lines
Juergen
Juergen Gross
maintainerQuoted 168 lines · Oleksandr Andrushchenko
Quoted 92 lines · Juergen Gross
Quoted 91 lines · Oleksandr Andrushchenko
Quoted 88 lines · Juergen Gross
Quoted 87 lines · Stefano Stabellini
Quoted 75 lines · Oleksandr Andrushchenko
Quoted 43 lines · Juergen Gross
Quoted 42 lines · Oleksandr Andrushchenko
Hello, Stefano!
Quoted 4 lines · Stefano Stabellini
Hi Oleksandr,
Why do you want to enable pciback on ARM? Is it only to "disable" a PCI device in Dom0 so that it can be safely assigned to a DomU?
Not only that
Quoted 5 lines
I am asking because actually I don't think we want to enable the PV PCI backend feature of pciback on ARM, right? That would clash with the PCI assignment work you have been doing in Xen. They couldn't both work at the same time.
Correct, it is not used
Quoted 3 lines
If we only need pciback to "park" a device in Dom0, wouldn't it be possible and better to use pci-stub instead?
Not only that, so pci-stub is not enough
The functionality which is implemented by the pciback and the toolstack and which is relevant/missing/needed for ARM:
1. pciback is used as a database for assignable PCI devices, e.g. xl pci-assignable-{add|remove|list} manipulates that list. So, whenever the toolstack needs to know which PCI devices can be passed through it reads that from the relevant sysfs entries of the pciback.
2. pciback is used to hold the unbound PCI devices, e.g. when passing through a PCI device it needs to be unbound from the relevant device driver and bound to pciback (strictly speaking it is not required that the device is bound to pciback, but pciback is again used as a database of the passed through PCI devices, so we can re-bind the devices back to their original drivers when guest domain shuts down)
3. Device reset
We have previously discussed on xen-devel ML possible solutions to that as from the above we see that pciback functionality is going to be only partially used on Arm.
Please see [1] and [2]:
Quoted 8 lines
Quoted 6 lines
1. It is not acceptable to manage the assignable list in Xen itself
2. pciback can be split into two parts: PCI assignable/bind/reset handling and the rest like vPCI etc.
3. pcifront is not used on Arm
It is neither in x86 PVH/HVM guests.
Didn't know that, thank you for pointing
Quoted 11 lines
Quoted 7 lines
So, limited use of the pciback is one of the bricks used to enable PCI passthrough on Arm. It was enough to just re-structure the driver and have it run on Arm to achieve all the goals above.
If we still think it is desirable to break the pciback driver into "common" and "pcifront specific" parts then it can be done, yet the patch is going to be the very first brick in that building.
Doing this split should be done, as the pcifront specific part could be omitted on x86, too, in case no PV guests using PCI passthrough have to be supported.
Agree, that the final solution should have the driver split
Quoted 8 lines
Quoted 2 lines
So, I think this patch is still going to be needed besides which direction we take.
Some kind of this patch, yes. It might look different in case the split is done first.
I don't mind doing it in either sequence.
With this patch we have Arm on the same page as the above mentioned x86 guests,
Quoted 7 lines
e.g. the driver has unused code, but yet allows Arm to function now.
At this stage of PCI passthrough on Arm it is yet enough. Long term, when
the driver gets split, Arm will benefit from that split too, but unfortunately I do not
have enough bandwidth for that piece of work at the moment.
That's fair and I don't want to scope-creep this simple patch asking for an enormous rework. At the same time I don't think we should enable the whole of pciback on ARM because it would be erroneous and confusing.
Quoted 6 lines
Quoted 3 lines
As the first stage before the driver is split or ifdef's used - can we take the patch as is now? In either way we chose this needs to be done, e.g. enable compiling for other architectures and common code move.
Fine with me in principle. I need to take a more thorough look at the patch, though.
Of course
Quoted 61 lines
Quoted 55 lines
Quoted 43 lines
Quoted 5 lines
I am wonder if there is a simple:
Quoted 8 lines
if (!xen_pv_domain())
return;That we could add in a couple of places in pciback to stop it from initializing the parts we don't care about. Something along these lines (untested and probably incomplete).
What do you guys think?
Uh no, not in this way, please. This will kill pci passthrough on x86 with dom0 running as PVH. I don't think this is working right now, but adding more code making it even harder to work should be avoided.
Quoted 12 lines
drivers/xen/xen-pciback/xenbus.c +1
-0@@ -15,6 +15,7 @@ #include <xen/xenbus.h> #include <xen/events.h> #include <xen/pci.h> +#include <xen/xen.h> #include "pciback.h" #define INVALID_EVTCHN_IRQ (-1)drivers/xen/xen-pciback/xenbus.c static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, · line 693
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +4
-1@@ -685,8 +686,12 @@ static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { int err = 0; - struct xen_pcibk_device *pdev = alloc_pdev(dev); + struct xen_pcibk_device *pdev; + + if (!xen_pv_domain()) + return 0; + pdev = alloc_pdev(dev);This hunk isn't needed, as with bailing out of
xen_pcibk_xenbus_registerearly will result inxen_pcibk_xenbus_probenever being called.Quoted 11 lines
drivers/xen/xen-pciback/xenbus.c const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; · line 752
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +3
-0if (pdev == NULL) { err = -ENOMEM; xenbus_dev_fatal(dev, err,@@ -743,6 +748,9 @@ const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; int __init xen_pcibk_xenbus_register(void) { + if (!xen_pv_domain()) + return 0; +Use #ifdef
CONFIG_X86instead.Quoted 5 lines
The title of this patch says that we want to allow this driver for other archs and now we want to introduce "#ifdef
CONFIG_X86" which doesn't sound right with that respect. Instead, we may want having something like a dedicated gate for this, e.g. "#ifdefCONFIG_XEN_PCIDEV_BACKEND_SUPP_PV" or something which is architecture agnostic.Quoted 5 lines
Something like that, yes. But I'd rather use
CONFIG_XEN_PCIDEV_BACKENDacting as this gate and introduceCONFIG_XEN_PCI_STUBfor the stub functionality needed on Arm.XEN_PCIDEV_BACKENDwould depend on X86 and selectXEN_PCI_STUB, while on ArmXEN_PCI_STUBcould be configured if wanted. The splitting of the driver can still be done later.
Quoted 5 lines
Hm, pciback is now compiled when CONFIG_XEN_PCIDEV_BACKEND is enabled and we want to skip some parts of its code when
CONFIG_XEN_PCI_STUBis set. So, I imagine that for x86 we just enableCONFIG_XEN_PCIDEV_BACKENDand the driver compiles in its current state. For Arm we enable bothCONFIG_XEN_PCIDEV_BACKENDandCONFIG_XEN_PCI_STUB, so part of the driver is not compiled.
No, I'd rather switch to compiling xen-pciback when CONFIG_XEN_PCI_STUB is set and compile only parts of it when CONFIG_XEN_PCIDEV_BACKEND is not set (this will be the case on Arm).
This is another step in the right direction preparing the split.
But as said before, this is not a requirement by me to take your patch.
Juergen
Quoted 175 lines · Juergen Gross
Quoted 168 lines · Oleksandr Andrushchenko
Quoted 92 lines · Juergen Gross
Quoted 91 lines · Oleksandr Andrushchenko
Quoted 88 lines · Juergen Gross
Quoted 87 lines · Stefano Stabellini
Quoted 75 lines · Oleksandr Andrushchenko
Quoted 43 lines · Juergen Gross
Quoted 42 lines · Oleksandr Andrushchenko
Hello, Stefano!
Quoted 4 lines · Stefano Stabellini
Hi Oleksandr,
Why do you want to enable pciback on ARM? Is it only to "disable" a PCI device in Dom0 so that it can be safely assigned to a DomU?
Not only that
Quoted 5 lines
I am asking because actually I don't think we want to enable the PV PCI backend feature of pciback on ARM, right? That would clash with the PCI assignment work you have been doing in Xen. They couldn't both work at the same time.
Correct, it is not used
Quoted 3 lines
If we only need pciback to "park" a device in Dom0, wouldn't it be possible and better to use pci-stub instead?
Not only that, so pci-stub is not enough
The functionality which is implemented by the pciback and the toolstack and which is relevant/missing/needed for ARM:
1. pciback is used as a database for assignable PCI devices, e.g. xl pci-assignable-{add|remove|list} manipulates that list. So, whenever the toolstack needs to know which PCI devices can be passed through it reads that from the relevant sysfs entries of the pciback.
2. pciback is used to hold the unbound PCI devices, e.g. when passing through a PCI device it needs to be unbound from the relevant device driver and bound to pciback (strictly speaking it is not required that the device is bound to pciback, but pciback is again used as a database of the passed through PCI devices, so we can re-bind the devices back to their original drivers when guest domain shuts down)
3. Device reset
We have previously discussed on xen-devel ML possible solutions to that as from the above we see that pciback functionality is going to be only partially used on Arm.
Please see [1] and [2]:
Quoted 8 lines
Quoted 6 lines
1. It is not acceptable to manage the assignable list in Xen itself
2. pciback can be split into two parts: PCI assignable/bind/reset handling and the rest like vPCI etc.
3. pcifront is not used on Arm
It is neither in x86 PVH/HVM guests.
Didn't know that, thank you for pointing
Quoted 11 lines
Quoted 7 lines
So, limited use of the pciback is one of the bricks used to enable PCI passthrough on Arm. It was enough to just re-structure the driver and have it run on Arm to achieve all the goals above.
If we still think it is desirable to break the pciback driver into "common" and "pcifront specific" parts then it can be done, yet the patch is going to be the very first brick in that building.
Doing this split should be done, as the pcifront specific part could be omitted on x86, too, in case no PV guests using PCI passthrough have to be supported.
Agree, that the final solution should have the driver split
Quoted 8 lines
Quoted 2 lines
So, I think this patch is still going to be needed besides which direction we take.
Some kind of this patch, yes. It might look different in case the split is done first.
I don't mind doing it in either sequence.
With this patch we have Arm on the same page as the above mentioned x86 guests,
Quoted 7 lines
e.g. the driver has unused code, but yet allows Arm to function now.
At this stage of PCI passthrough on Arm it is yet enough. Long term, when
the driver gets split, Arm will benefit from that split too, but unfortunately I do not
have enough bandwidth for that piece of work at the moment.
That's fair and I don't want to scope-creep this simple patch asking for an enormous rework. At the same time I don't think we should enable the whole of pciback on ARM because it would be erroneous and confusing.
Quoted 6 lines
Quoted 3 lines
As the first stage before the driver is split or ifdef's used - can we take the patch as is now? In either way we chose this needs to be done, e.g. enable compiling for other architectures and common code move.
Fine with me in principle. I need to take a more thorough look at the patch, though.
Of course
Quoted 61 lines
Quoted 55 lines
Quoted 43 lines
Quoted 5 lines
I am wonder if there is a simple:
Quoted 8 lines
if (!xen_pv_domain())
return;That we could add in a couple of places in pciback to stop it from initializing the parts we don't care about. Something along these lines (untested and probably incomplete).
What do you guys think?
Uh no, not in this way, please. This will kill pci passthrough on x86 with dom0 running as PVH. I don't think this is working right now, but adding more code making it even harder to work should be avoided.
Quoted 12 lines
drivers/xen/xen-pciback/xenbus.c +1
-0@@ -15,6 +15,7 @@ #include <xen/xenbus.h> #include <xen/events.h> #include <xen/pci.h> +#include <xen/xen.h> #include "pciback.h" #define INVALID_EVTCHN_IRQ (-1)drivers/xen/xen-pciback/xenbus.c static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, · line 693
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +4
-1@@ -685,8 +686,12 @@ static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { int err = 0; - struct xen_pcibk_device *pdev = alloc_pdev(dev); + struct xen_pcibk_device *pdev; + + if (!xen_pv_domain()) + return 0; + pdev = alloc_pdev(dev);This hunk isn't needed, as with bailing out of
xen_pcibk_xenbus_registerearly will result inxen_pcibk_xenbus_probenever being called.Quoted 11 lines
drivers/xen/xen-pciback/xenbus.c const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; · line 752
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +3
-0if (pdev == NULL) { err = -ENOMEM; xenbus_dev_fatal(dev, err,@@ -743,6 +748,9 @@ const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; int __init xen_pcibk_xenbus_register(void) { + if (!xen_pv_domain()) + return 0; +Use #ifdef
CONFIG_X86instead.Quoted 5 lines
The title of this patch says that we want to allow this driver for other archs and now we want to introduce "#ifdef
CONFIG_X86" which doesn't sound right with that respect. Instead, we may want having something like a dedicated gate for this, e.g. "#ifdefCONFIG_XEN_PCIDEV_BACKEND_SUPP_PV" or something which is architecture agnostic.Quoted 5 lines
Something like that, yes. But I'd rather use
CONFIG_XEN_PCIDEV_BACKENDacting as this gate and introduceCONFIG_XEN_PCI_STUBfor the stub functionality needed on Arm.XEN_PCIDEV_BACKENDwould depend on X86 and selectXEN_PCI_STUB, while on ArmXEN_PCI_STUBcould be configured if wanted. The splitting of the driver can still be done later.Quoted 5 lines
Hm, pciback is now compiled when CONFIG_XEN_PCIDEV_BACKEND is enabled and we want to skip some parts of its code when
CONFIG_XEN_PCI_STUBis set. So, I imagine that for x86 we just enableCONFIG_XEN_PCIDEV_BACKENDand the driver compiles in its current state. For Arm we enable bothCONFIG_XEN_PCIDEV_BACKENDandCONFIG_XEN_PCI_STUB, so part of the driver is not compiled.
Quoted 3 lines
No, I'd rather switch to compiling xen-pciback when
CONFIG_XEN_PCI_STUBis set and compile only parts of it whenCONFIG_XEN_PCIDEV_BACKENDis not set (this will be the case on Arm).
But this will require that the existing kernel configurations out there have to additionally
define CONFIG_XEN_PCI_STUB to get what they had before with simply enabling
CONFIG_XEN_PCIDEV_BACKEND. My point was that it is probably desirable not to break
the things while doing the split/re-work.
I also thought that "compile only parts of it when CONFIG_XEN_PCIDEV_BACKEND is not set"
may have more code gated rather than with gating unwanted code with CONFIG_XEN_PCI_STUB.
I am not quite sure about this though.
Quoted 4 lines
This is another step in the right direction preparing the split.
But as said before, this is not a requirement by me to take your patch.
Thank you
Quoted 3 lines
Juergen
Juergen Gross
maintainerQuoted 177 lines · Oleksandr Andrushchenko
Quoted 175 lines · Juergen Gross
Quoted 173 lines · Oleksandr Andrushchenko
Quoted 92 lines · Juergen Gross
Quoted 91 lines · Oleksandr Andrushchenko
Quoted 88 lines · Juergen Gross
Quoted 87 lines · Stefano Stabellini
Quoted 75 lines · Oleksandr Andrushchenko
Quoted 43 lines · Juergen Gross
Quoted 42 lines · Oleksandr Andrushchenko
Hello, Stefano!
Quoted 4 lines · Stefano Stabellini
Hi Oleksandr,
Why do you want to enable pciback on ARM? Is it only to "disable" a PCI device in Dom0 so that it can be safely assigned to a DomU?
Not only that
Quoted 5 lines
I am asking because actually I don't think we want to enable the PV PCI backend feature of pciback on ARM, right? That would clash with the PCI assignment work you have been doing in Xen. They couldn't both work at the same time.
Correct, it is not used
Quoted 3 lines
If we only need pciback to "park" a device in Dom0, wouldn't it be possible and better to use pci-stub instead?
Not only that, so pci-stub is not enough
The functionality which is implemented by the pciback and the toolstack and which is relevant/missing/needed for ARM:
1. pciback is used as a database for assignable PCI devices, e.g. xl pci-assignable-{add|remove|list} manipulates that list. So, whenever the toolstack needs to know which PCI devices can be passed through it reads that from the relevant sysfs entries of the pciback.
2. pciback is used to hold the unbound PCI devices, e.g. when passing through a PCI device it needs to be unbound from the relevant device driver and bound to pciback (strictly speaking it is not required that the device is bound to pciback, but pciback is again used as a database of the passed through PCI devices, so we can re-bind the devices back to their original drivers when guest domain shuts down)
3. Device reset
We have previously discussed on xen-devel ML possible solutions to that as from the above we see that pciback functionality is going to be only partially used on Arm.
Please see [1] and [2]:
Quoted 8 lines
Quoted 6 lines
1. It is not acceptable to manage the assignable list in Xen itself
2. pciback can be split into two parts: PCI assignable/bind/reset handling and the rest like vPCI etc.
3. pcifront is not used on Arm
It is neither in x86 PVH/HVM guests.
Didn't know that, thank you for pointing
Quoted 11 lines
Quoted 7 lines
So, limited use of the pciback is one of the bricks used to enable PCI passthrough on Arm. It was enough to just re-structure the driver and have it run on Arm to achieve all the goals above.
If we still think it is desirable to break the pciback driver into "common" and "pcifront specific" parts then it can be done, yet the patch is going to be the very first brick in that building.
Doing this split should be done, as the pcifront specific part could be omitted on x86, too, in case no PV guests using PCI passthrough have to be supported.
Agree, that the final solution should have the driver split
Quoted 8 lines
Quoted 2 lines
So, I think this patch is still going to be needed besides which direction we take.
Some kind of this patch, yes. It might look different in case the split is done first.
I don't mind doing it in either sequence.
With this patch we have Arm on the same page as the above mentioned x86 guests,
Quoted 7 lines
e.g. the driver has unused code, but yet allows Arm to function now.
At this stage of PCI passthrough on Arm it is yet enough. Long term, when
the driver gets split, Arm will benefit from that split too, but unfortunately I do not
have enough bandwidth for that piece of work at the moment.
That's fair and I don't want to scope-creep this simple patch asking for an enormous rework. At the same time I don't think we should enable the whole of pciback on ARM because it would be erroneous and confusing.
Quoted 6 lines
Quoted 3 lines
As the first stage before the driver is split or ifdef's used - can we take the patch as is now? In either way we chose this needs to be done, e.g. enable compiling for other architectures and common code move.
Fine with me in principle. I need to take a more thorough look at the patch, though.
Of course
Quoted 61 lines
Quoted 55 lines
Quoted 43 lines
Quoted 5 lines
I am wonder if there is a simple:
Quoted 8 lines
if (!xen_pv_domain())
return;That we could add in a couple of places in pciback to stop it from initializing the parts we don't care about. Something along these lines (untested and probably incomplete).
What do you guys think?
Uh no, not in this way, please. This will kill pci passthrough on x86 with dom0 running as PVH. I don't think this is working right now, but adding more code making it even harder to work should be avoided.
Quoted 12 lines
drivers/xen/xen-pciback/xenbus.c +1
-0@@ -15,6 +15,7 @@ #include <xen/xenbus.h> #include <xen/events.h> #include <xen/pci.h> +#include <xen/xen.h> #include "pciback.h" #define INVALID_EVTCHN_IRQ (-1)drivers/xen/xen-pciback/xenbus.c static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, · line 693
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +4
-1@@ -685,8 +686,12 @@ static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { int err = 0; - struct xen_pcibk_device *pdev = alloc_pdev(dev); + struct xen_pcibk_device *pdev; + + if (!xen_pv_domain()) + return 0; + pdev = alloc_pdev(dev);This hunk isn't needed, as with bailing out of
xen_pcibk_xenbus_registerearly will result inxen_pcibk_xenbus_probenever being called.Quoted 11 lines
drivers/xen/xen-pciback/xenbus.c const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; · line 752
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +3
-0if (pdev == NULL) { err = -ENOMEM; xenbus_dev_fatal(dev, err,@@ -743,6 +748,9 @@ const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; int __init xen_pcibk_xenbus_register(void) { + if (!xen_pv_domain()) + return 0; +Use #ifdef
CONFIG_X86instead.Quoted 5 lines
The title of this patch says that we want to allow this driver for other archs and now we want to introduce "#ifdef
CONFIG_X86" which doesn't sound right with that respect. Instead, we may want having something like a dedicated gate for this, e.g. "#ifdefCONFIG_XEN_PCIDEV_BACKEND_SUPP_PV" or something which is architecture agnostic.Quoted 5 lines
Something like that, yes. But I'd rather use
CONFIG_XEN_PCIDEV_BACKENDacting as this gate and introduceCONFIG_XEN_PCI_STUBfor the stub functionality needed on Arm.XEN_PCIDEV_BACKENDwould depend on X86 and selectXEN_PCI_STUB, while on ArmXEN_PCI_STUBcould be configured if wanted. The splitting of the driver can still be done later.Hm, pciback is now compiled when CONFIG_XEN_PCIDEV_BACKEND is enabled and we want to skip some parts of its code when
CONFIG_XEN_PCI_STUBis set. So, I imagine that for x86 we just enableCONFIG_XEN_PCIDEV_BACKENDand the driver compiles in its current state. For Arm we enable bothCONFIG_XEN_PCIDEV_BACKENDandCONFIG_XEN_PCI_STUB, so part of the driver is not compiled.
Quoted 6 lines
Quoted 3 lines
No, I'd rather switch to compiling xen-pciback when
CONFIG_XEN_PCI_STUBis set and compile only parts of it whenCONFIG_XEN_PCIDEV_BACKENDis not set (this will be the case on Arm).But this will require that the existing kernel configurations out there have to additionally define
CONFIG_XEN_PCI_STUBto get what they had before with simply enablingCONFIG_XEN_PCIDEV_BACKEND. My point was that it is probably desirable not to break the things while doing the split/re-work.
By letting XEN_PCIDEV_BACKEND select XEN_PCI_STUB this won't happen.
Quoted 3 lines
I also thought that "compile only parts of it when
CONFIG_XEN_PCIDEV_BACKENDis not set" may have more code gated rather than with gating unwanted code withCONFIG_XEN_PCI_STUB. I am not quite sure about this though.
This would be a very weird semantics of XEN_PCI_STUB, as the stub part is needed on X86 and on Arm.
Gating could even be done with Stefano's patch just by replacing his "!xen_pv_domain()" tests with "!IS_ENABLED(CONFIG_XEN_PCIDEV_BACKEND)".
Juergen
Quoted 178 lines · Juergen Gross
Quoted 177 lines · Oleksandr Andrushchenko
Quoted 175 lines · Juergen Gross
Quoted 173 lines · Oleksandr Andrushchenko
Quoted 92 lines · Juergen Gross
Quoted 91 lines · Oleksandr Andrushchenko
Quoted 88 lines · Juergen Gross
Quoted 87 lines · Stefano Stabellini
Quoted 75 lines · Oleksandr Andrushchenko
Quoted 43 lines · Juergen Gross
Quoted 42 lines · Oleksandr Andrushchenko
Hello, Stefano!
Quoted 4 lines · Stefano Stabellini
Hi Oleksandr,
Why do you want to enable pciback on ARM? Is it only to "disable" a PCI device in Dom0 so that it can be safely assigned to a DomU?
Not only that
Quoted 5 lines
I am asking because actually I don't think we want to enable the PV PCI backend feature of pciback on ARM, right? That would clash with the PCI assignment work you have been doing in Xen. They couldn't both work at the same time.
Correct, it is not used
Quoted 3 lines
If we only need pciback to "park" a device in Dom0, wouldn't it be possible and better to use pci-stub instead?
Not only that, so pci-stub is not enough
The functionality which is implemented by the pciback and the toolstack and which is relevant/missing/needed for ARM:
1. pciback is used as a database for assignable PCI devices, e.g. xl pci-assignable-{add|remove|list} manipulates that list. So, whenever the toolstack needs to know which PCI devices can be passed through it reads that from the relevant sysfs entries of the pciback.
2. pciback is used to hold the unbound PCI devices, e.g. when passing through a PCI device it needs to be unbound from the relevant device driver and bound to pciback (strictly speaking it is not required that the device is bound to pciback, but pciback is again used as a database of the passed through PCI devices, so we can re-bind the devices back to their original drivers when guest domain shuts down)
3. Device reset
We have previously discussed on xen-devel ML possible solutions to that as from the above we see that pciback functionality is going to be only partially used on Arm.
Please see [1] and [2]:
Quoted 8 lines
Quoted 6 lines
1. It is not acceptable to manage the assignable list in Xen itself
2. pciback can be split into two parts: PCI assignable/bind/reset handling and the rest like vPCI etc.
3. pcifront is not used on Arm
It is neither in x86 PVH/HVM guests.
Didn't know that, thank you for pointing
Quoted 11 lines
Quoted 7 lines
So, limited use of the pciback is one of the bricks used to enable PCI passthrough on Arm. It was enough to just re-structure the driver and have it run on Arm to achieve all the goals above.
If we still think it is desirable to break the pciback driver into "common" and "pcifront specific" parts then it can be done, yet the patch is going to be the very first brick in that building.
Doing this split should be done, as the pcifront specific part could be omitted on x86, too, in case no PV guests using PCI passthrough have to be supported.
Agree, that the final solution should have the driver split
Quoted 8 lines
Quoted 2 lines
So, I think this patch is still going to be needed besides which direction we take.
Some kind of this patch, yes. It might look different in case the split is done first.
I don't mind doing it in either sequence.
With this patch we have Arm on the same page as the above mentioned x86 guests,
Quoted 7 lines
e.g. the driver has unused code, but yet allows Arm to function now.
At this stage of PCI passthrough on Arm it is yet enough. Long term, when
the driver gets split, Arm will benefit from that split too, but unfortunately I do not
have enough bandwidth for that piece of work at the moment.
That's fair and I don't want to scope-creep this simple patch asking for an enormous rework. At the same time I don't think we should enable the whole of pciback on ARM because it would be erroneous and confusing.
Quoted 6 lines
Quoted 3 lines
As the first stage before the driver is split or ifdef's used - can we take the patch as is now? In either way we chose this needs to be done, e.g. enable compiling for other architectures and common code move.
Fine with me in principle. I need to take a more thorough look at the patch, though.
Of course
Quoted 61 lines
Quoted 55 lines
Quoted 43 lines
Quoted 5 lines
I am wonder if there is a simple:
Quoted 8 lines
if (!xen_pv_domain())
return;That we could add in a couple of places in pciback to stop it from initializing the parts we don't care about. Something along these lines (untested and probably incomplete).
What do you guys think?
Uh no, not in this way, please. This will kill pci passthrough on x86 with dom0 running as PVH. I don't think this is working right now, but adding more code making it even harder to work should be avoided.
Quoted 12 lines
drivers/xen/xen-pciback/xenbus.c +1
-0@@ -15,6 +15,7 @@ #include <xen/xenbus.h> #include <xen/events.h> #include <xen/pci.h> +#include <xen/xen.h> #include "pciback.h" #define INVALID_EVTCHN_IRQ (-1)drivers/xen/xen-pciback/xenbus.c static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, · line 693
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +4
-1@@ -685,8 +686,12 @@ static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { int err = 0; - struct xen_pcibk_device *pdev = alloc_pdev(dev); + struct xen_pcibk_device *pdev; + + if (!xen_pv_domain()) + return 0; + pdev = alloc_pdev(dev);This hunk isn't needed, as with bailing out of
xen_pcibk_xenbus_registerearly will result inxen_pcibk_xenbus_probenever being called.Quoted 11 lines
drivers/xen/xen-pciback/xenbus.c const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; · line 752
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +3
-0if (pdev == NULL) { err = -ENOMEM; xenbus_dev_fatal(dev, err,@@ -743,6 +748,9 @@ const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; int __init xen_pcibk_xenbus_register(void) { + if (!xen_pv_domain()) + return 0; +Use #ifdef
CONFIG_X86instead.Quoted 5 lines
The title of this patch says that we want to allow this driver for other archs and now we want to introduce "#ifdef
CONFIG_X86" which doesn't sound right with that respect. Instead, we may want having something like a dedicated gate for this, e.g. "#ifdefCONFIG_XEN_PCIDEV_BACKEND_SUPP_PV" or something which is architecture agnostic.Quoted 5 lines
Something like that, yes. But I'd rather use
CONFIG_XEN_PCIDEV_BACKENDacting as this gate and introduceCONFIG_XEN_PCI_STUBfor the stub functionality needed on Arm.XEN_PCIDEV_BACKENDwould depend on X86 and selectXEN_PCI_STUB, while on ArmXEN_PCI_STUBcould be configured if wanted. The splitting of the driver can still be done later.Hm, pciback is now compiled when
CONFIG_XEN_PCIDEV_BACKENDis enabled and we want to skip some parts of its code whenCONFIG_XEN_PCI_STUBis set. So, I imagine that for x86 we just enableCONFIG_XEN_PCIDEV_BACKENDand the driver compiles in its current state. For Arm we enable bothCONFIG_XEN_PCIDEV_BACKENDandCONFIG_XEN_PCI_STUB, so part of the driver is not compiled.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
No, I'd rather switch to compiling xen-pciback when
CONFIG_XEN_PCI_STUBis set and compile only parts of it whenCONFIG_XEN_PCIDEV_BACKENDis not set (this will be the case on Arm).But this will require that the existing kernel configurations out there have to additionally define
CONFIG_XEN_PCI_STUBto get what they had before with simply enablingCONFIG_XEN_PCIDEV_BACKEND. My point was that it is probably desirable not to break the things while doing the split/re-work.By letting
XEN_PCIDEV_BACKENDselectXEN_PCI_STUBthis won't happen.
Indeed
Quoted 10 lines
Quoted 4 lines
I also thought that "compile only parts of it when
CONFIG_XEN_PCIDEV_BACKENDis not set" may have more code gated rather than with gating unwanted code withCONFIG_XEN_PCI_STUB. I am not quite sure about this though.This would be a very weird semantics of
XEN_PCI_STUB, as the stub part is needed on X86 and on Arm.Gating could even be done with Stefano's patch just by replacing his "!xen_pv_domain()" tests with "!IS_ENABLED(CONFIG_XEN_PCIDEV_BACKEND)".
Makes sense.
Another question if we do not want the code to be compiled or not executed?
If the later then we can define something like:
bool need_pv_part(void)
{
return IS_ENABLED(CONFIG_XEN_PCIDEV_BACKEND);
}
and then just use need_pv_part() for the checks where it is needed.
This allows avoiding multiple ifdef's through the code
Quoted 3 lines
Juergen
Juergen Gross
maintainerQuoted 29 lines · Oleksandr Andrushchenko
From: Oleksandr Andrushchenko <[email protected]>
Xen-pciback driver was designed to be built for x86 only. But it can also be used by other architectures, e.g. Arm. Re-structure the driver in a way that it can be built for other platforms as well.
Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>---
Tested on Arm and x86.--- arch/x86/include/asm/xen/pci.h | 24 ---------- arch/x86/pci/xen.c | 74 +---------------------------- drivers/xen/Kconfig | 2 +- drivers/xen/events/events_base.c | 1 + drivers/xen/pci.c | 75 ++++++++++++++++++++++++++++++ drivers/xen/xen-pciback/pci_stub.c | 3 +- drivers/xen/xen-pciback/xenbus.c | 2 +- include/xen/pci.h | 34 ++++++++++++++ 8 files changed, 115 insertions(+), 100 deletions(-)create mode 100644
include/xen/pci.harch/x86/include/asm/xen/pci.h +0
-0
arch/x86/include/asm/xen/pci.h static inline int pci_xen_hvm_init(void) · line 18
Quoted 5 lines
arch/x86/include/asm/xen/pci.h +0
-2@@ -14,30 +14,6 @@ static inline int pci_xen_hvm_init(void) return -1; }#endif -#if defined(CONFIG_XEN_DOM0 ) -int __init pci_xen_initial_domain (void );
Why are you removing this prototype? It is X86 specific.
Quoted 133 lines
arch/x86/include/asm/xen/pci.h +0
-22-int xen_find_device_domain_owner (struct pci_dev *dev); -int xen_register_device_domain_owner (struct pci_dev *dev,uint16_t domain); -int xen_unregister_device_domain_owner (struct pci_dev *dev); -#else -static inline int __init pci_xen_initial_domain (void ) -{ -return -1 ; -} -static inline int xen_find_device_domain_owner (struct pci_dev *dev) -{ -return -1 ; -} -static inline int xen_register_device_domain_owner (struct pci_dev *dev, -uint16_t domain) -{ -return -1 ; -} -static inline int xen_unregister_device_domain_owner (struct pci_dev *dev) -{ -return -1 ; -} -#endif #if defined(CONFIG_PCI_MSI )#if defined(CONFIG_PCI_XEN )arch/x86/pci/xen.c +1
-73@@ -23,6 +23,7 @@#include <xen/features.h> #include <xen/events.h> +#include <xen/pci.h> #include <asm/xen/pci.h> #include <asm/xen/cpuid.h> #include <asm/apic.h> @@ -583,77 +584,4 @@ int __init pci_xen_initial_domain(void) }return 0 ; } - -struct xen_device_domain_owner { -domid_t domain; -struct pci_dev *dev; -struct list_head list; -}; - -static DEFINE_SPINLOCK (dev_domain_list_spinlock); -static struct list_head dev_domain_list =LIST_HEAD_INIT (dev_domain_list); - -static struct xen_device_domain_owner *find_device (struct pci_dev *dev) -{ -struct xen_device_domain_owner *owner; - -list_for_each_entry (owner, &dev_domain_list, list) { -if (owner->dev == dev) -return owner; - } -return NULL ; -} - -int xen_find_device_domain_owner (struct pci_dev *dev) -{ -struct xen_device_domain_owner *owner; -int domain = -ENODEV ; - -spin_lock (&dev_domain_list_spinlock); - owner =find_device (dev); -if (owner) - domain = owner->domain; -spin_unlock (&dev_domain_list_spinlock); -return domain; -} -EXPORT_SYMBOL_GPL (xen_find_device_domain_owner); - -int xen_register_device_domain_owner (struct pci_dev *dev,uint16_t domain) -{ -struct xen_device_domain_owner *owner; - - owner =kzalloc (sizeof (struct xen_device_domain_owner ),GFP_KERNEL ); -if (!owner) -return -ENODEV ; - -spin_lock (&dev_domain_list_spinlock); -if (find_device (dev)) { -spin_unlock (&dev_domain_list_spinlock); -kfree (owner); -return -EEXIST ; - } - owner->domain = domain; - owner->dev = dev; -list_add_tail (&owner->list, &dev_domain_list); -spin_unlock (&dev_domain_list_spinlock); -return 0 ; -} -EXPORT_SYMBOL_GPL (xen_register_device_domain_owner); - -int xen_unregister_device_domain_owner (struct pci_dev *dev) -{ -struct xen_device_domain_owner *owner; - -spin_lock (&dev_domain_list_spinlock); - owner =find_device (dev); -if (!owner) { -spin_unlock (&dev_domain_list_spinlock); -return -ENODEV ; - } -list_del (&owner->list); -spin_unlock (&dev_domain_list_spinlock); -kfree (owner); -return 0 ; -} -EXPORT_SYMBOL_GPL (xen_unregister_device_domain_owner);#endif drivers/xen/Kconfig +1
-1@@ -182,7 +182,7 @@ config SWIOTLB_XEN config XEN_PCIDEV_BACKEND tristate "Xen PCI-device backend driver" - depends on PCI && X86 && XEN + depends on PCI && XEN depends on XEN_BACKEND default m helpdrivers/xen/events/events_base.c +0
-0
drivers/xen/events/events_base.c line 68
Quoted 4 lines
drivers/xen/events/events_base.c +1
-0@@ -65,6 +65,7 @@#include <xen/interface/vcpu.h> #include <xen/xenbus.h> #include <asm/hw_irq.h> +#include <xen/pci.h>
This wouldn't be needed if you'd let the pci_xen_initial_domain() prototype where it has been.
Juergen
Quoted 25 lines · Juergen Gross
Quoted 24 lines · Oleksandr Andrushchenko
From: Oleksandr Andrushchenko <[email protected]>
Xen-pciback driver was designed to be built for x86 only. But it can also be used by other architectures, e.g. Arm. Re-structure the driver in a way that it can be built for other platforms as well.
Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>---
Tested on Arm and x86.
---
arch/x86/include/asm/xen/pci.h | 24 ---------- arch/x86/pci/xen.c | 74 +---------------------------- drivers/xen/Kconfig | 2 +- drivers/xen/events/events_base.c | 1 + drivers/xen/pci.c | 75 ++++++++++++++++++++++++++++++drivers/xen/xen-pciback/pci_stub.c| 3 +- drivers/xen/xen-pciback/xenbus.c | 2 +- include/xen/pci.h | 34 ++++++++++++++8 files changed, 115 insertions(+), 100 deletions(-)create mode 100644
include/xen/pci.h
Quoted 12 lines
arch/x86/include/asm/xen/pci.h static inline int pci_xen_hvm_init(void) · line 18
Quoted 10 lines
arch/x86/include/asm/xen/pci.h +0
-2@@ -14,30 +14,6 @@ static inline int pci_xen_hvm_init(void) return -1; } #endif -#if defined(CONFIG_XEN_DOM0 ) -int __init pci_xen_initial_domain (void );Why are you removing this prototype? It is X86 specific.
Indeed it is. Will not remove it form x86 code
Quoted 130 lines
Quoted 130 lines
arch/x86/include/asm/xen/pci.h +0
-22-int xen_find_device_domain_owner (struct pci_dev *dev); -int xen_register_device_domain_owner (struct pci_dev *dev,uint16_t domain); -int xen_unregister_device_domain_owner (struct pci_dev *dev); -#else -static inline int __init pci_xen_initial_domain (void ) -{ - return -1; -} -static inline int xen_find_device_domain_owner (struct pci_dev *dev) -{ - return -1; -} -static inline int xen_register_device_domain_owner (struct pci_dev *dev, - uint16_t domain) -{ - return -1; -} -static inline int xen_unregister_device_domain_owner (struct pci_dev *dev) -{ - return -1; -} -#endif #if defined(CONFIG_PCI_MSI) #if defined(CONFIG_PCI_XEN)arch/x86/pci/xen.c +1
-73@@ -23,6 +23,7 @@ #include <xen/features.h> #include <xen/events.h> +#include <xen/pci.h> #include <asm/xen/pci.h> #include <asm/xen/cpuid.h> #include <asm/apic.h>@@ -583,77 +584,4 @@ int __init pci_xen_initial_domain(void) } return 0; } - -struct xen_device_domain_owner { - domid_t domain; - struct pci_dev *dev; - struct list_head list; -}; - -static DEFINE_SPINLOCK (dev_domain_list_spinlock); -static struct list_head dev_domain_list =LIST_HEAD_INIT (dev_domain_list); - -static struct xen_device_domain_owner *find_device (struct pci_dev *dev) -{ - struct xen_device_domain_owner *owner; - - list_for_each_entry(owner, &dev_domain_list, list) { - if (owner->dev == dev) - return owner; - } - return NULL; -} - -int xen_find_device_domain_owner (struct pci_dev *dev) -{ - struct xen_device_domain_owner *owner; - int domain = -ENODEV; - - spin_lock(&dev_domain_list_spinlock); - owner = find_device(dev); - if (owner) - domain = owner->domain; - spin_unlock(&dev_domain_list_spinlock); - return domain; -} -EXPORT_SYMBOL_GPL (xen_find_device_domain_owner); - -int xen_register_device_domain_owner (struct pci_dev *dev,uint16_t domain) -{ - struct xen_device_domain_owner *owner; - - owner = kzalloc(sizeof(struct xen_device_domain_owner), GFP_KERNEL); - if (!owner) - return -ENODEV; - - spin_lock(&dev_domain_list_spinlock); - if (find_device(dev)) { - spin_unlock(&dev_domain_list_spinlock); - kfree(owner); - return -EEXIST; - } - owner->domain = domain; - owner->dev = dev; - list_add_tail(&owner->list, &dev_domain_list); - spin_unlock(&dev_domain_list_spinlock); - return 0; -} -EXPORT_SYMBOL_GPL (xen_register_device_domain_owner); - -int xen_unregister_device_domain_owner (struct pci_dev *dev) -{ - struct xen_device_domain_owner *owner; - - spin_lock(&dev_domain_list_spinlock); - owner = find_device(dev); - if (!owner) { - spin_unlock(&dev_domain_list_spinlock); - return -ENODEV; - } - list_del(&owner->list); - spin_unlock(&dev_domain_list_spinlock); - kfree(owner); - return 0; -} -EXPORT_SYMBOL_GPL (xen_unregister_device_domain_owner); #endifdrivers/xen/Kconfig +0
-0@@ -182,7 +182,7 @@ config SWIOTLB_XENconfig
XEN_PCIDEV_BACKEND
tristate "Xen PCI-device backend driver"
- depends on PCI && X86 && XEN
+ depends on PCI && XEN
depends onXEN_BACKEND
default m
helpdrivers/xen/events/events_base.c +0
-0
Quoted 8 lines
drivers/xen/events/events_base.c line 68
Quoted 5 lines
drivers/xen/events/events_base.c +1
-0@@ -65,6 +65,7 @@ #include <xen/interface/vcpu.h> #include <xen/xenbus.h> #include <asm/hw_irq.h> +#include <xen/pci.h> This wouldn't be needed if you'd let the
pci_xen_initial_domain()prototype where it has been.
Sure, will leave it where it was
Quoted 3 lines
Juergen
Stefano Stabellini
maintainerQuoted 209 lines · Oleksandr Andrushchenko
Quoted 178 lines · Juergen Gross
Quoted 177 lines · Oleksandr Andrushchenko
Quoted 175 lines · Juergen Gross
Quoted 173 lines · Oleksandr Andrushchenko
Quoted 92 lines · Juergen Gross
Quoted 91 lines · Oleksandr Andrushchenko
Quoted 88 lines · Juergen Gross
Quoted 87 lines · Stefano Stabellini
Quoted 75 lines · Oleksandr Andrushchenko
Quoted 43 lines · Juergen Gross
Quoted 42 lines · Oleksandr Andrushchenko
Hello, Stefano!
Quoted 4 lines · Stefano Stabellini
Hi Oleksandr,
Why do you want to enable pciback on ARM? Is it only to "disable" a PCI
device in Dom0 so that it can be safely assigned to a DomU?Not only that
Quoted 5 lines
I am asking because actually I don't think we want to enable the PV PCI
backend feature of pciback on ARM, right? That would clash with the PCI
assignment work you have been doing in Xen. They couldn't both work at
the same time.Correct, it is not used
Quoted 3 lines
If we only need pciback to "park" a device in Dom0, wouldn't it be
possible and better to use pci-stub instead?Not only that, so pci-stub is not enough
The functionality which is implemented by the pciback and the toolstack and which is relevant/missing/needed for ARM:
1. pciback is used as a database for assignable PCI devices, e.g. xl pci-assignable-{add|remove|list} manipulates that list. So, whenever the toolstack needs to know which PCI devices can be passed through it reads that from the relevant sysfs entries of the pciback.
2. pciback is used to hold the unbound PCI devices, e.g. when passing through a PCI device it needs to be unbound from the relevant device driver and bound to pciback (strictly speaking it is not required that the device is bound to pciback, but pciback is again used as a database of the passed through PCI devices, so we can re-bind the devices back to their original drivers when guest domain shuts down)
3. Device reset
We have previously discussed on xen-devel ML possible solutions to that as from the above we see that pciback functionality is going to be only partially used on Arm.
Please see [1] and [2]:
Quoted 8 lines
Quoted 6 lines
1. It is not acceptable to manage the assignable list in Xen itself
2. pciback can be split into two parts: PCI assignable/bind/reset handling and the rest like vPCI etc.
3. pcifront is not used on Arm
It is neither in x86 PVH/HVM guests.
Didn't know that, thank you for pointing
Quoted 11 lines
Quoted 7 lines
So, limited use of the pciback is one of the bricks used to enable PCI passthrough on Arm. It was enough to just re-structure the driver and have it run on Arm to achieve all the goals above.
If we still think it is desirable to break the pciback driver into "common" and "pcifront specific" parts then it can be done, yet the patch is going to be the very first brick in that building.
Doing this split should be done, as the pcifront specific part could be omitted on x86, too, in case no PV guests using PCI passthrough have to be supported.
Agree, that the final solution should have the driver split
Quoted 8 lines
Quoted 2 lines
So, I think this patch is still going to be needed besides which direction we take.
Some kind of this patch, yes. It might look different in case the split is done first.
I don't mind doing it in either sequence.
With this patch we have Arm on the same page as the above mentioned x86 guests,
Quoted 7 lines
e.g. the driver has unused code, but yet allows Arm to function now.
At this stage of PCI passthrough on Arm it is yet enough. Long term, when
the driver gets split, Arm will benefit from that split too, but unfortunately I do not
have enough bandwidth for that piece of work at the moment.
That's fair and I don't want to scope-creep this simple patch asking for an enormous rework. At the same time I don't think we should enable the whole of pciback on ARM because it would be erroneous and confusing.
Quoted 6 lines
Quoted 3 lines
As the first stage before the driver is split or ifdef's used - can we take the patch as is now? In either way we chose this needs to be done, e.g. enable compiling for other architectures and common code move.
Fine with me in principle. I need to take a more thorough look at the patch, though.
Of course
Quoted 61 lines
Quoted 55 lines
Quoted 43 lines
Quoted 5 lines
I am wonder if there is a simple:
Quoted 8 lines
if (!xen_pv_domain())
return;That we could add in a couple of places in pciback to stop it from initializing the parts we don't care about. Something along these lines (untested and probably incomplete).
What do you guys think?
Uh no, not in this way, please. This will kill pci passthrough on x86 with dom0 running as PVH. I don't think this is working right now, but adding more code making it even harder to work should be avoided.
Quoted 12 lines
drivers/xen/xen-pciback/xenbus.c +1
-0@@ -15,6 +15,7 @@ #include <xen/xenbus.h> #include <xen/events.h> #include <xen/pci.h> +#include <xen/xen.h> #include "pciback.h" #define INVALID_EVTCHN_IRQ (-1)drivers/xen/xen-pciback/xenbus.c static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, · line 693
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +4
-1@@ -685,8 +686,12 @@ static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { int err = 0; - struct xen_pcibk_device *pdev = alloc_pdev(dev); + struct xen_pcibk_device *pdev; + + if (!xen_pv_domain()) + return 0; + pdev = alloc_pdev(dev);This hunk isn't needed, as with bailing out of
xen_pcibk_xenbus_registerearly will result inxen_pcibk_xenbus_probenever being called.Quoted 11 lines
drivers/xen/xen-pciback/xenbus.c const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; · line 752
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +3
-0if (pdev == NULL) { err = -ENOMEM; xenbus_dev_fatal(dev, err,@@ -743,6 +748,9 @@ const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; int __init xen_pcibk_xenbus_register(void) { + if (!xen_pv_domain()) + return 0; +Use #ifdef
CONFIG_X86instead.Quoted 5 lines
The title of this patch says that we want to allow this driver for other archs and now we want to introduce "#ifdef
CONFIG_X86" which doesn't sound right with that respect. Instead, we may want having something like a dedicated gate for this, e.g. "#ifdefCONFIG_XEN_PCIDEV_BACKEND_SUPP_PV" or something which is architecture agnostic.Quoted 5 lines
Something like that, yes. But I'd rather use
CONFIG_XEN_PCIDEV_BACKENDacting as this gate and introduceCONFIG_XEN_PCI_STUBfor the stub functionality needed on Arm.XEN_PCIDEV_BACKENDwould depend on X86 and selectXEN_PCI_STUB, while on ArmXEN_PCI_STUBcould be configured if wanted. The splitting of the driver can still be done later.Hm, pciback is now compiled when
CONFIG_XEN_PCIDEV_BACKENDis enabled and we want to skip some parts of its code whenCONFIG_XEN_PCI_STUBis set. So, I imagine that for x86 we just enableCONFIG_XEN_PCIDEV_BACKENDand the driver compiles in its current state. For Arm we enable bothCONFIG_XEN_PCIDEV_BACKENDandCONFIG_XEN_PCI_STUB, so part of the driver is not compiled.Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
No, I'd rather switch to compiling xen-pciback when
CONFIG_XEN_PCI_STUBis set and compile only parts of it whenCONFIG_XEN_PCIDEV_BACKENDis not set (this will be the case on Arm).But this will require that the existing kernel configurations out there have to additionally define
CONFIG_XEN_PCI_STUBto get what they had before with simply enablingCONFIG_XEN_PCIDEV_BACKEND. My point was that it is probably desirable not to break the things while doing the split/re-work.By letting
XEN_PCIDEV_BACKENDselectXEN_PCI_STUBthis won't happen.Indeed
Quoted 10 lines
Quoted 4 lines
I also thought that "compile only parts of it when
CONFIG_XEN_PCIDEV_BACKENDis not set" may have more code gated rather than with gating unwanted code withCONFIG_XEN_PCI_STUB. I am not quite sure about this though.This would be a very weird semantics of
XEN_PCI_STUB, as the stub part is needed on X86 and on Arm.Gating could even be done with Stefano's patch just by replacing his "!xen_pv_domain()" tests with "!IS_ENABLED(CONFIG_XEN_PCIDEV_BACKEND)".
Makes sense.
Another question if we do not want the code to be compiled or not executed?
If the later then we can define something like:
bool
need_pv_part(void){
Quoted 7 lines
return
IS_ENABLED(CONFIG_XEN_PCIDEV_BACKEND);}
and then just use
need_pv_part()for the checks where it is needed.This allows avoiding multiple ifdef's through the code
This is even better.
For my clarity, Oleksandr, are you OK with adding a few need_pv_part() checks through the code as part of this series so that the PV PCI backend is not initialized?
I don't have a good test environment ready for this, so I cannot really volunteer myself.
I would prefer if we made this change as part of this series so that the PV PCI backend features doesn't get enabled on ARM, not even temporarily.
Quoted 185 lines · Stefano Stabellini
Quoted 184 lines · Oleksandr Andrushchenko
Quoted 154 lines · Juergen Gross
Quoted 153 lines · Oleksandr Andrushchenko
Quoted 152 lines · Juergen Gross
Quoted 151 lines · Oleksandr Andrushchenko
Quoted 78 lines · Juergen Gross
Quoted 77 lines · Oleksandr Andrushchenko
Quoted 76 lines · Juergen Gross
Quoted 75 lines · Stefano Stabellini
Quoted 74 lines · Oleksandr Andrushchenko
Quoted 40 lines · Juergen Gross
Quoted 39 lines · Oleksandr Andrushchenko
Hello, Stefano!
On 18.09.21 00:45, Stefano Stabellini wrote:
Hi Oleksandr,Why do you want to enable pciback on ARM? Is it only to "disable" a PCI
device in Dom0 so that it can be safely assigned to a DomU?
Not only that
I am asking because actually I don't think we want to enable the PV PCI
backend feature of pciback on ARM, right? That would clash with the PCI
assignment work you have been doing in Xen. They couldn't both work at
the same time.
Correct, it is not used
If we only need pciback to "park" a device in Dom0, wouldn't it be
possible and better to use pci-stub instead?
Not only that, so pci-stub is not enoughThe functionality which is implemented by the pciback and the toolstack
and which is relevant/missing/needed for ARM:1. pciback is used as a database for assignable PCI devices, e.g. xl
pci-assignable-{add|remove|list} manipulates that list. So, whenever the
toolstack needs to know which PCI devices can be passed through it reads
that from the relevant sysfs entries of the pciback.2. pciback is used to hold the unbound PCI devices, e.g. when passing through
a PCI device it needs to be unbound from the relevant device driver and bound
to pciback (strictly speaking it is not required that the device is bound to
pciback, but pciback is again used as a database of the passed through PCI
devices, so we can re-bind the devices back to their original drivers when
guest domain shuts down)3. Device reset
We have previously discussed on xen-devel ML possible solutions to that as from the
above we see that pciback functionality is going to be only partially used on Arm.Please see [1] and [2]:
Quoted 7 lines
Quoted 6 lines
1. It is not acceptable to manage the assignable list in Xen itself
2. pciback can be split into two parts: PCI assignable/bind/reset handling and
the rest like vPCI etc.3. pcifront is not used on Arm
It is neither in x86 PVH/HVM guests.
Didn't know that, thank you for pointing
Quoted 9 lines
Quoted 6 lines
So, limited use of the pciback is one of the bricks used to enable PCI passthrough
on Arm. It was enough to just re-structure the driver and have it run on Arm to achieve
all the goals above.If we still think it is desirable to break the pciback driver into "common" and "pcifront specific"
parts then it can be done, yet the patch is going to be the very first brick in that building.Doing this split should be done, as the pcifront specific part could be omitted on x86, too, in case no PV guests using PCI passthrough have to be supported.
Agree, that the final solution should have the driver split
Quoted 6 lines
Quoted 1 line
So, I think this patch is still going to be needed besides which direction we take.
Some kind of this patch, yes. It might look different in case the split is done first.
I don't mind doing it in either sequence.
With this patch we have Arm on the same page as the above mentioned x86 guests,
e.g. the driver has unused code, but yet allows Arm to function now.
At this stage of PCI passthrough on Arm it is yet enough. Long term, when
the driver gets split, Arm will benefit from that split too, but unfortunately I do not
have enough bandwidth for that piece of work at the moment.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
That's fair and I don't want to scope-creep this simple patch asking for an enormous rework. At the same time I don't think we should enable the whole of pciback on ARM because it would be erroneous and confusing.
As the first stage before the driver is split or ifdef's used - can we take the patch as is now? In either way we chose this needs to be done, e.g. enable compiling for other architectures and common code move.
Fine with me in principle. I need to take a more thorough look at the patch, though.
Of course
Quoted 53 lines
Quoted 48 lines
Quoted 38 lines
Quoted 10 lines
I am wonder if there is a simple:
if (!xen_pv_domain())
return;That we could add in a couple of places in pciback to stop it from initializing the parts we don't care about. Something along these lines (untested and probably incomplete).
What do you guys think?
Uh no, not in this way, please. This will kill pci passthrough on x86 with dom0 running as PVH. I don't think this is working right now, but adding more code making it even harder to work should be avoided.
Quoted 12 lines
drivers/xen/xen-pciback/xenbus.c +1
-0@@ -15,6 +15,7 @@ #include <xen/xenbus.h> #include <xen/events.h> #include <xen/pci.h> +#include <xen/xen.h> #include "pciback.h" #define INVALID_EVTCHN_IRQ (-1)drivers/xen/xen-pciback/xenbus.c static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, · line 693
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +4
-1@@ -685,8 +686,12 @@ static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { int err = 0; - struct xen_pcibk_device *pdev = alloc_pdev(dev); + struct xen_pcibk_device *pdev; + + if (!xen_pv_domain()) + return 0; + pdev = alloc_pdev(dev);This hunk isn't needed, as with bailing out of
xen_pcibk_xenbus_registerearly will result inxen_pcibk_xenbus_probenever being called.Quoted 10 lines
drivers/xen/xen-pciback/xenbus.c const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; · line 752
Quoted 9 lines
drivers/xen/xen-pciback/xenbus.c +3
-0if (pdev == NULL) { err = -ENOMEM; xenbus_dev_fatal(dev, err,@@ -743,6 +748,9 @@ const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; int __init xen_pcibk_xenbus_register(void) { + if (!xen_pv_domain()) + return 0; +Use #ifdef
CONFIG_X86instead.Quoted 5 lines
The title of this patch says that we want to allow this driver for other archs and now we want to introduce "#ifdef
CONFIG_X86" which doesn't sound right with that respect. Instead, we may want having something like a dedicated gate for this, e.g. "#ifdefCONFIG_XEN_PCIDEV_BACKEND_SUPP_PV" or something which is architecture agnostic.Quoted 5 lines
Something like that, yes. But I'd rather use
CONFIG_XEN_PCIDEV_BACKENDacting as this gate and introduceCONFIG_XEN_PCI_STUBfor the stub functionality needed on Arm.XEN_PCIDEV_BACKENDwould depend on X86 and selectXEN_PCI_STUB, while on ArmXEN_PCI_STUBcould be configured if wanted. The splitting of the driver can still be done later.Hm, pciback is now compiled when
CONFIG_XEN_PCIDEV_BACKENDis enabled and we want to skip some parts of its code whenCONFIG_XEN_PCI_STUBis set. So, I imagine that for x86 we just enableCONFIG_XEN_PCIDEV_BACKENDand the driver compiles in its current state. For Arm we enable bothCONFIG_XEN_PCIDEV_BACKENDandCONFIG_XEN_PCI_STUB, so part of the driver is not compiled.Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
No, I'd rather switch to compiling xen-pciback when
CONFIG_XEN_PCI_STUBis set and compile only parts of it whenCONFIG_XEN_PCIDEV_BACKENDis not set (this will be the case on Arm).But this will require that the existing kernel configurations out there have to additionally define
CONFIG_XEN_PCI_STUBto get what they had before with simply enablingCONFIG_XEN_PCIDEV_BACKEND. My point was that it is probably desirable not to break the things while doing the split/re-work.By letting
XEN_PCIDEV_BACKENDselectXEN_PCI_STUBthis won't happen.Indeed
Quoted 8 lines
Quoted 3 lines
I also thought that "compile only parts of it when
CONFIG_XEN_PCIDEV_BACKENDis not set" may have more code gated rather than with gating unwanted code withCONFIG_XEN_PCI_STUB. I am not quite sure about this though.This would be a very weird semantics of
XEN_PCI_STUB, as the stub part is needed on X86 and on Arm.Gating could even be done with Stefano's patch just by replacing his "!xen_pv_domain()" tests with "!IS_ENABLED(CONFIG_XEN_PCIDEV_BACKEND)".
Makes sense.
Another question if we do not want the code to be compiled or not executed?
If the later then we can define something like:
bool
need_pv_part(void){
return IS_ENABLED(CONFIG_XEN_PCIDEV_BACKEND);}
Quoted 8 lines
Quoted 3 lines
and then just use
need_pv_part()for the checks where it is needed.This allows avoiding multiple ifdef's through the code
This is even better.
For my clarity, Oleksandr, are you OK with adding a few
need_pv_part()checks through the code as part of this series so that the PV PCI backend is not initialized?
Yes
Quoted 6 lines
I don't have a good test environment ready for this, so I cannot really volunteer myself.
I would prefer if we made this change as part of this series so that the PV PCI backend features doesn't get enabled on ARM, not even temporarily.
Ok, I will push v2 today with the additional patch for PV