PCI Pass-through in Xen ARM - Draft 2.
PCI Pass-through in Xen ARM
--------------------------
Draft 2
Index
1. Background
2. Basic PCI Support in Xen ARM
2.1 pci_hostbridge and pci_hostbridge_ops
2.2 PHYSDEVOP_HOSTBRIDGE_ADD hypercall
3. Dom0 Access PCI devices
4. DomU assignment of PCI device
4.1 Holes in guest memory space
4.2 New entries in xenstore for device BARs
4.3 Hypercall for bdf mapping noification to xen
4.4 Change in Linux PCI FrontEnd - backend driver
for MSI/X programming
5. NUMA and PCI passthrough
6. DomU pci device attach flow
Revision History
----------------
Changes from Draft 1
a) map_mmio hypercall removed from earlier draft
b) device bar mapping into guest not 1:1
c) holes in guest address space 32bit / 64bit for MMIO virtual BARs
d) xenstore device's BAR info addition.
1. Background of PCI passthrough
--------------------------------
Passthrough refers to assigning a pci device to a guest domain (domU) such that the guest has full control over the device.The MMIO space and interrupts are managed by the guest itself, close to how a bare kernel manages a device.
Device's access to guest address space needs to be isolated and protected. SMMU (System MMU - IOMMU in ARM) is programmed by xen hypervisor to allow device access guest memory for data transfer and sending MSI/X interrupts. In case of MSI/X the device writes to GITS (ITS address space) Interrupt Translation Register.
2. Basic PCI Support for ARM
----------------------------
The apis to read write from pci configuration space are based on segment:bdf. How the sbdf is mapped to a physical address is under the realm of the pci host controller.
ARM PCI support in Xen, introduces pci host controller similar to what exists in Linux. Each drivers registers callbacks, which are invoked on matching the compatible property in pci device tree node.
2.1:
The init function in the pci host driver calls to register hostbridge callbacks:
int pci_hostbridge_register(pci_hostbridge_t *pcihb);
struct pci_hostbridge_ops {
u32 (*pci_conf_read)(struct pci_hostbridge*, u32 bus, u32 devfn,
u32 reg, u32 bytes);
void (*pci_conf_write)(struct pci_hostbridge*, u32 bus, u32 devfn,
u32 reg, u32 bytes, u32 val);
};struct pci_hostbridge{
u32 segno;
paddr_t cfg_base;
paddr_t cfg_size;
struct dt_device_node *dt_node;
struct pci_hostbridge_ops ops;
struct list_head list;
};A pci conf read function would internally be as follows:
u32 pcihb_conf_read(u32 seg, u32 bus, u32 devfn,u32 reg, u32 bytes)
{
pci_hostbridge_t *pcihb;
list_for_each_entry(pcihb, &pci_hostbridge_list, list)
{
if(pcihb->segno == seg)
return pcihb->ops.pci_conf_read(pcihb, bus, devfn, reg, bytes);
}
return -1;
}2.2 PHYSDEVOP_pci_host_bridge_add hypercall
Xen code accesses PCI configuration space based on the sbdf received from the guest. The order in which the pci device tree node appear may not be the same order of device enumeration in dom0. Thus there needs to be a mechanism to bind the segment number assigned by dom0 to the pci host controller. The hypercall is introduced:
#define PHYSDEVOP_pci_host_bridge_add 44
struct physdev_pci_host_bridge_add {
/* IN */
uint16_t seg;
uint64_t cfg_base;
uint64_t cfg_size;
};This hypercall is invoked before dom0 invokes the PHYSDEVOP_pci_device_add hypercall. The handler code invokes to update segment number in pci_hostbridge:
int pci_hostbridge_setup(uint32_t segno, uint64_t cfg_base, uint64_t cfg_size);
Subsequent calls to pci_conf_read/write are completed by the pci_hostbridge_ops of the respective pci_hostbridge.
3. Dom0 access PCI device
---------------------------------
As per the design of xen hypervisor, dom0 enumerates the PCI devices. For each device the MMIO space has to be mapped in the Stage2 translation for dom0. For dom0 xen maps the ranges in pci nodes in stage 2 translation.
GITS_ITRANSLATER space (4k( must be programmed in Stage2 translation so that MSI/X must work. This is done in vits initialization in dom0/domU.
4. DomU access / assignment PCI device
--------------------------------------
In the flow of pci-attach device, the toolkit will read the pci configuration space BAR registers. The toolkit has the guest memory map and the information of the MMIO holes.
When the first pci device is assigned to domU, toolkit allocates a virtual BAR region from the MMIO hole area. toolkit then sends domctl xc_domain_memory_mapping to map in stage2 translation.
4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR regions. These are defined in arch-arm.h
/* For 32bit */GUEST_MMIO_HOLE0_BASE, GUEST_MMIO_HOLE0_SIZE
/* For 64bit */GUEST_MMIO_HOLE1_BASE , GUEST_MMIO_HOLE1_SIZE
4.2 New entries in xenstore for device BARs
--------------------------------------------
toolkit also updates the xenstore information for the device (virtualbar:physical bar). This information is read by xenpciback and returned to the pcifront driver configuration space accesses.
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#define PHYSDEVOP_map_sbdf 43
typedef struct {
u32 s;
u8 b;
u8 df;
u16 res;
} sbdf_t;
struct physdev_map_sbdf {
int domain_id;
sbdf_t sbdf;
sbdf_t gsbdf;
};Each domain has a pdev list, which contains the list of all pci devices. The pdev structure already has a sbdf information. The arch_pci_dev is updated to contain the gsbdf information. (gs- guest segment id)
Whenever there is trap from guest or an interrupt has to be injected, the pdev list is iterated to find the gsbdf.
4.4 Change in Linux PCI ForntEnd - backend driver for MSI/X programming
-------------------------------------------------------------
On the Pci frontend bus a msi-parent as gicv3-its is added. As there is a single virtual its for a domU, as there is only a single virtual pci bus in domU. This ensures that the config_msi calls are handled by the gicv3 its driver in domU kernel and not utilizing frontend-backend communication between dom0-domU.
5. NUMA domU and vITS
-----------------------------
a) On NUMA systems domU still have a single its node.
b) How can xen identify the ITS on which a device is connected.
- Using segment number query using api which gives pci host controllers device node
struct dt_device_node* pci_hostbridge_dt_node(uint32_t segno)
c) Query the interrupt parent of the pci device node to find out the its.
6. DomU Bootup flow
---------------------
a. DomU boots up without any pci devices assigned. A daemon listens to events from the xenstore. When a device is attached to domU, the frontend pci bus driver starts enumerating the devices.Front end driver communicates with backend driver in dom0 to read the pci config space.
b. backend driver returns the virtual BAR ranges which are already mapped in domU stage 2 translation.
c. Device driver of the specific pci device invokes methods to configure the msi/x interrupt which are handled by the its driver in domU kernel. The read/writes by the its driver are trapped in xen. ITS driver finds out the actual sbdf based on the map_sbdf hypercall information.
Hi Manish,
Quoted 11 lines · Manish Jaggi
4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR regions.
These are defined inarch-arm.h/* For 32bit */
GUEST_MMIO_HOLE0_BASE,GUEST_MMIO_HOLE0_SIZE/* For 64bit */
GUEST_MMIO_HOLE1_BASE,GUEST_MMIO_HOLE1_SIZE
The memory layout for 32bit and 64bit are exactly the same. Why do you need to differ here?
Quoted 7 lines
4.2 New entries in xenstore for device BARs
--------------------------------------------
toolkit also updates the xenstore information for the device (virtualbar:physical bar).
This information is read by xenpciback and returned to the pcifront driver configuration
space accesses.
Can you details what do you plan to put in xenstore and how?
What about the expansion ROM?
Quoted 21 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices. The
pdev structure already has a sbdf information. Thearch_pci_devis updated to
contain the gsbdf information. (gs- guest segment id)
Quoted 3 lines
Whenever there is trap from guest or an interrupt has to be injected, the pdev
list is iterated to find the gsbdf.
Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?
- Who will call this hypercall?
- Why not setting the gsbdf when the device is assigned?
Regards,
Signature · 1 line
Julien Grall
Quoted 9 lines · Julien Grall
Hi Manish,
Quoted 6 lines · Manish Jaggi
4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR regions.
These are defined inarch-arm.h
Quoted 8 lines
Quoted 5 lines
/* For 32bit */
GUEST_MMIO_HOLE0_BASE,GUEST_MMIO_HOLE0_SIZE/* For 64bit */
GUEST_MMIO_HOLE1_BASE,GUEST_MMIO_HOLE1_SIZEThe memory layout for 32bit and 64bit are exactly the same. Why do you need to differ here?
I took this to be a "hole under 4GB" and a "hole over 4GB" IOW rather than specific to 32-bit/64-bit guests it is specific to 32/64 bit devices, the latter of which could be placed higher in RAM, which is useful since the space under 4GB is naturally more limited.
Ian.
Quoted 16 lines · Ian Campbell
Quoted 15 lines · Julien Grall
Hi Manish,
Quoted 11 lines · Manish Jaggi
4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR regions.
These are defined inarch-arm.h/* For 32bit */
GUEST_MMIO_HOLE0_BASE,GUEST_MMIO_HOLE0_SIZE/* For 64bit */
GUEST_MMIO_HOLE1_BASE,GUEST_MMIO_HOLE1_SIZE
Quoted 7 lines
Quoted 2 lines
The memory layout for 32bit and 64bit are exactly the same. Why do you need to differ here?
I took this to be a "hole under 4GB" and a "hole over 4GB" IOW rather than specific to 32-bit/64-bit guests it is specific to 32/64 bit devices, the latter of which could be placed higher in RAM, which is useful since the space under 4GB is naturally more limited.
I wasn't able to deduce that with this section. It needs a minimum of explanation based on what you just said.
That also bring the question about 64 bit PCI and short page table. Do we support it (i.e possibility to allocate 64 bit BAR below 4GB)?
I don't mind the answer, but it needs to be clarify for the implementation.
Regards,
Signature · 1 line
Julien Grall
Quoted 111 lines · Manish Jaggi
PCI Pass-through in Xen ARM
--------------------------Draft 2
Index
1. Background
2. Basic PCI Support in Xen ARM
2.1pci_hostbridgeandpci_hostbridge_ops
2.2PHYSDEVOP_HOSTBRIDGE_ADDhypercall3. Dom0 Access PCI devices
4. DomU assignment of PCI device
4.1 Holes in guest memory space
4.2 New entries in xenstore for device BARs
4.3 Hypercall for bdf mapping noification to xen
4.4 Change in Linux PCI FrontEnd - backend driver
for MSI/X programming5. NUMA and PCI passthrough
6. DomU pci device attach flow
Revision History
----------------
Changes from Draft 1
a)map_mmiohypercall removed from earlier draft
b) device bar mapping into guest not 1:1
c) holes in guest address space 32bit / 64bit for MMIO virtual BARs
d) xenstore device's BAR info addition.1. Background of PCI passthrough
--------------------------------
Passthrough refers to assigning a pci device to a guest domain (domU) such that the guest has full control over the device.The MMIO space and interrupts are managed by the guest itself, close to how a bare kernel manages a device.Device's access to guest address space needs to be isolated and protected. SMMU (System MMU - IOMMU in ARM) is programmed by xen hypervisor to allow device access guest memory for data transfer and sending MSI/X interrupts. In case of MSI/X the device writes to GITS (ITS address space) Interrupt Translation Register.
2. Basic PCI Support for ARM
----------------------------
The apis to read write from pci configuration space are based on segment:bdf. How the sbdf is mapped to a physical address is under the realm of the pci host controller.ARM PCI support in Xen, introduces pci host controller similar to what exists in Linux. Each drivers registers callbacks, which are invoked on matching the compatible property in pci device tree node.
2.1:
The init function in the pci host driver calls to register hostbridge callbacks:
intpci_hostbridge_register(pci_hostbridge_t *pcihb);struct pci_hostbridge_ops { u32 (*pci_conf_read)(struct pci_hostbridge*, u32 bus, u32 devfn, u32 reg, u32 bytes); void (*pci_conf_write)(struct pci_hostbridge*, u32 bus, u32 devfn, u32 reg, u32 bytes, u32 val); };struct pci_hostbridge{ u32 segno; paddr_t cfg_base; paddr_t cfg_size; struct dt_device_node *dt_node; struct pci_hostbridge_ops ops; struct list_head list; };A pci conf read function would internally be as follows:
u32pcihb_conf_read(u32 seg, u32 bus, u32 devfn,u32 reg, u32 bytes){ pci_hostbridge_t *pcihb; list_for_each_entry(pcihb, &pci_hostbridge_list, list) { if(pcihb->segno == seg) return pcihb->ops.pci_conf_read(pcihb, bus, devfn, reg, bytes); } return -1; }2.2
PHYSDEVOP_pci_host_bridge_addhypercallXen code accesses PCI configuration space based on the sbdf received from the guest. The order in which the pci device tree node appear may not be the same order of device enumeration in dom0. Thus there needs to be a mechanism to bind the segment number assigned by dom0 to the pci host controller. The hypercall is introduced:
#define
PHYSDEVOP_pci_host_bridge_add44struct physdev_pci_host_bridge_add { /* IN */ uint16_t seg; uint64_t cfg_base; uint64_t cfg_size; };This hypercall is invoked before dom0 invokes the
PHYSDEVOP_pci_device_addhypercall. The handler code invokes to update segment number inpci_hostbridge:int
pci_hostbridge_setup(uint32_t segno, uint64_t cfg_base, uint64_t cfg_size);
Quoted 7 lines
Subsequent calls to pci_conf_read/write are completed by the
pci_hostbridge_opsof the respectivepci_hostbridge.3. Dom0 access PCI device
---------------------------------
As per the design of xen hypervisor, dom0 enumerates the PCI devices. For each device the MMIO space has to be mapped in the Stage2 translation for dom0.
Here "device" is really host bridge, isn't it? i.e. this is done by mapping the entire MMIO window of each host bridge, not the individual BAR registers of each device one at a time.
IOW this is functionality of the pci host driver's intitial setup, not something which is driven from the dom0 enumeration of the bus.
Quoted 5 lines
For
dom0 xen maps the ranges in pci nodes in stage 2 translation.
GITS_ITRANSLATERspace (4k( must be programmed in Stage2 translation so that MSI/X must work. This is done in vits initialization in dom0/domU.
This also happens at start of day, but what isn't mentioned is that (AIUI) the SMMU will need to be programmed to map each SBDF to the dom0 p2m as the devices are discovered and reported. Right?
Quoted 4 lines
4. DomU access / assignment PCI device
--------------------------------------
In the flow of pci-attach device, the toolkit
I assume you mean "toolstack" throughout? If so then please run s/toolkit/toolstack/g so as to use the usual terminology.
Quoted 19 lines
will read the pci configuration
space BAR registers. The toolkit has the guest memory map and the information of the MMIO holes.When the first pci device is assigned to domU, toolkit allocates a virtual BAR region from the MMIO hole area. toolkit then sends domctl
xc_domain_memory_mappingto map in stage2 translation.4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR regions. These are defined inarch-arm.h/* For 32bit */
GUEST_MMIO_HOLE0_BASE,GUEST_MMIO_HOLE0_SIZE/* For 64bit */
GUEST_MMIO_HOLE1_BASE,GUEST_MMIO_HOLE1_SIZE
Quoted 7 lines
4.2 New entries in xenstore for device BARs
--------------------------------------------
toolkit also updates the xenstore information for the device (virtualbar:physical bar). This information is read by xenpciback and returned to the pcifront driver configuration space accesses.4.3 Hypercall for bdf mapping notification to xen
^v (I think) or maybe vs?
Quoted 14 lines
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };
Quoted 8 lines
Each domain has a pdev list, which contains the list of all pci devices. The pdev structure already has a sbdf information. The
arch_pci_devis updated to contain the gsbdf information. (gs- guest segment id)Whenever there is trap from guest or an interrupt has to be injected, the pdev list is iterated to find the gsbdf.
4.4 Change in Linux PCI ForntEnd - backend driver for MSI/X programming
Typo "Forntend"
Quoted 2 lines
-------------------------------------------------------------
On the Pci frontend bus a msi-parent as gicv3-its is added.
Are you talking about a device tree property or something else?
Note that pcifront is not described in the DT, only in the xenstore structure. So a dt property is unlikely to be the right way to describe this.
We need to think of some way of specifying this such that we don't tie ourselves into a single vits ABI.
Quoted 12 lines
As there is a single
virtual its for a domU, as there is only a single virtual pci bus in domU. This ensures that theconfig_msicalls are handled by the gicv3 its driver in domU kernel and not utilizing frontend-backend communication between dom0-domU.5. NUMA domU and vITS
-----------------------------
a) On NUMA systems domU still have a single its node.
b) How can xen identify the ITS on which a device is connected.
- Using segment number query using api which gives pci host controllers device node
Quoted 7 lines
struct dt_device_node*
pci_hostbridge_dt_node(uint32_t segno)c) Query the interrupt parent of the pci device node to find out the its.
6. DomU Bootup flow
---------------------
a. DomU boots up without any pci devices assigned.
I don't think we can/should rule out cold plug at this stage. IOW it must be possible to boot a domU with PCI devices already assigned.
Quoted 4 lines
A daemon listens to events
from the xenstore. When a device is attached to domU, the frontend pci bus driver starts enumerating the devices.Front end driver communicates with backend driver in dom0 to read the pci config space.
I'm afraid I don't follow any of this. What "daemon"? Is it in the front or backend? What does it do with the events it is listening for?
Quoted 8 lines
b. backend driver returns the virtual BAR ranges which are already mapped in domU stage 2 translation.
c. Device driver of the specific pci device invokes methods to configure the msi/x interrupt which are handled by the its driver in domU kernel. The read/writes by the its driver are trapped in xen. ITS driver finds out the actual sbdf based on the
map_sbdfhypercall information.
Quoted 9 lines · Julien Grall
Hi Manish,
Quoted 6 lines · Manish Jaggi
4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR regions.
These are defined inarch-arm.h
Quoted 7 lines
Quoted 5 lines
/* For 32bit */
GUEST_MMIO_HOLE0_BASE,GUEST_MMIO_HOLE0_SIZE/* For 64bit */
GUEST_MMIO_HOLE1_BASE,GUEST_MMIO_HOLE1_SIZEThe memory layout for 32bit and 64bit are exactly the same. Why do you need to differ here?
I think Ian has already replied. I will change the name of macro
Quoted 8 lines
Quoted 7 lines
4.2 New entries in xenstore for device BARs
--------------------------------------------
toolkit also updates the xenstore information for the device (virtualbar:physical bar).
This information is read by xenpciback and returned to the pcifront driver configuration
space accesses.Can you details what do you plan to put in xenstore and how?
It is implementation . But I plan to put under domU / device / heirarchy
Quoted 1 line
What about the expansion ROM?
Do you want to put some restriction on not using expansion ROM as a passthrough device.
Quoted 22 lines
Quoted 22 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices. The
pdev structure already has a sbdf information. Thearch_pci_devis updated to
contain the gsbdf information. (gs- guest segment id)
Quoted 6 lines
Quoted 3 lines
Whenever there is trap from guest or an interrupt has to be injected, the pdev
list is iterated to find the gsbdf.Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?
In the context of the hypercall processing.
Quoted 2 lines
- Who will call this hypercall?
- Why not setting the gsbdf when the device is assigned?
Can the maintainer of the pciback suggest an alternate.
The answer to your question is that I have only found a place to issue the hypercall where all the information can be located is the function__xen_pcibk_add_pci_dev
drivers/xen/xen-pciback/vpci.c
----
unlock:
...
kfree(dev_entry);
+ /*Issue Hypercall here */
+#ifdef CONFIG_ARM64
+ map_sbdf.domain_id = pdev->xdev->otherend_id;
+ map_sbdf.sbdf_s = dev->bus->domain_nr;
+ map_sbdf.sbdf_b = dev->bus->number;
+ map_sbdf.sbdf_d = dev->devfn>>3;
+ map_sbdf.sbdf_f = dev->devfn & 0x7;
+ map_sbdf.gsbdf_s = 0;
+ map_sbdf.gsbdf_b = 0;
+ map_sbdf.gsbdf_d = slot;
+ map_sbdf.gsbdf_f = dev->devfn & 0x7;
+ pr_info("## sbdf = %d:%d:%d.%d g_sbdf %d:%d:%d.%d \
+ domain_id=%d ##\r\n",
+ map_sbdf.sbdf_s,
+ map_sbdf.sbdf_b,
+ map_sbdf.sbdf_d,
+ map_sbdf.sbdf_f,
+ map_sbdf.gsbdf_s,
+ map_sbdf.gsbdf_b,
+ map_sbdf.gsbdf_d,
+ map_sbdf.gsbdf_f,
+ map_sbdf.domain_id);+
+ err = HYPERVISOR_physdev_op(PHYSDEVOP_map_sbdf, &map_sbdf);
+ if (err)
+ printk(KERN_ERR " Xen Error PHYSDEVOP_map_sbdf");
+#endif
---
Quoted 2 lines
Regards,
Quoted 52 lines · Manish Jaggi
Quoted 9 lines · Julien Grall
Hi Manish,
Quoted 6 lines · Manish Jaggi
4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR regions.
These are defined inarch-arm.hQuoted 6 lines
Quoted 4 lines
/* For 32bit */
GUEST_MMIO_HOLE0_BASE,GUEST_MMIO_HOLE0_SIZE
/* For 64bit */GUEST_MMIO_HOLE1_BASE,GUEST_MMIO_HOLE1_SIZEThe memory layout for 32bit and 64bit are exactly the same. Why do you need to differ here?
I think Ian has already replied. I will change the name of macro
Quoted 8 lines
Quoted 7 lines
4.2 New entries in xenstore for device BARs
--------------------------------------------
toolkit also updates the xenstore information for the device (virtualbar:physical bar).
This information is read by xenpciback and returned to the pcifront driver configuration
space accesses.Can you details what do you plan to put in xenstore and how?
It is implementation . But I plan to put under domU / device / heirarchy
Quoted 1 line
What about the expansion ROM?
Do you want to put some restriction on not using expansion ROM as a passthrough device.
Quoted 22 lines
Quoted 22 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices. The
pdev structure already has a sbdf information. Thearch_pci_devis updated to
contain the gsbdf information. (gs- guest segment id)
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Whenever there is trap from guest or an interrupt has to be injected, the pdev
list is iterated to find the gsbdf.Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?In the context of the hypercall processing.
The hypercall handler in xen, would call its_assign_device(sbdf, gsbdf, domid);
Quoted 51 lines
Quoted 2 lines
- Who will call this hypercall?
- Why not setting the gsbdf when the device is assigned?Can the maintainer of the pciback suggest an alternate.
The answer to your question is that I have only found a place to issue the hypercall where all the information can be located is the function__xen_pcibk_add_pci_dev
drivers/xen/xen-pciback/vpci.c
----
unlock:
...kfree(dev_entry);(quoted diff) +27
-1+ /*Issue Hypercall here */ +#ifdef CONFIG_ARM64 + map_sbdf.domain_id = pdev->xdev->otherend_id; + map_sbdf.sbdf_s = dev->bus->domain_nr; + map_sbdf.sbdf_b = dev->bus->number; + map_sbdf.sbdf_d = dev->devfn>>3; + map_sbdf.sbdf_f = dev->devfn & 0x7; + map_sbdf.gsbdf_s = 0; + map_sbdf.gsbdf_b = 0; + map_sbdf.gsbdf_d = slot; + map_sbdf.gsbdf_f = dev->devfn & 0x7; + pr_info("## sbdf = %d:%d:%d.%d g_sbdf %d:%d:%d.%d \ + domain_id=%d ##\r\n", + map_sbdf.sbdf_s, + map_sbdf.sbdf_b, + map_sbdf.sbdf_d, + map_sbdf.sbdf_f, + map_sbdf.gsbdf_s, + map_sbdf.gsbdf_b, + map_sbdf.gsbdf_d, + map_sbdf.gsbdf_f, + map_sbdf.domain_id); + + err = HYPERVISOR_physdev_op(PHYSDEVOP_map_sbdf, &map_sbdf); + if (err) + printk(KERN_ERR " Xen Error PHYSDEVOP_map_sbdf"); +#endif ---Quoted 3 lines
Regards,
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 26 lines · Manish Jaggi
Quoted 9 lines · Julien Grall
Hi Manish,
Quoted 6 lines · Manish Jaggi
4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR regions.
These are defined inarch-arm.hQuoted 7 lines
Quoted 5 lines
/* For 32bit */
GUEST_MMIO_HOLE0_BASE,GUEST_MMIO_HOLE0_SIZE/* For 64bit */
GUEST_MMIO_HOLE1_BASE,GUEST_MMIO_HOLE1_SIZEThe memory layout for 32bit and 64bit are exactly the same. Why do you need to differ here?
I think Ian has already replied. I will change the name of macro
Quoted 7 lines
Quoted 7 lines
4.2 New entries in xenstore for device BARs
--------------------------------------------
toolkit also updates the xenstore information for the device (virtualbar:physical bar).
This information is read by xenpciback and returned to the pcifront driver configuration
space accesses.
Quoted 2 lines
Quoted 1 line
Can you details what do you plan to put in xenstore and how?
It is implementation . But I plan to put under domU / device / heirarchy
Actually, xenstore is an API of sorts which needs to be maintained going forward (since front and backend can evolve separately, so it does need some level of design and documentation.
Quoted 3 lines
Quoted 1 line
What about the expansion ROM?
Do you want to put some restriction on not using expansion ROM as a passthrough device.
"expansion ROM as a passthrough device" doesn't make sense to me, passthrough devices may _have_ an expansion ROM.
The expansion ROM is just another BAR. I don't know how pcifront/back deal with those today on PV x86, but I see no reason for ARM to deviate.
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices. The
pdev structure already has a sbdf information. Thearch_pci_devis updated to
contain the gsbdf information. (gs- guest segment id)Whenever there is trap from guest or an interrupt has to be injected, the pdev
list is iterated to find the gsbdf.
Quoted 7 lines
Quoted 3 lines
Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?In the context of the hypercall processing.
Quoted 2 lines
- Who will call this hypercall?
- Why not setting the gsbdf when the device is assigned?Can the maintainer of the pciback suggest an alternate.
That's not me, but I don't think this belongs here, I think it can be done from the toolstack. If you think not then please explain what information the toolstack doesn't have in its possession which prevents this mapping from being done there.
Quoted 44 lines
The answer to your question is that I have only found a place to issue the hypercall where
all the information can be located is the function__xen_pcibk_add_pci_dev
drivers/xen/xen-pciback/vpci.c
----
unlock:
...kfree(dev_entry);(quoted diff) +27
-1+ /*Issue Hypercall here */ +#ifdef CONFIG_ARM64 + map_sbdf.domain_id = pdev->xdev->otherend_id; + map_sbdf.sbdf_s = dev->bus->domain_nr; + map_sbdf.sbdf_b = dev->bus->number; + map_sbdf.sbdf_d = dev->devfn>>3; + map_sbdf.sbdf_f = dev->devfn & 0x7; + map_sbdf.gsbdf_s = 0; + map_sbdf.gsbdf_b = 0; + map_sbdf.gsbdf_d = slot; + map_sbdf.gsbdf_f = dev->devfn & 0x7; + pr_info("## sbdf = %d:%d:%d.%d g_sbdf %d:%d:%d.%d \ + domain_id=%d ##\r\n", + map_sbdf.sbdf_s, + map_sbdf.sbdf_b, + map_sbdf.sbdf_d, + map_sbdf.sbdf_f, + map_sbdf.gsbdf_s, + map_sbdf.gsbdf_b, + map_sbdf.gsbdf_d, + map_sbdf.gsbdf_f, + map_sbdf.domain_id); + + err = HYPERVISOR_physdev_op(PHYSDEVOP_map_sbdf, &map_sbdf); + if (err) + printk(KERN_ERR " Xen Error PHYSDEVOP_map_sbdf"); +#endif ---Quoted 3 lines
Regards,
Quoted 69 lines · Ian Campbell
Quoted 25 lines · Manish Jaggi
Quoted 9 lines · Julien Grall
Hi Manish,
Quoted 6 lines · Manish Jaggi
4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR regions.
These are defined inarch-arm.hQuoted 7 lines
Quoted 5 lines
/* For 32bit */
GUEST_MMIO_HOLE0_BASE,GUEST_MMIO_HOLE0_SIZE/* For 64bit */
GUEST_MMIO_HOLE1_BASE,GUEST_MMIO_HOLE1_SIZEThe memory layout for 32bit and 64bit are exactly the same. Why do you need to differ here?
I think Ian has already replied. I will change the name of macro
Quoted 7 lines
Quoted 7 lines
4.2 New entries in xenstore for device BARs
--------------------------------------------
toolkit also updates the xenstore information for the device (virtualbar:physical bar).
This information is read by xenpciback and returned to the pcifront driver configuration
space accesses.Quoted 2 lines
Quoted 1 line
Can you details what do you plan to put in xenstore and how?
It is implementation . But I plan to put under domU / device / heirarchy
Actually, xenstore is an API of sorts which needs to be maintained going forward (since front and backend can evolve separately, so it does need some level of design and documentation.
Quoted 3 lines
Quoted 1 line
What about the expansion ROM?
Do you want to put some restriction on not using expansion ROM as a passthrough device.
"expansion ROM as a passthrough device" doesn't make sense to me, passthrough devices may _have_ an expansion ROM.
The expansion ROM is just another BAR. I don't know how pcifront/back deal with those today on PV x86, but I see no reason for ARM to deviate.
Quoted 27 lines
Quoted 27 lines
Quoted 21 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices. The
pdev structure already has a sbdf information. Thearch_pci_devis updated to
contain the gsbdf information. (gs- guest segment id)Quoted 3 lines
Whenever there is trap from guest or an interrupt has to be injected, the pdev
list is iterated to find the gsbdf.Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?
Quoted 8 lines
Quoted 4 lines
In the context of the hypercall processing.
Quoted 2 lines
- Who will call this hypercall?
- Why not setting the gsbdf when the device is assigned?Can the maintainer of the pciback suggest an alternate.
That's not me, but I don't think this belongs here, I think it can be done from the toolstack. If you think not then please explain what information the toolstack doesn't have in its possession which prevents this mapping from being done there.
The toolstack does not have the guest sbdf information. I could only find it in xenpciback.
Quoted 49 lines
Quoted 41 lines
The answer to your question is that I have only found a place to issue the hypercall where
all the information can be located is the function__xen_pcibk_add_pci_dev
drivers/xen/xen-pciback/vpci.c
----
unlock:
...kfree(dev_entry);(quoted diff) +27
-1+ /*Issue Hypercall here */ +#ifdef CONFIG_ARM64 + map_sbdf.domain_id = pdev->xdev->otherend_id; + map_sbdf.sbdf_s = dev->bus->domain_nr; + map_sbdf.sbdf_b = dev->bus->number; + map_sbdf.sbdf_d = dev->devfn>>3; + map_sbdf.sbdf_f = dev->devfn & 0x7; + map_sbdf.gsbdf_s = 0; + map_sbdf.gsbdf_b = 0; + map_sbdf.gsbdf_d = slot; + map_sbdf.gsbdf_f = dev->devfn & 0x7; + pr_info("## sbdf = %d:%d:%d.%d g_sbdf %d:%d:%d.%d \ + domain_id=%d ##\r\n", + map_sbdf.sbdf_s, + map_sbdf.sbdf_b, + map_sbdf.sbdf_d, + map_sbdf.sbdf_f, + map_sbdf.gsbdf_s, + map_sbdf.gsbdf_b, + map_sbdf.gsbdf_d, + map_sbdf.gsbdf_f, + map_sbdf.domain_id); + + err = HYPERVISOR_physdev_op(PHYSDEVOP_map_sbdf, &map_sbdf); + if (err) + printk(KERN_ERR " Xen Error PHYSDEVOP_map_sbdf"); +#endif ---Quoted 2 lines
Quoted 2 lines
Regards,
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 74 lines · Manish Jaggi
Quoted 72 lines · Ian Campbell
Quoted 25 lines · Manish Jaggi
Quoted 9 lines · Julien Grall
Hi Manish,
Quoted 6 lines · Manish Jaggi
4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR regions.
These are defined inarch-arm.hQuoted 7 lines
Quoted 5 lines
/* For 32bit */
GUEST_MMIO_HOLE0_BASE,GUEST_MMIO_HOLE0_SIZE/* For 64bit */
GUEST_MMIO_HOLE1_BASE,GUEST_MMIO_HOLE1_SIZEThe memory layout for 32bit and 64bit are exactly the same. Why do you need to differ here?
I think Ian has already replied. I will change the name of macro
Quoted 7 lines
Quoted 7 lines
4.2 New entries in xenstore for device BARs
--------------------------------------------
toolkit also updates the xenstore information for the device (virtualbar:physical bar).
This information is read by xenpciback and returned to the pcifront driver configuration
space accesses.Quoted 2 lines
Quoted 1 line
Can you details what do you plan to put in xenstore and how?
It is implementation . But I plan to put under domU / device / heirarchy
Actually, xenstore is an API of sorts which needs to be maintained going forward (since front and backend can evolve separately, so it does need some level of design and documentation.
Quoted 3 lines
Quoted 1 line
What about the expansion ROM?
Do you want to put some restriction on not using expansion ROM as a passthrough device.
"expansion ROM as a passthrough device" doesn't make sense to me, passthrough devices may _have_ an expansion ROM.
The expansion ROM is just another BAR. I don't know how pcifront/back deal with those today on PV x86, but I see no reason for ARM to deviate.
Quoted 30 lines
Quoted 21 lines
Quoted 21 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices. The
pdev structure already has a sbdf information. Thearch_pci_devis updated to
contain the gsbdf information. (gs- guest segment id)Quoted 6 lines
Quoted 3 lines
Whenever there is trap from guest or an interrupt has to be injected, the pdev
list is iterated to find the gsbdf.Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?In the context of the hypercall processing.
Quoted 2 lines
- Who will call this hypercall?
- Why not setting the gsbdf when the device is assigned?
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Can the maintainer of the pciback suggest an alternate.
That's not me, but I don't think this belongs here, I think it can be done from the toolstack. If you think not then please explain what information the toolstack doesn't have in its possession which prevents this mapping from being done there.
The toolstack does not have the guest sbdf information. I could only find it in xenpciback.
Are you sure? The sbdf relates to the physical device, correct? If so then surely the toolstack knows it -- it's written in the config file and is the primary parameter to all of the related libxl passthrough APIs. The toolstack wouldn't be able to do anything about passing through a given device without knowing which device it should be passing through.
Perhaps this info needs plumbing through to some new bit of the toolstack, but it is surely available somewhere.
If you meant the virtual SBDF then that is in libxl_device_pci.vdevfn.
Ian.
Quoted 21 lines · Manish Jaggi
Quoted 21 lines
Quoted 21 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices. The
pdev structure already has a sbdf information. Thearch_pci_devis updated to
contain the gsbdf information. (gs- guest segment id)
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Whenever there is trap from guest or an interrupt has to be injected, the pdev
list is iterated to find the gsbdf.Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?In the context of the hypercall processing.
That wasn't my question. I asked, how Xen will find the mapping between the gdbf and vDeviceID? He doesn't have access to the firmware table and therefore not able to find the right one.
Regards,
Signature · 1 line
Julien Grall
Quoted 25 lines · Julien Grall
Quoted 24 lines · Manish Jaggi
Quoted 24 lines
Quoted 24 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices. The
pdev structure already has a sbdf information. Thearch_pci_devis updated to
contain the gsbdf information. (gs- guest segment id)Whenever there is trap from guest or an interrupt has to be injected, the pdev
list is iterated to find the gsbdf.
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?In the context of the hypercall processing.
That wasn't my question. I asked, how Xen will find the mapping between the gdbf and vDeviceID? He doesn't have access to the firmware table and therefore not able to find the right one.
I believe gsbdf and vDeviceID would be same. In the hypercall processing its_assign_device would be called with params its_assign_device(sbdf, gsbdf, domid)
Quoted 3 lines
Regards,
Quoted 29 lines · Manish Jaggi
Quoted 26 lines · Julien Grall
Quoted 25 lines · Manish Jaggi
Quoted 25 lines
Quoted 25 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices.
The
pdev structure already has a sbdf information. Thearch_pci_devis updated to
contain the gsbdf information. (gs- guest segment id)Whenever there is trap from guest or an interrupt has to be injected, the pdev
list is iterated to find the gsbdf.
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?In the context of the hypercall processing.
That wasn't my question. I asked, how Xen will find the mapping between the gdbf and vDeviceID? He doesn't have access to the firmware table and therefore not able to find the right one.
I believe gsbdf and vDeviceID would be same.
Xen and the guest need to translate the gsbdf the same way. If this is clearly defined by a spec, then you should give a link to it.
If not, you have to explain in this design doc how you plan to have xen and the guest using the same vdevID for a given gsbdf.
Regards,
Signature · 1 line
Julien Grall
Quoted 32 lines · Julien Grall
Quoted 31 lines · Manish Jaggi
Quoted 29 lines · Julien Grall
Quoted 28 lines · Manish Jaggi
Quoted 28 lines
Quoted 22 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices.
The
pdev structure already has a sbdf information. Thearch_pci_devis updated to
contain the gsbdf information. (gs- guest segment id)Quoted 3 lines
Whenever there is trap from guest or an interrupt has to be injected, the pdev
list is iterated to find the gsbdf.Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
In the context of the hypercall processing.
That wasn't my question. I asked, how Xen will find the mapping between the gdbf and vDeviceID? He doesn't have access to the firmware table and therefore not able to find the right one.
I believe gsbdf and vDeviceID would be same.
Xen and the guest need to translate the gsbdf the same way. If this is clearly defined by a spec, then you should give a link to it.
They are same, will change sbdf ->DeviceID and gsbdf->vDeviceID.
Quoted 5 lines
If not, you have to explain in this design doc how you plan to have xen and the guest using the same vdevID for a given gsbdf.
Regards,
Hi Manish,
Quoted 35 lines · Manish Jaggi
Quoted 34 lines · Julien Grall
Quoted 33 lines · Manish Jaggi
Quoted 31 lines · Julien Grall
Quoted 30 lines · Manish Jaggi
Quoted 22 lines
Quoted 22 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices.
The
pdev structure already has a sbdf information. Thearch_pci_devis updated to
contain the gsbdf information. (gs- guest segment id)Quoted 7 lines
Quoted 4 lines
Whenever there is trap from guest or an interrupt has to be injected,
the pdev
list is iterated to find the gsbdf.Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?In the context of the hypercall processing.
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
That wasn't my question. I asked, how Xen will find the mapping between the gdbf and vDeviceID? He doesn't have access to the firmware table and
therefore not able to find the right one.I believe gsbdf and vDeviceID would be same.
Xen and the guest need to translate the gsbdf the same way. If this is clearly defined by a spec, then you should give a link to it.
They are same, will change sbdf ->DeviceID and
gsbdf->vDeviceID.
As asked you in the previous mail, can you please prove it? The function used to get the requester ID (pci_for_each_dma_alias) is more complex than a simple return sbdf.
Furthermore, AFAICT, the IORT Table (from ACPI) [1] is used to specify the relationships between the requester ID and the DeviceID. So it's not obvious that sbdf == DeviceID.
Quoted 6 lines
Quoted 5 lines
If not, you have to explain in this design doc how you plan to have xen and the guest using the same vdevID for a given gsbdf.
Regards,
[1] http://infocenter.arm.com/help/topic/com.arm.doc.den0049a/DEN0049A_IO_Remapping_Table.pdf
Signature · 1 line
Julien Grall
Quoted 42 lines · Julien Grall
Hi Manish,
Quoted 39 lines · Manish Jaggi
Quoted 38 lines · Julien Grall
Quoted 37 lines · Manish Jaggi
Quoted 35 lines · Julien Grall
Quoted 22 lines · Manish Jaggi
Quoted 22 lines
Quoted 22 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices.
The
pdev structure already has a sbdf information. Thearch_pci_devis updated to
contain the gsbdf information. (gs- guest segment id)Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Whenever there is trap from guest or an interrupt has to be injected,
the pdev
list is iterated to find the gsbdf.Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?In the context of the hypercall processing.
That wasn't my question. I asked, how Xen will find the mapping between the gdbf and vDeviceID? He doesn't have access to the firmware table and
therefore not able to find the right one.
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
I believe gsbdf and vDeviceID would be same.
Xen and the guest need to translate the gsbdf the same way. If this is clearly defined by a spec, then you should give a link to it.
They are same, will change sbdf ->DeviceID and
gsbdf->vDeviceID.As asked you in the previous mail, can you please prove it? The function used to get the requester ID (
pci_for_each_dma_alias) is more complex than a simple return sbdf.
I am not sure what you would like me to prove.
As of ThunderX Xen code we have assumed sbdf == deviceID. We are not using ACPI as of now. This is our implementation. It cannot be wrong outrightly. Can you please suggest what could be the other approach.
Quoted 13 lines
Furthermore, AFAICT, the IORT Table (from ACPI) [1] is used to specify the relationships between the requester ID and the DeviceID. So it's not obvious that sbdf == DeviceID.
Quoted 6 lines
Quoted 5 lines
If not, you have to explain in this design doc how you plan to have xen and the guest using the same vdevID for a given gsbdf.
Regards,
[1] http://infocenter.arm.com/help/topic/com.arm.doc.den0049a/DEN0049A_IO_Remapping_Table.pdf
Quoted 46 lines · Manish Jaggi
Quoted 43 lines · Julien Grall
Hi Manish,
Quoted 40 lines · Manish Jaggi
Quoted 39 lines · Julien Grall
Quoted 38 lines · Manish Jaggi
Quoted 27 lines · Julien Grall
Quoted 26 lines · Manish Jaggi
Quoted 26 lines
Quoted 26 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices.
The
pdev structure already has a sbdf information. Thearch_pci_devis updated to
contain the gsbdf information. (gs- guest segment id)Whenever there is trap from guest or an interrupt has to be injected,
the pdev
list is iterated to find the gsbdf.Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?In the context of the hypercall processing.
That wasn't my question. I asked, how Xen will find the mapping between the gdbf and vDeviceID? He doesn't have access to the firmware table and
therefore not able to find the right one.I believe gsbdf and vDeviceID would be same.
Quoted 21 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
Xen and the guest need to translate the gsbdf the same way. If this is clearly defined by a spec, then you should give a link to it.
They are same, will change sbdf ->DeviceID and
gsbdf->vDeviceID.As asked you in the previous mail, can you please prove it? The function used to get the requester ID (
pci_for_each_dma_alias) is more complex than a simple return sbdf.I am not sure what you would like me to prove.
As of ThunderX Xen code we have assumed sbdf == deviceID. We are not using ACPI as of now. This is our implementation. It cannot be wrong outrightly. Can you please suggest what could be the other approach.Quoted 12 lines
Furthermore, AFAICT, the IORT Table (from ACPI) [1] is used to specify the relationships between the requester ID and the DeviceID. So it's not obvious that sbdf == DeviceID.
Quoted 6 lines
Quoted 5 lines
If not, you have to explain in this design doc how you plan to have xen and the guest using the same vdevID for a given gsbdf.
Regards,
[1] http://infocenter.arm.com/help/topic/com.arm.doc.den0049a/DEN0049A_IO_Remapping_Table.pdf
If ACPI is not used IORT (sbdf - StreamID - deviceID mapping) has to be done in device tree. Can we add this as a TODO. So that first series of patches can be accepted with StreamID == DeviceID = sbdf
Quoted 7 lines
Quoted 1 line
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 5 lines · Manish Jaggi
Quoted 3 lines
As asked you in the previous mail, can you please prove it? The function used to get the requester ID (
pci_for_each_dma_alias) is more complex than a simple return sbdf.I am not sure what you would like me to prove. As of ThunderX Xen code we have assumed sbdf == deviceID.
Please remember that you are not writing "ThunderX Xen code" here, you are writing generic Xen code which you happen to be testing on Thunder X. The design and implementation does need to consider the more generic case I'm afraid.
In particular if this is going to be a PHYSDEVOP then it needs to be designed to be future proof, since PHYSDEVOP is a stable API i.e. it is hard to change in the future.
I think I did ask elsewhere _why_ this was a physdev op, since I can't see why it can't be done by the toolstack, and therefore why it can't be a domctl.
If this was a domctl there might be scope for accepting an implementation which made assumptions such as sbdf == deviceid. However I'd still like to see this topic given proper treatment in the design and not just glossed over with "this is how ThunderX does things".
Or maybe the solution is simple and we should just do it now -- i.e. can we add a new field to the PHYSDEVOP_pci_host_bridge_add argument struct which contains the base deviceid for that bridge (since I believe both DT and ACPI IORT assume a simple linear mapping[citation needed])?
Ian.
Quoted 92 lines · Manish Jaggi
Quoted 9 lines · Julien Grall
Hi Manish,
Quoted 6 lines · Manish Jaggi
4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR regions.
These are defined inarch-arm.hQuoted 6 lines
Quoted 4 lines
/* For 32bit */
GUEST_MMIO_HOLE0_BASE,GUEST_MMIO_HOLE0_SIZE
/* For 64bit */GUEST_MMIO_HOLE1_BASE,GUEST_MMIO_HOLE1_SIZEThe memory layout for 32bit and 64bit are exactly the same. Why do you need to differ here?
I think Ian has already replied. I will change the name of macro
Quoted 8 lines
Quoted 7 lines
4.2 New entries in xenstore for device BARs
--------------------------------------------
toolkit also updates the xenstore information for the device (virtualbar:physical bar).
This information is read by xenpciback and returned to the pcifront driver configuration
space accesses.Can you details what do you plan to put in xenstore and how?
It is implementation . But I plan to put under domU / device / heirarchy
Quoted 1 line
What about the expansion ROM?
Do you want to put some restriction on not using expansion ROM as a passthrough device.
Quoted 22 lines
Quoted 22 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices. The
pdev structure already has a sbdf information. Thearch_pci_devis updated to
contain the gsbdf information. (gs- guest segment id)Quoted 6 lines
Quoted 3 lines
Whenever there is trap from guest or an interrupt has to be injected, the pdev
list is iterated to find the gsbdf.Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?In the context of the hypercall processing.
Quoted 2 lines
- Who will call this hypercall?
- Why not setting the gsbdf when the device is assigned?Can the maintainer of the pciback suggest an alternate.
The answer to your question is that I have only found a place to issue the hypercall where
all the information can be located is the function__xen_pcibk_add_pci_dev
drivers/xen/xen-pciback/vpci.c
----
unlock:
...kfree(dev_entry);(quoted diff) +17
-0+ /*Issue Hypercall here */ +#ifdef CONFIG_ARM64 + map_sbdf.domain_id = pdev->xdev->otherend_id; + map_sbdf.sbdf_s = dev->bus->domain_nr; + map_sbdf.sbdf_b = dev->bus->number; + map_sbdf.sbdf_d = dev->devfn>>3; + map_sbdf.sbdf_f = dev->devfn & 0x7; + map_sbdf.gsbdf_s = 0; + map_sbdf.gsbdf_b = 0; + map_sbdf.gsbdf_d = slot; + map_sbdf.gsbdf_f = dev->devfn & 0x7; + pr_info("## sbdf = %d:%d:%d.%d g_sbdf %d:%d:%d.%d \ + domain_id=%d ##\r\n", + map_sbdf.sbdf_s, + map_sbdf.sbdf_b, + map_sbdf.sbdf_d, + map_sbdf.sbdf_f,
Review
Quoted 10 lines
(quoted diff) +10
-0+ map_sbdf.gsbdf_s, + map_sbdf.gsbdf_b, + map_sbdf.gsbdf_d, + map_sbdf.gsbdf_f, + map_sbdf.domain_id); + + err = HYPERVISOR_physdev_op(PHYSDEVOP_map_sbdf, &map_sbdf); + if (err) + printk(KERN_ERR " Xen Error PHYSDEVOP_map_sbdf"); +#endif
You probably also need the inverse - that is when xen_pcibk_release_pci_dev is called.
I would suggest you instead add in drivers/xen/xen-pciback/pciback.h for xen_pcibk_add_pci_dev and xen_pcibk_release_pci_dev an call to the arch specific code for this hypercall. On x86 it would be a nop while for ARM it would the above.
Quoted 5 lines
---
Quoted 2 lines
Regards,
Quoted 11 lines · Ian Campbell
Quoted 5 lines · Manish Jaggi
Quoted 3 lines
As asked you in the previous mail, can you please prove it? The function used to get the requester ID (
pci_for_each_dma_alias) is more complex than a simple return sbdf.I am not sure what you would like me to prove. As of ThunderX Xen code we have assumed sbdf == deviceID.
Please remember that you are not writing "ThunderX Xen code" here, you are writing generic Xen code which you happen to be testing on Thunder X. The design and implementation does need to consider the more generic case I'm afraid.
Quoted 7 lines
In particular if this is going to be a PHYSDEVOP then it needs to be designed to be future proof, since PHYSDEVOP is a stable API i.e. it is hard to change in the future.
I think I did ask elsewhere _why_ this was a physdev op, since I can't see why it can't be done by the toolstack, and therefore why it can't be a domctl.
If it can be done in domctl I prefer that. Will get back on this.
Quoted 5 lines
If this was a domctl there might be scope for accepting an implementation which made assumptions such as sbdf == deviceid. However I'd still like to see this topic given proper treatment in the design and not just glossed over with "this is how ThunderX does things".
I got your point.
Quoted 3 lines
Or maybe the solution is simple and we should just do it now -- i.e. can we add a new field to the
PHYSDEVOP_pci_host_bridge_addargument struct which contains the base deviceid for that bridge
deviceId would be same as sbdf. As we dont have a way to translate sbdf to deviceID. What about SMMU streamID, can we also have sbdf = deviceID = smmuid_bdf
FYI: In thunder each RC is on a separate smmu.
Can we take that as step1.
Quoted 2 lines
(since I believe both
DT and ACPI IORT assume a simple linear mapping[citation needed])?
I am ok with the approach but then we have to put something similar to IORT in device tree. Currently it is not there.
If we take that route of creating IORT for host / guest it would be altogether different effort.
Quoted 7 lines
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Hi Manish,
Quoted 11 lines · Manish Jaggi
Quoted 5 lines
If this was a domctl there might be scope for accepting an implementation which made assumptions such as sbdf == deviceid. However I'd still like to see this topic given proper treatment in the design and not just glossed over with "this is how ThunderX does things".
I got your point.
Quoted 3 lines
Or maybe the solution is simple and we should just do it now -- i.e. can we add a new field to the
PHYSDEVOP_pci_host_bridge_addargument struct which contains the base deviceid for that bridgedeviceId would be same as sbdf. As we dont have a way to translate sbdf to deviceID.
I think we have to be clear in this design document about the different meaning.
When the Device Tree is used, it's assumed that the deviceID will be equal to the requester ID and not the sbdf.
Linux provides a function (pci_for_each_dma_alias) which will return a requester ID for a given PCI device. It appears that the BDF (the 's' of sBDF is only internal to Linux and not part of the hardware) is equal to the requester ID on your platform but we can't assume it for anyone else.
When we have a PCI in hand, we have to find the requester ID for this device. On we have it we can deduce the streamID and the deviceID. The way to do it will depend on whether we use device tree or ACPI:
- For device tree, the streamID, and deviceID will be equal to the
requester ID
- For ACPI, we would have to look up in the ACPI IORT.
For the latter, I think they are static tables and therefore can be parse in Xen. So we wouldn't need to PHYSDEVOP_pci_host_bridge_add to pass an offset. This will also avoid any assumption that deviceID for a given root complex are always contiguous and make extendable for any new hardware require a different *ID.
So what we really care is the requester ID. Although, I'm not sure if you can find it in Xen. If not, we may need to customize (i.e adding a new PHYSDEVOP) PCI add device to take a requesterID in parameter.
Now, in the case of the guest, as we are only supporting device tree, we could make the assumption that requesterID == deviceID as long as this is exposed in a DOMCTL to allow us flexibility.
It would make sense to extend DOMCTL_assign_device to take the vBDF (or requesterID?) in parameter.
Regards,
Signature · 1 line
Julien Grall
Quoted 12 lines · Julien Grall
Hi Manish,
Quoted 9 lines · Manish Jaggi
Quoted 5 lines
If this was a domctl there might be scope for accepting an implementation which made assumptions such as sbdf == deviceid. However I'd still like to see this topic given proper treatment in the design and not just glossed over with "this is how ThunderX does things".
I got your point.
Quoted 3 lines
Or maybe the solution is simple and we should just do it now -- i.e. can we add a new field to the
PHYSDEVOP_pci_host_bridge_addargument struct which contains the base deviceid for that bridge
Quoted 6 lines
Quoted 2 lines
deviceId would be same as sbdf. As we dont have a way to translate sbdf to deviceID.
I think we have to be clear in this design document about the different meaning.
When the Device Tree is used, it's assumed that the deviceID will be equal to the requester ID and not the sbdf.
Does SMMU v2 has a concept of requesterID.
I see requesterID term in SMMUv3
Quoted 2 lines
Linux provides a function (
pci_for_each_dma_alias) which will return a requester ID for a given PCI device. It appears that the BDF (the 's' of sBDF is only internal to Linux and not part of the hardware) is equal to the requester ID on your platform but we can't assume it for anyone else.
so you mean requesterID = pci_for_each_dma_alias(sbdf)
Quoted 2 lines
When we have a PCI in hand, we have to find the requester ID for this device.
That is the question. How to map requesterID to sbdf
Quoted 1 line
On
Once ?
Quoted 3 lines
we have it we can deduce the streamID and the deviceID. The way to do it will depend on whether we use device tree or ACPI:
- For device tree, the streamID, and deviceID will be equal to the
requester ID
what do you think should be streamID when a device is PCI EP and is enumerated. Also per ARM SMMU 2.0 spec StreamID is implementation specific. As per SMMUv3 specs
"For PCI, it is intended that StreamID is generated from the PCI RequesterID. The generation function may be 1:1
where one Root Complex is hosted by one SMMU"
Quoted 12 lines
- For ACPI, we would have to look up in the ACPI IORT.
For the latter, I think they are static tables and therefore can be parse in Xen. So we wouldn't need to
PHYSDEVOP_pci_host_bridge_addto pass an offset. This will also avoid any assumption that deviceID for a given root complex are always contiguous and make extendable for any new hardware require a different *ID.So what we really care is the requester ID. Although, I'm not sure if you can find it in Xen. If not, we may need to customize (i.e adding a new PHYSDEVOP) PCI add device to take a requesterID in parameter.
Now, in the case of the guest, as we are only supporting device tree, we could make the assumption that requesterID == deviceID as long as this is exposed in a DOMCTL to allow us flexibility.
It would make sense to extend
DOMCTL_assign_deviceto take the vBDF (or requesterID?) in parameter.Regards,
Quoted 15 lines · Manish Jaggi
Quoted 14 lines · Julien Grall
Quoted 12 lines · Manish Jaggi
Quoted 5 lines
If this was a domctl there might be scope for accepting an implementation which made assumptions such as sbdf == deviceid. However I'd still like to see this topic given proper treatment in the design and not just glossed over with "this is how ThunderX does things".
I got your point.
Quoted 4 lines
Or maybe the solution is simple and we should just do it now -- i.e. can
we add a new field to thePHYSDEVOP_pci_host_bridge_addargument struct which contains the base deviceid for that bridgedeviceId would be same as sbdf. As we dont have a way to translate sbdf to deviceID.
Quoted 7 lines
Quoted 5 lines
I think we have to be clear in this design document about the different meaning.
When the Device Tree is used, it's assumed that the deviceID will be equal to the requester ID and not the sbdf.
Does SMMU v2 has a concept of requesterID.
I see requesterID term in SMMUv3
The requester ID is part of the PCI spec and not the SMMU.
The version of the SMMUv2 spec doesn't mention anything about PCI. I suspect this is because the spec has been written before the introduced PCI. And therefore this is implementation defined.
Quoted 7 lines
Quoted 6 lines
Linux provides a function (
pci_for_each_dma_alias) which will return a requester ID for a given PCI device. It appears that the BDF (the 's' of sBDF is only internal to Linux and not part of the hardware) is equal to the requester ID on your platform but we can't assume it for anyone else.so you mean requesterID =
pci_for_each_dma_alias(sbdf)
Yes.
Quoted 4 lines
Quoted 3 lines
When we have a PCI in hand, we have to find the requester ID for this device.
That is the question. How to map requesterID to sbdf
See above.
Quoted 2 lines
Quoted 1 line
On
Once ?
Yes.
Quoted 11 lines
Quoted 4 lines
we have it we can deduce the streamID and the deviceID. The way to do it will depend on whether we use device tree or ACPI:
- For device tree, the streamID, and deviceID will be equal to the
requester IDwhat do you think should be streamID when a device is PCI EP and is enumerated. Also per ARM SMMU 2.0 spec StreamID is implementation specific.
As per SMMUv3 specs
"For PCI, it is intended that StreamID is generated from the PCI RequesterID. The generation function may be 1:1
where one Root Complex is hosted by one SMMU"
I think my sentence "For device tree, the streamID, and deviceID will be equal to the requester ID" is pretty clear. FWIW, this is the solution chosen for Linux:
"Assume Stream ID == Requester ID for now. We need a way to describe the ID mappings in FDT" (see arm_smmu_add_pci_device in drivers/iommu/arm-smmu.c).
You can refer to my point below about ACPI tables. The solution would be exactly the same. If we have a requester ID in hand we can do pretty much everything.
The whole point of my previous email is to give insight about what we need and what we can deduce based on firmware tables. I didn't cover anything implementation details.
Regards,
Signature · 1 line
Julien Grall
Quoted 87 lines · Julien Grall
Quoted 22 lines · Manish Jaggi
Quoted 20 lines · Julien Grall
Quoted 16 lines · Manish Jaggi
Quoted 6 lines
If this was a domctl there might be scope for accepting an implementation which made assumptions such as sbdf == deviceid. However I'd still like to see this topic given proper treatment in the design and not just glossed over with "this is how ThunderX does things".
I got your point.
Quoted 5 lines
Or maybe the solution is simple and we should just do it now -- i.e. can
we add a new field to thePHYSDEVOP_pci_host_bridge_addargument struct which contains the base deviceid for that bridgedeviceId would be same as sbdf. As we dont have a way to translate sbdf to deviceID.
Quoted 8 lines
Quoted 5 lines
I think we have to be clear in this design document about the different meaning.
When the Device Tree is used, it's assumed that the deviceID will be equal to the requester ID and not the sbdf.
Does SMMU v2 has a concept of requesterID.
I see requesterID term in SMMUv3The requester ID is part of the PCI spec and not the SMMU.
The version of the SMMUv2 spec doesn't mention anything about PCI. I suspect this is because the spec has been written before the introduced PCI. And therefore this is implementation defined.
Quoted 8 lines
Quoted 6 lines
Linux provides a function (
pci_for_each_dma_alias) which will return a requester ID for a given PCI device. It appears that the BDF (the 's' of sBDF is only internal to Linux and not part of the hardware) is equal to the requester ID on your platform but we can't assume it for anyone else.so you mean requesterID =
pci_for_each_dma_alias(sbdf)Yes.
Quoted 5 lines
Quoted 3 lines
When we have a PCI in hand, we have to find the requester ID for this device.
That is the question. How to map requesterID to sbdf
See above.
Quoted 3 lines
Quoted 1 line
On
Once ?
Yes.
Quoted 5 lines
Quoted 4 lines
we have it we can deduce the streamID and the deviceID. The way to do it will depend on whether we use device tree or ACPI:
- For device tree, the streamID, and deviceID will be equal to the
requester IDQuoted 7 lines
what do you think should be streamID when a device is PCI EP and is enumerated. Also per ARM SMMU 2.0 spec StreamID is implementation specific.
As per SMMUv3 specs
"For PCI, it is intended that StreamID is generated from the PCI RequesterID. The generation function may be 1:1
where one Root Complex is hosted by one SMMU"I think my sentence "For device tree, the streamID, and deviceID will be equal to the requester ID" is pretty clear. FWIW, this is the solution chosen for Linux:
Quoted 6 lines
"Assume Stream ID == Requester ID for now. We need a way to describe the ID mappings in FDT" (see
arm_smmu_add_pci_deviceindrivers/iommu/arm-smmu.c).You can refer to my point below about ACPI tables. The solution would be exactly the same. If we have a requester ID in hand we can do pretty much everything.
There is already one proposal by Mark Rutland on this topic about describing StreamID to Requester ID mapping in DT.
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/333199.html
Probably till it gets finalized assuming RequesterID=StreamId is the only way since deriving StreamID from PCIe RequsterID will vary from one vendor to another.
Thanks,
Pranav
Quoted 15 lines
The whole point of my previous email is to give insight about what we need and what we can deduce based on firmware tables. I didn't cover anything implementation details.
Regards,
--
Julien Grall_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 18 lines · Julien Grall
Hi Manish,
Quoted 11 lines · Manish Jaggi
Quoted 5 lines
If this was a domctl there might be scope for accepting an implementation which made assumptions such as sbdf == deviceid. However I'd still like to see this topic given proper treatment in the design and not just glossed over with "this is how ThunderX does things".
I got your point.
Quoted 3 lines
Or maybe the solution is simple and we should just do it now -- i.e. can we add a new field to the
PHYSDEVOP_pci_host_bridge_addargument struct which contains the base deviceid for that bridgedeviceId would be same as sbdf. As we dont have a way to translate sbdf to deviceID.
I think we have to be clear in this design document about the different meaning.
Quoted 7 lines
When the Device Tree is used, it's assumed that the deviceID will be equal to the requester ID and not the sbdf.
Linux provides a function (
pci_for_each_dma_alias) which will return a requester ID for a given PCI device. It appears that the BDF (the 's' of sBDF is only internal to Linux and not part of the hardware) is equal to the requester ID on your platform but we can't assume it for anyone else.
The PCI Express Base Specification states that the requester ID is "The combination of a Requester's Bus Number, Device Number, and Function Number that uniquely identifies the Requester."
I think it is safe to assume BDF = requester ID on all platforms.
Quoted 6 lines
When we have a PCI in hand, we have to find the requester ID for this device. On we have it we can deduce the streamID and the deviceID. The way to do it will depend on whether we use device tree or ACPI:
- For device tree, the streamID, and deviceID will be equal to the
requester ID
- For ACPI, we would have to look up in the ACPI IORT.
This is true.
For now, given that the implementation is device tree only, we can go forward with the assumption that streamID == deviceID == requesterID, as long as it is clearly written down.
Quoted 1 line
So what we really care is the requester ID.
Indeed, but that's the BDF.
Quoted 3 lines
Although, I'm not sure if you can
find it in Xen. If not, we may need to customize (i.e adding a new PHYSDEVOP) PCI add device to take a requesterID in parameter.
I think there is no need. Let's just write down in a comment that we assume BDF == requester id.
Quoted 3 lines
Now, in the case of the guest, as we are only supporting device tree, we could make the assumption that requesterID == deviceID as long as this is exposed in a DOMCTL to allow us flexibility.
Yep
Quoted 2 lines
It would make sense to extend
DOMCTL_assign_deviceto take the vBDF (or requesterID?) in parameter.
Could be a good idea
Quoted 27 lines · Stefano Stabellini
Quoted 18 lines · Julien Grall
Hi Manish,
Quoted 11 lines · Manish Jaggi
Quoted 5 lines
If this was a domctl there might be scope for accepting an implementation which made assumptions such as sbdf == deviceid. However I'd still like to see this topic given proper treatment in the design and not just glossed over with "this is how ThunderX does things".
I got your point.
Quoted 3 lines
Or maybe the solution is simple and we should just do it now -- i.e. can we add a new field to the
PHYSDEVOP_pci_host_bridge_addargument struct which contains the base deviceid for that bridgedeviceId would be same as sbdf. As we dont have a way to translate sbdf to deviceID.
I think we have to be clear in this design document about the different meaning.
Quoted 7 lines
When the Device Tree is used, it's assumed that the deviceID will be equal to the requester ID and not the sbdf.
Linux provides a function (
pci_for_each_dma_alias) which will return a requester ID for a given PCI device. It appears that the BDF (the 's' of sBDF is only internal to Linux and not part of the hardware) is equal to the requester ID on your platform but we can't assume it for anyone else.
Quoted 5 lines
The PCI Express Base Specification states that the requester ID is "The combination of a Requester's Bus Number, Device Number, and Function Number that uniquely identifies the Requester."
I think it is safe to assume BDF = requester ID on all platforms.
With the catch that in case of ARI devices
(http://pcisig.com/sites/default/files/specification_documents/ECN-alt-rid-interpretation-070604.pdf),
BDF is actually BF because the device number is always 0 and the function number is 8 bits.
Quoted 16 lines · Ian Campbell
Quoted 5 lines · Manish Jaggi
Quoted 3 lines
As asked you in the previous mail, can you please prove it? The function used to get the requester ID (
pci_for_each_dma_alias) is more complex than a simple return sbdf.I am not sure what you would like me to prove. As of ThunderX Xen code we have assumed sbdf == deviceID.
Please remember that you are not writing "ThunderX Xen code" here, you are writing generic Xen code which you happen to be testing on Thunder X. The design and implementation does need to consider the more generic case I'm afraid.
In particular if this is going to be a PHYSDEVOP then it needs to be designed to be future proof, since PHYSDEVOP is a stable API i.e. it is hard to change in the future.
Quoted 6 lines
I think I did ask elsewhere _why_ this was a physdev op, since I can't see why it can't be done by the toolstack, and therefore why it can't be a domctl.
If this was a domctl there might be scope for accepting an implementation which made assumptions such as sbdf == deviceid.
It is always easier to deal with domctls compared to physdebops, so I agree with Ian. However I think we can assume BDF = requester ID, as I wrote earlier.
Quoted 3 lines
However
I'd still like to see this topic given proper treatment in the design and not just glossed over with "this is how ThunderX does things".
right
Quoted 4 lines
Or maybe the solution is simple and we should just do it now -- i.e. can we add a new field to the
PHYSDEVOP_pci_host_bridge_addargument struct which contains the base deviceid for that bridge (since I believe both DT and ACPI IORT assume a simple linear mapping[citation needed])?
Expanding XEN_DOMCTL_assign_device is also a good option
Hi Stefano,
Quoted 9 lines · Stefano Stabellini
Quoted 9 lines
Quoted 4 lines
Linux provides a function (
pci_for_each_dma_alias) which will return a requester ID for a given PCI device. It appears that the BDF (the 's' of sBDF is only internal to Linux and not part of the hardware) is equal to the requester ID on your platform but we can't assume it for anyone else.The PCI Express Base Specification states that the requester ID is "The combination of a Requester's Bus Number, Device Number, and Function Number that uniquely identifies the Requester."
Quoted 6 lines
Quoted 1 line
I think it is safe to assume BDF = requester ID on all platforms.
With the catch that in case of ARI devices
(http://pcisig.com/sites/default/files/specification_documents/ECN-alt-rid-interpretation-070604.pdf),
BDF is actually BF because the device number is always 0 and the function number is 8 bits.
And some other problem such as broken PCI device...
Both Xen x86 (domain_context_mapping in drivers/passthrough/vtd/iommu.c) and Linux (pci_dma_for_each_alias) use a code more complex than requesterID = BDF.
So I don't think we can use requesterID = BDF in physdev op unless we are *stricly* sure this is valid.
Although, based on the x86 code, Xen should be able to translate the BDF into the requester ID...
Regards,
Signature · 1 line
Julien Grall
Quoted 20 lines · Julien Grall
Hi Stefano,
Quoted 10 lines · Stefano Stabellini
Quoted 10 lines
Quoted 5 lines
Linux provides a function (
pci_for_each_dma_alias) which will return a requester ID for a given PCI device. It appears that the BDF (the 's' of sBDF
is only internal to Linux and not part of the hardware) is equal to the requester ID on your platform but we can't assume it for anyone else.The PCI Express Base Specification states that the requester ID is "The combination of a Requester's Bus Number, Device Number, and Function Number that uniquely identifies the Requester."
Quoted 6 lines
Quoted 1 line
I think it is safe to assume BDF = requester ID on all platforms.
With the catch that in case of ARI devices
(http://pcisig.com/sites/default/files/specification_documents/ECN-alt-rid-interpretation-070604.pdf),
BDF is actually BF because the device number is always 0 and the function number is 8 bits.
Quoted 6 lines
And some other problem such as broken PCI device...
Both Xen x86 (domain_context_mappingindrivers/passthrough/vtd/iommu.c) and Linux (pci_dma_for_each_alias) use a code more complex than requesterID = BDF.So I don't think we can use requesterID = BDF in physdev op unless we are *stricly* sure this is valid.
The spec is quite clear about it, but I guess there might be hardware quirks.
Quoted 2 lines
Although, based on the x86 code, Xen should be able to translate the BDF into the requester ID...
Yes, that is a good point.
Quoted 18 lines · Stefano Stabellini
Quoted 17 lines · Julien Grall
Hi Stefano,
Quoted 14 lines · Stefano Stabellini
Quoted 10 lines
Quoted 5 lines
Linux provides a function (
pci_for_each_dma_alias) which will return a requester ID for a given PCI device. It appears that the BDF (the 's' of sBDF
is only internal to Linux and not part of the hardware) is equal to the requester ID on your platform but we can't assume it for anyone else.The PCI Express Base Specification states that the requester ID is "The combination of a Requester's Bus Number, Device Number, and Function Number that uniquely identifies the Requester."
I think it is safe to assume BDF = requester ID on all platforms.
With the catch that in case of ARI devices
(http://pcisig.com/sites/default/files/specification_documents/ECN-alt-rid-interpretation-070604.pdf),
BDF is actually BF because the device number is always 0 and the function number is 8 bits.
Quoted 7 lines
Quoted 6 lines
And some other problem such as broken PCI device...
Both Xen x86 (domain_context_mappingindrivers/passthrough/vtd/iommu.c) and Linux (pci_dma_for_each_alias) use a code more complex than requesterID = BDF.So I don't think we can use requesterID = BDF in physdev op unless we are *stricly* sure this is valid.
The spec is quite clear about it, but I guess there might be hardware quirks.
Can we keep this open and for now till there is agreement make requesterid = bdf. If you are ok, I will update and send Draft 3.
Quoted 5 lines
Quoted 4 lines
Although, based on the x86 code, Xen should be able to translate the BDF into the requester ID...
Yes, that is a good point.
Hi Manish,
Quoted 3 lines · Manish Jaggi
Can we keep this open and for now till there is agreement make requesterid = bdf.
If you are ok, I will update and send Draft 3.
I think we can make an agreement on we are able to find a requesterID based on the BDF but not that requesterID = BDF. There is different reason for that: ARI, hardware quirks...
It would be nice if you can summarize how to find the requesterID, StreamIDs (SMMU), deviceID (IOMMU) and use the name accordingly in the spec.
Regards,
Signature · 1 line
Julien Grall
Quoted 88 lines · Ian Campbell
Quoted 73 lines · Manish Jaggi
Quoted 72 lines · Ian Campbell
Quoted 25 lines · Manish Jaggi
Quoted 9 lines · Julien Grall
Hi Manish,
Quoted 6 lines · Manish Jaggi
4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR regions.
These are defined inarch-arm.hQuoted 7 lines
Quoted 5 lines
/* For 32bit */
GUEST_MMIO_HOLE0_BASE,GUEST_MMIO_HOLE0_SIZE/* For 64bit */
GUEST_MMIO_HOLE1_BASE,GUEST_MMIO_HOLE1_SIZEThe memory layout for 32bit and 64bit are exactly the same. Why do you need to differ here?
I think Ian has already replied. I will change the name of macro
Quoted 7 lines
Quoted 7 lines
4.2 New entries in xenstore for device BARs
--------------------------------------------
toolkit also updates the xenstore information for the device (virtualbar:physical bar).
This information is read by xenpciback and returned to the pcifront driver configuration
space accesses.Quoted 2 lines
Quoted 1 line
Can you details what do you plan to put in xenstore and how?
It is implementation . But I plan to put under domU / device / heirarchy
Actually, xenstore is an API of sorts which needs to be maintained going forward (since front and backend can evolve separately, so it does need some level of design and documentation.
Quoted 3 lines
Quoted 1 line
What about the expansion ROM?
Do you want to put some restriction on not using expansion ROM as a passthrough device.
"expansion ROM as a passthrough device" doesn't make sense to me, passthrough devices may _have_ an expansion ROM.
The expansion ROM is just another BAR. I don't know how pcifront/back deal with those today on PV x86, but I see no reason for ARM to deviate.
Quoted 30 lines
Quoted 21 lines
Quoted 21 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices. The
pdev structure already has a sbdf information. Thearch_pci_devis updated to
contain the gsbdf information. (gs- guest segment id)Quoted 6 lines
Quoted 3 lines
Whenever there is trap from guest or an interrupt has to be injected, the pdev
list is iterated to find the gsbdf.Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?In the context of the hypercall processing.
Quoted 2 lines
- Who will call this hypercall?
- Why not setting the gsbdf when the device is assigned?Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Can the maintainer of the pciback suggest an alternate.
That's not me, but I don't think this belongs here, I think it can be done from the toolstack. If you think not then please explain what information the toolstack doesn't have in its possession which prevents this mapping from being done there.
The toolstack does not have the guest sbdf information. I could only find it in xenpciback.
Are you sure? The sbdf relates to the physical device, correct? If so then surely the toolstack knows it -- it's written in the config file and is the primary parameter to all of the related libxl passthrough APIs. The toolstack wouldn't be able to do anything about passing through a given device without knowing which device it should be passing through.
Quoted 4 lines
Perhaps this info needs plumbing through to some new bit of the toolstack, but it is surely available somewhere.
If you meant the virtual SBDF then that is in libxl_device_pci.vdevfn.
I added prints in libxl__device_pci_add. vdevfn is always 0 so this may not be the right variable to use. Can you please recheck.
Also the vdev-X entry in xenstore appears to be created from pciback code and not from xl. Check function xen_pcibk_publish_pci_dev.
So I have to send a hypercall from pciback only.
Quoted 7 lines
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 114 lines · Manish Jaggi
Quoted 104 lines · Ian Campbell
Quoted 87 lines · Manish Jaggi
Quoted 86 lines · Ian Campbell
Quoted 28 lines · Manish Jaggi
Quoted 10 lines · Julien Grall
Hi Manish,
Quoted 7 lines · Manish Jaggi
4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR
regions.
These are defined inarch-arm.hQuoted 8 lines
Quoted 5 lines
/* For 32bit */
GUEST_MMIO_HOLE0_BASE,GUEST_MMIO_HOLE0_SIZE/* For 64bit */
GUEST_MMIO_HOLE1_BASE,GUEST_MMIO_HOLE1_SIZEThe memory layout for 32bit and 64bit are exactly the same. Why do you
need to differ here?I think Ian has already replied. I will change the name of macro
Quoted 8 lines
Quoted 8 lines
4.2 New entries in xenstore for device BARs
--------------------------------------------
toolkit also updates the xenstore information for the device (virtualbar:physical bar).
This information is read by xenpciback and returned to the pcifront
driver configuration
space accesses.Quoted 3 lines
Quoted 1 line
Can you details what do you plan to put in xenstore and how?
It is implementation . But I plan to put under domU / device / heirarchy
Actually, xenstore is an API of sorts which needs to be maintained going
forward (since front and backend can evolve separately, so it does need
some level of design and documentation.Quoted 4 lines
Quoted 1 line
What about the expansion ROM?
Do you want to put some restriction on not using expansion ROM as a
passthrough device."expansion ROM as a passthrough device" doesn't make sense to me, passthrough devices may _have_ an expansion ROM.
The expansion ROM is just another BAR. I don't know how pcifront/back
deal with those today on PV x86, but I see no reason for ARM to deviate.Quoted 35 lines
Quoted 23 lines
Quoted 23 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices.
The
pdev structure already has a sbdf information. Thearch_pci_devis
updated to
contain the gsbdf information. (gs- guest segment id)Quoted 7 lines
Quoted 4 lines
Whenever there is trap from guest or an interrupt has to be injected,
the pdev
list is iterated to find the gsbdf.Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?In the context of the hypercall processing.
Quoted 3 lines
- Who will call this hypercall?
- Why not setting the gsbdf when the device is
assigned?Can the maintainer of the pciback suggest an alternate.
Quoted 8 lines
Quoted 6 lines
That's not me, but I don't think this belongs here, I think it can be
done from the toolstack. If you think not then please explain what information the toolstack doesn't have in its possession which prevents
this mapping from being done there.The toolstack does not have the guest sbdf information. I could only find it in xenpciback.
Are you sure? The sbdf relates to the physical device, correct? If so then surely the toolstack knows it -- it's written in the config file and is the primary parameter to all of the related libxl passthrough APIs. The toolstack wouldn't be able to do anything about passing through a given device without knowing which device it should be passing
through.Quoted 4 lines
Perhaps this info needs plumbing through to some new bit of the toolstack, but it is surely available somewhere.
If you meant the virtual SBDF then that is in libxl_device_pci.vdevfn.
I added prints in
libxl__device_pci_add. vdevfn is always 0 so this may not be the right variable to use.
Can you please recheck.
Quoted 5 lines
Also the vdev-X entry in xenstore appears to be created from pciback code and not from xl.
Check functionxen_pcibk_publish_pci_dev.So I have to send a hypercall from pciback only.
I don't think the necessarily follows.
You could have the tools read the vdev-X node back on plug.
Or you could change things such that vdevfn is always chosen by the toolstack for ARM, not optionally like it is on x86.
Please evaluate the options.
Ian.
Quoted 114 lines · Ian Campbell
Quoted 113 lines · Manish Jaggi
Quoted 104 lines · Ian Campbell
Quoted 87 lines · Manish Jaggi
Quoted 86 lines · Ian Campbell
Quoted 28 lines · Manish Jaggi
Quoted 10 lines · Julien Grall
Hi Manish,
Quoted 7 lines · Manish Jaggi
4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR
regions.
These are defined inarch-arm.hQuoted 8 lines
Quoted 5 lines
/* For 32bit */
GUEST_MMIO_HOLE0_BASE,GUEST_MMIO_HOLE0_SIZE/* For 64bit */
GUEST_MMIO_HOLE1_BASE,GUEST_MMIO_HOLE1_SIZEThe memory layout for 32bit and 64bit are exactly the same. Why do you
need to differ here?I think Ian has already replied. I will change the name of macro
Quoted 8 lines
Quoted 8 lines
4.2 New entries in xenstore for device BARs
--------------------------------------------
toolkit also updates the xenstore information for the device (virtualbar:physical bar).
This information is read by xenpciback and returned to the pcifront
driver configuration
space accesses.Quoted 3 lines
Quoted 1 line
Can you details what do you plan to put in xenstore and how?
It is implementation . But I plan to put under domU / device / heirarchy
Actually, xenstore is an API of sorts which needs to be maintained going
forward (since front and backend can evolve separately, so it does need
some level of design and documentation.Quoted 4 lines
Quoted 1 line
What about the expansion ROM?
Do you want to put some restriction on not using expansion ROM as a
passthrough device."expansion ROM as a passthrough device" doesn't make sense to me, passthrough devices may _have_ an expansion ROM.
The expansion ROM is just another BAR. I don't know how pcifront/back
deal with those today on PV x86, but I see no reason for ARM to deviate.Quoted 35 lines
Quoted 23 lines
Quoted 23 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all pci devices.
The
pdev structure already has a sbdf information. Thearch_pci_devis
updated to
contain the gsbdf information. (gs- guest segment id)Quoted 7 lines
Quoted 4 lines
Whenever there is trap from guest or an interrupt has to be injected,
the pdev
list is iterated to find the gsbdf.Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?In the context of the hypercall processing.
Quoted 3 lines
- Who will call this hypercall?
- Why not setting the gsbdf when the device is
assigned?Can the maintainer of the pciback suggest an alternate.
Quoted 8 lines
Quoted 6 lines
That's not me, but I don't think this belongs here, I think it can be
done from the toolstack. If you think not then please explain what information the toolstack doesn't have in its possession which prevents
this mapping from being done there.The toolstack does not have the guest sbdf information. I could only find it in xenpciback.
Are you sure? The sbdf relates to the physical device, correct? If so then surely the toolstack knows it -- it's written in the config file and is the primary parameter to all of the related libxl passthrough APIs. The toolstack wouldn't be able to do anything about passing through a given device without knowing which device it should be passing
through.Quoted 4 lines
Perhaps this info needs plumbing through to some new bit of the toolstack, but it is surely available somewhere.
If you meant the virtual SBDF then that is in libxl_device_pci.vdevfn.
I added prints in
libxl__device_pci_add. vdevfn is always 0 so this may not be the right variable to use.
Can you please recheck.
Quoted 8 lines
Quoted 5 lines
Also the vdev-X entry in xenstore appears to be created from pciback code and not from xl.
Check functionxen_pcibk_publish_pci_dev.So I have to send a hypercall from pciback only.
I don't think the necessarily follows.
You could have the tools read the vdev-X node back on plug.
I have been trying to get the flow of caller of libxl__device_pci_add during pci device assignemnt from cfg file(cold boot). It should be called form xl create flow. Is it called from C code or Python code.
libxl__device_pci_add calls xc_assign_device
Secondly, the vdev-X entry is created async by dom0 watching on event. So how the tools could read back and call assign device again.
static void xen_pcibk_be_watch(struct xenbus_watch *watch,
const char **vec, unsigned int len)
{
...
switch (xenbus_read_driver_state(pdev->xdev->nodename)) {
case XenbusStateInitWait:
xen_pcibk_setup_backend(pdev);
break;
}Quoted 12 lines
Or you could change things such that vdevfn is always chosen by the toolstack for ARM, not optionally like it is on x86.
Please evaluate the options.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 140 lines · Manish Jaggi
Quoted 138 lines · Ian Campbell
Quoted 137 lines · Manish Jaggi
Quoted 122 lines · Ian Campbell
Quoted 107 lines · Manish Jaggi
Quoted 98 lines · Ian Campbell
Quoted 32 lines · Manish Jaggi
Quoted 13 lines · Julien Grall
Hi Manish,
Quoted 10 lines · Manish Jaggi
4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR
regions.
These are defined inarch-arm.h/* For 32bit */
GUEST_MMIO_HOLE0_BASE,GUEST_MMIO_HOLE0_SIZEQuoted 6 lines
Quoted 2 lines
/* For 64bit */
GUEST_MMIO_HOLE1_BASE,GUEST_MMIO_HOLE1_SIZEThe memory layout for 32bit and 64bit are exactly the same. Why
do you
need to differ here?I think Ian has already replied. I will change the name of macro
Quoted 10 lines
Quoted 10 lines
4.2 New entries in xenstore for device BARs
--------------------------------------------
toolkit also updates the xenstore information for the device
(virtualbar:physical bar).
This information is read by xenpciback and returned to the
pcifront
driver configuration
space accesses.Quoted 5 lines
Quoted 2 lines
Can you details what do you plan to put in xenstore and how?
It is implementation . But I plan to put under domU / device /
heirarchyActually, xenstore is an API of sorts which needs to be maintained
going
forward (since front and backend can evolve separately, so it does
need
some level of design and documentation.Quoted 5 lines
Quoted 1 line
What about the expansion ROM?
Do you want to put some restriction on not using expansion ROM as
a
passthrough device."expansion ROM as a passthrough device" doesn't make sense to me,
passthrough devices may _have_ an expansion ROM.The expansion ROM is just another BAR. I don't know how pcifront/back
deal with those today on PV x86, but I see no reason for ARM to deviate.Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all
pci devices.
The
pdev structure already has a sbdf information. Thearch_pci_devis
updated to
contain the gsbdf information. (gs- guest segment id)Whenever there is trap from guest or an interrupt has to be
injected,
the pdev
list is iterated to find the gsbdf.Quoted 8 lines
Quoted 3 lines
Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?In the context of the hypercall processing.
Quoted 3 lines
- Who will call this hypercall?
- Why not setting the gsbdf when the device is
assigned?Can the maintainer of the pciback suggest an alternate.
Quoted 8 lines
That's not me, but I don't think this belongs here, I think it can
be
done from the toolstack. If you think not then please explain what
information the toolstack doesn't have in its possession which prevents
this mapping from being done there.Quoted 3 lines
The toolstack does not have the guest sbdf information. I could only
find it in xenpciback.Are you sure? The sbdf relates to the physical device, correct? If so
then surely the toolstack knows it -- it's written in the config file
and is the primary parameter to all of the related libxl passthrough
APIs. The toolstack wouldn't be able to do anything about passing through a given device without knowing which device it should be passing
through.Quoted 5 lines
Perhaps this info needs plumbing through to some new bit of the toolstack, but it is surely available somewhere.
If you meant the virtual SBDF then that is in
libxl_device_pci.vdevfn.I added prints in
libxl__device_pci_add. vdevfn is always 0 so this may
not be the right variable to use.
Can you please recheck.Also the vdev-X entry in xenstore appears to be created from pciback code and not from xl.
Check functionxen_pcibk_publish_pci_dev.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
So I have to send a hypercall from pciback only.
I don't think the necessarily follows.
You could have the tools read the vdev-X node back on plug.
I have been trying to get the flow of caller of
libxl__device_pci_addduring pci device assignemnt from cfg file(cold boot).
It should be called form xl create flow. Is it called from C code or Python code.
There is no Python code which you need to worry about involved here. You can completely ignore tools/python.
In the first instance you need only to worry about tools/libxl/libxl* (the toolstack library). The xl commands are in tools/libxl/xl* and calls libxl_domain_create_new with a libxl_domain_config struct which contains the array of pci devices to cold plug.
Hotplug starts at libxl_device_pci_add.
Most of the code for the PCI specific bits are in tools/libxl/libxl_pci.c.
Quoted 3 lines
Secondly, the vdev-X entry is created async by dom0 watching on event.
So how the tools could read back and call assign device again.
Perhaps by using a xenstore watch on that node to wait for the assignment from pciback to occur.
Quoted 2 lines
Quoted 2 lines
Or you could change things such that vdevfn is always chosen by the toolstack for ARM, not optionally like it is on x86.
For this one, the struct libxl_device_pci has a field "vdevfn", which is supposed to allow the user to specify a specific vdevfn. I'm not sure how that happens or fits together but libxl could undertake to set that on ARM in the case where the user hasn't done so, effectively taking control of the PCI bus assignment.
Ian.
Quoted 156 lines · Ian Campbell
Quoted 139 lines · Manish Jaggi
Quoted 138 lines · Ian Campbell
Quoted 137 lines · Manish Jaggi
Quoted 122 lines · Ian Campbell
Quoted 107 lines · Manish Jaggi
Quoted 98 lines · Ian Campbell
Quoted 32 lines · Manish Jaggi
Quoted 13 lines · Julien Grall
Hi Manish,
Quoted 10 lines · Manish Jaggi
4.1 Holes in guest memory space
----------------------------
Holes are added in the guest memory space for mapping pci device's BAR
regions.
These are defined inarch-arm.h/* For 32bit */
GUEST_MMIO_HOLE0_BASE,GUEST_MMIO_HOLE0_SIZEQuoted 6 lines
Quoted 2 lines
/* For 64bit */
GUEST_MMIO_HOLE1_BASE,GUEST_MMIO_HOLE1_SIZEThe memory layout for 32bit and 64bit are exactly the same. Why
do you
need to differ here?I think Ian has already replied. I will change the name of macro
Quoted 10 lines
Quoted 10 lines
4.2 New entries in xenstore for device BARs
--------------------------------------------
toolkit also updates the xenstore information for the device
(virtualbar:physical bar).
This information is read by xenpciback and returned to the
pcifront
driver configuration
space accesses.Quoted 5 lines
Quoted 2 lines
Can you details what do you plan to put in xenstore and how?
It is implementation . But I plan to put under domU / device /
heirarchyActually, xenstore is an API of sorts which needs to be maintained
going
forward (since front and backend can evolve separately, so it does
need
some level of design and documentation.Quoted 5 lines
Quoted 1 line
What about the expansion ROM?
Do you want to put some restriction on not using expansion ROM as
a
passthrough device."expansion ROM as a passthrough device" doesn't make sense to me,
passthrough devices may _have_ an expansion ROM.The expansion ROM is just another BAR. I don't know how pcifront/back
deal with those today on PV x86, but I see no reason for ARM to deviate.Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
4.3 Hypercall for bdf mapping notification to xen
-----------------------------------------------
#definePHYSDEVOP_map_sbdf43typedef struct { u32 s; u8 b; u8 df; u16 res; } sbdf_t; struct physdev_map_sbdf { int domain_id; sbdf_t sbdf; sbdf_t gsbdf; };Each domain has a pdev list, which contains the list of all
pci devices.
The
pdev structure already has a sbdf information. Thearch_pci_devis
updated to
contain the gsbdf information. (gs- guest segment id)Whenever there is trap from guest or an interrupt has to be
injected,
the pdev
list is iterated to find the gsbdf.Quoted 8 lines
Quoted 3 lines
Can you give more background for this section? i.e:
- Why do you need this?
- How xen will translate the gbdf to a vDeviceID?In the context of the hypercall processing.
Quoted 3 lines
- Who will call this hypercall?
- Why not setting the gsbdf when the device is
assigned?Can the maintainer of the pciback suggest an alternate.
Quoted 8 lines
That's not me, but I don't think this belongs here, I think it can
be
done from the toolstack. If you think not then please explain what
information the toolstack doesn't have in its possession which prevents
this mapping from being done there.Quoted 3 lines
The toolstack does not have the guest sbdf information. I could only
find it in xenpciback.Are you sure? The sbdf relates to the physical device, correct? If so
then surely the toolstack knows it -- it's written in the config file
and is the primary parameter to all of the related libxl passthrough
APIs. The toolstack wouldn't be able to do anything about passing through a given device without knowing which device it should be passing
through.Quoted 5 lines
Perhaps this info needs plumbing through to some new bit of the toolstack, but it is surely available somewhere.
If you meant the virtual SBDF then that is in
libxl_device_pci.vdevfn.I added prints in
libxl__device_pci_add. vdevfn is always 0 so this may
not be the right variable to use.
Can you please recheck.Also the vdev-X entry in xenstore appears to be created from pciback code and not from xl.
Check functionxen_pcibk_publish_pci_dev.Quoted 8 lines
Quoted 4 lines
Quoted 1 line
So I have to send a hypercall from pciback only.
I don't think the necessarily follows.
You could have the tools read the vdev-X node back on plug.
I have been trying to get the flow of caller of
libxl__device_pci_addduring pci device assignemnt from cfg file(cold boot).
It should be called form xl create flow. Is it called from C code or Python code.There is no Python code which you need to worry about involved here. You can completely ignore
tools/python.In the first instance you need only to worry about
tools/libxl/libxl*(the toolstack library). The xl commands are intools/libxl/xl*and callslibxl_domain_create_newwith alibxl_domain_configstruct which contains the array of pci devices to cold plug.
Quoted 8 lines
Hotplug starts at
libxl_device_pci_add.Most of the code for the PCI specific bits are in
tools/libxl/libxl_pci.c.Quoted 2 lines
Secondly, the vdev-X entry is created async by dom0 watching on event. So how the tools could read back and call assign device again.
Perhaps by using a xenstore watch on that node to wait for the assignment from pciback to occur.
As per the flow in the do_pci_add function, assign_device is called first and based on the success xenstore entry is created. Are you suggesting to change the sequence.
We can discuss this more on #xenarm irc
Quoted 14 lines
Quoted 2 lines
Quoted 2 lines
Or you could change things such that vdevfn is always chosen by the toolstack for ARM, not optionally like it is on x86.
For this one, the struct
libxl_device_pcihas a field "vdevfn", which is supposed to allow the user to specify a specific vdevfn. I'm not sure how that happens or fits together but libxl could undertake to set that on ARM in the case where the user hasn't done so, effectively taking control of the PCI bus assignment.Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 9 lines · Manish Jaggi
Quoted 6 lines
Quoted 3 lines
Secondly, the vdev-X entry is created async by dom0 watching on event.
So how the tools could read back and call assign device again.Perhaps by using a xenstore watch on that node to wait for the assignment
from pciback to occur.As per the flow in the
do_pci_addfunction,assign_deviceis called first and based on the success xenstore entry is created. Are you suggesting to change the sequence.
Perhaps that is what it would take, yes, or maybe some other refactoring (e.g. splitting assign_device into two stages) might be the answer.
My current preference is for the suggestion below which is to let the toolstack pick the vdevfn and have pciback honour it.
Quoted 1 line
We can discuss this more on #xenarm irc
Sorry I missed your ping yesterday, I had already gone home.
Quoted 19 lines
Quoted 18 lines
Quoted 2 lines
Quoted 2 lines
Or you could change things such that vdevfn is always chosen by the toolstack for ARM, not optionally like it is on x86.
For this one, the struct
libxl_device_pcihas a field "vdevfn", which is
supposed to allow the user to specify a specific vdevfn. I'm not sure how
that happens or fits together but libxl could undertake to set that on ARM
in the case where the user hasn't done so, effectively taking control of
the PCI bus assignment.Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 3 lines · Ian Campbell
Quoted 2 lines · Manish Jaggi
Quoted 2 lines
Quoted 2 lines
Secondly, the vdev-X entry is created async by dom0 watching on event.
Stefano points out that there are, confusingly, two nodes in xenstore relating to the virtual-SBDF.
vdev-X is written by pciback and is read by pcifront, it is effectively there to communicate the vSBDF to the guest.
vdevfn-X is written by the toolstack (libxl_create_pci_backend_device) to tell the backend (pciback, or qemu in x86/HVM configurations using old qemu) the vSBDF to be associated with the device.
It looks like vdevfn-X is not actually currently supported by pciback in Linux (seemingly only the x86/HVM qemu backend consumes it). I think we should add that support to pciback for consistency with the qemu based backend used by x86/HVM guests.
The names are a certainly a bit confusing. We could add a new key with a better name to communicate the vSBDF from toolstack->backend, but itseems to me to be that would just adding even more confusion, so I recommend we don't do that.
Once pciback supports vdevfn then libxl will be able to choose the PCI bus layout for ARM guests in the case where the use has not requested an explicit vdevfn for the device.
Does that make sense?
Ian.
Quoted 4 lines · Ian Campbell
Quoted 3 lines · Manish Jaggi
Quoted 3 lines
Quoted 3 lines
Secondly, the vdev-X entry is created async by dom0 watching on event.
So how the tools could read back and call assign device again.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Perhaps by using a xenstore watch on that node to wait for the assignment
from pciback to occur.As per the flow in the
do_pci_addfunction,assign_deviceis called first and based on the success xenstore entry is created. Are you suggesting to change the sequence.Perhaps that is what it would take, yes, or maybe some other refactoring (e.g. splitting
assign_deviceinto two stages) might be the answer.
The hypercall from xenpciback (what I implemented) is actually making the assign device in 2 stages. I think the point of contention is the second stage should be from toolstack.
I think calling xc_assign_device after xenstore from the watch callback is the only option. One question is how to split the code for ARM and x86 as this is the common code. Would #ifdef CONFIG_ARM64 ok with maintainers.
Quoted 3 lines
My current preference is for the suggestion below which is to let the toolstack pick the vdevfn and have pciback honour it.
That would duplicate code for dev-fn generation into toolstack from __xen_pcibk_add_pci_dev.
Quoted 25 lines
Quoted 1 line
We can discuss this more on #xenarm irc
Sorry I missed your ping yesterday, I had already gone home.
Quoted 12 lines
Quoted 12 lines
Quoted 2 lines
Quoted 2 lines
Or you could change things such that vdevfn is always chosen by the toolstack for ARM, not optionally like it is on x86.
For this one, the struct
libxl_device_pcihas a field "vdevfn", which is
supposed to allow the user to specify a specific vdevfn. I'm not sure how
that happens or fits together but libxl could undertake to set that on ARM
in the case where the user hasn't done so, effectively taking control of
the PCI bus assignment.Quoted 6 lines
Quoted 6 lines
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 15 lines · Manish Jaggi
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Manish Jaggi
Quoted 6 lines
Quoted 3 lines
Secondly, the vdev-X entry is created async by dom0 watching on event.
So how the tools could read back and call assign device again.Perhaps by using a xenstore watch on that node to wait for the assignment
from pciback to occur.Quoted 6 lines
Quoted 3 lines
As per the flow in the
do_pci_addfunction,assign_deviceis called first and based on the success xenstore entry is created. Are you suggesting to change the sequence.Perhaps that is what it would take, yes, or maybe some other refactoring
(e.g. splittingassign_deviceinto two stages) might be the answer.
Quoted 7 lines
The hypercall from xenpciback (what I implemented) is actually making the assign device in 2 stages.
I think the point of contention is the second stage should be from toolstack.I think calling
xc_assign_deviceafter xenstore from the watch callback is the only option.
Only if you ignore the other option I proposed.
Quoted 3 lines
One question is how to split the code for ARM and x86 as this is the common code.
Would #ifdefCONFIG_ARM64ok with maintainers.
No. arch hooks in libxl_$ARCH.c (with nop implementations where necessary) would be the way to approach this. However I still am not convinced this is the approach we should be taking.
Quoted 4 lines
Quoted 2 lines
My current preference is for the suggestion below which is to let the toolstack pick the vdevfn and have pciback honour it.
That would duplicate code for dev-fn generation into toolstack from
__xen_pcibk_add_pci_dev.
IMHO the toolstack is the correct place for this code, at least for ARM guests. The toolstack is, in general, responsible for all aspects of the guest layout. I don't think delegating the PCI bus parts of that to the dom0 kernel makes sense.
I'd not be surprised if the same turns out to be true for x86/PVH guests too.
Ian.
Quoted 31 lines · Ian Campbell
Quoted 14 lines · Manish Jaggi
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Manish Jaggi
Quoted 6 lines
Quoted 3 lines
Secondly, the vdev-X entry is created async by dom0 watching on event.
So how the tools could read back and call assign device again.Perhaps by using a xenstore watch on that node to wait for the assignment
from pciback to occur.Quoted 6 lines
Quoted 3 lines
As per the flow in the
do_pci_addfunction,assign_deviceis called first and based on the success xenstore entry is created. Are you suggesting to change the sequence.Perhaps that is what it would take, yes, or maybe some other refactoring
(e.g. splittingassign_deviceinto two stages) might be the answer.Quoted 7 lines
The hypercall from xenpciback (what I implemented) is actually making the assign device in 2 stages.
I think the point of contention is the second stage should be from toolstack.I think calling
xc_assign_deviceafter xenstore from the watch callback is the only option.Only if you ignore the other option I proposed.
Quoted 3 lines
One question is how to split the code for ARM and x86 as this is the common code.
Would #ifdefCONFIG_ARM64ok with maintainers.No. arch hooks in libxl_$ARCH.c (with nop implementations where necessary) would be the way to approach this. However I still am not convinced this is the approach we should be taking.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
My current preference is for the suggestion below which is to let the toolstack pick the vdevfn and have pciback honour it.
That would duplicate code for dev-fn generation into toolstack from
__xen_pcibk_add_pci_dev.IMHO the toolstack is the correct place for this code, at least for ARM guests. The toolstack is, in general, responsible for all aspects of the guest layout. I don't think delegating the PCI bus parts of that to the dom0 kernel makes sense.
Ok, i will implement the same from pciback to toolstack. I am not sure about the complexity but will give it a try. With this xen-pciback will not create the vdev-X entry at all.
Quoted 9 lines
I'd not be surprised if the same turns out to be true for x86/PVH guests too.
Ian._______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 44 lines · Manish Jaggi
Quoted 42 lines · Ian Campbell
Quoted 17 lines · Manish Jaggi
Quoted 9 lines · Ian Campbell
Quoted 8 lines · Manish Jaggi
Quoted 8 lines
Quoted 5 lines
Secondly, the vdev-X entry is created async by dom0 watching on
event.
So how the tools could read back and call assign device again.Perhaps by using a xenstore watch on that node to wait for the assignment
from pciback to occur.Quoted 7 lines
Quoted 4 lines
As per the flow in the
do_pci_addfunction,assign_deviceis called
first and based on the success xenstore entry is created. Are you suggesting to change the sequence.Perhaps that is what it would take, yes, or maybe some other refactoring
(e.g. splittingassign_deviceinto two stages) might be the answer.Quoted 8 lines
The hypercall from xenpciback (what I implemented) is actually making the assign device in 2 stages.
I think the point of contention is the second stage should be from toolstack.I think calling
xc_assign_deviceafter xenstore from the watch callback
is the only option.Only if you ignore the other option I proposed.
Quoted 3 lines
One question is how to split the code for ARM and x86 as this is the common code.
Would #ifdefCONFIG_ARM64ok with maintainers.No. arch hooks in libxl_$ARCH.c (with nop implementations where necessary)
would be the way to approach this. However I still am not convinced this is
the approach we should be taking.Quoted 5 lines
Quoted 3 lines
My current preference is for the suggestion below which is to let the
toolstack pick the vdevfn and have pciback honour it.That would duplicate code for dev-fn generation into toolstack from
__xen_pcibk_add_pci_dev.
Quoted 7 lines
Quoted 5 lines
IMHO the toolstack is the correct place for this code, at least for ARM guests. The toolstack is, in general, responsible for all aspects of the
guest layout. I don't think delegating the PCI bus parts of that to the dom0 kernel makes sense.Ok, i will implement the same from pciback to toolstack. I am not sure about the complexity but will give it a try.
Thank you.
Quoted 1 line
With this xen-pciback will not create the vdev-X entry at all.
Uh, where did you get that idea? That node communicates from b.e. to f.e., surely it is still needed for that purpose?
The flow seems like it should be:
toolstack -> xenstore:vdevfn-X -> backend -> xenstore:vdev-X -> frontend
where "backend" is codei n pciback which does something like (maybe not in one function, but logically):
foo = read(vdevfn-X)
if (!foo)
allocate SBDF as code today, setting foo to the result
write(vdev-X, foo)
IOW if vdevfn-X is unset the backend does the same as today, if it is set (by the toolstack) then pciback honours it.
Ian.
Hi Manish,
Quoted 3 lines · Manish Jaggi
Ok, i will implement the same from pciback to toolstack. I am not sure about the complexity but will give it a try.
With this xen-pciback will not create the vdev-X entry at all.
Can you send a new draft before continuing to implement PCI support in Xen?
As long as we are not agree about it, you loose your time trying to implement something that can drastically change in the next revision.
Regards,
Signature · 1 line
Julien Grall
Quoted 7 lines · Julien Grall
Hi Manish,
Quoted 3 lines · Manish Jaggi
Ok, i will implement the same from pciback to toolstack. I am not sure about the complexity but will give it a try.
With this xen-pciback will not create the vdev-X entry at all.
Quoted 5 lines
Can you send a new draft before continuing to implement PCI support in Xen?
As long as we are not agree about it, you loose your time trying to implement something that can drastically change in the next revision.
Very good idea, yes.
Ian.
Quoted 25 lines · Ian Campbell
Quoted 3 lines · Ian Campbell
Quoted 2 lines · Manish Jaggi
Quoted 2 lines
Quoted 2 lines
Secondly, the vdev-X entry is created async by dom0 watching on event.
Stefano points out that there are, confusingly, two nodes in xenstore relating to the virtual-SBDF.
vdev-X is written by pciback and is read by pcifront, it is effectively there to communicate the vSBDF to the guest.
vdevfn-X is written by the toolstack (
libxl_create_pci_backend_device) to tell the backend (pciback, or qemu in x86/HVM configurations using old qemu) the vSBDF to be associated with the device.It looks like vdevfn-X is not actually currently supported by pciback in Linux (seemingly only the x86/HVM qemu backend consumes it). I think we should add that support to pciback for consistency with the qemu based backend used by x86/HVM guests.
The names are a certainly a bit confusing. We could add a new key with a better name to communicate the vSBDF from
toolstack->backend, but itseems to me to be that would just adding even more confusion, so I recommend we don't do that.
Quoted 5 lines
Once pciback supports vdevfn then libxl will be able to choose the PCI bus layout for ARM guests in the case where the use has not requested an explicit vdevfn for the device.
Does that make sense?
Yes.
Quoted 8 lines
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Hi Julien,
Quoted 7 lines · Julien Grall
Hi Manish,
Quoted 3 lines · Manish Jaggi
Ok, i will implement the same from pciback to toolstack. I am not sure about the complexity but will give it a try.
With this xen-pciback will not create the vdev-X entry at all.Can you send a new draft before continuing to implement PCI support in Xen?
I am working on the Draft 3 and addressing comments in draft 2. I am doing a feasibility of the stuff I put in draft3.
Quoted 1 line
As long as we are not agree about it,
I thought I was trying to discuss the same. If you have any point please raise it.
Quoted 2 lines
you loose your time trying to
implement something that can drastically change in the next revision.
I am only putting the stuff in the Draft3 which *can* be implemented later. Regards,
Quoted 5 lines · Manish Jaggi
Hi Julien,
Quoted 2 lines · Julien Grall
Hi Manish,
Quoted 8 lines
Quoted 6 lines · Manish Jaggi
Quoted 3 lines
Ok, i will implement the same from pciback to toolstack. I am not sure about the complexity but will give it a try.
With this xen-pciback will not create the vdev-X entry at all.Can you send a new draft before continuing to implement PCI support in Xen?
I am working on the Draft 3 and addressing comments in draft 2. I am doing a feasibility of the stuff I put in draft3.
Well, I don't think that anything we say within this thread was impossible to do.
Quoted 3 lines
Quoted 1 line
As long as we are not agree about it,
I thought I was trying to discuss the same. If you have any point please raise it.
What I meant is, this is a 40-messages thread with lots of discussions on it.
A new draft containing a summary on what was said would benefits everyone and help us to get on a design that we think is good.
Quoted 3 lines
Quoted 2 lines
you loose your time trying to
implement something that can drastically change in the next revision.I am only putting the stuff in the Draft3 which *can* be implemented later.
But nothing prevent someone in the discussion on Draft3 to say this is wrong and it has to be done in a different way.
Usually the time between two draft should be pretty short in order to get sane base for discussion. For now, we are talking about small portion of design and speculating/trying to remember what was agreed on other sub-thread.
Regards,
Signature · 1 line
Julien Grall
Quoted 28 lines · Julien Grall
Quoted 5 lines · Manish Jaggi
Hi Julien,
Quoted 2 lines · Julien Grall
Hi Manish,
Quoted 8 lines
Quoted 6 lines · Manish Jaggi
Quoted 3 lines
Ok, i will implement the same from pciback to toolstack. I am not sure about the complexity but will give it a try.
With this xen-pciback will not create the vdev-X entry at all.Can you send a new draft before continuing to implement PCI support in Xen?
I am working on the Draft 3 and addressing comments in draft 2. I am doing a feasibility of the stuff I put in draft3.
Well, I don't think that anything we say within this thread was impossible to do.
Quoted 3 lines
Quoted 1 line
As long as we are not agree about it,
I thought I was trying to discuss the same. If you have any point please raise it.
What I meant is, this is a 40-messages thread with lots of discussions on it.
A new draft containing a summary on what was said would benefits everyone and help us to get on a design that we think is good.
Quoted 2 lines
Quoted 2 lines
you loose your time trying to
implement something that can drastically change in the next revision.
Quoted 8 lines
Quoted 1 line
I am only putting the stuff in the Draft3 which *can* be implemented later.
But nothing prevent someone in the discussion on Draft3 to say this is wrong and it has to be done in a different way.
Usually the time between two draft should be pretty short in order to get sane base for discussion. For now, we are talking about small portion of design and speculating/trying to remember what was agreed on other sub-thread.
ok will send draft 3 with the points on this topic as under discussion. Is that fine?
Quoted 3 lines
Regards,
Quoted 6 lines · Manish Jaggi
Quoted 4 lines
Usually the time between two draft should be pretty short in order to get sane base for discussion. For now, we are talking about small portion of design and speculating/trying to remember what was agreed on other sub-thread.
ok will send draft 3 with the points on this topic as under discussion. Is that fine?
Yes please.
Thank you,
Signature · 1 line
Julien Grall