PCI devices passthrough on Arm
PATCH v6 2/3 xen/arm: Enable the existing x86 virtual PCI support for ARM.
In reply to Bertrand MarquisFrom: Rahul Singh <[email protected]>
The existing VPCI support available for X86 is adapted for Arm. When the device is added to XEN via the hyper call “PHYSDEVOP_pci_device_add”, VPCI handler for the config space access is added to the Xen to emulate the PCI devices config space.
A MMIO trap handler for the PCI ECAM space is registered in XEN so that when guest is trying to access the PCI config space,XEN will trap the access and emulate read/write using the VPCI and not the real PCI hardware.
For Dom0less systems scan_pci_devices() would be used to discover the PCI device in XEN and VPCI handler will be added during XEN boots.
This patch is also doing some small fixes to fix compilation errors on arm32 of vpci:
- add a cast to unsigned long in print in header.c
- add a cast to uint64_t in vpci_ecam_mmio_write
---
Changes in v6:
- Use new vpci_ecam_ helpers for PCI access
- Do not set XEN_DOMCTL_CDF_vpci for dom0 for now (will be done in a future patch once everything is ready)
- rename REGISTER_OFFSET to ECAM_REG_OFFSET and move it to pci.h
- remove not needed local variables in vpci_mmio_write, the one in read has been kept to ensure proper compilation on arm32
- move call to vpci_add_handlers before iommu init to simplify exit path
- move call to pci_cleanup_msi in the out section of pci_add_device if pdev is not NULL and on error
- initialize pdev to NULL to handle properly exit path call of pci_cleanup_msi
- keep has_vpci to return false for now as CFG_vpci has been removed. Added a comment on top of the definition.
- fix compilation errors on arm32 (print in header.c, cast missing in mmio_write.
- local variable was kept in vpci_mmio_read on arm to prevent a cast error in arm32.
Change in v5:
- Add pci_cleanup_msi(pdev) incleanup part.
- Added Reviewed-by: Stefano Stabellini <[email protected]> Change in v4:
- Move addition of XEN_DOMCTL_CDF_vpci flag to separate patch Change in v3:
- Use is_pci_passthrough_enabled() in place of pci_passthrough_enabled variable
- Reject XEN_DOMCTL_CDF_vpci for x86 in arch_sanitise_domain_config()
- Remove IS_ENABLED(CONFIG_HAS_VPCI) from has_vpci()
Change in v2:
- Add new XEN_DOMCTL_CDF_vpci flag
- modify has_vpci() to include XEN_DOMCTL_CDF_vpci
- enable vpci support when pci-passthough option is enabled.
---
--- xen/arch/arm/Makefile | 1 + xen/arch/arm/domain.c | 4 ++ xen/arch/arm/vpci.c | 74 +++++++++++++++++++++++++++++++++++ xen/arch/arm/vpci.h | 36 +++++++++++++++++ xen/drivers/passthrough/pci.c | 18 ++++++++- xen/drivers/vpci/header.c | 3 +- xen/drivers/vpci/vpci.c | 2 +- xen/include/asm-arm/domain.h | 1 + xen/include/asm-x86/pci.h | 2 - xen/include/public/arch-arm.h | 7 ++++ xen/include/xen/pci.h | 3 ++ 11 files changed, 146 insertions(+), 5 deletions(-) create mode 100644 xen/arch/arm/vpci.c create mode 100644 xen/arch/arm/vpci.h
xen/arch/arm/Makefile +1 -0
@@ -7,6 +7,7 @@ ifneq ($(CONFIG_NO_PLAT),y) obj-y += platforms/ endif obj-$(CONFIG_TEE) += tee/ +obj-$(CONFIG_HAS_VPCI) += vpci.o obj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o obj-y += bootfdt.init.o
xen/arch/arm/domain.c +4 -0
@@ -39,6 +39,7 @@#include <asm/vgic.h> #include <asm/vtimer.h> +#include "vpci.h" #include "vuart.h" DEFINE_PER_CPU(struct vcpu *, curr_vcpu);
@@ -773,6 +774,9 @@ int arch_domain_create(struct domain *d,if (is_hardware_domain (d) && (rc =domain_vuart_init (d)) ) goto fail; +if ( (rc =domain_vpci_init (d)) !=0 ) + goto fail; +return 0 ; fail:
xen/arch/arm/vpci.c new file +74 -0
74 lines not on this page · raw message
xen/arch/arm/vpci.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* xen/arch/arm/vpci.h +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __ARCH_ARM_VPCI_H__ +#define __ARCH_ARM_VPCI_H__ + +#ifdef CONFIG_HAS_VPCI +int domain_vpci_init (struct domain *d); +#else +static inline int domain_vpci_init (struct domain *d) +{ +return 0 ; +} +#endif + +#endif /* __ARCH_ARM_VPCI_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/drivers/passthrough/pci.c +17 -1
@@ -658,7 +658,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, const struct pci_dev_info *info, nodeid_t node) { struct pci_seg *pseg; -struct pci_dev *pdev; +struct pci_dev *pdev =NULL ;unsigned int slot =PCI_SLOT (devfn), func =PCI_FUNC (devfn);const char *pdev_type;int ret;
@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev); +#ifdef CONFIG_ARM +/* +* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ + ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif + ret =0 ;if ( !pdev->domain ) {
@@ -784,6 +797,9 @@ out: &PCI_SBDF(seg, bus, slot, func)); } } +else if ( pdev ) +pci_cleanup_msi (pdev); +return ret; }
xen/drivers/vpci/header.c +2 -1
@@ -374,7 +374,8 @@ static void bar_write(const struct pci_dev *pdev, unsigned int reg,if ( val != (uint32_t )(bar->addr >> (hi ?32 :0 )) )gprintk (XENLOG_WARNING ,"%pp: ignored BAR %lu write with memory decoding enabled\n" , - &pdev->sbdf, bar - pdev->vpci->header.bars + hi); + &pdev->sbdf, + (unsigned long )(bar - pdev->vpci->header.bars + hi));return ; }
xen/drivers/vpci/vpci.c +1 -1
@@ -507,7 +507,7 @@ int vpci_ecam_mmio_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int len,vpci_write (sbdf, reg,min (4u , len), data);if ( len ==8 ) -vpci_write (sbdf, reg +4 ,4 , data >>32 ); +vpci_write (sbdf, reg +4 ,4 , (uint64_t )data >>32 );return 1 ; }
xen/include/asm-arm/domain.h +1 -0
@@ -263,6 +263,7 @@ static inline void arch_vcpu_block(struct vcpu *v) {}#define arch_vm_assist_valid_mask (d) (1UL << VMASST_TYPE_runstate_update_flag) +/* vPCI is not available on Arm */ #define has_vpci (d) ({ (void)(d); false; })#endif /* __ASM_DOMAIN_H__ */
xen/include/asm-x86/pci.h +0 -2
@@ -6,8 +6,6 @@#define CF8_ADDR_HI (cf8) ( ((cf8) & 0x0f000000) >> 16)#define CF8_ENABLED (cf8) (!!((cf8) & 0x80000000)) -#define ECAM_BDF (addr) ( ((addr) & 0x0ffff000) >> 12) -#define IS_SNB_GFX (id) (id == 0x01068086 || id == 0x01168086 \ || id == 0x01268086 || id == 0x01028086 \ || id == 0x01128086 || id == 0x01228086 \
xen/include/public/arch-arm.h +7 -0
@@ -418,6 +418,13 @@ typedef uint64_t xen_callback_t;#define GUEST_GICV3_GICR0_BASE xen_mk_ullong(0x03020000)/* vCPU0..127 */ #define GUEST_GICV3_GICR0_SIZE xen_mk_ullong(0x01000000) +/* +* 256 MB is reserved for VPCI configuration space based on calculation +* 256 buses × 32 devices × 8 functions × 4 KB = 256 MB +*/ +#define GUEST_VPCI_ECAM_BASE xen_mk_ullong(0x10000000) +#define GUEST_VPCI_ECAM_SIZE xen_mk_ullong(0x10000000) +/* ACPI tables physical address */ #define GUEST_ACPI_BASE xen_mk_ullong(0x20000000)#define GUEST_ACPI_SIZE xen_mk_ullong(0x02000000)
xen/include/xen/pci.h +3 -0
@@ -40,6 +40,9 @@#define PCI_SBDF3 (s,b,df) \ ((pci_sbdf_t){ .sbdf = (((s) & 0xffff) << 16) | PCI_BDF2(b, df) }) +#define ECAM_BDF (addr) ( ((addr) & 0x0ffff000) >> 12) +#define ECAM_REG_OFFSET (addr) ((addr) & 0x00000fff) + typedef union { uint32_t sbdf; struct {
Signature · 1 line
2.25.1
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Quoted 12 lines · Bertrand Marquis
From: Rahul Singh <[email protected]>
The existing VPCI support available for X86 is adapted for Arm. When the device is added to XEN via the hyper call “PHYSDEVOP_pci_device_add”, VPCI handler for the config space access is added to the Xen to emulate the PCI devices config space.
A MMIO trap handler for the PCI ECAM space is registered in XEN so that when guest is trying to access the PCI config space,XEN will trap the access and emulate read/write using the VPCI and not the real PCI hardware.
Quoted 7 lines
For Dom0less systems
scan_pci_devices()would be used to discover the PCI device in XEN and VPCI handler will be added during XEN boots.This patch is also doing some small fixes to fix compilation errors on arm32 of vpci:
- add a cast to unsigned long in print inheader.c
- add a cast touint64_tinvpci_ecam_mmio_write
Thank you for these! Strictly speaking they are not required now but they are welcome. I would also be OK if they were removed from this patch but it is fine to have them in here.
There is an issues with this patch, see below at the bottom
Quoted 308 lines
Signed-off-by Rahul Singh <[email protected]>Signed-off-by Bertrand Marquis <[email protected]>---
Changes in v6:
- Use newvpci_ecam_helpers for PCI access
- Do not setXEN_DOMCTL_CDF_vpcifor dom0 for now (will be done in a future patch once everything is ready)
- renameREGISTER_OFFSETtoECAM_REG_OFFSETand move it topci.h
- remove not needed local variables invpci_mmio_write, the one in read has been kept to ensure proper compilation on arm32
- move call tovpci_add_handlersbefore iommu init to simplify exit path
- move call topci_cleanup_msiin the out section ofpci_add_deviceif pdev is not NULL and on error
- initialize pdev to NULL to handle properly exit path call ofpci_cleanup_msi
- keephas_vpcito return false for now asCFG_vpcihas been removed. Added a comment on top of the definition.
- fix compilation errors on arm32 (print inheader.c, cast missing inmmio_write.
- local variable was kept invpci_mmio_readon arm to prevent a cast error in arm32.
Change in v5:
- Addpci_cleanup_msi(pdev)incleanup part.
- Added Reviewed-by: Stefano Stabellini <[email protected]> Change in v4:
- Move addition ofXEN_DOMCTL_CDF_vpciflag to separate patch Change in v3:
- Useis_pci_passthrough_enabled()in place ofpci_passthrough_enabledvariable
- RejectXEN_DOMCTL_CDF_vpcifor x86 inarch_sanitise_domain_config()
- RemoveIS_ENABLED(CONFIG_HAS_VPCI)fromhas_vpci()
Change in v2:
- Add newXEN_DOMCTL_CDF_vpciflag
- modifyhas_vpci()to includeXEN_DOMCTL_CDF_vpci
- enable vpci support when pci-passthough option is enabled.
------ xen/arch/arm/Makefile | 1 + xen/arch/arm/domain.c | 4 ++ xen/arch/arm/vpci.c | 74 +++++++++++++++++++++++++++++++++++ xen/arch/arm/vpci.h | 36 +++++++++++++++++ xen/drivers/passthrough/pci.c | 18 ++++++++- xen/drivers/vpci/header.c | 3 +- xen/drivers/vpci/vpci.c | 2 +- xen/include/asm-arm/domain.h | 1 + xen/include/asm-x86/pci.h | 2 - xen/include/public/arch-arm.h | 7 ++++ xen/include/xen/pci.h | 3 ++ 11 files changed, 146 insertions(+), 5 deletions(-) create mode 100644 xen/arch/arm/vpci.c create mode 100644 xen/arch/arm/vpci.hxen/arch/arm/Makefile +1
-0@@ -7,6 +7,7 @@ ifneq ($(CONFIG_NO_PLAT),y) obj-y += platforms/ endif obj-$(CONFIG_TEE) += tee/ +obj-$(CONFIG_HAS_VPCI) += vpci.o obj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o obj-y += bootfdt.init.oxen/arch/arm/domain.c +4
-0@@ -39,6 +39,7 @@#include <asm/vgic.h> #include <asm/vtimer.h> +#include "vpci.h" #include "vuart.h" DEFINE_PER_CPU(struct vcpu *, curr_vcpu);@@ -773,6 +774,9 @@ int arch_domain_create(struct domain *d,if (is_hardware_domain (d) && (rc =domain_vuart_init (d)) ) goto fail; +if ( (rc =domain_vpci_init (d)) !=0 ) + goto fail; +return 0 ; fail:xen/arch/arm/vpci.c new file +74
-0@@ -0,0 +1,74 @@ +/* +* xen/arch/arm/vpci.c +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ +#include <xen/sched.h> +#include <xen/vpci.h> + +#include <asm/mmio.h> + +static int vpci_mmio_read (struct vcpu *v,mmio_info_t *info, +register_t *r,void *p) +{ +pci_sbdf_t sbdf; +/* data is needed to prevent a pointer cast on 32bit */ +unsigned long data = ~0ul ; +int ret; + +/* We ignore segment part and always handle segment 0 */ + sbdf.sbdf =ECAM_BDF (info->gpa); + + ret =vpci_ecam_mmio_read (sbdf,ECAM_REG_OFFSET (info->gpa), +1U << info->dabt.size, &data); + + *r = data; + +return ret; +} + +static int vpci_mmio_write (struct vcpu *v,mmio_info_t *info, +register_t r,void *p) +{ +pci_sbdf_t sbdf; + +/* We ignore segment part and always handle segment 0 */ + sbdf.sbdf =ECAM_BDF (info->gpa); + +return vpci_ecam_mmio_write (sbdf,ECAM_REG_OFFSET (info->gpa), +1U << info->dabt.size, r); +} + +static const struct mmio_handler_ops vpci_mmio_handler = { + .read = vpci_mmio_read, + .write = vpci_mmio_write, +}; + +int domain_vpci_init (struct domain *d) +{ +if ( !has_vpci (d) ) +return 0 ; + +register_mmio_handler (d, &vpci_mmio_handler, +GUEST_VPCI_ECAM_BASE ,GUEST_VPCI_ECAM_SIZE ,NULL ); + +return 0 ; +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ +xen/arch/arm/vpci.h new file +36
-0@@ -0,0 +1,36 @@ +/* +* xen/arch/arm/vpci.h +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __ARCH_ARM_VPCI_H__ +#define __ARCH_ARM_VPCI_H__ + +#ifdef CONFIG_HAS_VPCI +int domain_vpci_init (struct domain *d); +#else +static inline int domain_vpci_init (struct domain *d) +{ +return 0 ; +} +#endif + +#endif /* __ARCH_ARM_VPCI_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ xen/drivers/passthrough/pci.c +17
-1@@ -658,7 +658,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, const struct pci_dev_info *info, nodeid_t node) { struct pci_seg *pseg; -struct pci_dev *pdev; +struct pci_dev *pdev =NULL ;unsigned int slot =PCI_SLOT (devfn), func =PCI_FUNC (devfn);const char *pdev_type;int ret;@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev); +#ifdef CONFIG_ARM +/* +* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ + ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif + ret =0 ;if ( !pdev->domain ) {@@ -784,6 +797,9 @@ out: &PCI_SBDF(seg, bus, slot, func)); } } +else if ( pdev ) +pci_cleanup_msi (pdev); +return ret; }xen/drivers/vpci/header.c +2
-1@@ -374,7 +374,8 @@ static void bar_write(const struct pci_dev *pdev, unsigned int reg,if ( val != (uint32_t )(bar->addr >> (hi ?32 :0 )) )gprintk (XENLOG_WARNING ,"%pp: ignored BAR %lu write with memory decoding enabled\n" , - &pdev->sbdf, bar - pdev->vpci->header.bars + hi); + &pdev->sbdf, + (unsigned long )(bar - pdev->vpci->header.bars + hi));return ; }xen/drivers/vpci/vpci.c +1
-1@@ -507,7 +507,7 @@ int vpci_ecam_mmio_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int len,vpci_write (sbdf, reg,min (4u , len), data);if ( len ==8 ) -vpci_write (sbdf, reg +4 ,4 , data >>32 ); +vpci_write (sbdf, reg +4 ,4 , (uint64_t )data >>32 );return 1 ; }xen/include/asm-arm/domain.h +1
-0@@ -263,6 +263,7 @@ static inline void arch_vcpu_block(struct vcpu *v) {}#define arch_vm_assist_valid_mask (d) (1UL << VMASST_TYPE_runstate_update_flag) +/* vPCI is not available on Arm */ #define has_vpci (d) ({ (void)(d); false; })#endif /* __ASM_DOMAIN_H__ */ xen/include/asm-x86/pci.h +0
-2@@ -6,8 +6,6 @@#define CF8_ADDR_HI (cf8) ( ((cf8) & 0x0f000000) >> 16)#define CF8_ENABLED (cf8) (!!((cf8) & 0x80000000)) -#define ECAM_BDF (addr) ( ((addr) & 0x0ffff000) >> 12) -#define IS_SNB_GFX (id) (id == 0x01068086 || id == 0x01168086 \ || id == 0x01268086 || id == 0x01028086 \ || id == 0x01128086 || id == 0x01228086 \xen/include/public/arch-arm.h +0
-0
xen/include/public/arch-arm.h typedef uint64_t xen_callback_t; · line 424
Quoted 7 lines
xen/include/public/arch-arm.h +4
-0@@ -418,6 +418,13 @@ typedef uint64_t xen_callback_t;#define GUEST_GICV3_GICR0_BASE xen_mk_ullong(0x03020000)/* vCPU0..127 */ #define GUEST_GICV3_GICR0_SIZE xen_mk_ullong(0x01000000) +/* +* 256 MB is reserved for VPCI configuration space based on calculation +* 256 buses × 32 devices × 8 functions × 4 KB = 256 MB +*/
Somehow 3 non-ascii characters sneaked into this patch. The 'x' are not 'x' but are 0xc3 and cause the following errors in a few gitlab-ci builds:
python3 mkheader.py arm32 arm32.h.tmp /builds/xen-project/people/sstabellini/xen/tools/include/xen-foreign/../../../xen/include/public/arch-arm.h /builds/xen-project/people/sstabellini/xen/tools/include/xen-foreign/../../../xen/include/public/xen.h Traceback (most recent call last):
File "mkheader.py", line 120, in <module>
input += f.read();
File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 14641: ordinal not in range(128) Makefile:28: recipe for target 'arm32.h' failed
make[2]: *** [arm32.h] Error 1
Full logs here:
https://gitlab.com/xen-project/people/sstabellini/xen/-/pipelines/38855078
https://gitlab.com/xen-project/people/sstabellini/xen/-/jobs/16810108756
Replacing the 3 characters with 'x' solves the problem.
https://gitlab.com/xen-project/people/sstabellini/xen/-/pipelines/388721262
With the three 'x' changed to ascii:
Quoted 23 lines
xen/include/public/arch-arm.h +3
-0+#define GUEST_VPCI_ECAM_BASE xen_mk_ullong(0x10000000) +#define GUEST_VPCI_ECAM_SIZE xen_mk_ullong(0x10000000) +/* ACPI tables physical address */ #define GUEST_ACPI_BASE xen_mk_ullong(0x20000000)#define GUEST_ACPI_SIZE xen_mk_ullong(0x02000000)xen/include/xen/pci.h +3
-0@@ -40,6 +40,9 @@#define PCI_SBDF3 (s,b,df) \ ((pci_sbdf_t){ .sbdf = (((s) & 0xffff) << 16) | PCI_BDF2(b, df) }) +#define ECAM_BDF (addr) ( ((addr) & 0x0ffff000) >> 12) +#define ECAM_REG_OFFSET (addr) ((addr) & 0x00000fff) + typedef union { uint32_t sbdf; struct {Signature · 1 line
2.25.1
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Quoted 26 lines · Stefano Stabellini
xen/include/public/arch-arm.h typedef uint64_t xen_callback_t; · line 424
Quoted 10 lines · Bertrand Marquis
xen/include/public/arch-arm.h +4
-0@@ -418,6 +418,13 @@ typedef uint64_t xen_callback_t;#define GUEST_GICV3_GICR0_BASE xen_mk_ullong(0x03020000)/* vCPU0..127 */ #define GUEST_GICV3_GICR0_SIZE xen_mk_ullong(0x01000000) +/* +* 256 MB is reserved for VPCI configuration space based on calculation +* 256 buses × 32 devices × 8 functions × 4 KB = 256 MB +*/ Somehow 3 non-ascii characters sneaked into this patch. The 'x' are not 'x' but are
0xc3and cause the following errors in a few gitlab-ci builds:python3
mkheader.pyarm32 arm32.h.tmp /builds/xen-project/people/sstabellini/xen/tools/include/xen-foreign/../../../xen/include/public/arch-arm.h /builds/xen-project/people/sstabellini/xen/tools/include/xen-foreign/../../../xen/include/public/xen.h Traceback (most recent call last):
File "mkheader.py", line 120, in <module>input += f.read();File "
/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
returncodecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte0xc3in position 14641: ordinal not in range(128) Makefile:28: recipe for target 'arm32.h' failed
make[2]: *** [arm32.h] Error 1
Quoted 7 lines
Full logs here:
https://gitlab.com/xen-project/people/sstabellini/xen/-/pipelines/38855078
https://gitlab.com/xen-project/people/sstabellini/xen/-/jobs/16810108756Replacing the 3 characters with 'x' solves the problem.
https://gitlab.com/xen-project/people/sstabellini/xen/-/pipelines/388721262
Interesting. I thought we permit UTF-8 in the sources; see e.g. tools/tests/x86_emulator/simd-sha.c using Σ. Is mkheader.py in need of adjustment? Of course I can see that right now the easiest is to use ASCII x, but I think it was deliberate to use × here.
Then again, with the goal of the public headers being usable with pretty old compilers as well (C89 being the assumed baseline), excluding them from the permission to use UTF-8 may also be quite reasonable.
Jan
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Jan Beulich writes ("Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM."):
Quoted 8 lines · Stefano Stabellini
Quoted 2 lines
Replacing the 3 characters with 'x' solves the problem.
https://gitlab.com/xen-project/people/sstabellini/xen/-/pipelines/388721262Interesting. I thought we permit UTF-8 in the sources; see e.g.
tools/tests/x86_emulator/simd-sha.cusing Σ. Ismkheader.pyin need of adjustment? Of course I can see that right now the easiest is to use ASCII x, but I think it was deliberate to use × here.
I think in general we should permit UTF-8 in sources.
But:
Quoted 4 lines
Then again, with the goal of the public headers being usable with pretty old compilers as well (C89 being the assumed baseline), excluding them from the permission to use UTF-8 may also be quite reasonable.
This is a good reason to do otherwise for the public headers. Maybe this should be documented in CODING_STYLE (can be done after feature freeze obviously).
That python has such botched unicode handling is a bug of course but we could decide we think it's a feature :-). In which case maybe mkheaders should be adjusted to explicitly set IO to ascii so that this will fail in local builds too.
Anyway, for now we need to replace the UTF-8 in this patch.
Thanks,
Ian.
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
In reply to Stefano StabelliniHi Stefano,
Quoted 365 lines · Stefano Stabellini
Quoted 12 lines · Bertrand Marquis
From: Rahul Singh <[email protected]>
The existing VPCI support available for X86 is adapted for Arm. When the device is added to XEN via the hyper call “PHYSDEVOP_pci_device_add”, VPCI handler for the config space access is added to the Xen to emulate the PCI devices config space.
A MMIO trap handler for the PCI ECAM space is registered in XEN so that when guest is trying to access the PCI config space,XEN will trap the access and emulate read/write using the VPCI and not the real PCI hardware.
Quoted 7 lines
For Dom0less systems
scan_pci_devices()would be used to discover the PCI device in XEN and VPCI handler will be added during XEN boots.This patch is also doing some small fixes to fix compilation errors on arm32 of vpci:
- add a cast to unsigned long in print inheader.c
- add a cast touint64_tinvpci_ecam_mmio_writeThank you for these! Strictly speaking they are not required now but they are welcome. I would also be OK if they were removed from this patch but it is fine to have them in here.
There is an issues with this patch, see below at the bottom
Quoted 308 lines
Signed-off-by Rahul Singh <[email protected]>Signed-off-by Bertrand Marquis <[email protected]>---
Changes in v6:
- Use newvpci_ecam_helpers for PCI access
- Do not setXEN_DOMCTL_CDF_vpcifor dom0 for now (will be done in a future patch once everything is ready)
- renameREGISTER_OFFSETtoECAM_REG_OFFSETand move it topci.h
- remove not needed local variables invpci_mmio_write, the one in read has been kept to ensure proper compilation on arm32
- move call tovpci_add_handlersbefore iommu init to simplify exit path
- move call topci_cleanup_msiin the out section ofpci_add_deviceif pdev is not NULL and on error
- initialize pdev to NULL to handle properly exit path call ofpci_cleanup_msi
- keephas_vpcito return false for now asCFG_vpcihas been removed. Added a comment on top of the definition.
- fix compilation errors on arm32 (print inheader.c, cast missing inmmio_write.
- local variable was kept invpci_mmio_readon arm to prevent a cast error in arm32.
Change in v5:
- Addpci_cleanup_msi(pdev)incleanup part.
- Added Reviewed-by: Stefano Stabellini <[email protected]> Change in v4:
- Move addition ofXEN_DOMCTL_CDF_vpciflag to separate patch Change in v3:
- Useis_pci_passthrough_enabled()in place ofpci_passthrough_enabledvariable
- RejectXEN_DOMCTL_CDF_vpcifor x86 inarch_sanitise_domain_config()
- RemoveIS_ENABLED(CONFIG_HAS_VPCI)fromhas_vpci()
Change in v2:
- Add newXEN_DOMCTL_CDF_vpciflag
- modifyhas_vpci()to includeXEN_DOMCTL_CDF_vpci
- enable vpci support when pci-passthough option is enabled.
---
---xen/arch/arm/Makefile | 1 + xen/arch/arm/domain.c | 4 ++ xen/arch/arm/vpci.c | 74 +++++++++++++++++++++++++++++++++++ xen/arch/arm/vpci.h | 36 +++++++++++++++++ xen/drivers/passthrough/pci.c | 18 ++++++++- xen/drivers/vpci/header.c | 3 +- xen/drivers/vpci/vpci.c | 2 +- xen/include/asm-arm/domain.h | 1 + xen/include/asm-x86/pci.h | 2 - xen/include/public/arch-arm.h | 7 ++++ xen/include/xen/pci.h | 3 ++ 11 files changed, 146 insertions(+), 5 deletions(-)create mode 100644
xen/arch/arm/vpci.c
create mode 100644xen/arch/arm/vpci.hxen/arch/arm/Makefile +0
-0@@ -7,6 +7,7 @@ ifneq ($(CONFIG_NO_PLAT),y)obj-y += platforms/
endif
obj-$(CONFIG_TEE) += tee/
+obj-$(CONFIG_HAS_VPCI) += vpci.oobj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o
obj-y += bootfdt.init.oxen/arch/arm/domain.c +4
-0@@ -39,6 +39,7 @@#include <asm/vgic.h> #include <asm/vtimer.h> +#include "vpci.h" #include "vuart.h" DEFINE_PER_CPU(struct vcpu *, curr_vcpu);@@ -773,6 +774,9 @@ int arch_domain_create(struct domain *d,if (is_hardware_domain (d) && (rc =domain_vuart_init (d)) ) goto fail; +if ( (rc =domain_vpci_init (d)) !=0 ) + goto fail; +return 0 ;fail:
xen/arch/arm/vpci.c new file +74
-0@@ -0,0 +1,74 @@ +/* +* xen/arch/arm/vpci.c +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ +#include <xen/sched.h> +#include <xen/vpci.h> + +#include <asm/mmio.h> + +static int vpci_mmio_read (struct vcpu *v,mmio_info_t *info, +register_t *r,void *p) +{ +pci_sbdf_t sbdf; +/* data is needed to prevent a pointer cast on 32bit */ +unsigned long data = ~0ul ; +int ret; + +/* We ignore segment part and always handle segment 0 */ + sbdf.sbdf =ECAM_BDF (info->gpa); + + ret =vpci_ecam_mmio_read (sbdf,ECAM_REG_OFFSET (info->gpa), +1U << info->dabt.size, &data); + + *r = data; + +return ret; +} + +static int vpci_mmio_write (struct vcpu *v,mmio_info_t *info, +register_t r,void *p) +{ +pci_sbdf_t sbdf; + +/* We ignore segment part and always handle segment 0 */ + sbdf.sbdf =ECAM_BDF (info->gpa); + +return vpci_ecam_mmio_write (sbdf,ECAM_REG_OFFSET (info->gpa), +1U << info->dabt.size, r); +} + +static const struct mmio_handler_ops vpci_mmio_handler = { + .read = vpci_mmio_read, + .write = vpci_mmio_write, +}; + +int domain_vpci_init (struct domain *d) +{ +if ( !has_vpci (d) ) +return 0 ; + +register_mmio_handler (d, &vpci_mmio_handler, +GUEST_VPCI_ECAM_BASE ,GUEST_VPCI_ECAM_SIZE ,NULL ); + +return 0 ; +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ +xen/arch/arm/vpci.h new file +36
-0@@ -0,0 +1,36 @@ +/* +* xen/arch/arm/vpci.h +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __ARCH_ARM_VPCI_H__ +#define __ARCH_ARM_VPCI_H__ + +#ifdef CONFIG_HAS_VPCI +int domain_vpci_init (struct domain *d); +#else +static inline int domain_vpci_init (struct domain *d) +{ +return 0 ; +} +#endif + +#endif /* __ARCH_ARM_VPCI_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ xen/drivers/passthrough/pci.c +17
-1@@ -658,7 +658,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, const struct pci_dev_info *info, nodeid_t node) { struct pci_seg *pseg; -struct pci_dev *pdev; +struct pci_dev *pdev =NULL ;unsigned int slot =PCI_SLOT (devfn), func =PCI_FUNC (devfn);const char *pdev_type;int ret;@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev); +#ifdef CONFIG_ARM +/* +* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ + ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif + ret =0 ;if ( !pdev->domain ) {@@ -784,6 +797,9 @@ out: &PCI_SBDF(seg, bus, slot, func)); } } +else if ( pdev ) +pci_cleanup_msi (pdev); +return ret; }xen/drivers/vpci/header.c +2
-1@@ -374,7 +374,8 @@ static void bar_write(const struct pci_dev *pdev, unsigned int reg,if ( val != (uint32_t )(bar->addr >> (hi ?32 :0 )) )gprintk (XENLOG_WARNING ,"%pp: ignored BAR %lu write with memory decoding enabled\n" , - &pdev->sbdf, bar - pdev->vpci->header.bars + hi); + &pdev->sbdf, + (unsigned long )(bar - pdev->vpci->header.bars + hi));return ; }xen/drivers/vpci/vpci.c +1
-1@@ -507,7 +507,7 @@ int vpci_ecam_mmio_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int len,vpci_write (sbdf, reg,min (4u , len), data);if ( len ==8 ) -vpci_write (sbdf, reg +4 ,4 , data >>32 ); +vpci_write (sbdf, reg +4 ,4 , (uint64_t )data >>32 );return 1 ; }xen/include/asm-arm/domain.h +1
-0@@ -263,6 +263,7 @@ static inline void arch_vcpu_block(struct vcpu *v) {}#define arch_vm_assist_valid_mask (d) (1UL << VMASST_TYPE_runstate_update_flag) +/* vPCI is not available on Arm */ #define has_vpci (d) ({ (void)(d); false; })#endif /* __ASM_DOMAIN_H__ */ xen/include/asm-x86/pci.h +0
-2@@ -6,8 +6,6 @@#define CF8_ADDR_HI (cf8) ( ((cf8) & 0x0f000000) >> 16)#define CF8_ENABLED (cf8) (!!((cf8) & 0x80000000)) -#define ECAM_BDF (addr) ( ((addr) & 0x0ffff000) >> 12) -#define IS_SNB_GFX (id) (id == 0x01068086 || id == 0x01168086 \ || id == 0x01268086 || id == 0x01028086 \ || id == 0x01128086 || id == 0x01228086 \xen/include/public/arch-arm.h +0
-0xen/include/public/arch-arm.h typedef uint64_t xen_callback_t; · line 424
Quoted 7 lines
xen/include/public/arch-arm.h +4
-0@@ -418,6 +418,13 @@ typedef uint64_t xen_callback_t;#define GUEST_GICV3_GICR0_BASE xen_mk_ullong(0x03020000)/* vCPU0..127 */ #define GUEST_GICV3_GICR0_SIZE xen_mk_ullong(0x01000000) +/* +* 256 MB is reserved for VPCI configuration space based on calculation +* 256 buses × 32 devices × 8 functions × 4 KB = 256 MB +*/ Somehow 3 non-ascii characters sneaked into this patch. The 'x' are not 'x' but are
0xc3and cause the following errors in a few gitlab-ci builds:python3
mkheader.pyarm32 arm32.h.tmp /builds/xen-project/people/sstabellini/xen/tools/include/xen-foreign/../../../xen/include/public/arch-arm.h /builds/xen-project/people/sstabellini/xen/tools/include/xen-foreign/../../../xen/include/public/xen.h Traceback (most recent call last):
File "mkheader.py", line 120, in <module>
input +=f.read();
File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
returncodecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte0xc3in position 14641: ordinal not in range(128)
Makefile:28: recipe for target 'arm32.h' failed
make[2]: *** [arm32.h] Error 1Full logs here:
https://gitlab.com/xen-project/people/sstabellini/xen/-/pipelines/38855078
https://gitlab.com/xen-project/people/sstabellini/xen/-/jobs/16810108756
Quoted 7 lines
Replacing the 3 characters with 'x' solves the problem.
https://gitlab.com/xen-project/people/sstabellini/xen/-/pipelines/388721262With the three 'x' changed to ascii:
Reviewed-by Stefano Stabellini <[email protected]>
I will fix that but sadly seeing all other changes to be done I do not think I can keep your R-b.
Thanks
Bertrand
Quoted 25 lines
Quoted 25 lines
xen/include/public/arch-arm.h +3
-0+#define GUEST_VPCI_ECAM_BASE xen_mk_ullong(0x10000000) +#define GUEST_VPCI_ECAM_SIZE xen_mk_ullong(0x10000000) +/* ACPI tables physical address */ #define GUEST_ACPI_BASE xen_mk_ullong(0x20000000)#define GUEST_ACPI_SIZE xen_mk_ullong(0x02000000)xen/include/xen/pci.h +3
-0@@ -40,6 +40,9 @@#define PCI_SBDF3 (s,b,df) \ ((pci_sbdf_t){ .sbdf = (((s) & 0xffff) << 16) | PCI_BDF2(b, df) }) +#define ECAM_BDF (addr) ( ((addr) & 0x0ffff000) >> 12) +#define ECAM_REG_OFFSET (addr) ((addr) & 0x00000fff) + typedef union { uint32_t sbdf; struct {Signature · 1 line
2.25.1
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
In reply to Bertrand MarquisQuoted 9 lines · Bertrand Marquis
xen/drivers/passthrough/pci.c +5
-0@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev); +#ifdef CONFIG_ARM +/* +* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/
xen/drivers/passthrough/pci.c int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 769
Quoted 10 lines
xen/drivers/passthrough/pci.c +8
-0+ ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif + ret =0 ;if ( !pdev->domain )
Elsewhere I did point out that you need to be careful wrt pdev->domain being NULL. As the code in context clearly documents, you're now adding handlers before that field was set. In comments to a prior version I did already suggest to consider placing the new code inside the if() in question (albeit at the time this was mainly to make clear that error cleanup may not fiddle with things not put in place by the iommu_enable_device() alternative path). This would have the further benefit of making is crystal clear that here only handlers for Dom0 would get put in place (and hence their installing for DomU-s would need to be looked for elsewhere).
xen/drivers/passthrough/pci.c out: · line 801
Quoted 6 lines
xen/drivers/passthrough/pci.c +2
-0@@ -784,6 +797,9 @@ out: &PCI_SBDF(seg, bus, slot, func)); } } +else if ( pdev ) +pci_cleanup_msi (pdev);
Have you thoroughly checked that this call is benign on x86? There's no wording to that effect in the description afaics, and I can't easily convince myself that it would be correct when the iommu_enable_device() path was taken. (I'm also not going to exclude that it should have been there even prior to your work, albeit then adding this would want to be a separate bugfix patch.)
xen/drivers/vpci/header.c static void bar_write(const struct pci_dev *pdev, unsigned int reg, · line 378
Quoted 9 lines
xen/drivers/vpci/header.c +2
-1@@ -374,7 +374,8 @@ static void bar_write(const struct pci_dev *pdev, unsigned int reg,if ( val != (uint32_t )(bar->addr >> (hi ?32 :0 )) )gprintk (XENLOG_WARNING ,"%pp: ignored BAR %lu write with memory decoding enabled\n" , - &pdev->sbdf, bar - pdev->vpci->header.bars + hi); + &pdev->sbdf, + (unsigned long )(bar - pdev->vpci->header.bars + hi));
This looks like an entirely unrelated change which I'm afraid I don't even understand why it needs making. The description says this is for Arm32, but it remains unclear what the compilation error would have been. My best guess is that perhaps you really mean to change the format specifier to %zu (really this should be %td, but our vsprintf() doesn't support 't' for whatever reason).
Please recall that we try to avoid casts where possible.
xen/drivers/vpci/vpci.c int vpci_ecam_mmio_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int len, · line 510
Quoted 8 lines
xen/drivers/vpci/vpci.c +1
-1@@ -507,7 +507,7 @@ int vpci_ecam_mmio_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int len,vpci_write (sbdf, reg,min (4u , len), data);if ( len ==8 ) -vpci_write (sbdf, reg +4 ,4 , data >>32 ); +vpci_write (sbdf, reg +4 ,4 , (uint64_t )data >>32 );
I assume the need for this change will go away with the use of CONFIG_64BIT in the earlier patch.
xen/include/xen/pci.h line 44
Quoted 8 lines
xen/include/xen/pci.h +2
-0@@ -40,6 +40,9 @@#define PCI_SBDF3 (s,b,df) \ ((pci_sbdf_t){ .sbdf = (((s) & 0xffff) << 16) | PCI_BDF2(b, df) }) +#define ECAM_BDF (addr) ( ((addr) & 0x0ffff000) >> 12) +#define ECAM_REG_OFFSET (addr) ((addr) & 0x00000fff)
The latter is fine to be put here (i.e. FTAOD I'm fine with it staying here). For the former I even question its original placement in asm-x86/pci.h: It's not generally correct as per the PCI spec, as the bus portion of the address can be anywhere from 1 to 8 bits. And in fact there is a reason why this macro was/is used in only a single place, but not e.g. in x86'es handling of physical MCFG. It is merely an implementation choice in vPCI that the entire segment 0 has a linear address range covering all 256 buses. Hence I think this wants to move to xen/vpci.h and then perhaps also be named VPCI_ECAM_BDF().
Also, as already pointed out on a much earlier version, while the blank following the opening parenthesis was warranted in asm-x86/pci.h for alignment reasons, it is no longer warranted here. It was certainly gone in v4 and v5.
And one final nit: I don't think we commonly use full stops in patch titles. (Personally I therefore also think titles shouldn't start with a capital letter, but I know others think differently.)
Jan
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Hi Jan,
Quoted 25 lines · Jan Beulich
Quoted 9 lines · Bertrand Marquis
xen/drivers/passthrough/pci.c +5
-0@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev); +#ifdef CONFIG_ARM +/* +* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ xen/drivers/passthrough/pci.c int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 769
Quoted 10 lines
xen/drivers/passthrough/pci.c +8
-0+ ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif + ret =0 ;if ( !pdev->domain )Elsewhere I did point out that you need to be careful wrt
pdev->domainbeing NULL. As the code in context clearly documents, you're now
Quoted 8 lines
adding handlers before that field was set. In comments to a prior version I did already suggest to consider placing the new code inside the
if()in question (albeit at the time this was mainly to make clear that error cleanup may not fiddle with things not put in place by theiommu_enable_device()alternative path). This would have the further benefit of making is crystal clear that here only handlers for Dom0 would get put in place (and hence their installing for DomU-s would need to be looked for elsewhere).
I asked Oleksandr for confirmation here but on arm there will be 2 other use cases:
- PCI own by a DomD so device enumeration done from there
- dom0less with devices detection done inside Xen
Quoted 14 lines
xen/drivers/passthrough/pci.c out: · line 801
Quoted 7 lines
xen/drivers/passthrough/pci.c +2
-0@@ -784,6 +797,9 @@ out: &PCI_SBDF(seg, bus, slot, func)); } } +else if ( pdev ) +pci_cleanup_msi (pdev);Have you thoroughly checked that this call is benign on x86? There's no wording to that effect in the description afaics, and I can't easily convince myself that it would be correct when the
iommu_enable_device()path was taken. (I'm also not going to exclude that it should have been there even prior to your work, albeit then adding this would want to be a separate bugfix patch.)
This was not in the original serie and requested by Stefano. I must admit I am not completely sure on the details here so I am really ok to remove this but this would go against what was requested on the previous versions (4 and 5).
Quoted 17 lines
xen/drivers/vpci/header.c static void bar_write(const struct pci_dev *pdev, unsigned int reg, · line 378
Quoted 10 lines
xen/drivers/vpci/header.c +2
-1@@ -374,7 +374,8 @@ static void bar_write(const struct pci_dev *pdev, unsigned int reg,if ( val != (uint32_t )(bar->addr >> (hi ?32 :0 )) )gprintk (XENLOG_WARNING ,"%pp: ignored BAR %lu write with memory decoding enabled\n" , - &pdev->sbdf, bar - pdev->vpci->header.bars + hi); + &pdev->sbdf, + (unsigned long )(bar - pdev->vpci->header.bars + hi));This looks like an entirely unrelated change which I'm afraid I don't even understand why it needs making. The description says this is for Arm32, but it remains unclear what the compilation error would have been. My best guess is that perhaps you really mean to change the format specifier to %zu (really this should be %td, but our
vsprintf()doesn't support 't' for whatever reason).
Compilation error is about an invalid %lu print for an unsigned int value when compiled for arm32.
I will use zu instead in the next version and remove the cast.
Quoted 2 lines
Please recall that we try to avoid casts where possible.
Sure I will.
Quoted 5 lines
Quoted 5 lines
xen/drivers/vpci/vpci.c +0
-0@@ -507,7 +507,7 @@ int vpci_ecam_mmio_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int len,
Quoted 7 lines
xen/drivers/vpci/vpci.c int vpci_ecam_mmio_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int len, · line 510
Quoted 4 lines
xen/drivers/vpci/vpci.c +1
-1vpci_write (sbdf, reg,min (4u , len), data);if ( len ==8 ) -vpci_write (sbdf, reg +4 ,4 , data >>32 ); +vpci_write (sbdf, reg +4 ,4 , (uint64_t )data >>32 );I assume the need for this change will go away with the use of
CONFIG_64BITin the earlier patch.
Yes
Quoted 7 lines
Quoted 7 lines
xen/include/xen/pci.h +0
-0@@ -40,6 +40,9 @@#define PCI_SBDF3 (s,b,df) \ ((pci_sbdf_t){ .sbdf = (((s) & 0xffff) << 16) | PCI_BDF2(b, df) })
Quoted 13 lines
xen/include/xen/pci.h line 44
Quoted 2 lines
xen/include/xen/pci.h +2
-0+#define ECAM_BDF (addr) ( ((addr) & 0x0ffff000) >> 12) +#define ECAM_REG_OFFSET (addr) ((addr) & 0x00000fff)The latter is fine to be put here (i.e. FTAOD I'm fine with it staying here). For the former I even question its original placement in
asm-x86/pci.h: It's not generally correct as per the PCI spec, as the bus portion of the address can be anywhere from 1 to 8 bits. And in fact there is a reason why this macro was/is used in only a single place, but not e.g. in x86'es handling of physical MCFG. It is merely an implementation choice in vPCI that the entire segment 0 has a linear address range covering all 256 buses. Hence I think this wants to move toxen/vpci.hand then perhaps also be namedVPCI_ECAM_BDF().
On previous version it was request to renamed this to ECAM and agreed to put is here. Now you want me to rename it to VPCI and move it again. I would like to have a confirmation that this is ok and the final move if possible.
@Roger can you confirm this is what is wanted ?
Also if I have to do this I will do the same for REG_OFFSET of course.
Quoted 5 lines
Also, as already pointed out on a much earlier version, while the blank following the opening parenthesis was warranted in
asm-x86/pci.hfor alignment reasons, it is no longer warranted here. It was certainly gone in v4 and v5.
Yes my mistake during the process I did a copy and paste from the original one and did not modify. I will fix that.
Quoted 4 lines
And one final nit: I don't think we commonly use full stops in patch titles. (Personally I therefore also think titles shouldn't start with a capital letter, but I know others think differently.)
Ok I will fix the patch name.
Cheers
Bertrand
Quoted 3 lines
Jan
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Bertrand Marquis writes ("Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM."):
Quoted 12 lines
Quoted 11 lines · Jan Beulich
The latter is fine to be put here (i.e. FTAOD I'm fine with it staying here). For the former I even question its original placement in
asm-x86/pci.h: It's not generally correct as per the PCI spec, as the bus portion of the address can be anywhere from 1 to 8 bits. And in fact there is a reason why this macro was/is used in only a single place, but not e.g. in x86'es handling of physical MCFG. It is merely an implementation choice in vPCI that the entire segment 0 has a linear address range covering all 256 buses. Hence I think this wants to move toxen/vpci.hand then perhaps also be namedVPCI_ECAM_BDF().
Quoted 5 lines
On previous version it was request to renamed this to ECAM and agreed to put is here. Now you want me to rename it to VPCI and move it again. I would like to have a confirmation that this is ok and the final move if possible.
@Roger can you confirm this is what is wanted ?
I think Roger is not available today I'm afraid.
Bertrand, can you give me a link to the comment from Roger ? Assuming that it says what I think it will say:
I think the best thing to do will be to leave the name as it was in the most recent version of your series. I don't think it makes sense to block this patch over a naming disagreement. And it would be best to minimise unnecessary churn.
I would be happy to release-ack a name change (perhaps proposed bo Jan or Roger) supposing that that is the ultimate maintainer consensus.
Jan, would that approach be OK with you ?
Ian.
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Quoted 29 lines · Ian Jackson
Bertrand Marquis writes ("Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM."):
Quoted 12 lines
Quoted 11 lines · Jan Beulich
The latter is fine to be put here (i.e. FTAOD I'm fine with it staying here). For the former I even question its original placement in
asm-x86/pci.h: It's not generally correct as per the PCI spec, as the bus portion of the address can be anywhere from 1 to 8 bits. And in fact there is a reason why this macro was/is used in only a single place, but not e.g. in x86'es handling of physical MCFG. It is merely an implementation choice in vPCI that the entire segment 0 has a linear address range covering all 256 buses. Hence I think this wants to move toxen/vpci.hand then perhaps also be namedVPCI_ECAM_BDF().Quoted 5 lines
On previous version it was request to renamed this to ECAM and agreed to put is here. Now you want me to rename it to VPCI and move it again. I would like to have a confirmation that this is ok and the final move if possible.
@Roger can you confirm this is what is wanted ?
I think Roger is not available today I'm afraid.
Bertrand, can you give me a link to the comment from Roger ? Assuming that it says what I think it will say:
I think the best thing to do will be to leave the name as it was in the most recent version of your series. I don't think it makes sense to block this patch over a naming disagreement. And it would be best to minimise unnecessary churn.
Quoted 4 lines
I would be happy to release-ack a name change (perhaps proposed bo Jan or Roger) supposing that that is the ultimate maintainer consensus.
Jan, would that approach be OK with you ?
Well, yes, if a subsequent name change is okay, then I could live with that. I'd still find it odd to rename a function immediately after it already got renamed. As expressed elsewhere, I suspect in his request Roger did not pay attention to a use of the function in non-ECAM code.
Jan
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Quoted 33 lines · Jan Beulich
Quoted 32 lines · Ian Jackson
Bertrand Marquis writes ("Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM."):
Quoted 12 lines
Quoted 11 lines · Jan Beulich
The latter is fine to be put here (i.e. FTAOD I'm fine with it staying here). For the former I even question its original placement in
asm-x86/pci.h: It's not generally correct as per the PCI spec, as the bus portion of the address can be anywhere from 1 to 8 bits. And in fact there is a reason why this macro was/is used in only a single place, but not e.g. in x86'es handling of physical MCFG. It is merely an implementation choice in vPCI that the entire segment 0 has a linear address range covering all 256 buses. Hence I think this wants to move toxen/vpci.hand then perhaps also be namedVPCI_ECAM_BDF().Quoted 5 lines
On previous version it was request to renamed this to ECAM and agreed to put is here. Now you want me to rename it to VPCI and move it again. I would like to have a confirmation that this is ok and the final move if possible.
@Roger can you confirm this is what is wanted ?
I think Roger is not available today I'm afraid.
Bertrand, can you give me a link to the comment from Roger ? Assuming that it says what I think it will say:
I think the best thing to do will be to leave the name as it was in the most recent version of your series. I don't think it makes sense to block this patch over a naming disagreement. And it would be best to minimise unnecessary churn.
I would be happy to release-ack a name change (perhaps proposed bo Jan or Roger) supposing that that is the ultimate maintainer consensus.
Quoted 6 lines
Quoted 1 line
Jan, would that approach be OK with you ?
Well, yes, if a subsequent name change is okay, then I could live with that. I'd still find it odd to rename a function immediately after it already got renamed. As expressed elsewhere, I suspect in his request Roger did not pay attention to a use of the function in non-ECAM code.
Using MMCFG_BDF was original requested by Julien, not myself I think:
https://lore.kernel.org/xen-devel/[email protected]/
I'm slightly loss in so many messages. On x86 we subtract the MCFG start address from the passed one before getting the BDF, and then we add the startting bus address passed in the ACPI table. This is so far not need on Arm AFAICT because of the fixed nature of the selected virtual ECAM region.
Thanks, Roger.
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Hi Roger,
Quoted 45 lines · Roger Pau Monné
Quoted 33 lines · Jan Beulich
Quoted 32 lines · Ian Jackson
Bertrand Marquis writes ("Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM."):
Quoted 12 lines
Quoted 11 lines · Jan Beulich
The latter is fine to be put here (i.e. FTAOD I'm fine with it staying here). For the former I even question its original placement in
asm-x86/pci.h: It's not generally correct as per the PCI spec, as the bus portion of the address can be anywhere from 1 to 8 bits. And in fact there is a reason why this macro was/is used in only a single place, but not e.g. in x86'es handling of physical MCFG. It is merely an implementation choice in vPCI that the entire segment 0 has a linear address range covering all 256 buses. Hence I think this wants to move toxen/vpci.hand then perhaps also be namedVPCI_ECAM_BDF().Quoted 5 lines
On previous version it was request to renamed this to ECAM and agreed to put is here. Now you want me to rename it to VPCI and move it again. I would like to have a confirmation that this is ok and the final move if possible.
@Roger can you confirm this is what is wanted ?
I think Roger is not available today I'm afraid.
Bertrand, can you give me a link to the comment from Roger ? Assuming that it says what I think it will say:
I think the best thing to do will be to leave the name as it was in the most recent version of your series. I don't think it makes sense to block this patch over a naming disagreement. And it would be best to minimise unnecessary churn.
I would be happy to release-ack a name change (perhaps proposed bo Jan or Roger) supposing that that is the ultimate maintainer consensus.
Quoted 6 lines
Quoted 1 line
Jan, would that approach be OK with you ?
Well, yes, if a subsequent name change is okay, then I could live with that. I'd still find it odd to rename a function immediately after it already got renamed. As expressed elsewhere, I suspect in his request Roger did not pay attention to a use of the function in non-ECAM code.
Using
MMCFG_BDFwas original requested by Julien, not myself I think:
Quoted 7 lines
https://lore.kernel.org/xen-devel/[email protected]/
I'm slightly loss in so many messages. On x86 we subtract the MCFG start address from the passed one before getting the BDF, and then we add the startting bus address passed in the ACPI table. This is so far not need on Arm AFAICT because of the fixed nature of the selected virtual ECAM region.
At the end my patch will add in xen/pci.h:
#define ECAM_BDF(addr) (((addr) & 0x0ffff000) >> 12)
#define ECAM_REG_OFFSET(addr) ((addr) & 0x00000fff)
Now seeing the comment the question is should those be renamed with a VPCI prefix and be moved to xen/vpci.h.
So far ECAM_BDF is only used in vpci_mmcfg_decode_addr which is only called before calling vpci_ecam_{read/write}.
ECAM_REG_OFFSET is only used in arm vpci code.
Do you think the current state is ok of the renaming + moving should be done ?
Cheers
Bertrand
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Quoted 49 lines · Bertrand Marquis
Hi Roger,
Quoted 47 lines · Roger Pau Monné
Quoted 33 lines · Jan Beulich
Quoted 32 lines · Ian Jackson
Bertrand Marquis writes ("Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM."):
Quoted 12 lines
Quoted 11 lines · Jan Beulich
The latter is fine to be put here (i.e. FTAOD I'm fine with it staying here). For the former I even question its original placement in
asm-x86/pci.h: It's not generally correct as per the PCI spec, as the bus portion of the address can be anywhere from 1 to 8 bits. And in fact there is a reason why this macro was/is used in only a single place, but not e.g. in x86'es handling of physical MCFG. It is merely an implementation choice in vPCI that the entire segment 0 has a linear address range covering all 256 buses. Hence I think this wants to move toxen/vpci.hand then perhaps also be namedVPCI_ECAM_BDF().Quoted 5 lines
On previous version it was request to renamed this to ECAM and agreed to put is here. Now you want me to rename it to VPCI and move it again. I would like to have a confirmation that this is ok and the final move if possible.
@Roger can you confirm this is what is wanted ?
I think Roger is not available today I'm afraid.
Bertrand, can you give me a link to the comment from Roger ? Assuming that it says what I think it will say:
I think the best thing to do will be to leave the name as it was in the most recent version of your series. I don't think it makes sense to block this patch over a naming disagreement. And it would be best to minimise unnecessary churn.
I would be happy to release-ack a name change (perhaps proposed bo Jan or Roger) supposing that that is the ultimate maintainer consensus.
Quoted 6 lines
Quoted 1 line
Jan, would that approach be OK with you ?
Well, yes, if a subsequent name change is okay, then I could live with that. I'd still find it odd to rename a function immediately after it already got renamed. As expressed elsewhere, I suspect in his request Roger did not pay attention to a use of the function in non-ECAM code.
Using
MMCFG_BDFwas original requested by Julien, not myself I think:
Quoted 8 lines
Quoted 5 lines
I'm slightly loss in so many messages. On x86 we subtract the MCFG start address from the passed one before getting the BDF, and then we add the startting bus address passed in the ACPI table. This is so far not need on Arm AFAICT because of the fixed nature of the selected virtual ECAM region.
At the end my patch will add in
xen/pci.h:
#defineECAM_BDF(addr)(((addr) &0x0ffff000) >> 12)
Since you still make this proposal, once again: I'm not going to accept such a macro in this header, whatever the name. Its prior placement was wrong as well. Only ...
Quoted 1 line
#define
ECAM_REG_OFFSET(addr)((addr) &0x00000fff)
... this one is fine to live here (and presumably it could gain uses elsewhere).
Jan
Quoted 13 lines
Now seeing the comment the question is should those be renamed with a VPCI prefix and be moved to
xen/vpci.h.So far
ECAM_BDFis only used invpci_mmcfg_decode_addrwhich is only called before calling vpci_ecam_{read/write}.
ECAM_REG_OFFSETis only used in arm vpci code.Do you think the current state is ok of the renaming + moving should be done ?
Cheers
Bertrand
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Hi Jan,
Quoted 61 lines · Jan Beulich
Quoted 49 lines · Bertrand Marquis
Hi Roger,
Quoted 47 lines · Roger Pau Monné
Quoted 33 lines · Jan Beulich
Quoted 32 lines · Ian Jackson
Bertrand Marquis writes ("Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM."):
Quoted 12 lines
Quoted 11 lines · Jan Beulich
The latter is fine to be put here (i.e. FTAOD I'm fine with it staying here). For the former I even question its original placement in
asm-x86/pci.h: It's not generally correct as per the PCI spec, as the bus portion of the address can be anywhere from 1 to 8 bits. And in fact there is a reason why this macro was/is used in only a single place, but not e.g. in x86'es handling of physical MCFG. It is merely an implementation choice in vPCI that the entire segment 0 has a linear address range covering all 256 buses. Hence I think this wants to move toxen/vpci.hand then perhaps also be namedVPCI_ECAM_BDF().Quoted 5 lines
On previous version it was request to renamed this to ECAM and agreed to put is here. Now you want me to rename it to VPCI and move it again. I would like to have a confirmation that this is ok and the final move if possible.
@Roger can you confirm this is what is wanted ?
I think Roger is not available today I'm afraid.
Bertrand, can you give me a link to the comment from Roger ? Assuming that it says what I think it will say:
I think the best thing to do will be to leave the name as it was in the most recent version of your series. I don't think it makes sense to block this patch over a naming disagreement. And it would be best to minimise unnecessary churn.
I would be happy to release-ack a name change (perhaps proposed bo Jan or Roger) supposing that that is the ultimate maintainer consensus.
Quoted 6 lines
Quoted 1 line
Jan, would that approach be OK with you ?
Well, yes, if a subsequent name change is okay, then I could live with that. I'd still find it odd to rename a function immediately after it already got renamed. As expressed elsewhere, I suspect in his request Roger did not pay attention to a use of the function in non-ECAM code.
Using
MMCFG_BDFwas original requested by Julien, not myself I think:Quoted 8 lines
Quoted 5 lines
I'm slightly loss in so many messages. On x86 we subtract the MCFG start address from the passed one before getting the BDF, and then we add the startting bus address passed in the ACPI table. This is so far not need on Arm AFAICT because of the fixed nature of the selected virtual ECAM region.
At the end my patch will add in
xen/pci.h:
#defineECAM_BDF(addr)(((addr) &0x0ffff000) >> 12)
Quoted 8 lines
Since you still make this proposal, once again: I'm not going to accept such a macro in this header, whatever the name. Its prior placement was wrong as well. Only ...
Quoted 1 line
#define
ECAM_REG_OFFSET(addr)((addr) &0x00000fff)... this one is fine to live here (and presumably it could gain uses elsewhere).
So you would agree if they are both moved to vpci.h with a VPCI_ prefix ?
Bertrand
Quoted 15 lines
Jan
Quoted 12 lines
Now seeing the comment the question is should those be renamed with a VPCI prefix and be moved to
xen/vpci.h.So far
ECAM_BDFis only used invpci_mmcfg_decode_addrwhich is only called before calling vpci_ecam_{read/write}.
ECAM_REG_OFFSETis only used in arm vpci code.Do you think the current state is ok of the renaming + moving should be done ?
Cheers
Bertrand
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Quoted 61 lines · Bertrand Marquis
Quoted 61 lines · Jan Beulich
Quoted 46 lines · Bertrand Marquis
Quoted 46 lines · Roger Pau Monné
Quoted 33 lines · Jan Beulich
Quoted 32 lines · Ian Jackson
Bertrand Marquis writes ("Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM."):
Quoted 12 lines
Quoted 11 lines · Jan Beulich
The latter is fine to be put here (i.e. FTAOD I'm fine with it staying here). For the former I even question its original placement in
asm-x86/pci.h: It's not generally correct as per the PCI spec, as the bus portion of the address can be anywhere from 1 to 8 bits. And in fact there is a reason why this macro was/is used in only a single place, but not e.g. in x86'es handling of physical MCFG. It is merely an implementation choice in vPCI that the entire segment 0 has a linear address range covering all 256 buses. Hence I think this wants to move toxen/vpci.hand then perhaps also be namedVPCI_ECAM_BDF().Quoted 5 lines
On previous version it was request to renamed this to ECAM and agreed to put is here. Now you want me to rename it to VPCI and move it again. I would like to have a confirmation that this is ok and the final move if possible.
@Roger can you confirm this is what is wanted ?
I think Roger is not available today I'm afraid.
Bertrand, can you give me a link to the comment from Roger ? Assuming that it says what I think it will say:
I think the best thing to do will be to leave the name as it was in the most recent version of your series. I don't think it makes sense to block this patch over a naming disagreement. And it would be best to minimise unnecessary churn.
I would be happy to release-ack a name change (perhaps proposed bo Jan or Roger) supposing that that is the ultimate maintainer consensus.
Quoted 6 lines
Quoted 1 line
Jan, would that approach be OK with you ?
Well, yes, if a subsequent name change is okay, then I could live with that. I'd still find it odd to rename a function immediately after it already got renamed. As expressed elsewhere, I suspect in his request Roger did not pay attention to a use of the function in non-ECAM code.
Using
MMCFG_BDFwas original requested by Julien, not myself I think:Quoted 8 lines
Quoted 5 lines
I'm slightly loss in so many messages. On x86 we subtract the MCFG start address from the passed one before getting the BDF, and then we add the startting bus address passed in the ACPI table. This is so far not need on Arm AFAICT because of the fixed nature of the selected virtual ECAM region.
At the end my patch will add in
xen/pci.h:
#defineECAM_BDF(addr)(((addr) &0x0ffff000) >> 12)Since you still make this proposal, once again: I'm not going to accept such a macro in this header, whatever the name. Its prior placement was wrong as well. Only ...
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
#define
ECAM_REG_OFFSET(addr)((addr) &0x00000fff)... this one is fine to live here (and presumably it could gain uses elsewhere).
So you would agree if they are both moved to
vpci.hwith aVPCI_prefix ?
I wouldn't object, but as said several times before I see no reason to also move and rename ECAM_REG_OFFSET(). If you moved it and if later we find a use for it outside of vPCI, we'd need to rename and move it again.
Jan
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Hi Jan,
Quoted 69 lines · Jan Beulich
Quoted 66 lines · Bertrand Marquis
Quoted 65 lines · Jan Beulich
Quoted 46 lines · Bertrand Marquis
Quoted 46 lines · Roger Pau Monné
Quoted 33 lines · Jan Beulich
Quoted 32 lines · Ian Jackson
Bertrand Marquis writes ("Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM."):
Quoted 12 lines
Quoted 11 lines · Jan Beulich
The latter is fine to be put here (i.e. FTAOD I'm fine with it staying here). For the former I even question its original placement in
asm-x86/pci.h: It's not generally correct as per the PCI spec, as the bus portion of the address can be anywhere from 1 to 8 bits. And in fact there is a reason why this macro was/is used in only a single place, but not e.g. in x86'es handling of physical MCFG. It is merely an implementation choice in vPCI that the entire segment 0 has a linear address range covering all 256 buses. Hence I think this wants to move toxen/vpci.hand then perhaps also be namedVPCI_ECAM_BDF().Quoted 5 lines
On previous version it was request to renamed this to ECAM and agreed to put is here. Now you want me to rename it to VPCI and move it again. I would like to have a confirmation that this is ok and the final move if possible.
@Roger can you confirm this is what is wanted ?
I think Roger is not available today I'm afraid.
Bertrand, can you give me a link to the comment from Roger ? Assuming that it says what I think it will say:
I think the best thing to do will be to leave the name as it was in the most recent version of your series. I don't think it makes sense to block this patch over a naming disagreement. And it would be best to minimise unnecessary churn.
I would be happy to release-ack a name change (perhaps proposed bo Jan or Roger) supposing that that is the ultimate maintainer consensus.
Quoted 6 lines
Quoted 1 line
Jan, would that approach be OK with you ?
Well, yes, if a subsequent name change is okay, then I could live with that. I'd still find it odd to rename a function immediately after it already got renamed. As expressed elsewhere, I suspect in his request Roger did not pay attention to a use of the function in non-ECAM code.
Using
MMCFG_BDFwas original requested by Julien, not myself I think:Quoted 8 lines
Quoted 5 lines
I'm slightly loss in so many messages. On x86 we subtract the MCFG start address from the passed one before getting the BDF, and then we add the startting bus address passed in the ACPI table. This is so far not need on Arm AFAICT because of the fixed nature of the selected virtual ECAM region.
At the end my patch will add in
xen/pci.h:
#defineECAM_BDF(addr)(((addr) &0x0ffff000) >> 12)Since you still make this proposal, once again: I'm not going to accept such a macro in this header, whatever the name. Its prior placement was wrong as well. Only ...
Quoted 1 line
#define
ECAM_REG_OFFSET(addr)((addr) &0x00000fff)... this one is fine to live here (and presumably it could gain uses elsewhere).
Quoted 6 lines
Quoted 1 line
So you would agree if they are both moved to
vpci.hwith aVPCI_prefix ?I wouldn't object, but as said several times before I see no reason to also move and rename
ECAM_REG_OFFSET(). If you moved it and if later we find a use for it outside of vPCI, we'd need to rename and move it again.
I will move BDF to vpci.h and had VPCI prefix and keep REG_OFFSET as it is and where it is then.
Cheers
Bertrand
Quoted 3 lines
Jan
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
In reply to Bertrand MarquisQuoted 33 lines · Bertrand Marquis
Quoted 24 lines · Jan Beulich
Quoted 9 lines · Bertrand Marquis
xen/drivers/passthrough/pci.c +5
-0@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev); +#ifdef CONFIG_ARM +/* +* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ xen/drivers/passthrough/pci.c int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 769
Quoted 10 lines
xen/drivers/passthrough/pci.c +8
-0+ ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif + ret =0 ;if ( !pdev->domain )Elsewhere I did point out that you need to be careful wrt
pdev->domainbeing NULL. As the code in context clearly documents, you're nowQuoted 8 lines
adding handlers before that field was set. In comments to a prior version I did already suggest to consider placing the new code inside the
if()in question (albeit at the time this was mainly to make clear that error cleanup may not fiddle with things not put in place by theiommu_enable_device()alternative path). This would have the further benefit of making is crystal clear that here only handlers for Dom0 would get put in place (and hence their installing for DomU-s would need to be looked for elsewhere).
Quoted 3 lines
I asked Oleksandr for confirmation here but on arm there will be 2 other use cases:
- PCI own by a DomD so device enumeration done from there
- dom0less with devices detection done inside Xen
Question is whether at this time you mean to handle all these cases. Installing handlers when device detection happens in Xen might need to be done differently, for example - e.g. more along the lines of what x86 PVH Dom0 has done.
Anything you don't mean to handle (and is safe to be left out, i.e. without breaking existing cases) will want spelling out in the description.
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
xen/drivers/passthrough/pci.c +1
-0@@ -784,6 +797,9 @@ out: &PCI_SBDF(seg, bus, slot, func)); } } +else if ( pdev )Quoted 8 lines
xen/drivers/passthrough/pci.c out: · line 801
Quoted 1 line
xen/drivers/passthrough/pci.c +1
-0+pci_cleanup_msi (pdev);Have you thoroughly checked that this call is benign on x86? There's no wording to that effect in the description afaics, and I can't easily convince myself that it would be correct when the
iommu_enable_device()path was taken. (I'm also not going to exclude that it should have been there even prior to your work, albeit then adding this would want to be a separate bugfix patch.)
Quoted 3 lines
This was not in the original serie and requested by Stefano. I must admit I am not completely sure on the details here so I am really ok to remove this but this would go against what was requested on the previous versions (4 and 5).
I understand this, but a request to add something still requires that it be checked that the addition can't have bad effects in other cases. A compromise here (which I wouldn't like very much) might be to add another #ifdef CONFIG_ARM, solely to leave the existing x86 case undisturbed. Yet then, with the called function doing nothing on Arm, not adding the code here might as well be an option (which it looked like Stefano would be amenable to). A TODO item would then perhaps best be left here in a comment.
Quoted 20 lines
Quoted 6 lines
Quoted 6 lines
xen/include/xen/pci.h +0
-0@@ -40,6 +40,9 @@#define PCI_SBDF3 (s,b,df) \ ((pci_sbdf_t){ .sbdf = (((s) & 0xffff) << 16) | PCI_BDF2(b, df) })Quoted 13 lines
xen/include/xen/pci.h line 44
Quoted 2 lines
xen/include/xen/pci.h +2
-0+#define ECAM_BDF (addr) ( ((addr) & 0x0ffff000) >> 12) +#define ECAM_REG_OFFSET (addr) ((addr) & 0x00000fff)The latter is fine to be put here (i.e. FTAOD I'm fine with it staying here). For the former I even question its original placement in
asm-x86/pci.h: It's not generally correct as per the PCI spec, as the bus portion of the address can be anywhere from 1 to 8 bits. And in fact there is a reason why this macro was/is used in only a single place, but not e.g. in x86'es handling of physical MCFG. It is merely an implementation choice in vPCI that the entire segment 0 has a linear address range covering all 256 buses. Hence I think this wants to move toxen/vpci.hand then perhaps also be namedVPCI_ECAM_BDF().
Quoted 4 lines
On previous version it was request to renamed this to ECAM and agreed to put is here. Now you want me to rename it to VPCI and move it again. I would like to have a confirmation that this is ok and the final move if possible.
A final confirmation is, unfortunately, only as final as it can be at the very moment it is given. It was the MCFG vs ECAM naming discussion which made me pull out again the section in the spec, reminding me of aspects I didn't previously take into consideration. I'm sorry for this, but it's an iterative process on all sides.
So, FTAOD, as a maintainer of this headed I will continue to object to a non-spec-compliant construct to be put into here. It'll be Roger, being the vPCI maintainer, to confirm that putting it in xen/vpci.h is fine.
Quoted 1 line
Also if I have to do this I will do the same for
REG_OFFSETof course.
As said - that one, being in line with the PCI spec, is fine to remain as and where you have it.
Jan
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
In reply to Bertrand MarquisQuoted 20 lines · Bertrand Marquis
From: Rahul Singh <[email protected]>
The existing VPCI support available for X86 is adapted for Arm. When the device is added to XEN via the hyper call “PHYSDEVOP_pci_device_add”, VPCI handler for the config space access is added to the Xen to emulate the PCI devices config space.
A MMIO trap handler for the PCI ECAM space is registered in XEN so that when guest is trying to access the PCI config space,XEN will trap the access and emulate read/write using the VPCI and not the real PCI hardware.
For Dom0less systems
scan_pci_devices()would be used to discover the PCI device in XEN and VPCI handler will be added during XEN boots.This patch is also doing some small fixes to fix compilation errors on arm32 of vpci:
- add a cast to unsigned long in print inheader.c
- add a cast touint64_tinvpci_ecam_mmio_write
Quoted 7 lines
Signed-off-by Rahul Singh <[email protected]>Signed-off-by Bertrand Marquis <[email protected]>---
Changes in v6:
- Use newvpci_ecam_helpers for PCI access
- Do not setXEN_DOMCTL_CDF_vpcifor dom0 for now (will be done in a future patch once everything is ready)
Isn't the series missing a revert of XEN_DOMCTL_CDF_vpci? I think that's what we agreed would be the way forward.
Quoted 122 lines
- rename
REGISTER_OFFSETtoECAM_REG_OFFSETand move it topci.h
- remove not needed local variables invpci_mmio_write, the one in read has been kept to ensure proper compilation on arm32
- move call tovpci_add_handlersbefore iommu init to simplify exit path
- move call topci_cleanup_msiin the out section ofpci_add_deviceif pdev is not NULL and on error
- initialize pdev to NULL to handle properly exit path call ofpci_cleanup_msi
- keephas_vpcito return false for now asCFG_vpcihas been removed. Added a comment on top of the definition.
- fix compilation errors on arm32 (print inheader.c, cast missing inmmio_write.
- local variable was kept invpci_mmio_readon arm to prevent a cast error in arm32.
Change in v5:
- Addpci_cleanup_msi(pdev)incleanup part.
- Added Reviewed-by: Stefano Stabellini <[email protected]> Change in v4:
- Move addition ofXEN_DOMCTL_CDF_vpciflag to separate patch Change in v3:
- Useis_pci_passthrough_enabled()in place ofpci_passthrough_enabledvariable
- RejectXEN_DOMCTL_CDF_vpcifor x86 inarch_sanitise_domain_config()
- RemoveIS_ENABLED(CONFIG_HAS_VPCI)fromhas_vpci()
Change in v2:
- Add newXEN_DOMCTL_CDF_vpciflag
- modifyhas_vpci()to includeXEN_DOMCTL_CDF_vpci
- enable vpci support when pci-passthough option is enabled.
------ xen/arch/arm/Makefile | 1 + xen/arch/arm/domain.c | 4 ++ xen/arch/arm/vpci.c | 74 +++++++++++++++++++++++++++++++++++ xen/arch/arm/vpci.h | 36 +++++++++++++++++ xen/drivers/passthrough/pci.c | 18 ++++++++- xen/drivers/vpci/header.c | 3 +- xen/drivers/vpci/vpci.c | 2 +- xen/include/asm-arm/domain.h | 1 + xen/include/asm-x86/pci.h | 2 - xen/include/public/arch-arm.h | 7 ++++ xen/include/xen/pci.h | 3 ++ 11 files changed, 146 insertions(+), 5 deletions(-) create mode 100644 xen/arch/arm/vpci.c create mode 100644 xen/arch/arm/vpci.hxen/arch/arm/Makefile +1
-0@@ -7,6 +7,7 @@ ifneq ($(CONFIG_NO_PLAT),y) obj-y += platforms/ endif obj-$(CONFIG_TEE) += tee/ +obj-$(CONFIG_HAS_VPCI) += vpci.o obj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o obj-y += bootfdt.init.oxen/arch/arm/domain.c +4
-0@@ -39,6 +39,7 @@#include <asm/vgic.h> #include <asm/vtimer.h> +#include "vpci.h" #include "vuart.h" DEFINE_PER_CPU(struct vcpu *, curr_vcpu);@@ -773,6 +774,9 @@ int arch_domain_create(struct domain *d,if (is_hardware_domain (d) && (rc =domain_vuart_init (d)) ) goto fail; +if ( (rc =domain_vpci_init (d)) !=0 ) + goto fail; +return 0 ; fail:xen/arch/arm/vpci.c new file +38
-0@@ -0,0 +1,74 @@ +/* +* xen/arch/arm/vpci.c +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ +#include <xen/sched.h> +#include <xen/vpci.h> + +#include <asm/mmio.h> + +static int vpci_mmio_read (struct vcpu *v,mmio_info_t *info, +register_t *r,void *p) +{ +pci_sbdf_t sbdf; +/* data is needed to prevent a pointer cast on 32bit */ +unsigned long data = ~0ul ; +int ret; + +/* We ignore segment part and always handle segment 0 */ + sbdf.sbdf =ECAM_BDF (info->gpa); + + ret =vpci_ecam_mmio_read (sbdf,ECAM_REG_OFFSET (info->gpa), +1U << info->dabt.size, &data); + + *r = data; + +return ret; +} + +static int vpci_mmio_write(struct vcpu *v, mmio_info_t *info,
xen/arch/arm/vpci.c line 48
Quoted 10 lines
xen/arch/arm/vpci.c new file +10
-0+ register_t r, void *p) +{ + pci_sbdf_t sbdf; + +/* We ignore segment part and always handle segment 0 */ + sbdf.sbdf =ECAM_BDF (info->gpa); + +return vpci_ecam_mmio_write (sbdf,ECAM_REG_OFFSET (info->gpa), +1U << info->dabt.size, r); +}
I'm not sure returning an error value here is helpful, as I'm not sure how native Arm behaves and how this error is propagated into the guest. FWIWreturning ~0 or dropping writes is what we do in x86 when vPCI is not capable of handling the access.
Quoted 87 lines
xen/arch/arm/vpci.c new file +26
-0+ +static const struct mmio_handler_ops vpci_mmio_handler = { + .read = vpci_mmio_read, + .write = vpci_mmio_write, +}; + +int domain_vpci_init (struct domain *d) +{ +if ( !has_vpci (d) ) +return 0 ; + +register_mmio_handler (d, &vpci_mmio_handler, +GUEST_VPCI_ECAM_BASE ,GUEST_VPCI_ECAM_SIZE ,NULL ); + +return 0 ; +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ +xen/arch/arm/vpci.h new file +36
-0@@ -0,0 +1,36 @@ +/* +* xen/arch/arm/vpci.h +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __ARCH_ARM_VPCI_H__ +#define __ARCH_ARM_VPCI_H__ + +#ifdef CONFIG_HAS_VPCI +int domain_vpci_init (struct domain *d); +#else +static inline int domain_vpci_init (struct domain *d) +{ +return 0 ; +} +#endif + +#endif /* __ARCH_ARM_VPCI_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ xen/drivers/passthrough/pci.c +3
-1@@ -658,7 +658,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, const struct pci_dev_info *info, nodeid_t node) { struct pci_seg *pseg; -struct pci_dev *pdev; +struct pci_dev *pdev =NULL ;unsigned int slot =PCI_SLOT (devfn), func =PCI_FUNC (devfn);const char *pdev_type;int ret;@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev); +#ifdef CONFIG_ARM +/*
xen/drivers/passthrough/pci.c int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 10 lines
xen/drivers/passthrough/pci.c +10
-0+* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ + ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif
I think vpci_add_handlers should be called after checking that pdev->domain is != NULL, so I would move this chunk a bit below.
xen/drivers/passthrough/pci.c out: · line 801
Quoted 10 lines
xen/drivers/passthrough/pci.c +3
-0+ ret =0 ;if ( !pdev->domain ) {@@ -784,6 +797,9 @@ out: &PCI_SBDF(seg, bus, slot, func)); } } +else if ( pdev ) +pci_cleanup_msi (pdev);
I'm slightly lost at why you add this chunk, is this strictly related to the patch?
Quoted 78 lines
xen/drivers/passthrough/pci.c +0
-0return ret; }xen/drivers/vpci/header.c +2
-1@@ -374,7 +374,8 @@ static void bar_write(const struct pci_dev *pdev, unsigned int reg,if ( val != (uint32_t )(bar->addr >> (hi ?32 :0 )) )gprintk (XENLOG_WARNING ,"%pp: ignored BAR %lu write with memory decoding enabled\n" , - &pdev->sbdf, bar - pdev->vpci->header.bars + hi); + &pdev->sbdf, + (unsigned long )(bar - pdev->vpci->header.bars + hi));return ; }xen/drivers/vpci/vpci.c +1
-1@@ -507,7 +507,7 @@ int vpci_ecam_mmio_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int len,vpci_write (sbdf, reg,min (4u , len), data);if ( len ==8 ) -vpci_write (sbdf, reg +4 ,4 , data >>32 ); +vpci_write (sbdf, reg +4 ,4 , (uint64_t )data >>32 );return 1 ; }xen/include/asm-arm/domain.h +1
-0@@ -263,6 +263,7 @@ static inline void arch_vcpu_block(struct vcpu *v) {}#define arch_vm_assist_valid_mask (d) (1UL << VMASST_TYPE_runstate_update_flag) +/* vPCI is not available on Arm */ #define has_vpci (d) ({ (void)(d); false; })#endif /* __ASM_DOMAIN_H__ */ xen/include/asm-x86/pci.h +0
-2@@ -6,8 +6,6 @@#define CF8_ADDR_HI (cf8) ( ((cf8) & 0x0f000000) >> 16)#define CF8_ENABLED (cf8) (!!((cf8) & 0x80000000)) -#define ECAM_BDF (addr) ( ((addr) & 0x0ffff000) >> 12) -#define IS_SNB_GFX (id) (id == 0x01068086 || id == 0x01168086 \ || id == 0x01268086 || id == 0x01028086 \ || id == 0x01128086 || id == 0x01228086 \xen/include/public/arch-arm.h +7
-0@@ -418,6 +418,13 @@ typedef uint64_t xen_callback_t;#define GUEST_GICV3_GICR0_BASE xen_mk_ullong(0x03020000)/* vCPU0..127 */ #define GUEST_GICV3_GICR0_SIZE xen_mk_ullong(0x01000000) +/* +* 256 MB is reserved for VPCI configuration space based on calculation +* 256 buses × 32 devices × 8 functions × 4 KB = 256 MB +*/ +#define GUEST_VPCI_ECAM_BASE xen_mk_ullong(0x10000000) +#define GUEST_VPCI_ECAM_SIZE xen_mk_ullong(0x10000000) +/* ACPI tables physical address */ #define GUEST_ACPI_BASE xen_mk_ullong(0x20000000)#define GUEST_ACPI_SIZE xen_mk_ullong(0x02000000)xen/include/xen/pci.h +0
-0
xen/include/xen/pci.h line 43
Quoted 4 lines
xen/include/xen/pci.h +1
-0@@ -40,6 +40,9 @@#define PCI_SBDF3 (s,b,df) \ ((pci_sbdf_t){ .sbdf = (((s) & 0xffff) << 16) | PCI_BDF2(b, df) }) +#define ECAM_BDF (addr) ( ((addr) & 0x0ffff000) >> 12)
^ extra space?
Thanks, Roger.
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Quoted 29 lines · Roger Pau Monné
Quoted 20 lines · Bertrand Marquis
From: Rahul Singh <[email protected]>
The existing VPCI support available for X86 is adapted for Arm. When the device is added to XEN via the hyper call “PHYSDEVOP_pci_device_add”, VPCI handler for the config space access is added to the Xen to emulate the PCI devices config space.
A MMIO trap handler for the PCI ECAM space is registered in XEN so that when guest is trying to access the PCI config space,XEN will trap the access and emulate read/write using the VPCI and not the real PCI hardware.
For Dom0less systems
scan_pci_devices()would be used to discover the PCI device in XEN and VPCI handler will be added during XEN boots.This patch is also doing some small fixes to fix compilation errors on arm32 of vpci:
- add a cast to unsigned long in print inheader.c
- add a cast touint64_tinvpci_ecam_mmio_writeQuoted 7 lines
Signed-off-by Rahul Singh <[email protected]>Signed-off-by Bertrand Marquis <[email protected]>---
Changes in v6:
- Use newvpci_ecam_helpers for PCI access
- Do not setXEN_DOMCTL_CDF_vpcifor dom0 for now (will be done in a future patch once everything is ready)
Quoted 3 lines
Isn't the series missing a revert of
XEN_DOMCTL_CDF_vpci? I think that's what we agreed would be the way forward.
The revert patch has already been merged.
https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=9516d01ac3015f522528ed6dafb3f584eaa7ed2c
Quoted 339 lines
Quoted 122 lines
- rename
REGISTER_OFFSETtoECAM_REG_OFFSETand move it topci.h
- remove not needed local variables invpci_mmio_write, the one in read has been kept to ensure proper compilation on arm32
- move call tovpci_add_handlersbefore iommu init to simplify exit path
- move call topci_cleanup_msiin the out section ofpci_add_deviceif pdev is not NULL and on error
- initialize pdev to NULL to handle properly exit path call ofpci_cleanup_msi
- keephas_vpcito return false for now asCFG_vpcihas been removed. Added a comment on top of the definition.
- fix compilation errors on arm32 (print inheader.c, cast missing inmmio_write.
- local variable was kept invpci_mmio_readon arm to prevent a cast error in arm32.
Change in v5:
- Addpci_cleanup_msi(pdev)incleanup part.
- Added Reviewed-by: Stefano Stabellini <[email protected]> Change in v4:
- Move addition ofXEN_DOMCTL_CDF_vpciflag to separate patch Change in v3:
- Useis_pci_passthrough_enabled()in place ofpci_passthrough_enabledvariable
- RejectXEN_DOMCTL_CDF_vpcifor x86 inarch_sanitise_domain_config()
- RemoveIS_ENABLED(CONFIG_HAS_VPCI)fromhas_vpci()
Change in v2:
- Add newXEN_DOMCTL_CDF_vpciflag
- modifyhas_vpci()to includeXEN_DOMCTL_CDF_vpci
- enable vpci support when pci-passthough option is enabled.
------ xen/arch/arm/Makefile | 1 + xen/arch/arm/domain.c | 4 ++ xen/arch/arm/vpci.c | 74 +++++++++++++++++++++++++++++++++++ xen/arch/arm/vpci.h | 36 +++++++++++++++++ xen/drivers/passthrough/pci.c | 18 ++++++++- xen/drivers/vpci/header.c | 3 +- xen/drivers/vpci/vpci.c | 2 +- xen/include/asm-arm/domain.h | 1 + xen/include/asm-x86/pci.h | 2 - xen/include/public/arch-arm.h | 7 ++++ xen/include/xen/pci.h | 3 ++ 11 files changed, 146 insertions(+), 5 deletions(-) create mode 100644 xen/arch/arm/vpci.c create mode 100644 xen/arch/arm/vpci.hxen/arch/arm/Makefile +1
-0@@ -7,6 +7,7 @@ ifneq ($(CONFIG_NO_PLAT),y) obj-y += platforms/ endif obj-$(CONFIG_TEE) += tee/ +obj-$(CONFIG_HAS_VPCI) += vpci.o obj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o obj-y += bootfdt.init.oxen/arch/arm/domain.c +4
-0@@ -39,6 +39,7 @@#include <asm/vgic.h> #include <asm/vtimer.h> +#include "vpci.h" #include "vuart.h" DEFINE_PER_CPU(struct vcpu *, curr_vcpu);@@ -773,6 +774,9 @@ int arch_domain_create(struct domain *d,if (is_hardware_domain (d) && (rc =domain_vuart_init (d)) ) goto fail; +if ( (rc =domain_vpci_init (d)) !=0 ) + goto fail; +return 0 ; fail:xen/arch/arm/vpci.c new file +38
-0@@ -0,0 +1,74 @@ +/* +* xen/arch/arm/vpci.c +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ +#include <xen/sched.h> +#include <xen/vpci.h> + +#include <asm/mmio.h> + +static int vpci_mmio_read (struct vcpu *v,mmio_info_t *info, +register_t *r,void *p) +{ +pci_sbdf_t sbdf; +/* data is needed to prevent a pointer cast on 32bit */ +unsigned long data = ~0ul ; +int ret; + +/* We ignore segment part and always handle segment 0 */ + sbdf.sbdf =ECAM_BDF (info->gpa); + + ret =vpci_ecam_mmio_read (sbdf,ECAM_REG_OFFSET (info->gpa), +1U << info->dabt.size, &data); + + *r = data; + +return ret; +} + +static int vpci_mmio_write(struct vcpu *v, mmio_info_t *info,xen/arch/arm/vpci.c line 48
Quoted 10 lines
xen/arch/arm/vpci.c new file +10
-0+ register_t r, void *p) +{ + pci_sbdf_t sbdf; + +/* We ignore segment part and always handle segment 0 */ + sbdf.sbdf =ECAM_BDF (info->gpa); + +return vpci_ecam_mmio_write (sbdf,ECAM_REG_OFFSET (info->gpa), +1U << info->dabt.size, r); +}I'm not sure returning an error value here is helpful, as I'm not sure how native Arm behaves and how this error is propagated into the guest. FWIWreturning ~0 or dropping writes is what we do in x86 when vPCI is not capable of handling the access.
Quoted 87 lines
xen/arch/arm/vpci.c new file +26
-0+ +static const struct mmio_handler_ops vpci_mmio_handler = { + .read = vpci_mmio_read, + .write = vpci_mmio_write, +}; + +int domain_vpci_init (struct domain *d) +{ +if ( !has_vpci (d) ) +return 0 ; + +register_mmio_handler (d, &vpci_mmio_handler, +GUEST_VPCI_ECAM_BASE ,GUEST_VPCI_ECAM_SIZE ,NULL ); + +return 0 ; +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ +xen/arch/arm/vpci.h new file +36
-0@@ -0,0 +1,36 @@ +/* +* xen/arch/arm/vpci.h +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __ARCH_ARM_VPCI_H__ +#define __ARCH_ARM_VPCI_H__ + +#ifdef CONFIG_HAS_VPCI +int domain_vpci_init (struct domain *d); +#else +static inline int domain_vpci_init (struct domain *d) +{ +return 0 ; +} +#endif + +#endif /* __ARCH_ARM_VPCI_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ xen/drivers/passthrough/pci.c +3
-1@@ -658,7 +658,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, const struct pci_dev_info *info, nodeid_t node) { struct pci_seg *pseg; -struct pci_dev *pdev; +struct pci_dev *pdev =NULL ;unsigned int slot =PCI_SLOT (devfn), func =PCI_FUNC (devfn);const char *pdev_type;int ret;@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev); +#ifdef CONFIG_ARM +/* xen/drivers/passthrough/pci.c int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 10 lines
xen/drivers/passthrough/pci.c +10
-0+* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ + ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif I think
vpci_add_handlersshould be called after checking thatpdev->domainis != NULL, so I would move this chunk a bit below.xen/drivers/passthrough/pci.c out: · line 801
Quoted 10 lines
xen/drivers/passthrough/pci.c +3
-0+ ret =0 ;if ( !pdev->domain ) {@@ -784,6 +797,9 @@ out: &PCI_SBDF(seg, bus, slot, func)); } } +else if ( pdev ) +pci_cleanup_msi (pdev);I'm slightly lost at why you add this chunk, is this strictly related to the patch?
Quoted 78 lines
xen/drivers/passthrough/pci.c +0
-0return ret; }xen/drivers/vpci/header.c +2
-1@@ -374,7 +374,8 @@ static void bar_write(const struct pci_dev *pdev, unsigned int reg,if ( val != (uint32_t )(bar->addr >> (hi ?32 :0 )) )gprintk (XENLOG_WARNING ,"%pp: ignored BAR %lu write with memory decoding enabled\n" , - &pdev->sbdf, bar - pdev->vpci->header.bars + hi); + &pdev->sbdf, + (unsigned long )(bar - pdev->vpci->header.bars + hi));return ; }xen/drivers/vpci/vpci.c +1
-1@@ -507,7 +507,7 @@ int vpci_ecam_mmio_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int len,vpci_write (sbdf, reg,min (4u , len), data);if ( len ==8 ) -vpci_write (sbdf, reg +4 ,4 , data >>32 ); +vpci_write (sbdf, reg +4 ,4 , (uint64_t )data >>32 );return 1 ; }xen/include/asm-arm/domain.h +1
-0@@ -263,6 +263,7 @@ static inline void arch_vcpu_block(struct vcpu *v) {}#define arch_vm_assist_valid_mask (d) (1UL << VMASST_TYPE_runstate_update_flag) +/* vPCI is not available on Arm */ #define has_vpci (d) ({ (void)(d); false; })#endif /* __ASM_DOMAIN_H__ */ xen/include/asm-x86/pci.h +0
-2@@ -6,8 +6,6 @@#define CF8_ADDR_HI (cf8) ( ((cf8) & 0x0f000000) >> 16)#define CF8_ENABLED (cf8) (!!((cf8) & 0x80000000)) -#define ECAM_BDF (addr) ( ((addr) & 0x0ffff000) >> 12) -#define IS_SNB_GFX (id) (id == 0x01068086 || id == 0x01168086 \ || id == 0x01268086 || id == 0x01028086 \ || id == 0x01128086 || id == 0x01228086 \xen/include/public/arch-arm.h +7
-0@@ -418,6 +418,13 @@ typedef uint64_t xen_callback_t;#define GUEST_GICV3_GICR0_BASE xen_mk_ullong(0x03020000)/* vCPU0..127 */ #define GUEST_GICV3_GICR0_SIZE xen_mk_ullong(0x01000000) +/* +* 256 MB is reserved for VPCI configuration space based on calculation +* 256 buses × 32 devices × 8 functions × 4 KB = 256 MB +*/ +#define GUEST_VPCI_ECAM_BASE xen_mk_ullong(0x10000000) +#define GUEST_VPCI_ECAM_SIZE xen_mk_ullong(0x10000000) +/* ACPI tables physical address */ #define GUEST_ACPI_BASE xen_mk_ullong(0x20000000)#define GUEST_ACPI_SIZE xen_mk_ullong(0x02000000)xen/include/xen/pci.h +0
-0xen/include/xen/pci.h line 43
Quoted 4 lines
xen/include/xen/pci.h +1
-0@@ -40,6 +40,9 @@#define PCI_SBDF3 (s,b,df) \ ((pci_sbdf_t){ .sbdf = (((s) & 0xffff) << 16) | PCI_BDF2(b, df) }) +#define ECAM_BDF (addr) ( ((addr) & 0x0ffff000) >> 12)^ extra space?
Thanks, Roger.
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
In reply to Roger Pau MonnéHi Roger,
Quoted 31 lines · Roger Pau Monné
Quoted 20 lines · Bertrand Marquis
From: Rahul Singh <[email protected]>
The existing VPCI support available for X86 is adapted for Arm. When the device is added to XEN via the hyper call “PHYSDEVOP_pci_device_add”, VPCI handler for the config space access is added to the Xen to emulate the PCI devices config space.
A MMIO trap handler for the PCI ECAM space is registered in XEN so that when guest is trying to access the PCI config space,XEN will trap the access and emulate read/write using the VPCI and not the real PCI hardware.
For Dom0less systems
scan_pci_devices()would be used to discover the PCI device in XEN and VPCI handler will be added during XEN boots.This patch is also doing some small fixes to fix compilation errors on arm32 of vpci:
- add a cast to unsigned long in print inheader.c
- add a cast touint64_tinvpci_ecam_mmio_writeQuoted 7 lines
Signed-off-by Rahul Singh <[email protected]>Signed-off-by Bertrand Marquis <[email protected]>---
Changes in v6:
- Use newvpci_ecam_helpers for PCI access
- Do not setXEN_DOMCTL_CDF_vpcifor dom0 for now (will be done in a future patch once everything is ready)
Quoted 2 lines
Isn't the series missing a revert of
XEN_DOMCTL_CDF_vpci? I think that's what we agreed would be the way forward.
A separate reverse patch for that has already been merged:
https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=9516d01ac3015f522528ed6dafb3f584eaa7ed2c
Quoted 130 lines
Quoted 130 lines
- rename
REGISTER_OFFSETtoECAM_REG_OFFSETand move it topci.h
- remove not needed local variables invpci_mmio_write, the one in read has been kept to ensure proper compilation on arm32
- move call tovpci_add_handlersbefore iommu init to simplify exit path
- move call topci_cleanup_msiin the out section ofpci_add_deviceif pdev is not NULL and on error
- initialize pdev to NULL to handle properly exit path call ofpci_cleanup_msi
- keephas_vpcito return false for now asCFG_vpcihas been removed. Added a comment on top of the definition.
- fix compilation errors on arm32 (print inheader.c, cast missing inmmio_write.
- local variable was kept invpci_mmio_readon arm to prevent a cast error in arm32.
Change in v5:
- Addpci_cleanup_msi(pdev)incleanup part.
- Added Reviewed-by: Stefano Stabellini <[email protected]> Change in v4:
- Move addition ofXEN_DOMCTL_CDF_vpciflag to separate patch Change in v3:
- Useis_pci_passthrough_enabled()in place ofpci_passthrough_enabledvariable
- RejectXEN_DOMCTL_CDF_vpcifor x86 inarch_sanitise_domain_config()
- RemoveIS_ENABLED(CONFIG_HAS_VPCI)fromhas_vpci()
Change in v2:
- Add newXEN_DOMCTL_CDF_vpciflag
- modifyhas_vpci()to includeXEN_DOMCTL_CDF_vpci
- enable vpci support when pci-passthough option is enabled.
---
---xen/arch/arm/Makefile | 1 + xen/arch/arm/domain.c | 4 ++ xen/arch/arm/vpci.c | 74 +++++++++++++++++++++++++++++++++++ xen/arch/arm/vpci.h | 36 +++++++++++++++++ xen/drivers/passthrough/pci.c | 18 ++++++++- xen/drivers/vpci/header.c | 3 +- xen/drivers/vpci/vpci.c | 2 +- xen/include/asm-arm/domain.h | 1 + xen/include/asm-x86/pci.h | 2 - xen/include/public/arch-arm.h | 7 ++++ xen/include/xen/pci.h | 3 ++ 11 files changed, 146 insertions(+), 5 deletions(-)create mode 100644
xen/arch/arm/vpci.c
create mode 100644xen/arch/arm/vpci.hxen/arch/arm/Makefile +0
-0@@ -7,6 +7,7 @@ ifneq ($(CONFIG_NO_PLAT),y)obj-y += platforms/
endif
obj-$(CONFIG_TEE) += tee/
+obj-$(CONFIG_HAS_VPCI) += vpci.oobj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o
obj-y += bootfdt.init.oxen/arch/arm/domain.c +4
-0@@ -39,6 +39,7 @@#include <asm/vgic.h> #include <asm/vtimer.h> +#include "vpci.h" #include "vuart.h" DEFINE_PER_CPU(struct vcpu *, curr_vcpu);@@ -773,6 +774,9 @@ int arch_domain_create(struct domain *d,if (is_hardware_domain (d) && (rc =domain_vuart_init (d)) ) goto fail; +if ( (rc =domain_vpci_init (d)) !=0 ) + goto fail; +return 0 ;fail:
xen/arch/arm/vpci.c new file +45
-0@@ -0,0 +1,74 @@ +/* +* xen/arch/arm/vpci.c +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ +#include <xen/sched.h> +#include <xen/vpci.h> + +#include <asm/mmio.h> + +static int vpci_mmio_read (struct vcpu *v,mmio_info_t *info, +register_t *r,void *p) +{ +pci_sbdf_t sbdf; +/* data is needed to prevent a pointer cast on 32bit */ +unsigned long data = ~0ul ; +int ret; + +/* We ignore segment part and always handle segment 0 */ + sbdf.sbdf =ECAM_BDF (info->gpa); + + ret =vpci_ecam_mmio_read (sbdf,ECAM_REG_OFFSET (info->gpa), +1U << info->dabt.size, &data); + + *r = data; + +return ret; +} + +static int vpci_mmio_write (struct vcpu *v,mmio_info_t *info, +register_t r,void *p) +{ +pci_sbdf_t sbdf; + +/* We ignore segment part and always handle segment 0 */ + sbdf.sbdf =ECAM_BDF (info->gpa); +
Quoted 8 lines
xen/arch/arm/vpci.c line 48
Quoted 3 lines
xen/arch/arm/vpci.c new file +3
-0+return vpci_ecam_mmio_write (sbdf,ECAM_REG_OFFSET (info->gpa), +1U << info->dabt.size, r); +}I'm not sure returning an error value here is helpful, as I'm not sure how native Arm behaves and how this error is propagated into the guest. FWIWreturning ~0 or dropping writes is what we do in x86 when vPCI is not capable of handling the access.
Mmio handlers can take a return code on arm if something did not work so I think this is the right way to do it on arm.
Now has agreed with Jan, we will change the return type of vpci_ecam_write (also renamed) to be a boolean.
Quoted 86 lines
Quoted 86 lines
xen/arch/arm/vpci.c new file +26
-0+ +static const struct mmio_handler_ops vpci_mmio_handler = { + .read = vpci_mmio_read, + .write = vpci_mmio_write, +}; + +int domain_vpci_init (struct domain *d) +{ +if ( !has_vpci (d) ) +return 0 ; + +register_mmio_handler (d, &vpci_mmio_handler, +GUEST_VPCI_ECAM_BASE ,GUEST_VPCI_ECAM_SIZE ,NULL ); + +return 0 ; +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ +xen/arch/arm/vpci.h new file +36
-0@@ -0,0 +1,36 @@ +/* +* xen/arch/arm/vpci.h +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __ARCH_ARM_VPCI_H__ +#define __ARCH_ARM_VPCI_H__ + +#ifdef CONFIG_HAS_VPCI +int domain_vpci_init (struct domain *d); +#else +static inline int domain_vpci_init (struct domain *d) +{ +return 0 ; +} +#endif + +#endif /* __ARCH_ARM_VPCI_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ xen/drivers/passthrough/pci.c +1
-1@@ -658,7 +658,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, const struct pci_dev_info *info, nodeid_t node) { struct pci_seg *pseg; -struct pci_dev *pdev; +struct pci_dev *pdev =NULL ;unsigned int slot =PCI_SLOT (devfn), func =PCI_FUNC (devfn);const char *pdev_type;int ret;@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev);
Quoted 15 lines
xen/drivers/passthrough/pci.c int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 12 lines
xen/drivers/passthrough/pci.c +12
-0+#ifdef CONFIG_ARM +/* +* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ + ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif I think
vpci_add_handlersshould be called after checking thatpdev->domainis != NULL, so I would move this chunk a bit below.
On arm this would prevent the dom0less use case or to have the PCI bus enumerated from an other domain.
@oleksandr: can you comment on this one, you might have a better answer than me on this ?
Quoted 14 lines
xen/drivers/passthrough/pci.c out: · line 801
Quoted 11 lines
xen/drivers/passthrough/pci.c +3
-0+ ret =0 ;if ( !pdev->domain ) {@@ -784,6 +797,9 @@ out: &PCI_SBDF(seg, bus, slot, func)); } } +else if ( pdev ) +pci_cleanup_msi (pdev);I'm slightly lost at why you add this chunk, is this strictly related to the patch?
This was discussed a lot in previous version of the patch and requested by Stefano. The idea here is that as soon as handlers are added some bits might be modified in the PCI config space leading possibly to msi interrupts. So it is safer to cleanup on the error path. For references please see discussion on v4 and v5 where this was actually added (to much references as the discussion was long so here [1] and [2] are the patchwork thread).
[1] https://patchwork.kernel.org/project/xen-devel/patch/9bdca2cda5d2e83f94dc2423e55714273539760a.1633540842.git.rahul.singh@arm.com/
[2] https://patchwork.kernel.org/project/xen-devel/patch/f093de681c2560a7196895bcd666ef8840885c1d.1633340795.git.rahul.singh@arm.com/
Regards
Bertrand
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Quoted 289 lines · Bertrand Marquis
Hi Roger,
Quoted 31 lines · Roger Pau Monné
Quoted 20 lines · Bertrand Marquis
From: Rahul Singh <[email protected]>
The existing VPCI support available for X86 is adapted for Arm. When the device is added to XEN via the hyper call “PHYSDEVOP_pci_device_add”, VPCI handler for the config space access is added to the Xen to emulate the PCI devices config space.
A MMIO trap handler for the PCI ECAM space is registered in XEN so that when guest is trying to access the PCI config space,XEN will trap the access and emulate read/write using the VPCI and not the real PCI hardware.
For Dom0less systems
scan_pci_devices()would be used to discover the PCI device in XEN and VPCI handler will be added during XEN boots.This patch is also doing some small fixes to fix compilation errors on arm32 of vpci:
- add a cast to unsigned long in print inheader.c
- add a cast touint64_tinvpci_ecam_mmio_writeQuoted 7 lines
Signed-off-by Rahul Singh <[email protected]>Signed-off-by Bertrand Marquis <[email protected]>---
Changes in v6:
- Use newvpci_ecam_helpers for PCI access
- Do not setXEN_DOMCTL_CDF_vpcifor dom0 for now (will be done in a future patch once everything is ready)Quoted 2 lines
Isn't the series missing a revert of
XEN_DOMCTL_CDF_vpci? I think that's what we agreed would be the way forward.A separate reverse patch for that has already been merged:
https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=9516d01ac3015f522528ed6dafb3f584eaa7ed2cQuoted 130 lines
Quoted 130 lines
- rename
REGISTER_OFFSETtoECAM_REG_OFFSETand move it topci.h
- remove not needed local variables invpci_mmio_write, the one in read has been kept to ensure proper compilation on arm32
- move call tovpci_add_handlersbefore iommu init to simplify exit path
- move call topci_cleanup_msiin the out section ofpci_add_deviceif pdev is not NULL and on error
- initialize pdev to NULL to handle properly exit path call ofpci_cleanup_msi
- keephas_vpcito return false for now asCFG_vpcihas been removed. Added a comment on top of the definition.
- fix compilation errors on arm32 (print inheader.c, cast missing inmmio_write.
- local variable was kept invpci_mmio_readon arm to prevent a cast error in arm32.
Change in v5:
- Addpci_cleanup_msi(pdev)incleanup part.
- Added Reviewed-by: Stefano Stabellini <[email protected]> Change in v4:
- Move addition ofXEN_DOMCTL_CDF_vpciflag to separate patch Change in v3:
- Useis_pci_passthrough_enabled()in place ofpci_passthrough_enabledvariable
- RejectXEN_DOMCTL_CDF_vpcifor x86 inarch_sanitise_domain_config()
- RemoveIS_ENABLED(CONFIG_HAS_VPCI)fromhas_vpci()
Change in v2:
- Add newXEN_DOMCTL_CDF_vpciflag
- modifyhas_vpci()to includeXEN_DOMCTL_CDF_vpci
- enable vpci support when pci-passthough option is enabled.
---
---xen/arch/arm/Makefile | 1 + xen/arch/arm/domain.c | 4 ++ xen/arch/arm/vpci.c | 74 +++++++++++++++++++++++++++++++++++ xen/arch/arm/vpci.h | 36 +++++++++++++++++ xen/drivers/passthrough/pci.c | 18 ++++++++- xen/drivers/vpci/header.c | 3 +- xen/drivers/vpci/vpci.c | 2 +- xen/include/asm-arm/domain.h | 1 + xen/include/asm-x86/pci.h | 2 - xen/include/public/arch-arm.h | 7 ++++ xen/include/xen/pci.h | 3 ++ 11 files changed, 146 insertions(+), 5 deletions(-)create mode 100644
xen/arch/arm/vpci.c
create mode 100644xen/arch/arm/vpci.hxen/arch/arm/Makefile +0
-0@@ -7,6 +7,7 @@ ifneq ($(CONFIG_NO_PLAT),y)obj-y += platforms/
endif
obj-$(CONFIG_TEE) += tee/
+obj-$(CONFIG_HAS_VPCI) += vpci.oobj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o
obj-y += bootfdt.init.oxen/arch/arm/domain.c +4
-0@@ -39,6 +39,7 @@#include <asm/vgic.h> #include <asm/vtimer.h> +#include "vpci.h" #include "vuart.h" DEFINE_PER_CPU(struct vcpu *, curr_vcpu);@@ -773,6 +774,9 @@ int arch_domain_create(struct domain *d,if (is_hardware_domain (d) && (rc =domain_vuart_init (d)) ) goto fail; +if ( (rc =domain_vpci_init (d)) !=0 ) + goto fail; +return 0 ;fail:
xen/arch/arm/vpci.c new file +45
-0@@ -0,0 +1,74 @@ +/* +* xen/arch/arm/vpci.c +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ +#include <xen/sched.h> +#include <xen/vpci.h> + +#include <asm/mmio.h> + +static int vpci_mmio_read (struct vcpu *v,mmio_info_t *info, +register_t *r,void *p) +{ +pci_sbdf_t sbdf; +/* data is needed to prevent a pointer cast on 32bit */ +unsigned long data = ~0ul ; +int ret; + +/* We ignore segment part and always handle segment 0 */ + sbdf.sbdf =ECAM_BDF (info->gpa); + + ret =vpci_ecam_mmio_read (sbdf,ECAM_REG_OFFSET (info->gpa), +1U << info->dabt.size, &data); + + *r = data; + +return ret; +} + +static int vpci_mmio_write (struct vcpu *v,mmio_info_t *info, +register_t r,void *p) +{ +pci_sbdf_t sbdf; + +/* We ignore segment part and always handle segment 0 */ + sbdf.sbdf =ECAM_BDF (info->gpa); +Quoted 8 lines
xen/arch/arm/vpci.c line 48
Quoted 3 lines
xen/arch/arm/vpci.c new file +3
-0+return vpci_ecam_mmio_write (sbdf,ECAM_REG_OFFSET (info->gpa), +1U << info->dabt.size, r); +}I'm not sure returning an error value here is helpful, as I'm not sure how native Arm behaves and how this error is propagated into the guest. FWIWreturning ~0 or dropping writes is what we do in x86 when vPCI is not capable of handling the access.
Mmio handlers can take a return code on arm if something did not work so I think this is the right way to do it on arm.
Now has agreed with Jan, we will change the return type ofvpci_ecam_write(also renamed) to be a boolean.Quoted 86 lines
Quoted 86 lines
xen/arch/arm/vpci.c new file +26
-0+ +static const struct mmio_handler_ops vpci_mmio_handler = { + .read = vpci_mmio_read, + .write = vpci_mmio_write, +}; + +int domain_vpci_init (struct domain *d) +{ +if ( !has_vpci (d) ) +return 0 ; + +register_mmio_handler (d, &vpci_mmio_handler, +GUEST_VPCI_ECAM_BASE ,GUEST_VPCI_ECAM_SIZE ,NULL ); + +return 0 ; +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ +xen/arch/arm/vpci.h new file +36
-0@@ -0,0 +1,36 @@ +/* +* xen/arch/arm/vpci.h +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __ARCH_ARM_VPCI_H__ +#define __ARCH_ARM_VPCI_H__ + +#ifdef CONFIG_HAS_VPCI +int domain_vpci_init (struct domain *d); +#else +static inline int domain_vpci_init (struct domain *d) +{ +return 0 ; +} +#endif + +#endif /* __ARCH_ARM_VPCI_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ xen/drivers/passthrough/pci.c +1
-1@@ -658,7 +658,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, const struct pci_dev_info *info, nodeid_t node) { struct pci_seg *pseg; -struct pci_dev *pdev; +struct pci_dev *pdev =NULL ;unsigned int slot =PCI_SLOT (devfn), func =PCI_FUNC (devfn);const char *pdev_type;int ret;@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev);Quoted 15 lines
xen/drivers/passthrough/pci.c int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 12 lines
xen/drivers/passthrough/pci.c +12
-0+#ifdef CONFIG_ARM +/* +* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ + ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif I think
vpci_add_handlersshould be called after checking thatpdev->domainis != NULL, so I would move this chunk a bit below.
Quoted 4 lines
On arm this would prevent the dom0less use case or to have the PCI bus enumerated from an other domain.
@oleksandr: can you comment on this one, you might have a better answer than me on this ?
For my understanding, as also Jan pointed out, this should be put inside the If ( !pdev->domain ) because also as the comment suggests, this operation should be performed only when there is a Dom0 and when we are using a dom0less setup the pdev->domain should be NULL if I’m not wrong. @oleksandr maybe can confirm
Quoted 29 lines
Quoted 15 lines
xen/drivers/passthrough/pci.c out: · line 801
Quoted 12 lines
xen/drivers/passthrough/pci.c +3
-0+ ret =0 ;if ( !pdev->domain ) {@@ -784,6 +797,9 @@ out: &PCI_SBDF(seg, bus, slot, func)); } } +else if ( pdev ) +pci_cleanup_msi (pdev);I'm slightly lost at why you add this chunk, is this strictly related to the patch?
This was discussed a lot in previous version of the patch and requested by Stefano. The idea here is that as soon as handlers are added some bits might be modified in the PCI config space leading possibly to msi interrupts. So it is safer to cleanup on the error path. For references please see discussion on v4 and v5 where this was actually added (to much references as the discussion was long so here [1] and [2] are the patchwork thread).
[1] https://patchwork.kernel.org/project/xen-devel/patch/9bdca2cda5d2e83f94dc2423e55714273539760a.1633540842.git.rahul.singh@arm.com/
[2] https://patchwork.kernel.org/project/xen-devel/patch/f093de681c2560a7196895bcd666ef8840885c1d.1633340795.git.rahul.singh@arm.com/Regards
Bertrand
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Hi Luca,
Quoted 296 lines · Luca Fancellu
Quoted 290 lines · Bertrand Marquis
Hi Roger,
Quoted 31 lines · Roger Pau Monné
Quoted 20 lines · Bertrand Marquis
From: Rahul Singh <[email protected]>
The existing VPCI support available for X86 is adapted for Arm. When the device is added to XEN via the hyper call “PHYSDEVOP_pci_device_add”, VPCI handler for the config space access is added to the Xen to emulate the PCI devices config space.
A MMIO trap handler for the PCI ECAM space is registered in XEN so that when guest is trying to access the PCI config space,XEN will trap the access and emulate read/write using the VPCI and not the real PCI hardware.
For Dom0less systems
scan_pci_devices()would be used to discover the PCI device in XEN and VPCI handler will be added during XEN boots.This patch is also doing some small fixes to fix compilation errors on arm32 of vpci:
- add a cast to unsigned long in print inheader.c
- add a cast touint64_tinvpci_ecam_mmio_writeQuoted 7 lines
Signed-off-by Rahul Singh <[email protected]>Signed-off-by Bertrand Marquis <[email protected]>---
Changes in v6:
- Use newvpci_ecam_helpers for PCI access
- Do not setXEN_DOMCTL_CDF_vpcifor dom0 for now (will be done in a future patch once everything is ready)Quoted 2 lines
Isn't the series missing a revert of
XEN_DOMCTL_CDF_vpci? I think that's what we agreed would be the way forward.A separate reverse patch for that has already been merged:
https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=9516d01ac3015f522528ed6dafb3f584eaa7ed2cQuoted 130 lines
Quoted 130 lines
- rename
REGISTER_OFFSETtoECAM_REG_OFFSETand move it topci.h
- remove not needed local variables invpci_mmio_write, the one in read has been kept to ensure proper compilation on arm32
- move call tovpci_add_handlersbefore iommu init to simplify exit path
- move call topci_cleanup_msiin the out section ofpci_add_deviceif pdev is not NULL and on error
- initialize pdev to NULL to handle properly exit path call ofpci_cleanup_msi
- keephas_vpcito return false for now asCFG_vpcihas been removed. Added a comment on top of the definition.
- fix compilation errors on arm32 (print inheader.c, cast missing inmmio_write.
- local variable was kept invpci_mmio_readon arm to prevent a cast error in arm32.
Change in v5:
- Addpci_cleanup_msi(pdev)incleanup part.
- Added Reviewed-by: Stefano Stabellini <[email protected]> Change in v4:
- Move addition ofXEN_DOMCTL_CDF_vpciflag to separate patch Change in v3:
- Useis_pci_passthrough_enabled()in place ofpci_passthrough_enabledvariable
- RejectXEN_DOMCTL_CDF_vpcifor x86 inarch_sanitise_domain_config()
- RemoveIS_ENABLED(CONFIG_HAS_VPCI)fromhas_vpci()
Change in v2:
- Add newXEN_DOMCTL_CDF_vpciflag
- modifyhas_vpci()to includeXEN_DOMCTL_CDF_vpci
- enable vpci support when pci-passthough option is enabled.
---
---xen/arch/arm/Makefile | 1 + xen/arch/arm/domain.c | 4 ++ xen/arch/arm/vpci.c | 74 +++++++++++++++++++++++++++++++++++ xen/arch/arm/vpci.h | 36 +++++++++++++++++ xen/drivers/passthrough/pci.c | 18 ++++++++- xen/drivers/vpci/header.c | 3 +- xen/drivers/vpci/vpci.c | 2 +- xen/include/asm-arm/domain.h | 1 + xen/include/asm-x86/pci.h | 2 - xen/include/public/arch-arm.h | 7 ++++ xen/include/xen/pci.h | 3 ++ 11 files changed, 146 insertions(+), 5 deletions(-)create mode 100644
xen/arch/arm/vpci.c
create mode 100644xen/arch/arm/vpci.hxen/arch/arm/Makefile +0
-0@@ -7,6 +7,7 @@ ifneq ($(CONFIG_NO_PLAT),y)obj-y += platforms/
endif
obj-$(CONFIG_TEE) += tee/
+obj-$(CONFIG_HAS_VPCI) += vpci.oobj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o
obj-y += bootfdt.init.oxen/arch/arm/domain.c +4
-0@@ -39,6 +39,7 @@#include <asm/vgic.h> #include <asm/vtimer.h> +#include "vpci.h" #include "vuart.h" DEFINE_PER_CPU(struct vcpu *, curr_vcpu);@@ -773,6 +774,9 @@ int arch_domain_create(struct domain *d,if (is_hardware_domain (d) && (rc =domain_vuart_init (d)) ) goto fail; +if ( (rc =domain_vpci_init (d)) !=0 ) + goto fail; +return 0 ;fail:
xen/arch/arm/vpci.c new file +45
-0@@ -0,0 +1,74 @@ +/* +* xen/arch/arm/vpci.c +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ +#include <xen/sched.h> +#include <xen/vpci.h> + +#include <asm/mmio.h> + +static int vpci_mmio_read (struct vcpu *v,mmio_info_t *info, +register_t *r,void *p) +{ +pci_sbdf_t sbdf; +/* data is needed to prevent a pointer cast on 32bit */ +unsigned long data = ~0ul ; +int ret; + +/* We ignore segment part and always handle segment 0 */ + sbdf.sbdf =ECAM_BDF (info->gpa); + + ret =vpci_ecam_mmio_read (sbdf,ECAM_REG_OFFSET (info->gpa), +1U << info->dabt.size, &data); + + *r = data; + +return ret; +} + +static int vpci_mmio_write (struct vcpu *v,mmio_info_t *info, +register_t r,void *p) +{ +pci_sbdf_t sbdf; + +/* We ignore segment part and always handle segment 0 */ + sbdf.sbdf =ECAM_BDF (info->gpa); +Quoted 8 lines
xen/arch/arm/vpci.c line 48
Quoted 3 lines
xen/arch/arm/vpci.c new file +3
-0+return vpci_ecam_mmio_write (sbdf,ECAM_REG_OFFSET (info->gpa), +1U << info->dabt.size, r); +}I'm not sure returning an error value here is helpful, as I'm not sure how native Arm behaves and how this error is propagated into the guest. FWIWreturning ~0 or dropping writes is what we do in x86 when vPCI is not capable of handling the access.
Mmio handlers can take a return code on arm if something did not work so I think this is the right way to do it on arm.
Now has agreed with Jan, we will change the return type ofvpci_ecam_write(also renamed) to be a boolean.Quoted 86 lines
Quoted 86 lines
xen/arch/arm/vpci.c new file +26
-0+ +static const struct mmio_handler_ops vpci_mmio_handler = { + .read = vpci_mmio_read, + .write = vpci_mmio_write, +}; + +int domain_vpci_init (struct domain *d) +{ +if ( !has_vpci (d) ) +return 0 ; + +register_mmio_handler (d, &vpci_mmio_handler, +GUEST_VPCI_ECAM_BASE ,GUEST_VPCI_ECAM_SIZE ,NULL ); + +return 0 ; +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ +xen/arch/arm/vpci.h new file +36
-0@@ -0,0 +1,36 @@ +/* +* xen/arch/arm/vpci.h +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __ARCH_ARM_VPCI_H__ +#define __ARCH_ARM_VPCI_H__ + +#ifdef CONFIG_HAS_VPCI +int domain_vpci_init (struct domain *d); +#else +static inline int domain_vpci_init (struct domain *d) +{ +return 0 ; +} +#endif + +#endif /* __ARCH_ARM_VPCI_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ xen/drivers/passthrough/pci.c +1
-1@@ -658,7 +658,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, const struct pci_dev_info *info, nodeid_t node) { struct pci_seg *pseg; -struct pci_dev *pdev; +struct pci_dev *pdev =NULL ;unsigned int slot =PCI_SLOT (devfn), func =PCI_FUNC (devfn);const char *pdev_type;int ret;@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev);Quoted 15 lines
xen/drivers/passthrough/pci.c int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 12 lines
xen/drivers/passthrough/pci.c +12
-0+#ifdef CONFIG_ARM +/* +* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ + ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif I think
vpci_add_handlersshould be called after checking thatpdev->domainis != NULL, so I would move this chunk a bit below.Quoted 4 lines
On arm this would prevent the dom0less use case or to have the PCI bus enumerated from an other domain.
@oleksandr: can you comment on this one, you might have a better answer than me on this ?
Quoted 5 lines
For my understanding, as also Jan pointed out, this should be put inside the If ( !pdev->domain ) because also as the comment suggests, this operation should be performed only when there is a Dom0 and when we are using a dom0less setup the
pdev->domainshould be NULL if I’m not wrong. @oleksandr maybe can confirm
You are right.
I will fix that and move that into an if.
Regards
Bertrand
Quoted 30 lines
Quoted 30 lines
Quoted 16 lines
xen/drivers/passthrough/pci.c out: · line 801
Quoted 13 lines
xen/drivers/passthrough/pci.c +3
-0+ ret =0 ;if ( !pdev->domain ) {@@ -784,6 +797,9 @@ out: &PCI_SBDF(seg, bus, slot, func)); } } +else if ( pdev ) +pci_cleanup_msi (pdev);I'm slightly lost at why you add this chunk, is this strictly related to the patch?
This was discussed a lot in previous version of the patch and requested by Stefano. The idea here is that as soon as handlers are added some bits might be modified in the PCI config space leading possibly to msi interrupts. So it is safer to cleanup on the error path. For references please see discussion on v4 and v5 where this was actually added (to much references as the discussion was long so here [1] and [2] are the patchwork thread).
[1] https://patchwork.kernel.org/project/xen-devel/patch/9bdca2cda5d2e83f94dc2423e55714273539760a.1633540842.git.rahul.singh@arm.com/
[2] https://patchwork.kernel.org/project/xen-devel/patch/f093de681c2560a7196895bcd666ef8840885c1d.1633340795.git.rahul.singh@arm.com/Regards
Bertrand
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
In reply to Bertrand MarquisQuoted 39 lines · Bertrand Marquis
Hi Roger,
Quoted 21 lines · Roger Pau Monné
Quoted 18 lines · Bertrand Marquis
From: Rahul Singh <[email protected]>
xen/drivers/passthrough/pci.c +1
-1@@ -658,7 +658,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, const struct pci_dev_info *info, nodeid_t node) { struct pci_seg *pseg; -struct pci_dev *pdev; +struct pci_dev *pdev =NULL ;unsigned int slot =PCI_SLOT (devfn), func =PCI_FUNC (devfn);const char *pdev_type;int ret;@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev);Quoted 15 lines
xen/drivers/passthrough/pci.c int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 12 lines
xen/drivers/passthrough/pci.c +12
-0+#ifdef CONFIG_ARM +/* +* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ + ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif I think
vpci_add_handlersshould be called after checking thatpdev->domainis != NULL, so I would move this chunk a bit below.
Quoted 2 lines
On arm this would prevent the dom0less use case or to have the PCI bus enumerated from an other domain.
vpci_add_handlers will try to access pdev->domain, so passing a pdev without domain being set is wrong.
Quoted 18 lines
@oleksandr: can you comment on this one, you might have a better answer than me on this ?
Quoted 14 lines
xen/drivers/passthrough/pci.c out: · line 801
Quoted 11 lines
xen/drivers/passthrough/pci.c +3
-0+ ret =0 ;if ( !pdev->domain ) {@@ -784,6 +797,9 @@ out: &PCI_SBDF(seg, bus, slot, func)); } } +else if ( pdev ) +pci_cleanup_msi (pdev);I'm slightly lost at why you add this chunk, is this strictly related to the patch?
Quoted 7 lines
This was discussed a lot in previous version of the patch and requested by Stefano. The idea here is that as soon as handlers are added some bits might be modified in the PCI config space leading possibly to msi interrupts. So it is safer to cleanup on the error path. For references please see discussion on v4 and v5 where this was actually added (to much references as the discussion was long so here [1] and [2] are the patchwork thread).
pci_add_device being solely used by trusted domains, I think it would be fine to require that the domain doesn't poke the PCI config space until the call to pci_add_device has finished. Else it's likely to get inconsistent results, or mess up with the device state.
In any case, such addition needs some kind of reasoning added to the commit message if it's really required.
Thanks, Roger.
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Hi,
Quoted 42 lines · Roger Pau Monné
Quoted 39 lines · Bertrand Marquis
Hi Roger,
Quoted 36 lines · Roger Pau Monné
Quoted 20 lines · Bertrand Marquis
From: Rahul Singh <[email protected]>
xen/drivers/passthrough/pci.c +3
-1@@ -658,7 +658,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, const struct pci_dev_info *info, nodeid_t node) { struct pci_seg *pseg; -struct pci_dev *pdev; +struct pci_dev *pdev =NULL ;unsigned int slot =PCI_SLOT (devfn), func =PCI_FUNC (devfn);const char *pdev_type;int ret;@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev); +#ifdef CONFIG_ARM +/* xen/drivers/passthrough/pci.c int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 10 lines
xen/drivers/passthrough/pci.c +10
-0+* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ + ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif I think
vpci_add_handlersshould be called after checking thatpdev->domainis != NULL, so I would move this chunk a bit below.
Quoted 5 lines
Quoted 2 lines
On arm this would prevent the dom0less use case or to have the PCI bus enumerated from an other domain.
vpci_add_handlerswill try to accesspdev->domain, so passing a pdev without domain being set is wrong.
Right and the initial comment from Rahul in the code is saying so. I will move the block inside the if.
Quoted 27 lines
Quoted 19 lines
@oleksandr: can you comment on this one, you might have a better answer than me on this ?
Quoted 14 lines
xen/drivers/passthrough/pci.c out: · line 801
Quoted 11 lines
xen/drivers/passthrough/pci.c +3
-0+ ret =0 ;if ( !pdev->domain ) {@@ -784,6 +797,9 @@ out: &PCI_SBDF(seg, bus, slot, func)); } } +else if ( pdev ) +pci_cleanup_msi (pdev);I'm slightly lost at why you add this chunk, is this strictly related to the patch?
Quoted 7 lines
This was discussed a lot in previous version of the patch and requested by Stefano. The idea here is that as soon as handlers are added some bits might be modified in the PCI config space leading possibly to msi interrupts. So it is safer to cleanup on the error path. For references please see discussion on v4 and v5 where this was actually added (to much references as the discussion was long so here [1] and [2] are the patchwork thread).
Quoted 4 lines
pci_add_devicebeing solely used by trusted domains, I think it would be fine to require that the domain doesn't poke the PCI config space until the call topci_add_devicehas finished. Else it's likely to get inconsistent results, or mess up with the device state.
Ack.
Quoted 3 lines
In any case, such addition needs some kind of reasoning added to the commit message if it's really required.
With the code moving inside the following else and pci_cleanup_msi being empty for now on arm, I will remove the pci_cleanup_msi as it does not related directly to this change for now and might change the behaviour on x86.
If this is needed at some point due to arm, this will be done once msi support will be added.
Regards
Bertrand
Quoted 2 lines
Thanks, Roger.
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
In reply to Bertrand MarquisQuoted 22 lines · Bertrand Marquis
Quoted 6 lines · Roger Pau Monné
Quoted 4 lines · Bertrand Marquis
xen/drivers/passthrough/pci.c +0
-0@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev);Quoted 15 lines
xen/drivers/passthrough/pci.c int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 12 lines
xen/drivers/passthrough/pci.c +12
-0+#ifdef CONFIG_ARM +/* +* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ + ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif I think
vpci_add_handlersshould be called after checking thatpdev->domainis != NULL, so I would move this chunk a bit below.
Quoted 4 lines
On arm this would prevent the dom0less use case or to have the PCI bus enumerated from an other domain.
@oleksandr: can you comment on this one, you might have a better answer than me on this ?
Well, without Xen doing the enumeration, some other entity would need to do so, including the reporting to Xen. Obviously without a Dom0 it would be ambiguous which domain to assign the device to; perhaps it should be the caller in this case? That would make that caller domain a pseudo-hwdom though, as far as PCI is concerned, which may not be desirable according to my (limited) understanding of dom0less.
Quoted 18 lines
Quoted 9 lines
xen/drivers/passthrough/pci.c out: · line 801
Quoted 6 lines
xen/drivers/passthrough/pci.c +2
-0@@ -784,6 +797,9 @@ out: &PCI_SBDF(seg, bus, slot, func)); } } +else if ( pdev ) +pci_cleanup_msi (pdev);I'm slightly lost at why you add this chunk, is this strictly related to the patch?
This was discussed a lot in previous version of the patch and requested by Stefano. The idea here is that as soon as handlers are added some bits might be modified in the PCI config space leading possibly to msi interrupts. So it is safer to cleanup on the error path. For references please see discussion on v4 and v5 where this was actually added (to much references as the discussion was long so here [1] and [2] are the patchwork thread).
Quoted 2 lines
[1] https://patchwork.kernel.org/project/xen-devel/patch/9bdca2cda5d2e83f94dc2423e55714273539760a.1633540842.git.rahul.singh@arm.com/
[2] https://patchwork.kernel.org/project/xen-devel/patch/f093de681c2560a7196895bcd666ef8840885c1d.1633340795.git.rahul.singh@arm.com/
The addition of this call has repeatedly raised questions. This is a good indication that sufficient discussion thereof has been lacking from the patch description.
Jan
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Quoted 32 lines · Jan Beulich
Quoted 22 lines · Bertrand Marquis
Quoted 6 lines · Roger Pau Monné
Quoted 4 lines · Bertrand Marquis
xen/drivers/passthrough/pci.c +0
-0@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev);Quoted 15 lines
xen/drivers/passthrough/pci.c int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 12 lines
xen/drivers/passthrough/pci.c +12
-0+#ifdef CONFIG_ARM +/* +* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ + ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif I think
vpci_add_handlersshould be called after checking thatpdev->domainis != NULL, so I would move this chunk a bit below.Quoted 4 lines
On arm this would prevent the dom0less use case or to have the PCI bus enumerated from an other domain.
@oleksandr: can you comment on this one, you might have a better answer than me on this ?
Quoted 6 lines
Well, without Xen doing the enumeration, some other entity would need to do so, including the reporting to Xen. Obviously without a Dom0 it would be ambiguous which domain to assign the device to; perhaps it should be the caller in this case? That would make that caller domain a pseudo-hwdom though, as far as PCI is concerned, which may not be desirable according to my (limited) understanding of dom0less.
This is not really related to this patch but the plan is the following:
- enumeration would have to be done by the firmware or boot loader before
- xen will have some code to detect PCI devices
- dom0less can be used to assign PCI devices to guest
Anyway does not change the fact that this must be called when domain is not NULL and I will fix that.
Quoted 19 lines
Quoted 19 lines
Quoted 10 lines
xen/drivers/passthrough/pci.c out: · line 801
Quoted 7 lines
xen/drivers/passthrough/pci.c +2
-0@@ -784,6 +797,9 @@ out: &PCI_SBDF(seg, bus, slot, func)); } } +else if ( pdev ) +pci_cleanup_msi (pdev);I'm slightly lost at why you add this chunk, is this strictly related to the patch?
This was discussed a lot in previous version of the patch and requested by Stefano. The idea here is that as soon as handlers are added some bits might be modified in the PCI config space leading possibly to msi interrupts. So it is safer to cleanup on the error path. For references please see discussion on v4 and v5 where this was actually added (to much references as the discussion was long so here [1] and [2] are the patchwork thread).
Quoted 6 lines
Quoted 2 lines
[1] https://patchwork.kernel.org/project/xen-devel/patch/9bdca2cda5d2e83f94dc2423e55714273539760a.1633540842.git.rahul.singh@arm.com/
[2] https://patchwork.kernel.org/project/xen-devel/patch/f093de681c2560a7196895bcd666ef8840885c1d.1633340795.git.rahul.singh@arm.com/The addition of this call has repeatedly raised questions. This is a good indication that sufficient discussion thereof has been lacking from the patch description.
Yes and I will remove it as it only impacts x86 right now.
If this is needed, we will have to do it while adding MSI support on Arm.
Regards
Bertrand
Quoted 3 lines
Jan
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Quoted 36 lines · Bertrand Marquis
Quoted 29 lines · Jan Beulich
Quoted 22 lines · Bertrand Marquis
Quoted 6 lines · Roger Pau Monné
Quoted 4 lines · Bertrand Marquis
xen/drivers/passthrough/pci.c +0
-0@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev);Quoted 15 lines
xen/drivers/passthrough/pci.c int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 12 lines
xen/drivers/passthrough/pci.c +12
-0+#ifdef CONFIG_ARM +/* +* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ + ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif I think
vpci_add_handlersshould be called after checking thatpdev->domainis != NULL, so I would move this chunk a bit below.Quoted 4 lines
On arm this would prevent the dom0less use case or to have the PCI bus enumerated from an other domain.
@oleksandr: can you comment on this one, you might have a better answer than me on this ?Quoted 6 lines
Well, without Xen doing the enumeration, some other entity would need to do so, including the reporting to Xen. Obviously without a Dom0 it would be ambiguous which domain to assign the device to; perhaps it should be the caller in this case? That would make that caller domain a pseudo-hwdom though, as far as PCI is concerned, which may not be desirable according to my (limited) understanding of dom0less.
Quoted 7 lines
This is not really related to this patch but the plan is the following:
- enumeration would have to be done by the firmware or boot loader before
- xen will have some code to detect PCI devices
- dom0less can be used to assign PCI devices to guestAnyway does not change the fact that this must be called when domain is not NULL and I will fix that.
Since we now all seem to agree that the NULL would have been a problem, may I ask in how far any of this has actually been tested?
Jan
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Hi Jan,
Quoted 44 lines · Jan Beulich
Quoted 41 lines · Bertrand Marquis
Quoted 29 lines · Jan Beulich
Quoted 22 lines · Bertrand Marquis
Quoted 6 lines · Roger Pau Monné
Quoted 4 lines · Bertrand Marquis
xen/drivers/passthrough/pci.c +0
-0@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,check_pdev (pdev);Quoted 15 lines
xen/drivers/passthrough/pci.c int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 12 lines
xen/drivers/passthrough/pci.c +12
-0+#ifdef CONFIG_ARM +/* +* On ARM PCI devices discovery will be done by Dom0. Add vpci handler when +* Dom0 inform XEN to add the PCI devices in XEN. +*/ + ret =vpci_add_handlers (pdev); +if ( ret ) + { +printk (XENLOG_ERR "Setup of vPCI failed: %d\n" , ret); + goto out; + } +#endif I think
vpci_add_handlersshould be called after checking thatpdev->domainis != NULL, so I would move this chunk a bit below.Quoted 4 lines
On arm this would prevent the dom0less use case or to have the PCI bus enumerated from an other domain.
@oleksandr: can you comment on this one, you might have a better answer than me on this ?Quoted 6 lines
Well, without Xen doing the enumeration, some other entity would need to do so, including the reporting to Xen. Obviously without a Dom0 it would be ambiguous which domain to assign the device to; perhaps it should be the caller in this case? That would make that caller domain a pseudo-hwdom though, as far as PCI is concerned, which may not be desirable according to my (limited) understanding of dom0less.
This is not really related to this patch but the plan is the following:
- enumeration would have to be done by the firmware or boot loader before
- xen will have some code to detect PCI devices
- dom0less can be used to assign PCI devices to guest
Quoted 5 lines
Quoted 2 lines
Anyway does not change the fact that this must be called when domain is not NULL and I will fix that.
Since we now all seem to agree that the NULL would have been a problem, may I ask in how far any of this has actually been tested?
With the whole serie currently on gitlab we have extensively tested passing through PCI devices on Arm in several configuration (number of device, MSI, MSI-X) and check that PCI was still functional on x86.
With the patches pushed to Xen right now it was checked that:
- xen compiles properly on arm32, arm64 and x86
- xen compiles properly with VPCI activated (using a patch) on arm32 and arm64
- xen on x86 is functionnal (using basic test on QEMU)
- xen on arm64 is functionnal (with some extensive tests on different targets)
We are only lacking some actual testing on arm32 internally.
Regards
Bertrand
Quoted 2 lines
Jan
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Quoted 56 lines · Bertrand Marquis
Hi Jan,
Quoted 44 lines · Jan Beulich
Quoted 41 lines · Bertrand Marquis
Quoted 29 lines · Jan Beulich
Quoted 22 lines · Bertrand Marquis
Quoted 6 lines · Roger Pau Monné
Quoted 4 lines · Bertrand Marquis
(quoted diff) +0
-0@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, check_pdev(pdev);Quoted 15 lines
Review int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 12 lines
(quoted diff) +12
-0+#ifdef CONFIG_ARM + /* + * On ARM PCI devices discovery will be done by Dom0. Add vpci handler when + * Dom0 inform XEN to add the PCI devices in XEN. + */ + ret = vpci_add_handlers(pdev); + if ( ret ) + { + printk(XENLOG_ERR "Setup of vPCI failed: %d\n", ret); + goto out; + } +#endifI think
vpci_add_handlersshould be called after checking thatpdev->domainis != NULL, so I would move this chunk a bit below.Quoted 4 lines
On arm this would prevent the dom0less use case or to have the PCI bus enumerated from an other domain.
@oleksandr: can you comment on this one, you might have a better answer than me on this ?Quoted 6 lines
Well, without Xen doing the enumeration, some other entity would need to do so, including the reporting to Xen. Obviously without a Dom0 it would be ambiguous which domain to assign the device to; perhaps it should be the caller in this case? That would make that caller domain a pseudo-hwdom though, as far as PCI is concerned, which may not be desirable according to my (limited) understanding of dom0less.
This is not really related to this patch but the plan is the following:
- enumeration would have to be done by the firmware or boot loader before
- xen will have some code to detect PCI devices
- dom0less can be used to assign PCI devices to guestQuoted 5 lines
Quoted 2 lines
Anyway does not change the fact that this must be called when domain is not NULL and I will fix that.
Since we now all seem to agree that the NULL would have been a problem, may I ask in how far any of this has actually been tested?
With the whole serie currently on gitlab we have extensively tested passing through PCI devices on Arm in several configuration (number of device, MSI, MSI-X) and check that PCI was still functional on x86.
Quoted 5 lines
With the patches pushed to Xen right now it was checked that:
- xen compiles properly on arm32, arm64 and x86
- xen compiles properly with VPCI activated (using a patch) on arm32 and arm64
- xen on x86 is functionnal (using basic test on QEMU)
- xen on arm64 is functionnal (with some extensive tests on different targets)
But somehow in the testing done you must have avoided the code path in question, or else you would have observed a crash.
Jan
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Hi,
Quoted 59 lines · Jan Beulich
Quoted 56 lines · Bertrand Marquis
Hi Jan,
Quoted 44 lines · Jan Beulich
Quoted 41 lines · Bertrand Marquis
Quoted 29 lines · Jan Beulich
Quoted 22 lines · Bertrand Marquis
Quoted 6 lines · Roger Pau Monné
Quoted 4 lines · Bertrand Marquis
(quoted diff) +0
-0@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, check_pdev(pdev);Quoted 15 lines
Review int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 12 lines
(quoted diff) +12
-0+#ifdef CONFIG_ARM + /* + * On ARM PCI devices discovery will be done by Dom0. Add vpci handler when + * Dom0 inform XEN to add the PCI devices in XEN. + */ + ret = vpci_add_handlers(pdev); + if ( ret ) + { + printk(XENLOG_ERR "Setup of vPCI failed: %d\n", ret); + goto out; + } +#endifI think
vpci_add_handlersshould be called after checking thatpdev->domainis != NULL, so I would move this chunk a bit below.Quoted 4 lines
On arm this would prevent the dom0less use case or to have the PCI bus enumerated from an other domain.
@oleksandr: can you comment on this one, you might have a better answer than me on this ?Quoted 6 lines
Well, without Xen doing the enumeration, some other entity would need to do so, including the reporting to Xen. Obviously without a Dom0 it would be ambiguous which domain to assign the device to; perhaps it should be the caller in this case? That would make that caller domain a pseudo-hwdom though, as far as PCI is concerned, which may not be desirable according to my (limited) understanding of dom0less.
This is not really related to this patch but the plan is the following:
- enumeration would have to be done by the firmware or boot loader before
- xen will have some code to detect PCI devices
- dom0less can be used to assign PCI devices to guestQuoted 5 lines
Quoted 2 lines
Anyway does not change the fact that this must be called when domain is not NULL and I will fix that.
Since we now all seem to agree that the NULL would have been a problem, may I ask in how far any of this has actually been tested?
With the whole serie currently on gitlab we have extensively tested passing through PCI devices on Arm in several configuration (number of device, MSI, MSI-X) and check that PCI was still functional on x86.
Quoted 8 lines
Quoted 5 lines
With the patches pushed to Xen right now it was checked that:
- xen compiles properly on arm32, arm64 and x86
- xen compiles properly with VPCI activated (using a patch) on arm32 and arm64
- xen on x86 is functionnal (using basic test on QEMU)
- xen on arm64 is functionnal (with some extensive tests on different targets)But somehow in the testing done you must have avoided the code path in question, or else you would have observed a crash.
Device_add is always called by dom0 so we did not have issues here. Dom0less PCI passthrough implementation is not done right now.
So yes we did not go through this path.
Bertrand
Quoted 3 lines
Jan
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
In reply to Bertrand MarquisQuoted 56 lines · Bertrand Marquis
Hi Jan,
Quoted 44 lines · Jan Beulich
Quoted 41 lines · Bertrand Marquis
Quoted 29 lines · Jan Beulich
Quoted 22 lines · Bertrand Marquis
Quoted 6 lines · Roger Pau Monné
Quoted 4 lines · Bertrand Marquis
(quoted diff) +0
-0@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, check_pdev(pdev);Quoted 15 lines
Review int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 12 lines
(quoted diff) +12
-0+#ifdef CONFIG_ARM + /* + * On ARM PCI devices discovery will be done by Dom0. Add vpci handler when + * Dom0 inform XEN to add the PCI devices in XEN. + */ + ret = vpci_add_handlers(pdev); + if ( ret ) + { + printk(XENLOG_ERR "Setup of vPCI failed: %d\n", ret); + goto out; + } +#endifI think
vpci_add_handlersshould be called after checking thatpdev->domainis != NULL, so I would move this chunk a bit below.Quoted 4 lines
On arm this would prevent the dom0less use case or to have the PCI bus enumerated from an other domain.
@oleksandr: can you comment on this one, you might have a better answer than me on this ?Quoted 6 lines
Well, without Xen doing the enumeration, some other entity would need to do so, including the reporting to Xen. Obviously without a Dom0 it would be ambiguous which domain to assign the device to; perhaps it should be the caller in this case? That would make that caller domain a pseudo-hwdom though, as far as PCI is concerned, which may not be desirable according to my (limited) understanding of dom0less.
This is not really related to this patch but the plan is the following:
- enumeration would have to be done by the firmware or boot loader before
- xen will have some code to detect PCI devices
- dom0less can be used to assign PCI devices to guestQuoted 5 lines
Quoted 2 lines
Anyway does not change the fact that this must be called when domain is not NULL and I will fix that.
Since we now all seem to agree that the NULL would have been a problem, may I ask in how far any of this has actually been tested?
With the whole serie currently on gitlab we have extensively tested passing through PCI devices on Arm in several configuration (number of device, MSI, MSI-X) and check that PCI was still functional on x86.
Quoted 5 lines
With the patches pushed to Xen right now it was checked that:
- xen compiles properly on arm32, arm64 and x86
- xen compiles properly with VPCI activated (using a patch) on arm32 and arm64
- xen on x86 is functionnal (using basic test on QEMU)
- xen on arm64 is functionnal (with some extensive tests on different targets)
I thinks it's unlikely, but since I haven't checked myself, could you see if the vpci user-space test harness (tools/tests/vpci) still builds and functions properly?
Thanks, Roger.
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Quoted 67 lines · Roger Pau Monné
Quoted 56 lines · Bertrand Marquis
Hi Jan,
Quoted 44 lines · Jan Beulich
Quoted 41 lines · Bertrand Marquis
Quoted 29 lines · Jan Beulich
Quoted 22 lines · Bertrand Marquis
Quoted 6 lines · Roger Pau Monné
Quoted 4 lines · Bertrand Marquis
(quoted diff) +0
-0@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, check_pdev(pdev);Quoted 15 lines
Review int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 12 lines
(quoted diff) +12
-0+#ifdef CONFIG_ARM + /* + * On ARM PCI devices discovery will be done by Dom0. Add vpci handler when + * Dom0 inform XEN to add the PCI devices in XEN. + */ + ret = vpci_add_handlers(pdev); + if ( ret ) + { + printk(XENLOG_ERR "Setup of vPCI failed: %d\n", ret); + goto out; + } +#endifI think
vpci_add_handlersshould be called after checking thatpdev->domainis != NULL, so I would move this chunk a bit below.Quoted 4 lines
On arm this would prevent the dom0less use case or to have the PCI bus enumerated from an other domain.
@oleksandr: can you comment on this one, you might have a better answer than me on this ?Quoted 6 lines
Well, without Xen doing the enumeration, some other entity would need to do so, including the reporting to Xen. Obviously without a Dom0 it would be ambiguous which domain to assign the device to; perhaps it should be the caller in this case? That would make that caller domain a pseudo-hwdom though, as far as PCI is concerned, which may not be desirable according to my (limited) understanding of dom0less.
This is not really related to this patch but the plan is the following:
- enumeration would have to be done by the firmware or boot loader before
- xen will have some code to detect PCI devices
- dom0less can be used to assign PCI devices to guestQuoted 5 lines
Quoted 2 lines
Anyway does not change the fact that this must be called when domain is not NULL and I will fix that.
Since we now all seem to agree that the NULL would have been a problem, may I ask in how far any of this has actually been tested?
With the whole serie currently on gitlab we have extensively tested passing through PCI devices on Arm in several configuration (number of device, MSI, MSI-X) and check that PCI was still functional on x86.
Quoted 5 lines
With the patches pushed to Xen right now it was checked that:
- xen compiles properly on arm32, arm64 and x86
- xen compiles properly with VPCI activated (using a patch) on arm32 and arm64
- xen on x86 is functionnal (using basic test on QEMU)
- xen on arm64 is functionnal (with some extensive tests on different targets)
Quoted 3 lines
I thinks it's unlikely, but since I haven't checked myself, could you see if the vpci user-space test harness (
tools/tests/vpci) still builds and functions properly?
Hi Roger,
Bertrand is going to send the v7, however I’m keen to do this test but unfortunately I’ve never used it before and I don’t have an x86 environment, do you have any resource that I can read or some guidance?
Cheers,
Luca
Quoted 3 lines
Thanks, Roger.
Re: [PATCH v6 2/3] xen/arm: Enable the existing x86 virtual PCI support for ARM.
Quoted 71 lines · Luca Fancellu
Quoted 67 lines · Roger Pau Monné
Quoted 56 lines · Bertrand Marquis
Hi Jan,
Quoted 44 lines · Jan Beulich
Quoted 41 lines · Bertrand Marquis
Quoted 29 lines · Jan Beulich
Quoted 22 lines · Bertrand Marquis
Quoted 6 lines · Roger Pau Monné
Quoted 4 lines · Bertrand Marquis
(quoted diff) +0
-0@@ -752,6 +752,19 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, check_pdev(pdev);Quoted 15 lines
Review int pci_add_device(u16 seg, u8 bus, u8 devfn, · line 766
Quoted 12 lines
(quoted diff) +12
-0+#ifdef CONFIG_ARM + /* + * On ARM PCI devices discovery will be done by Dom0. Add vpci handler when + * Dom0 inform XEN to add the PCI devices in XEN. + */ + ret = vpci_add_handlers(pdev); + if ( ret ) + { + printk(XENLOG_ERR "Setup of vPCI failed: %d\n", ret); + goto out; + } +#endifI think
vpci_add_handlersshould be called after checking thatpdev->domainis != NULL, so I would move this chunk a bit below.Quoted 4 lines
On arm this would prevent the dom0less use case or to have the PCI bus enumerated from an other domain.
@oleksandr: can you comment on this one, you might have a better answer than me on this ?Quoted 6 lines
Well, without Xen doing the enumeration, some other entity would need to do so, including the reporting to Xen. Obviously without a Dom0 it would be ambiguous which domain to assign the device to; perhaps it should be the caller in this case? That would make that caller domain a pseudo-hwdom though, as far as PCI is concerned, which may not be desirable according to my (limited) understanding of dom0less.
This is not really related to this patch but the plan is the following:
- enumeration would have to be done by the firmware or boot loader before
- xen will have some code to detect PCI devices
- dom0less can be used to assign PCI devices to guestQuoted 5 lines
Quoted 2 lines
Anyway does not change the fact that this must be called when domain is not NULL and I will fix that.
Since we now all seem to agree that the NULL would have been a problem, may I ask in how far any of this has actually been tested?
With the whole serie currently on gitlab we have extensively tested passing through PCI devices on Arm in several configuration (number of device, MSI, MSI-X) and check that PCI was still functional on x86.
Quoted 5 lines
With the patches pushed to Xen right now it was checked that:
- xen compiles properly on arm32, arm64 and x86
- xen compiles properly with VPCI activated (using a patch) on arm32 and arm64
- xen on x86 is functionnal (using basic test on QEMU)
- xen on arm64 is functionnal (with some extensive tests on different targets)Quoted 3 lines
I thinks it's unlikely, but since I haven't checked myself, could you see if the vpci user-space test harness (
tools/tests/vpci) still builds and functions properly?
Quoted 5 lines
Hi Roger,
Bertrand is going to send the v7, however I’m keen to do this test but unfortunately I’ve never used it before and I don’t have an x86 environment, do you have any resource that I can read or some guidance?
Oh, you just need to build it (make) and then run it (make run). If it returns success everything is fine.
Regards, Roger.
PATCH v6 3/3 arm/libxl: Emulated PCI device tree node in libxl
In reply to Bertrand MarquisFrom: Rahul Singh <[email protected]>
libxl will create an emulated PCI device tree node in the device tree to enable the guest OS to discover the virtual PCI during guest boot. Emulated PCI device tree node will only be created when there is any device assigned to guest.
A new area has been reserved in the arm guest physical map at which the VPCI bus is declared in the device tree (reg and ranges parameters of the node).
b_info.arch_arm.vpci is set by default to false and it is not set to true anywhere. This way the vpci node is not going to be created and we are only introducing functions to create vpci DT node to be used in the future.
---
Changes in v6:
According to https://marc.info/?l=xen-devel&m=163415838129479&w=2:
-do not set XEN_DOMCTL_CDF_vpci
-do not enable VPCI support (by setting b_info.arch_arm.vpci) -do not define LIBXL_HAVE_BUILDINFO_ARM_VPCI
-keep b_info.arch_arm.vpci, make_vpci_node and its helpers Change in v5:
- Move setting the arch_arm.vpci and XEN_DOMCTL_CDF_vpci to libxl_arm.c Change in v4:
- Gate code for x86 for setting the XEN_DOMCTL_CDF_vpci for x86. Change in v3:
- Make GUEST_VPCI_MEM_ADDR address 2MB aligned
Change in v2:
- enable doamin_vpci_init() when XEN_DOMCTL_CDF_vpci is set for domain.
--- tools/libs/light/libxl_arm.c | 105 +++++++++++++++++++++++++++++++ tools/libs/light/libxl_types.idl | 1 + xen/include/public/arch-arm.h | 10 +++ 3 files changed, 116 insertions(+)
tools/libs/light/libxl_arm.c +105 -0
@@ -269,6 +269,58 @@ static int fdt_property_regs(libxl__gc *gc, void *fdt,return fdt_property (fdt,"reg" , regs,sizeof (regs)); } +static int fdt_property_values (libxl__gc *gc,void *fdt, +const char *name,unsigned num_cells, ...) +{ +uint32_t prop[num_cells]; +be32 *cells = &prop[0 ]; +int i; +va_list ap; +uint32_t arg; + +va_start (ap, num_cells); +for (i =0 ; i < num_cells; i++) { + arg =va_arg (ap, uint32_t); +set_cell (&cells,1 , arg); + } +va_end (ap); + +return fdt_property (fdt, name, prop,sizeof (prop)); +} + +static int fdt_property_vpci_ranges (libxl__gc *gc,void *fdt, +unsigned addr_cells, +unsigned size_cells, +unsigned num_regs, ...) +{ +uint32_t regs[num_regs*((addr_cells*2 )+size_cells+1 )]; +be32 *cells = ®s[0 ]; +int i; +va_list ap; +uint64_t arg; + +va_start (ap, num_regs); +for (i =0 ; i < num_regs; i++) { +/* Set the memory bit field */ + arg =va_arg (ap, uint32_t); +set_cell (&cells,1 , arg); + +/* Set the vpci bus address */ + arg = addr_cells ?va_arg (ap, uint64_t) :0 ; +set_cell (&cells, addr_cells , arg); + +/* Set the cpu bus address where vpci address is mapped */ +set_cell (&cells, addr_cells, arg); + +/* Set the vpci size requested */ + arg = size_cells ?va_arg (ap, uint64_t) :0 ; +set_cell (&cells, size_cells, arg); + } +va_end (ap); + +return fdt_property (fdt,"ranges" , regs,sizeof (regs)); +} +static int make_root_properties (libxl__gc *gc,const libxl_version_info *vers,void *fdt)
@@ -668,6 +720,53 @@ static int make_vpl011_uart_node(libxl__gc *gc, void *fdt,return 0 ; } +static int make_vpci_node (libxl__gc *gc,void *fdt, +const struct arch_info *ainfo, +struct xc_dom_image *dom) +{ +int res; +const uint64_t vpci_ecam_base =GUEST_VPCI_ECAM_BASE ; +const uint64_t vpci_ecam_size =GUEST_VPCI_ECAM_SIZE ; +const char *name =GCSPRINTF ("pcie@%" PRIx64, vpci_ecam_base); + + res =fdt_begin_node (fdt, name); +if (res)return res; + + res =fdt_property_compat (gc, fdt,1 ,"pci-host-ecam-generic" ); +if (res)return res; + + res =fdt_property_string (fdt,"device_type" ,"pci" ); +if (res)return res; + + res =fdt_property_regs (gc, fdt,GUEST_ROOT_ADDRESS_CELLS , +GUEST_ROOT_SIZE_CELLS ,1 , vpci_ecam_base, vpci_ecam_size); +if (res)return res; + + res =fdt_property_values (gc, fdt,"bus-range" ,2 ,0 ,255 ); +if (res)return res; + + res =fdt_property_cell (fdt,"#address-cells" ,3 ); +if (res)return res; + + res =fdt_property_cell (fdt,"#size-cells" ,2 ); +if (res)return res; + + res =fdt_property_string (fdt,"status" ,"okay" ); +if (res)return res; + + res =fdt_property_vpci_ranges (gc, fdt,GUEST_ROOT_ADDRESS_CELLS , +GUEST_ROOT_SIZE_CELLS ,2 , +GUEST_VPCI_ADDR_TYPE_MEM ,GUEST_VPCI_MEM_ADDR ,GUEST_VPCI_MEM_SIZE , +GUEST_VPCI_ADDR_TYPE_PREFETCH_MEM ,GUEST_VPCI_PREFETCH_MEM_ADDR , +GUEST_VPCI_PREFETCH_MEM_SIZE ); +if (res)return res; + + res =fdt_end_node (fdt); +if (res)return res; + +return 0 ; +} +static const struct arch_info *get_arch_info (libxl__gc *gc,const struct xc_dom_image *dom) {
@@ -971,6 +1070,9 @@ next_resize:if (info->tee ==LIBXL_TEE_TYPE_OPTEE )FDT (make_optee_node (gc, fdt) ); +if (libxl_defbool_val (info->arch_arm.vpci)) +FDT (make_vpci_node (gc, fdt, ainfo, dom) ); +if (pfdt)FDT (copy_partial_fdt (gc, fdt, pfdt) );
@@ -1189,6 +1291,9 @@ void libxl__arch_domain_build_info_setdefault(libxl__gc *gc,/* ACPI is disabled by default */ libxl_defbool_setdefault (&b_info->acpi, false); +/* VPCI is disabled by default */ +libxl_defbool_setdefault (&b_info->arch_arm.vpci, false); +if (b_info->type !=LIBXL_DOMAIN_TYPE_PV )return ;
tools/libs/light/libxl_types.idl +1 -0
@@ -644,6 +644,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("arch_arm", Struct(None, [("gic_version", libxl_gic_version), ("vuart", libxl_vuart_type), + ("vpci", libxl_defbool), ])), ("arch_x86", Struct(None, [("msr_relaxed", libxl_defbool), ])),
xen/include/public/arch-arm.h +10 -0
@@ -433,6 +433,11 @@ typedef uint64_t xen_callback_t;#define GUEST_PL011_BASE xen_mk_ullong(0x22000000)#define GUEST_PL011_SIZE xen_mk_ullong(0x00001000) +/* Guest PCI-PCIe memory space where config space and BAR will be available.*/ +#define GUEST_VPCI_ADDR_TYPE_MEM xen_mk_ullong(0x02000000) +#define GUEST_VPCI_MEM_ADDR xen_mk_ullong(0x23000000) +#define GUEST_VPCI_MEM_SIZE xen_mk_ullong(0x10000000) +/* * 16MB == 4096 pages reserved for guest to use as a region to map its * grant table in.
@@ -448,6 +453,11 @@ typedef uint64_t xen_callback_t;#define GUEST_RAM0_BASE xen_mk_ullong(0x40000000)/* 3GB of low RAM @ 1GB */ #define GUEST_RAM0_SIZE xen_mk_ullong(0xc0000000) +/* 4GB @ 4GB Prefetch Memory for VPCI */ +#define GUEST_VPCI_ADDR_TYPE_PREFETCH_MEM xen_mk_ullong(0x42000000) +#define GUEST_VPCI_PREFETCH_MEM_ADDR xen_mk_ullong(0x100000000) +#define GUEST_VPCI_PREFETCH_MEM_SIZE xen_mk_ullong(0x100000000) +#define GUEST_RAM1_BASE xen_mk_ullong(0x0200000000)/* 1016GB of RAM @ 8GB */ #define GUEST_RAM1_SIZE xen_mk_ullong(0xfe00000000)
Signature · 1 line
2.25.1
Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]
(Replying to both the earlier subthread on v5 and to the new v6 patch.)
Bertrand Marquis writes ("Re: [PATCH v5 10/11] arm/libxl: Emulated PCI device tree node in libxl"):
Quoted 1 line
Now you suggest to add a new field
arm_vpciinlibxl__domain_create_state.
Hi. I was handwaving, hence "probably" :-). I hadn't actually looked at the existing code to see precisely how it would fit.
Quoted 3 lines
Once we have done that I will need to access this structure to know if I need to add the DT part and somehow to give it a value depending something which for now would the number of pcidevs as there will be no user parameter anymore.
Right.
I looked at libxl_arm.c again:
It seems that the main entrypoint to all this is libxl__prepare_dtb, and it is that function you want to do new stuff. That gets libxl_domain_build_info (which is specified by the IDL and comes from outside libxl, subject to libxl's default-filling machinery) and libxl__domain_build_state (which is the general state struct).
The information you need is is libxl_domain_create_info. libxl__domain_config_setdefault already arranges to set c_info->passthrough based on the number of PCI PT devices (search for need_pt in libxl_create.c).
That is, as I understand it on ARM vpci should be enabled if passthrough is enabled and not otherwise. That is precisely what the variable c_info->passthrough is.
There is a slight issue because of the distinction between create_info and build_info and domain_config (and, the corresponding _state) structs. Currently the DT code ony gets b_info, not the whole libxl_domain_config. These distinctions largely historical nowadays. Certainly there is no reason not to pass a pointer to the whole libxl_domain_config, rather than just libxl_domain_build_info, into libxl__arch_domain_init_hw_description.
So I think the right approach for this looks something like this:
1. Change libxl__arch_domain_init_hw_description to take libxl_domain_config* rather than libxl_domain_build_info*. libxl_domain_config contains libxl_domain_build_info so this is easy.
If you put in a convenience alias variable for the libxl_domain_build_info* you can avoid extra typing in the function body. (If you call the convenience alias info you won't need to change the body at all, but maybe info isn't the best name so you could rename it to b_info maybe; up to you.)
2. Make the same change to libxl__prepare_dtb.
3. Now you can use d_config->c_info.passthrough to gate the addition of the additional stuff to the DT. Ie, that is a respin of this patch 3/3.
1 and 2 need to be separated out from 3, in a different patch (or two different patches) added to this series before what is now 3/3. Ie 1+2, or 1 and 2 separately, should be pure plumbing changes with no functional change.
I hope this is helpful.
Thanks,
Ian.
Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]
Quoted 59 lines · Ian Jackson
(Replying to both the earlier subthread on v5 and to the new v6 patch.)
Bertrand Marquis writes ("Re: [PATCH v5 10/11] arm/libxl: Emulated PCI device tree node in libxl"):
Quoted 1 line
Now you suggest to add a new field
arm_vpciinlibxl__domain_create_state.Hi. I was handwaving, hence "probably" :-). I hadn't actually looked at the existing code to see precisely how it would fit.
Quoted 3 lines
Once we have done that I will need to access this structure to know if I need to add the DT part and somehow to give it a value depending something which for now would the number of pcidevs as there will be no user parameter anymore.
Right.
I looked at
libxl_arm.cagain:It seems that the main entrypoint to all this is
libxl__prepare_dtb, and it is that function you want to do new stuff. That getslibxl_domain_build_info(which is specified by the IDL and comes from outside libxl, subject to libxl's default-filling machinery) andlibxl__domain_build_state(which is the general state struct).The information you need is is
libxl_domain_create_info.libxl__domain_config_setdefaultalready arranges to setc_info->passthroughbased on the number of PCI PT devices (search forneed_ptinlibxl_create.c).That is, as I understand it on ARM vpci should be enabled if passthrough is enabled and not otherwise. That is precisely what the variable
c_info->passthroughis.There is a slight issue because of the distinction between
create_infoandbuild_infoanddomain_config(and, the corresponding_state) structs. Currently the DT code ony getsb_info, not the wholelibxl_domain_config. These distinctions largely historical nowadays. Certainly there is no reason not to pass a pointer to the wholelibxl_domain_config, rather than justlibxl_domain_build_info, intolibxl__arch_domain_init_hw_description.So I think the right approach for this looks something like this:
1. Change
libxl__arch_domain_init_hw_descriptionto take libxl_domain_config* rather than libxl_domain_build_info*.libxl_domain_configcontainslibxl_domain_build_infoso this is easy.If you put in a convenience alias variable for the libxl_domain_build_info* you can avoid extra typing in the function body. (If you call the convenience alias
infoyou won't need to change the body at all, but maybeinfoisn't the best name so you could rename it tob_infomaybe; up to you.)2. Make the same change to
libxl__prepare_dtb.3. Now you can use
d_config->c_info.passthroughto gate the addition of the additional stuff to the DT. Ie, that is a respin of this patch 3/3.
Quoted 6 lines
1 and 2 need to be separated out from 3, in a different patch (or two different patches) added to this series before what is now 3/3. Ie 1+2, or 1 and 2 separately, should be pure plumbing changes with no functional change.
I hope this is helpful.
The explanation is clear and makes sense to me too.
FYI I suggested something similar and Rahul agreed on it; in fact, he seemed to have already made the change and tested it:
https://marc.info/?l=xen-devel&m=163362066215155
I am just mentioning it in case Bertrand might be able to find Rahul's updated patch somewhere and it might be useful as a base for his work.
The rest looks good, including the new changes.
Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]
In reply to Ian JacksonHi Ian,
Quoted 23 lines · Ian Jackson
(Replying to both the earlier subthread on v5 and to the new v6 patch.)
Bertrand Marquis writes ("Re: [PATCH v5 10/11] arm/libxl: Emulated PCI device tree node in libxl"):
Quoted 1 line
Now you suggest to add a new field
arm_vpciinlibxl__domain_create_state.Hi. I was handwaving, hence "probably" :-). I hadn't actually looked at the existing code to see precisely how it would fit.
Quoted 3 lines
Once we have done that I will need to access this structure to know if I need to add the DT part and somehow to give it a value depending something which for now would the number of pcidevs as there will be no user parameter anymore.
Right.
I looked at
libxl_arm.cagain:It seems that the main entrypoint to all this is
libxl__prepare_dtb, and it is that function you want to do new stuff. That getslibxl_domain_build_info(which is specified by the IDL and comes from outside libxl, subject to libxl's default-filling machinery) andlibxl__domain_build_state(which is the general state struct).
Quoted 8 lines
The information you need is is
libxl_domain_create_info.libxl__domain_config_setdefaultalready arranges to setc_info->passthroughbased on the number of PCI PT devices (search forneed_ptinlibxl_create.c).That is, as I understand it on ARM vpci should be enabled if passthrough is enabled and not otherwise. That is precisely what the variable
c_info->passthroughis.
On Arm, c_info->passthrough is also set when assigning platform devives (e.g. a non-PCI network card). At least for now, we don't want to create a node for vCPI in the Device-Tree because we don't enable the emulation. So...
Quoted 22 lines
There is a slight issue because of the distinction between
create_infoandbuild_infoanddomain_config(and, the corresponding_state) structs. Currently the DT code ony getsb_info, not the wholelibxl_domain_config. These distinctions largely historical nowadays. Certainly there is no reason not to pass a pointer to the wholelibxl_domain_config, rather than justlibxl_domain_build_info, intolibxl__arch_domain_init_hw_description.So I think the right approach for this looks something like this:
1. Change
libxl__arch_domain_init_hw_descriptionto take libxl_domain_config* rather than libxl_domain_build_info*.libxl_domain_configcontainslibxl_domain_build_infoso this is easy.If you put in a convenience alias variable for the libxl_domain_build_info* you can avoid extra typing in the function body. (If you call the convenience alias
infoyou won't need to change the body at all, but maybeinfoisn't the best name so you could rename it tob_infomaybe; up to you.)
Quoted 5 lines
2. Make the same change to
libxl__prepare_dtb.3. Now you can use
d_config->c_info.passthroughto gate the addition of the additional stuff to the DT. Ie, that is a respin of this patch 3/3.
... we will need to check d_config->num_pcidevs for the time being.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]
Hi guys,
Quoted 61 lines · Julien Grall
Hi Ian,
Quoted 23 lines · Ian Jackson
(Replying to both the earlier subthread on v5 and to the new v6 patch.)
Bertrand Marquis writes ("Re: [PATCH v5 10/11] arm/libxl: Emulated PCI device tree node in libxl"):
Quoted 1 line
Now you suggest to add a new field
arm_vpciinlibxl__domain_create_state.Hi. I was handwaving, hence "probably" :-). I hadn't actually looked at the existing code to see precisely how it would fit.
Quoted 3 lines
Once we have done that I will need to access this structure to know if I need to add the DT part and somehow to give it a value depending something which for now would the number of pcidevs as there will be no user parameter anymore.
Right.
I looked at
libxl_arm.cagain:It seems that the main entrypoint to all this is
libxl__prepare_dtb, and it is that function you want to do new stuff. That getslibxl_domain_build_info(which is specified by the IDL and comes from outside libxl, subject to libxl's default-filling machinery) andlibxl__domain_build_state(which is the general state struct).Quoted 8 lines
The information you need is is
libxl_domain_create_info.libxl__domain_config_setdefaultalready arranges to setc_info->passthroughbased on the number of PCI PT devices (search forneed_ptinlibxl_create.c).That is, as I understand it on ARM vpci should be enabled if passthrough is enabled and not otherwise. That is precisely what the variable
c_info->passthroughis.On Arm,
c_info->passthroughis also set when assigning platform devives (e.g. a non-PCI network card). At least for now, we don't want to create a node for vCPI in the Device-Tree because we don't enable the emulation. So...Quoted 24 lines
There is a slight issue because of the distinction between
create_infoandbuild_infoanddomain_config(and, the corresponding_state) structs. Currently the DT code ony getsb_info, not the whole libxl_domain_config. These distinctions largely historical nowadays. Certainly there is no reason not to pass a pointer to the wholelibxl_domain_config, rather than justlibxl_domain_build_info, intolibxl__arch_domain_init_hw_description.So I think the right approach for this looks something like this:
1. Change
libxl__arch_domain_init_hw_descriptionto take libxl_domain_config* rather than libxl_domain_build_info*.libxl_domain_configcontainslibxl_domain_build_infoso this is easy.If you put in a convenience alias variable for the libxl_domain_build_info* you can avoid extra typing in the function body. (If you call the convenience alias
infoyou won't need to change the body at all, but maybeinfoisn't the best name so you could rename it tob_infomaybe; up to you.)2. Make the same change to
libxl__prepare_dtb.
Quoted 8 lines
Quoted 3 lines
3. Now you can use
d_config->c_info.passthroughto gate the addition of the additional stuff to the DT. Ie, that is a respin of this patch 3/3.... we will need to check
d_config->num_pcidevsfor the time being.Cheers,
Thanks Julien for a good catch.
Do you agree on the following approach:
1. Modify argument of libxl__arch_domain_init_hw_description to libxl_domain_config (patch 1)
2. Modify argument of libxl__prepare_dtb to libxl_domain_config (patch 2)
3. Remove arch_arm.vpci completely and in libxl__prepare_dtb add a check (patch 3):
if (d_config->num_pcidevs)
FDT( make_vpci_node(gc, fdt, ainfo, dom) );
+ make_vpci_node implementation
Does it sound ok for you?
Cheers,
Michal
Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]
Hi Michal,
Quoted 9 lines · Michal Orzel
Do you agree on the following approach:
1. Modify argument oflibxl__arch_domain_init_hw_descriptiontolibxl_domain_config(patch 1)
2. Modify argument oflibxl__prepare_dtbtolibxl_domain_config(patch 2)
3. Remove arch_arm.vpci completely and inlibxl__prepare_dtbadd a check (patch 3):
if (d_config->num_pcidevs)FDT( make_vpci_node(gc, fdt, ainfo, dom) );+
make_vpci_nodeimplementationDoes it sound ok for you?
This sounds ok to me.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]
In reply to Julien GrallJulien Grall writes ("Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]"):
Quoted 1 line · Ian Jackson
...
Quoted 8 lines
Quoted 3 lines
That is, as I understand it on ARM vpci should be enabled if passthrough is enabled and not otherwise. That is precisely what the variable
c_info->passthroughis.On Arm,
c_info->passthroughis also set when assigning platform devives (e.g. a non-PCI network card). At least for now, we don't want to create a node for vCPI in the Device-Tree because we don't enable the emulation. So...
Oh.
Quoted 5 lines
Quoted 3 lines
3. Now you can use
d_config->c_info.passthroughto gate the addition of the additional stuff to the DT. Ie, that is a respin of this patch 3/3.... we will need to check
d_config->num_pcidevsfor the time being.
OK.
Can you leave a comment somewhere (near where c_info.passthrough is set) pointing to this use of num_pcidevs ? That might save someone some future confusion.
Thanks,
Ian.
Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]
Hi,
Quoted 18 lines · Ian Jackson
Julien Grall writes ("Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]"):
Quoted 1 line · Ian Jackson
...
Quoted 8 lines
Quoted 3 lines
That is, as I understand it on ARM vpci should be enabled if passthrough is enabled and not otherwise. That is precisely what the variable
c_info->passthroughis.On Arm,
c_info->passthroughis also set when assigning platform devives (e.g. a non-PCI network card). At least for now, we don't want to create a node for vCPI in the Device-Tree because we don't enable the emulation. So...Oh.
Quoted 4 lines
Quoted 3 lines
3. Now you can use
d_config->c_info.passthroughto gate the addition of the additional stuff to the DT. Ie, that is a respin of this patch 3/3.
Quoted 8 lines
Quoted 1 line
... we will need to check
d_config->num_pcidevsfor the time being.OK.
Can you leave a comment somewhere (near where c_info.passthrough is set) pointing to this use of
num_pcidevs? That might save someone some future confusion.
Here, c_info->passthrough is set to enabled if either d_config->num_pcidevs or d_config->num_dtdevs is set. Do you think we need to add there additional comment? If so can you please help with what should I write there?
BTW. None of the patch I'm preparing with regards to this discussion modifies libxl_create where c_info.passthrough i set. Do you still want me to add some comment there?
Quoted 3 lines
Thanks,
Ian.
Cheers,
Michal
Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]
Quoted 25 lines · Michal Orzel
Hi,
Quoted 22 lines · Ian Jackson
Julien Grall writes ("Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]"):
Quoted 1 line · Ian Jackson
...
Quoted 8 lines
Quoted 3 lines
That is, as I understand it on ARM vpci should be enabled if passthrough is enabled and not otherwise. That is precisely what the variable
c_info->passthroughis.On Arm,
c_info->passthroughis also set when assigning platform devives (e.g. a non-PCI network card). At least for now, we don't want to create a node for vCPI in the Device-Tree because we don't enable the emulation. So...Oh.
Quoted 5 lines
Quoted 3 lines
3. Now you can use
d_config->c_info.passthroughto gate the addition of the additional stuff to the DT. Ie, that is a respin of this patch 3/3.... we will need to check
d_config->num_pcidevsfor the time being.OK.
Quoted 8 lines
Quoted 4 lines
Can you leave a comment somewhere (near where c_info.passthrough is set) pointing to this use of
num_pcidevs? That might save someone some future confusion.Here,
c_info->passthroughis set to enabled if eitherd_config->num_pcidevsord_config->num_dtdevsis set. Do you think we need to add there additional comment? If so can you please help with what should I write there?
I forgot to add a link:
https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libs/light/libxl_create.c;h=6ebb2bfc768d060fb898619be907fc973375cce5;hb=HEAD#l1099
Quoted 8 lines
BTW. None of the patch I'm preparing with regards to this discussion modifies
libxl_createwhere c_info.passthrough i set. Do you still want me to add some comment there?Quoted 3 lines
Thanks,
Ian.Cheers,
Michal
Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]
In reply to Michal OrzelMichal Orzel writes ("Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]"):
Quoted 11 lines · Ian Jackson
Quoted 3 lines
Can you leave a comment somewhere (near where c_info.passthrough is set) pointing to this use of
num_pcidevs? That might save someone some future confusion.Here,
c_info->passthroughis set to enabled if eitherd_config->num_pcidevsord_config->num_dtdevsis set. Do you think we need to add there additional comment? If so can you please help with what should I write there?BTW. None of the patch I'm preparing with regards to this discussion modifies
libxl_createwhere c_info.passthrough i set. Do you still want me to add some comment there?
Yes, I think so. I won't insisting on it if you feel it doesn't make sense.
Maybe something like
// NB, on ARM, libxl__arch_blah directly examines num_pcidevs to // decide whether to enable vpci, rather than using c_info->passthrough. // This will be insufficient if and when ARM does PCI hotplug.
?
Ian.
Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]
Quoted 13 lines · Ian Jackson
Michal Orzel writes ("Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]"):
Quoted 11 lines · Ian Jackson
Quoted 3 lines
Can you leave a comment somewhere (near where c_info.passthrough is set) pointing to this use of
num_pcidevs? That might save someone some future confusion.Here,
c_info->passthroughis set to enabled if eitherd_config->num_pcidevsord_config->num_dtdevsis set. Do you think we need to add there additional comment? If so can you please help with what should I write there?BTW. None of the patch I'm preparing with regards to this discussion modifies
libxl_createwhere c_info.passthrough i set. Do you still want me to add some comment there?
Quoted 9 lines
Yes, I think so. I won't insisting on it if you feel it doesn't make sense.
Maybe something like
// NB, on ARM,
libxl__arch_blahdirectly examinesnum_pcidevsto // decide whether to enable vpci, rather than usingc_info->passthrough. // This will be insufficient if and when ARM does PCI hotplug.
Well we are not enabling vpci. We are creating a DT node for it. So either I will write:
/*
* Note: libxl_arm directly examines num_pcidevs to decide whether
* to create a vPCI DT node, rather than using c_info->passthrough.
* This will be insufficient if and when ARM does PCI hotplug. */
or I will not add any comment (it can be add in the future when "enabling" vpci). @Julien?
Quoted 4 lines
?
Ian.
Cheers,
Michal
Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]
Hi Michal,
Quoted 33 lines · Michal Orzel
Quoted 13 lines · Ian Jackson
Michal Orzel writes ("Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]"):
Quoted 11 lines · Ian Jackson
Quoted 3 lines
Can you leave a comment somewhere (near where c_info.passthrough is set) pointing to this use of
num_pcidevs? That might save someone some future confusion.Here,
c_info->passthroughis set to enabled if eitherd_config->num_pcidevsord_config->num_dtdevsis set. Do you think we need to add there additional comment? If so can you please help with what should I write there?BTW. None of the patch I'm preparing with regards to this discussion modifies
libxl_createwhere c_info.passthrough i set. Do you still want me to add some comment there?Quoted 9 lines
Yes, I think so. I won't insisting on it if you feel it doesn't make sense.
Maybe something like
// NB, on ARM, libxl__arch_blah directly examines num_pcidevs to // decide whether to enable vpci, rather than using c_info->passthrough. // This will be insufficient if and when ARM does PCI hotplug.Well we are not enabling vpci. We are creating a DT node for it. So either I will write:
/*
* Note:libxl_armdirectly examinesnum_pcidevsto decide whether
* to create a vPCI DT node, rather than usingc_info->passthrough.
* This will be insufficient if and when ARM does PCI hotplug. */
Quoted 2 lines
or I will not add any comment (it can be add in the future when "enabling" vpci). @Julien?
I would prefer if we had a comment. Your proposal makes more sense as we only create the DT.
Long term, I would expect a similar check to be necessary to set the vCPI flag at the domain creation. So it would be best to introduce an internal field 'vpci' to avoid duplicating that check. (Note I am not requesting this change for Xen 4.16).
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]
Julien Grall writes ("Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]"):
Quoted 4 lines
Long term, I would expect a similar check to be necessary to set the vCPI flag at the domain creation. So it would be best to introduce an internal field 'vpci' to avoid duplicating that check. (Note I am not requesting this change for Xen 4.16).
Yes, I agree with all of that.
Ian.
Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]
In reply to Michal OrzelMichal Orzel writes ("Re: [PATCH v6 3/3] arm/libxl: Emulated PCI device tree node in libxl [and 1 more messages]"):
Quoted 7 lines · Ian Jackson
Quoted 5 lines
Maybe something like
// NB, on ARM,
libxl__arch_blahdirectly examinesnum_pcidevsto // decide whether to enable vpci, rather than usingc_info->passthrough. // This will be insufficient if and when ARM does PCI hotplug.
Quoted 7 lines
Well we are not enabling vpci. We are creating a DT node for it. So either I will write:
/*
* Note:libxl_armdirectly examinesnum_pcidevsto decide whether
* to create a vPCI DT node, rather than usingc_info->passthrough.
* This will be insufficient if and when ARM does PCI hotplug. */
That sounds good to me. Thank you for correcting me :-).
Ian.