swiotlb-xen: remaining fixes and adjustments
Subsystems (5)
v2 cover swiotlb-xen: remaining fixes and adjustments
The primary intention really was the last patch, there you go (on top of what is already in xen/tip.git for-linus-5.15) ...
1: swiotlb-xen: ensure to issue well-formed XENMEM_exchange requests 2: PCI: only build xen-pcifront in PV-enabled environments 3: xen/pci-swiotlb: reduce visibility of symbols
4: swiotlb-xen: this is PV-only on x86
Jan
PATCH v2 1/4 swiotlb-xen: ensure to issue well-formed XENMEM_exchange requests
While the hypervisor hasn't been enforcing this, we would still better avoid issuing requests with GFNs not aligned to the requested order. Instead of altering the value also in the call to panic(), drop it there for being static and hence easy to determine without being part of the panic message.
---
I question how useful it is to wrap "bytes" in PAGE_ALIGN(), when it is a multiple of a segment's size anyway (or at least was supposed to be, prior to "swiotlb-xen: maintain slab count properly"). But that's perhaps yet another separate patch.
---
v2: Drop logging of alignment. Wrap lines.
drivers/xen/swiotlb-xen.c +4 -3
@@ -230,10 +230,11 @@ retry:/* * Get IO TLB memory from any location. */ - start =memblock_alloc (PAGE_ALIGN (bytes),PAGE_SIZE ); + start =memblock_alloc (PAGE_ALIGN (bytes), +IO_TLB_SEGSIZE <<IO_TLB_SHIFT );if (!start) -panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , - __func__,PAGE_ALIGN (bytes),PAGE_SIZE ); +panic ("%s: Failed to allocate %lu bytes\n" , + __func__,PAGE_ALIGN (bytes));/* * And replace that memory with pages under 4GB.
Re: [PATCH v2 1/4] swiotlb-xen: ensure to issue well-formed XENMEM_exchange requests
Quoted 7 lines · Jan Beulich
While the hypervisor hasn't been enforcing this, we would still better avoid issuing requests with GFNs not aligned to the requested order. Instead of altering the value also in the call to
panic(), drop it there for being static and hence easy to determine without being part of the panic message.Signed-off-by Jan Beulich <[email protected]>
Quoted 16 lines
---
I question how useful it is to wrap "bytes" inPAGE_ALIGN(), when it is a multiple of a segment's size anyway (or at least was supposed to be, prior to "swiotlb-xen: maintain slab count properly"). But that's perhaps yet another separate patch.
---
v2: Drop logging of alignment. Wrap lines.drivers/xen/swiotlb-xen.c +0
-1@@ -230,10 +230,11 @@ retry:/* * Get IO TLB memory from any location. */ - start =memblock_alloc (PAGE_ALIGN (bytes),PAGE_SIZE );
drivers/xen/swiotlb-xen.c retry: · line 240
Quoted 10 lines
drivers/xen/swiotlb-xen.c +4
-2+ start =memblock_alloc (PAGE_ALIGN (bytes), +IO_TLB_SEGSIZE <<IO_TLB_SHIFT );if (!start) -panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , - __func__,PAGE_ALIGN (bytes),PAGE_SIZE ); +panic ("%s: Failed to allocate %lu bytes\n" , + __func__,PAGE_ALIGN (bytes));/* * And replace that memory with pages under 4GB.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH v2 2/4 PCI: only build xen-pcifront in PV-enabled environments
In reply to Jan BeulichThe driver's module init function, pcifront_init(), invokes xen_pv_domain() first thing. That construct produces constant "false" when !CONFIG_XEN_PV. Hence there's no point building the driver in non-PV configurations.
Drop the (now implicit and generally wrong) X86 dependency: At present, XEN_PV con only be set when X86 is also enabled. In general an architecture supporting Xen PV (and PCI) would want to have this driver built.
---
v2: Title and description redone.
drivers/pci/Kconfig +1 -1
@@ -110,7 +110,7 @@ config PCI_PF_STUB config XEN_PCIDEV_FRONTEND tristate "Xen PCI Frontend" - depends on X86 && XEN + depends on XEN_PV select PCI_XEN select XEN_XENBUS_FRONTEND default y
Re: [PATCH v2 2/4] PCI: only build xen-pcifront in PV-enabled environments
s/only/Only/ in subject
Quoted 4 lines · Jan Beulich
The driver's module init function,
pcifront_init(), invokesxen_pv_domain()first thing. That construct produces constant "false" when !CONFIG_XEN_PV. Hence there's no point building the driver in non-PV configurations.
Thanks for these bread crumbs. xen_domain_type is set to XEN_PV_DOMAIN only by xen_start_kernel() in enlighten_pv.c, which is only built when CONFIG_XEN_PV=y, so even I can verify this :)
Quoted 4 lines
Drop the (now implicit and generally wrong) X86 dependency: At present,
XEN_PVcon only be set when X86 is also enabled. In general an architecture supporting Xen PV (and PCI) would want to have this driver built.
s/con only/can only/
Quoted 2 lines
Signed-off-by Jan Beulich <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>
Quoted 15 lines
---
v2: Title and description redone.drivers/pci/Kconfig +1
-1@@ -110,7 +110,7 @@ config PCI_PF_STUB config XEN_PCIDEV_FRONTEND tristate "Xen PCI Frontend" - depends on X86 && XEN + depends on XEN_PV select PCI_XEN select XEN_XENBUS_FRONTEND default y
PATCH v2 3/4 xen/pci-swiotlb: reduce visibility of symbols
In reply to Jan Beulichxen_swiotlb and pci_xen_swiotlb_init() are only used within the file defining them, so make them static and remove the stubs. Otoh pci_xen_swiotlb_detect() has a use (as function pointer) from the main pci-swiotlb.c file - convert its stub to a #define to NULL.
arch/x86/include/asm/xen/swiotlb-xen.h +1 -5
@@ -3,14 +3,10 @@#define _ASM_X86_SWIOTLB_XEN_H#ifdef CONFIG_SWIOTLB_XEN -extern int xen_swiotlb;extern int __init pci_xen_swiotlb_detect (void ); -extern void __init pci_xen_swiotlb_init (void );extern int pci_xen_swiotlb_init_late (void );#else -#define xen_swiotlb (0) -static inline int __init pci_xen_swiotlb_detect (void ) {return 0 ; } -static inline void __init pci_xen_swiotlb_init (void ) { } +#define pci_xen_swiotlb_detect NULLstatic inline int pci_xen_swiotlb_init_late (void ) {return -ENXIO ; }#endif
arch/x86/xen/pci-swiotlb-xen.c +2 -2
@@ -18,7 +18,7 @@#endif #include <linux/export.h> -int xen_swiotlb__read_mostly ; +static int xen_swiotlb__read_mostly ;/* * pci_xen_swiotlb_detect - set xen_swiotlb to 1 if necessary
@@ -56,7 +56,7 @@ int __init pci_xen_swiotlb_detect(void)return xen_swiotlb; } -void __init pci_xen_swiotlb_init (void ) +static void __init pci_xen_swiotlb_init (void ) {if (xen_swiotlb) {xen_swiotlb_init_early ();
PATCH v2 4/4 swiotlb-xen: this is PV-only on x86
In reply to Jan BeulichThe code is unreachable for HVM or PVH, and it also makes little sense in auto-translated environments. On Arm, with xen_{create,destroy}_contiguous_region() both being stubs, I have a hard time seeing what good the Xen specific variant does - the generic one ought to be fine for all purposes there. Still Arm code explicitly references symbols here, so the code will continue to be included there.
Instead of making PCI_XEN's "select" conditional, simply drop it - SWIOTLB_XEN will be available unconditionally in the PV case anyway, and is - as explained above - dead code in non-PV environments.
This in turn allows dropping the stubs for xen_{create,destroy}_contiguous_region(), the former of which was broken anyway - it failed to set the DMA handle output.
arch/x86/Kconfig +0 -1
@@ -2605,7 +2605,6 @@ config PCI_OLPC config PCI_XEN def_bool y depends on PCI && XEN - select SWIOTLB_XEN config MMCONF_FAM10H def_bool y
drivers/xen/Kconfig +1 -0
@@ -177,6 +177,7 @@ config XEN_GRANT_DMA_ALLOC config SWIOTLB_XEN def_bool y + depends on XEN_PV || ARM || ARM64 select DMA_OPS select SWIOTLB
include/xen/xen-ops.h +0 -12
@@ -46,19 +46,7 @@ extern unsigned long *xen_contiguous_bitint xen_create_contiguous_region (phys_addr_t pstart,unsigned int order,unsigned int address_bits,dma_addr_t *dma_handle); -void xen_destroy_contiguous_region (phys_addr_t pstart,unsigned int order); -#else -static inline int xen_create_contiguous_region (phys_addr_t pstart, -unsigned int order, -unsigned int address_bits, -dma_addr_t *dma_handle) -{ -return 0 ; -} - -static inline void xen_destroy_contiguous_region (phys_addr_t pstart, -unsigned int order) { }#endif #if defined(CONFIG_XEN_PV )
Juergen Gross
maintainerQuoted 7 lines · Jan Beulich
The primary intention really was the last patch, there you go (on top of what is already in xen/tip.git for-linus-5.15) ...
1: swiotlb-xen: ensure to issue well-formed
XENMEM_exchangerequests 2: PCI: only build xen-pcifront in PV-enabled environments 3: xen/pci-swiotlb: reduce visibility of symbols
4: swiotlb-xen: this is PV-only on x86
All 4 patches pushed to xen/tip.git for-linus-5.15b
Juergen
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu