[Xen-devel] [PATCH for-4.11] x86/dom0: add extra RAM regions as RESERVED for PVH memory map

2018-05-03 Thread Roger Pau Monne
When running as PVH Dom0 the native memory map is used in order to craft a tailored memory map for Dom0 taking into account it's memory limit. Dom0 memory is always going to be smaller than the total amount of memory present on the host, so in order to prevent Dom0 from relocating PCI BARs over RA

[Xen-devel] [PATCH v2] x86/dom0: add extra RAM regions as UNUSABLE for PVH memory map

2018-05-03 Thread Roger Pau Monne
When running as PVH Dom0 the native memory map is used in order to craft a tailored memory map for Dom0 taking into account it's memory limit. Dom0 memory is always going to be smaller than the total amount of memory present on the host, so in order to prevent Dom0 from relocating PCI BARs over RA

[Xen-devel] [PATCH 2/3] xen/store: do not store local values in xen_start_info

2018-05-03 Thread Roger Pau Monne
There's no need to store the xenstore page or event channel in xen_start_info if they are locally initialized. This also fixes PVH local xenstore initialization due to the lack of xen_start_info in that case. Signed-off-by: Boris Ostrovsky Signed-off-by: Roger Pau Monné --- Cc: Boris Ostrovsky

[Xen-devel] [PATCH 1/3] xen/pvh: enable and set default MTRR type

2018-05-03 Thread Roger Pau Monne
On PVH MTRR is not initialized by the firmware (because there's no firmware), so the kernel is started with MTRR disabled which means all memory accesses are UC. So far there have been no issues (ie: slowdowns) caused by this because PVH only supported DomU mode without passed-through devices, so

[Xen-devel] [PATCH 3/3] xen: share start flags between PV and PVH

2018-05-03 Thread Roger Pau Monne
Use a global variable to store the start flags for both PV and PVH. This allows the xen_initial_domain macro to work properly on PVH. Signed-off-by: Boris Ostrovsky Signed-off-by: Roger Pau Monné --- Cc: Boris Ostrovsky Cc: Juergen Gross Cc: xen-devel@lists.xenproject.org --- arch/x86/xen/enl

[Xen-devel] [PATCH v3] x86/dom0: add extra RAM regions as UNUSABLE for PVH memory map

2018-05-03 Thread Roger Pau Monne
When running as PVH Dom0 the native memory map is used in order to craft a tailored memory map for Dom0 taking into account it's memory limit. Dom0 memory is always going to be smaller than the total amount of memory present on the host, so in order to prevent Dom0 from relocating PCI BARs over RA

[Xen-devel] [PATCH 0/2] vpci/msi: fix updating already bound MSI interrupts

2018-05-08 Thread Roger Pau Monne
o fix this incorrect behavior introduce a new update helper that should be used to update the bindings of an already enabled group of MSI interrupts. Thanks, Roger. Roger Pau Monne (2): vpci/msi: split code to bind pirq vpci/msi: fix update of bound MSI interrupts xen/arch/x86/hvm/vmsi.c

[Xen-devel] [PATCH 2/2] vpci/msi: fix update of bound MSI interrupts

2018-05-08 Thread Roger Pau Monne
Current update process of already bound MSI interrupts is wrong because unmap_domain_pirq calls pci_disable_msi, which disables MSI interrupts on the device. On the other hand map_domain_pirq doesn't enable MSI, so the current update process of already enabled MSI entries is wrong because MSI contr

[Xen-devel] [PATCH 1/2] vpci/msi: split code to bind pirq

2018-05-08 Thread Roger Pau Monne
And put it in a separate update function. This is required in order to improve binding of MSI PIRQs when using vPCI. No functional change. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/hvm/vmsi.c | 73 + 1 file ch

[Xen-devel] [PATCH] pci: treat class 0 devices as endpoints

2018-05-08 Thread Roger Pau Monne
Class 0 devices are legacy pre PCI 2.0 devices that didn't have a class code. Treat them as endpoints, so that they can be handled by the IOMMU and properly passed-through to the hardware domain. Such device has been seen on a Super Micro server, lspci -vv reports: 00:13.0 Non-VGA unclassified de

[Xen-devel] [PATCH for-4.11] libacpi: fixes for iasl >= 20180427

2018-05-09 Thread Roger Pau Monne
New versions of iasl have introduced improved C file generation, as reported in the changelog: iASL: Enhanced the -tc option (which creates an AML hex file in C, suitable for import into a firmware project): 1) Create a unique name for the table, to simplify use of multiple SSDTs. 2) Add a pro

[Xen-devel] [PATCH v2 3/3] xen: share start flags between PV and PVH

2018-05-09 Thread Roger Pau Monne
Use a global variable to store the start flags for both PV and PVH. This allows the xen_initial_domain macro to work properly on PVH. Note that ARM is also switched to use the new variable. Signed-off-by: Boris Ostrovsky Signed-off-by: Roger Pau Monné --- Cc: Boris Ostrovsky Cc: Juergen Gross

[Xen-devel] [PATCH v2 2/3] xen/store: do not store local values in xen_start_info

2018-05-09 Thread Roger Pau Monne
There's no need to store the xenstore page or event channel in xen_start_info if they are locally initialized. This also fixes PVH local xenstore initialization due to the lack of xen_start_info in that case. Signed-off-by: Boris Ostrovsky Signed-off-by: Roger Pau Monné --- Cc: Boris Ostrovsky

[Xen-devel] [PATCH v2 1/3] xen/pvh: enable and set default MTRR type

2018-05-09 Thread Roger Pau Monne
On PVH MTRR is not initialized by the firmware (because there's no firmware), so the kernel is started with MTRR disabled which means all memory accesses are UC. So far there have been no issues (ie: slowdowns) caused by this because PVH only supported DomU mode without passed-through devices, so

[Xen-devel] [PATCH RFC] libxl: set 1GB MMIO hole for PVH

2018-05-09 Thread Roger Pau Monne
This prevents page-shattering, by being able to populate the RAM regions below 4GB using 1GB pages, provided the guest memory size is set to a multiple of a GB. Note that there are some special and ACPI pages in the MMIO hole that will be populated using smaller order pages, but those shouldn't be

[Xen-devel] [PATCH] vhpet: check that the set interrupt route is valid

2018-05-10 Thread Roger Pau Monne
The value written by the guest must be valid according to the mask provided in the interrupt routing capabilities register. If the interrupt is not valid set it to the first valid IRQ in the capabilities field if the timer is enabled, else just clear the field. Also refuse to start any timer that

[Xen-devel] [PATCH 4/5] libxc/pvh: set default MTRR type to write-back

2018-05-10 Thread Roger Pau Monne
And enable MTRR. This allows to provide a sane initial MTRR state for PVH DomUs. This will have to be expanded when pci-passthrough support is added to PVH guests, so that MMIO regions of devices are set as UC. Note that initial MTRR setup is done by hvmloader for HVM guests, that's not used by PV

[Xen-devel] [PATCH 1/5] hvm/mtrr: add emacs local variables block with formatting info

2018-05-10 Thread Roger Pau Monne
Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/hvm/mtrr.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/xen/arch/x86/hvm/mtrr.c b/xen/arch/x86/hvm/mtrr.c index b721c6330f..b3c08c3977 100644 --- a/xen/arch/x86/hvm/mtrr.c +++ b/xen/arch/x86

[Xen-devel] [PATCH 2/5] hvm/mtrr: use the hardware number of variable ranges for Dom0

2018-05-10 Thread Roger Pau Monne
Expand the size of the variable ranges array to match the size of the underlying hardware, this is a preparatory change for copying the hardware MTRR state for Dom0. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/hvm/mtrr.c | 13 +++-- 1 file chan

[Xen-devel] [PATCH 3/5] hvm/mtrr: copy hardware state for Dom0

2018-05-10 Thread Roger Pau Monne
Copy the state found on the hardware when creating a PVH Dom0. Since the memory map provided to a PVH Dom0 is based on the native one using the same set of MTRR ranges should provide Dom0 with a sane MTRR state without having to manually build it in Xen. Signed-off-by: Roger Pau Monné --- Cc: Jan

[Xen-devel] [PATCH 0/5] PVH MTRR initial state

2018-05-10 Thread Roger Pau Monne
, Roger. Roger Pau Monne (5): hvm/mtrr: add emacs local variables block with formatting info hvm/mtrr: use the hardware number of variable ranges for Dom0 hvm/mtrr: copy hardware state for Dom0 libxc/pvh: set default MTRR type to write-back docs/pvh: document initial MTRR state docs/misc

[Xen-devel] [PATCH 5/5] docs/pvh: document initial MTRR state

2018-05-10 Thread Roger Pau Monne
Provided to both Dom0 and DomUs. Signed-off-by: Roger Pau Monné --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu --- docs/misc/pvh.markdown | 15 +++ 1 file ch

[Xen-devel] [PATCH v2 3/3] vpci/msi: fix update of bound MSI interrupts

2018-05-15 Thread Roger Pau Monne
Current update process of already bound MSI interrupts is wrong because unmap_domain_pirq calls pci_disable_msi, which disables MSI interrupts on the device. On the other hand map_domain_pirq doesn't enable MSI, so the current update process of already enabled MSI entries is wrong because MSI contr

[Xen-devel] [PATCH v2 2/3] vpci/msi: split code to bind pirq

2018-05-15 Thread Roger Pau Monne
And put it in a separate update function. This is required in order to improve binding of MSI PIRQs when using vPCI. No functional change. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/hvm/vmsi.c | 73 + 1 file ch

[Xen-devel] [PATCH v2 1/3] vpci/msi: fix unbind loop

2018-05-15 Thread Roger Pau Monne
The current unbind loop on failure in vpci_msi_enable is wrong and will only work correctly if the initial pirq is 0. Fix this by adding a proper bound. Reported-by: Jan Beulich Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/hvm/vmsi.c | 2 +- 1 file cha

[Xen-devel] [PATCH v2 0/3] vpci/msi: fix updating already bound MSI interrupts

2018-05-15 Thread Roger Pau Monne
o fix this incorrect behavior introduce a new update helper that should be used to update the bindings of an already enabled group of MSI interrupts. Thanks, Roger. Roger Pau Monne (3): vpci/msi: fix unbind loop vpci/msi: split code to bind pirq vpci/msi: fix update of bound MSI interrupts xen

[Xen-devel] [PATCH v2 4/6] hvm/mtrr: copy hardware state for Dom0

2018-05-15 Thread Roger Pau Monne
Copy the state found on the hardware when creating a PVH Dom0. Since the memory map provided to a PVH Dom0 is based on the native one using the same set of MTRR ranges should provide Dom0 with a sane MTRR state without having to manually build it in Xen. Signed-off-by: Roger Pau Monné --- Cc: Jan

[Xen-devel] [PATCH v2 2/6] mtrr: introduce mask to get VCNT from MTRRcap MSR

2018-05-15 Thread Roger Pau Monne
No functional change. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/cpu/mtrr/main.c| 2 +- xen/arch/x86/hvm/mtrr.c | 6 +++--- xen/include/asm-x86/msr-index.h | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86

[Xen-devel] [PATCH v2 0/6] PVH MTRR initial stat

2018-05-15 Thread Roger Pau Monne
, Roger. Roger Pau Monne (6): hvm/mtrr: add emacs local variables block with formatting info mtrr: introduce mask to get VCNT from MTRRcap MSR hvm/mtrr: use the hardware number of variable ranges for Dom0 hvm/mtrr: copy hardware state for Dom0 libxc/pvh: set default MTRR type to write-back

[Xen-devel] [PATCH v2 1/6] hvm/mtrr: add emacs local variables block with formatting info

2018-05-15 Thread Roger Pau Monne
Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/hvm/mtrr.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/xen/arch/x86/hvm/mtrr.c b/xen/arch/x86/hvm/mtrr.c index b721c6330f..b3c08c3977 100644 --- a/xen/arch/x86/hvm/mtrr.c +++ b/xen/arch/x86

[Xen-devel] [PATCH v2 3/6] hvm/mtrr: use the hardware number of variable ranges for Dom0

2018-05-15 Thread Roger Pau Monne
Expand the size of the variable ranges array to match the size of the underlying hardware, this is a preparatory change for copying the hardware MTRR state for Dom0. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- Changes since v1: - Fix hvm_msr_{read,write}_intercept(

[Xen-devel] [PATCH v2 5/6] libxc/pvh: set default MTRR type to write-back

2018-05-15 Thread Roger Pau Monne
And enable MTRR. This allows to provide a sane initial MTRR state for PVH DomUs. This will have to be expanded when pci-passthrough support is added to PVH guests, so that MMIO regions of devices are set as UC. Note that initial MTRR setup is done by hvmloader for HVM guests, that's not used by PV

[Xen-devel] [PATCH v2 6/6] docs/pvh: document initial MTRR state

2018-05-15 Thread Roger Pau Monne
Provided to both Dom0 and DomUs. Signed-off-by: Roger Pau Monné --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu --- Changes since v1: - Add an extra paragraph to clarify

[Xen-devel] [PATCH v2] xl: remove apic option for PVH guests

2018-03-14 Thread Roger Pau Monne
XSA-256 forces the local APIC to always be enabled for PVH guests, so ignore any apic option for PVH guests. Update the documentation accordingly. Signed-off-by: Roger Pau Monné --- Cc: Ian Jackson Cc: Wei Liu Cc: Andrew Cooper Cc: George Dunlap Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc:

[Xen-devel] [PATCH v9 03/11] x86/physdev: enable PHYSDEVOP_pci_mmcfg_reserved for PVH Dom0

2018-03-14 Thread Roger Pau Monne
So that MMCFG regions not present in the MCFG ACPI table can be added at run time by the hardware domain. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich Reviewed-by: Paul Durrant --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Paul Durrant --- Changes since v7: - Add newline in hvm_physd

[Xen-devel] [PATCH v9 11/11] vpci/msix: add MSI-X handlers

2018-03-14 Thread Roger Pau Monne
Add handlers for accesses to the MSI-X message control field on the PCI configuration space, and traps for accesses to the memory region that contains the MSI-X table and PBA. This traps detect attempts from the guest to configure MSI-X interrupts and properly sets them up. Note that accesses to t

[Xen-devel] [PATCH v9 07/11] vpci/bars: add handlers to map the BARs

2018-03-14 Thread Roger Pau Monne
Introduce a set of handlers that trap accesses to the PCI BARs and the command register, in order to snoop BAR sizing and BAR relocation. The command handler is used to detect changes to bit 2 (response to memory space accesses), and maps/unmaps the BARs of the device into the guest p2m. A rangese

[Xen-devel] [PATCH v9 09/11] vpci/msi: add MSI handlers

2018-03-14 Thread Roger Pau Monne
Add handlers for the MSI control, address, data and mask fields in order to detect accesses to them and setup the interrupts as requested by the guest. Note that the pending register is not trapped, and the guest can freely read/write to it. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc

[Xen-devel] [PATCH v9 01/11] vpci: introduce basic handlers to trap accesses to the PCI config space

2018-03-14 Thread Roger Pau Monne
This functionality is going to reside in vpci.c (and the corresponding vpci.h header), and should be arch-agnostic. The handlers introduced in this patch setup the basic functionality required in order to trap accesses to the PCI config space, and allow decoding the address and finding the correspo

[Xen-devel] [PATCH v9 05/11] pci: add support to size ROM BARs to pci_size_mem_bar

2018-03-14 Thread Roger Pau Monne
Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu --- Changes since v6: - Remove the rom local variable. Changes si

[Xen-devel] [PATCH v9 10/11] vpci: add a priority parameter to the vPCI register initializer

2018-03-14 Thread Roger Pau Monne
This is needed for MSI-X, since MSI-X will need to be initialized before parsing the BARs, so that the header BAR handlers are aware of the MSI-X related holes and make sure they are not mapped in order for the trap handlers to work properly. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulic

[Xen-devel] [PATCH v9 04/11] pci: split code to size BARs from pci_add_device

2018-03-14 Thread Roger Pau Monne
So that it can be called from outside in order to get the size of regular PCI BARs. This will be required in order to map the BARs from PCI devices into PVH Dom0 p2m. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackso

[Xen-devel] [PATCH v9 02/11] x86/mmcfg: add handlers for the PVH Dom0 MMCFG areas

2018-03-14 Thread Roger Pau Monne
Introduce a set of handlers for the accesses to the MMCFG areas. Those areas are setup based on the contents of the hardware MMCFG tables, and the list of handled MMCFG areas is stored inside of the hvm_domain struct. The read/writes are forwarded to the generic vpci handlers once the address is d

[Xen-devel] [PATCH v9 00/11] vpci: PCI config space emulation

2018-03-14 Thread Roger Pau Monne
9 Note that this is only safe to use for the hardware domain (that's trusted), any non-trusted domain will need a lot more handlers before it can freely access the PCI configuration space. Roger Pau Monne (11): vpci: introduce basic handlers to trap accesses to the PCI config space x86/mm

[Xen-devel] [PATCH v9 08/11] x86/pt: mask MSI vectors on unbind

2018-03-14 Thread Roger Pau Monne
When a MSI device with per-vector masking capabilities is detected or added to Xen all the vectors are masked when initializing it. This implies that the first time the interrupt is bound to a domain it's masked. This however only applies to the first time the interrupt is bound because neither th

[Xen-devel] [PATCH v9 06/11] xen: introduce rangeset_consume_ranges

2018-03-14 Thread Roger Pau Monne
This function allows to iterate over a rangeset while removing the processed regions. This will be used in order to split processing of large memory areas when mapping them into the guest p2m. Signed-off-by: Roger Pau Monné Reviewed-by: Wei Liu --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian

[Xen-devel] [PATCH v10 03/11] x86/physdev: enable PHYSDEVOP_pci_mmcfg_reserved for PVH Dom0

2018-03-16 Thread Roger Pau Monne
So that MMCFG regions not present in the MCFG ACPI table can be added at run time by the hardware domain. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich Reviewed-by: Paul Durrant --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Paul Durrant --- Changes since v7: - Add newline in hvm_physd

[Xen-devel] [PATCH v10 02/11] x86/mmcfg: add handlers for the PVH Dom0 MMCFG areas

2018-03-16 Thread Roger Pau Monne
Introduce a set of handlers for the accesses to the MMCFG areas. Those areas are setup based on the contents of the hardware MMCFG tables, and the list of handled MMCFG areas is stored inside of the hvm_domain struct. The read/writes are forwarded to the generic vpci handlers once the address is d

[Xen-devel] [PATCH v10 10/11] vpci: add a priority parameter to the vPCI register initializer

2018-03-16 Thread Roger Pau Monne
This is needed for MSI-X, since MSI-X will need to be initialized before parsing the BARs, so that the header BAR handlers are aware of the MSI-X related holes and make sure they are not mapped in order for the trap handlers to work properly. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulic

[Xen-devel] [PATCH v10 06/11] xen: introduce rangeset_consume_ranges

2018-03-16 Thread Roger Pau Monne
This function allows to iterate over a rangeset while removing the processed regions. This will be used in order to split processing of large memory areas when mapping them into the guest p2m. Signed-off-by: Roger Pau Monné Reviewed-by: Wei Liu --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian

[Xen-devel] [PATCH v10 08/11] x86/pt: mask MSI vectors on unbind

2018-03-16 Thread Roger Pau Monne
When a MSI device with per-vector masking capabilities is detected or added to Xen all the vectors are masked when initializing it. This implies that the first time the interrupt is bound to a domain it's masked. This however only applies to the first time the interrupt is bound because neither th

[Xen-devel] [PATCH v10 01/11] vpci: introduce basic handlers to trap accesses to the PCI config space

2018-03-16 Thread Roger Pau Monne
This functionality is going to reside in vpci.c (and the corresponding vpci.h header), and should be arch-agnostic. The handlers introduced in this patch setup the basic functionality required in order to trap accesses to the PCI config space, and allow decoding the address and finding the correspo

[Xen-devel] [PATCH v10 00/11] vpci: PCI config space emulation

2018-03-16 Thread Roger Pau Monne
0 Note that this is only safe to use for the hardware domain (that's trusted), any non-trusted domain will need a lot more handlers before it can freely access the PCI configuration space. Roger Pau Monne (11): vpci: introduce basic handlers to trap accesses to the PCI config space x8

[Xen-devel] [PATCH v10 04/11] pci: split code to size BARs from pci_add_device

2018-03-16 Thread Roger Pau Monne
So that it can be called from outside in order to get the size of regular PCI BARs. This will be required in order to map the BARs from PCI devices into PVH Dom0 p2m. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackso

[Xen-devel] [PATCH v10 05/11] pci: add support to size ROM BARs to pci_size_mem_bar

2018-03-16 Thread Roger Pau Monne
Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu --- Changes since v6: - Remove the rom local variable. Changes si

[Xen-devel] [PATCH v10 11/11] vpci/msix: add MSI-X handlers

2018-03-16 Thread Roger Pau Monne
Add handlers for accesses to the MSI-X message control field on the PCI configuration space, and traps for accesses to the memory region that contains the MSI-X table and PBA. This traps detect attempts from the guest to configure MSI-X interrupts and properly sets them up. Note that accesses to t

[Xen-devel] [PATCH v10 09/11] vpci/msi: add MSI handlers

2018-03-16 Thread Roger Pau Monne
Add handlers for the MSI control, address, data and mask fields in order to detect accesses to them and setup the interrupts as requested by the guest. Note that the pending register is not trapped, and the guest can freely read/write to it. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulic

[Xen-devel] [PATCH v10 07/11] vpci/bars: add handlers to map the BARs

2018-03-16 Thread Roger Pau Monne
Introduce a set of handlers that trap accesses to the PCI BARs and the command register, in order to snoop BAR sizing and BAR relocation. The command handler is used to detect changes to bit 2 (response to memory space accesses), and maps/unmaps the BARs of the device into the guest p2m. A rangese

[Xen-devel] [PATCH v11 00/12] vpci: PCI config space emulation

2018-03-20 Thread Roger Pau Monne
1 Note that this is only safe to use for the hardware domain (that's trusted), any non-trusted domain will need a lot more handlers before it can freely access the PCI configuration space. Roger Pau Monne (12): vpci: introduce basic handlers to trap accesses to the PCI config space x8

[Xen-devel] [PATCH v11 05/12] pci: add support to size ROM BARs to pci_size_mem_bar

2018-03-20 Thread Roger Pau Monne
Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu --- Changes since v6: - Remove the rom local variable. Changes si

[Xen-devel] [PATCH v11 09/12] vpci/msi: add MSI handlers

2018-03-20 Thread Roger Pau Monne
Add handlers for the MSI control, address, data and mask fields in order to detect accesses to them and setup the interrupts as requested by the guest. Note that the pending register is not trapped, and the guest can freely read/write to it. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulic

[Xen-devel] [PATCH v11 11/12] vpci/msix: add MSI-X handlers

2018-03-20 Thread Roger Pau Monne
Add handlers for accesses to the MSI-X message control field on the PCI configuration space, and traps for accesses to the memory region that contains the MSI-X table and PBA. This traps detect attempts from the guest to configure MSI-X interrupts and properly sets them up. Note that accesses to t

[Xen-devel] [PATCH v11 01/12] vpci: introduce basic handlers to trap accesses to the PCI config space

2018-03-20 Thread Roger Pau Monne
This functionality is going to reside in vpci.c (and the corresponding vpci.h header), and should be arch-agnostic. The handlers introduced in this patch setup the basic functionality required in order to trap accesses to the PCI config space, and allow decoding the address and finding the correspo

[Xen-devel] [PATCH v11 02/12] x86/mmcfg: add handlers for the PVH Dom0 MMCFG areas

2018-03-20 Thread Roger Pau Monne
Introduce a set of handlers for the accesses to the MMCFG areas. Those areas are setup based on the contents of the hardware MMCFG tables, and the list of handled MMCFG areas is stored inside of the hvm_domain struct. The read/writes are forwarded to the generic vpci handlers once the address is d

[Xen-devel] [PATCH v11 04/12] pci: split code to size BARs from pci_add_device

2018-03-20 Thread Roger Pau Monne
So that it can be called from outside in order to get the size of regular PCI BARs. This will be required in order to map the BARs from PCI devices into PVH Dom0 p2m. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackso

[Xen-devel] [PATCH v11 03/12] x86/physdev: enable PHYSDEVOP_pci_mmcfg_reserved for PVH Dom0

2018-03-20 Thread Roger Pau Monne
So that MMCFG regions not present in the MCFG ACPI table can be added at run time by the hardware domain. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich Reviewed-by: Paul Durrant --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Paul Durrant --- Changes since v7: - Add newline in hvm_physd

[Xen-devel] [PATCH v11 10/12] vpci: add a priority parameter to the vPCI register initializer

2018-03-20 Thread Roger Pau Monne
This is needed for MSI-X, since MSI-X will need to be initialized before parsing the BARs, so that the header BAR handlers are aware of the MSI-X related holes and make sure they are not mapped in order for the trap handlers to work properly. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulic

[Xen-devel] [PATCH v11 08/12] x86/pt: mask MSI vectors on unbind

2018-03-20 Thread Roger Pau Monne
When a MSI device with per-vector masking capabilities is detected or added to Xen all the vectors are masked when initializing it. This implies that the first time the interrupt is bound to a domain it's masked. This however only applies to the first time the interrupt is bound because neither th

[Xen-devel] [PATCH v11 06/12] xen: introduce rangeset_consume_ranges

2018-03-20 Thread Roger Pau Monne
This function allows to iterate over a rangeset while removing the processed regions. This will be used in order to split processing of large memory areas when mapping them into the guest p2m. Signed-off-by: Roger Pau Monné Reviewed-by: Wei Liu --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian

[Xen-devel] [PATCH v11 07/12] vpci: add header handlers

2018-03-20 Thread Roger Pau Monne
Introduce a set of handlers that trap accesses to the PCI BARs and the command register, in order to snoop BAR sizing and BAR relocation. The command handler is used to detect changes to bit 2 (response to memory space accesses), and maps/unmaps the BARs of the device into the guest p2m. A rangese

[Xen-devel] [PATCH v11 12/12] vpci: do not expose unneeded functions to the user-space test harness

2018-03-20 Thread Roger Pau Monne
Some functions in vpci.c (vpci_remove_device and vpci_add_handlers) are not used by the user-space test harness, so guard them with __XEN__ in order to avoid exposing them to the user-space test harness. Requested-by: Jan Beulich Signed-off-by: Roger Pau Monné --- tools/tests/vpci/Makefile | 8

[Xen-devel] [PATCH for-4.11 1/2] libxc/x86: fix mapping of the start_info area

2018-03-21 Thread Roger Pau Monne
The start_info size calculated in bootlate_hvm is wrong. It should use HVMLOADER_MODULE_MAX_COUNT instead of dom->num_modules and it doesn't take into account the size of the modules command line. This is not a problem so far because the actually used amount of memory doesn't cross a page boundary

[Xen-devel] [PATCH for-4.11 0/2] libxc/x86: fix a couple of bugs

2018-03-21 Thread Roger Pau Monne
Hello, Following two patches fix two bugs related to the mapping and handling of the hvm_start_info. Thanks, Roger. Roger Pau Monne (2): libxc/x86: fix mapping of the start_info area libxc/x86: do not unconditionally set the module cmdline address tools/libxc/xc_dom_x86.c | 11

[Xen-devel] [PATCH for-4.11 2/2] libxc/x86: do not unconditionally set the module cmdline address

2018-03-21 Thread Roger Pau Monne
This will lead to writing a wrong module command line physical memory address if no command line is actually provided. This hasn't caused problems so far because hvmloader is the only consumer of the modules command line, and it's unconditionally set in that case. Signed-off-by: Roger Pau Monné

[Xen-devel] [PATCH v12 06/12] xen: introduce rangeset_consume_ranges

2018-03-22 Thread Roger Pau Monne
This function allows to iterate over a rangeset while removing the processed regions. This will be used in order to split processing of large memory areas when mapping them into the guest p2m. Signed-off-by: Roger Pau Monné Reviewed-by: Wei Liu --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian

[Xen-devel] [PATCH v12 05/12] pci: add support to size ROM BARs to pci_size_mem_bar

2018-03-22 Thread Roger Pau Monne
Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu --- Changes since v6: - Remove the rom local variable. Changes si

[Xen-devel] [PATCH v12 02/12] x86/mmcfg: add handlers for the PVH Dom0 MMCFG areas

2018-03-22 Thread Roger Pau Monne
Introduce a set of handlers for the accesses to the MMCFG areas. Those areas are setup based on the contents of the hardware MMCFG tables, and the list of handled MMCFG areas is stored inside of the hvm_domain struct. The read/writes are forwarded to the generic vpci handlers once the address is d

[Xen-devel] [PATCH v12 07/12] vpci: add header handlers

2018-03-22 Thread Roger Pau Monne
Introduce a set of handlers that trap accesses to the PCI BARs and the command register, in order to snoop BAR sizing and BAR relocation. The command handler is used to detect changes to bit 2 (response to memory space accesses), and maps/unmaps the BARs of the device into the guest p2m. A rangese

[Xen-devel] [PATCH v12 12/12] vpci: do not expose unneeded functions to the user-space test harness

2018-03-22 Thread Roger Pau Monne
Some functions in vpci.c (vpci_remove_device and vpci_add_handlers) are not used by the user-space test harness, so guard them with __XEN__ in order to avoid exposing them to the user-space test harness. Requested-by: Jan Beulich Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Cc: I

[Xen-devel] [PATCH v12 09/12] vpci/msi: add MSI handlers

2018-03-22 Thread Roger Pau Monne
Add handlers for the MSI control, address, data and mask fields in order to detect accesses to them and setup the interrupts as requested by the guest. Note that the pending register is not trapped, and the guest can freely read/write to it. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulic

[Xen-devel] [PATCH v12 04/12] pci: split code to size BARs from pci_add_device

2018-03-22 Thread Roger Pau Monne
So that it can be called from outside in order to get the size of regular PCI BARs. This will be required in order to map the BARs from PCI devices into PVH Dom0 p2m. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackso

[Xen-devel] [PATCH v12 08/12] x86/pt: mask MSI vectors on unbind

2018-03-22 Thread Roger Pau Monne
When a MSI device with per-vector masking capabilities is detected or added to Xen all the vectors are masked when initializing it. This implies that the first time the interrupt is bound to a domain it's masked. This however only applies to the first time the interrupt is bound because neither th

[Xen-devel] [PATCH v12 10/12] vpci: add a priority parameter to the vPCI register initializer

2018-03-22 Thread Roger Pau Monne
This is needed for MSI-X, since MSI-X will need to be initialized before parsing the BARs, so that the header BAR handlers are aware of the MSI-X related holes and make sure they are not mapped in order for the trap handlers to work properly. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulic

[Xen-devel] [PATCH v12 01/12] vpci: introduce basic handlers to trap accesses to the PCI config space

2018-03-22 Thread Roger Pau Monne
This functionality is going to reside in vpci.c (and the corresponding vpci.h header), and should be arch-agnostic. The handlers introduced in this patch setup the basic functionality required in order to trap accesses to the PCI config space, and allow decoding the address and finding the correspo

[Xen-devel] [PATCH v12 00/12] vpci: PCI config space emulation

2018-03-22 Thread Roger Pau Monne
1 Note that this is only safe to use for the hardware domain (that's trusted), any non-trusted domain will need a lot more handlers before it can freely access the PCI configuration space. Roger Pau Monne (12): vpci: introduce basic handlers to trap accesses to the PCI config space x8

[Xen-devel] [PATCH v12 11/12] vpci/msix: add MSI-X handlers

2018-03-22 Thread Roger Pau Monne
Add handlers for accesses to the MSI-X message control field on the PCI configuration space, and traps for accesses to the memory region that contains the MSI-X table and PBA. This traps detect attempts from the guest to configure MSI-X interrupts and properly sets them up. Note that accesses to t

[Xen-devel] [PATCH v12 03/12] x86/physdev: enable PHYSDEVOP_pci_mmcfg_reserved for PVH Dom0

2018-03-22 Thread Roger Pau Monne
So that MMCFG regions not present in the MCFG ACPI table can be added at run time by the hardware domain. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich Reviewed-by: Paul Durrant --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Paul Durrant --- Changes since v7: - Add newline in hvm_physd

[Xen-devel] [PATCH] SUPPORT.md: add Domain 0 section

2018-03-23 Thread Roger Pau Monne
Signed-off-by: Roger Pau Monné --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu --- SUPPORT.md | 24 1 file changed, 24 insertions(+) diff --git a

[Xen-devel] [PATCH for-4.11] x86/libxc: fix usage of XEN_X86_EMU_ALL after VPCI addition

2018-03-23 Thread Roger Pau Monne
HVM guest should be created with (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI). This is not an issue for xl/libxl because it already sets the correct emulation flags and doesn't pass a NULL xc_domain_configuration_t to xc_domain_create. Signed-off-by: Roger Pau Monné --- Cc: Ian Jackson Cc: Wei Liu ---

[Xen-devel] [PATCH v2] SUPPORT.md: add PVH Dom0 status

2018-03-23 Thread Roger Pau Monne
Also fix x86/HVM to spell out that only DomU HVM mode is supported and remove the 'guest' from the ARM section, ARM supports both Dom0/DomU using the same mode. Signed-off-by: Roger Pau Monné --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Julien Grall Cc: Konrad

[Xen-devel] [PATCH for-4.11 0/3] vpci bugfixes

2018-03-26 Thread Roger Pau Monne
Hello, This tree patches are bugfixes for the vPCI code merged last week. They where spotted by Coverity. Thanks, Roger. Roger Pau Monne (3): vpci/bars: fix error message vpci/msix: fix incorrect usage of bitmask vpci/msi: fix size of the vectors fields xen/drivers/vpci/header.c | 2

[Xen-devel] [PATCH for-4.11 3/3] vpci/msi: fix size of the vectors fields

2018-03-26 Thread Roger Pau Monne
The current size (5bits) is not enough to store the maximum number of vectors (32), bump it by one bit. Note that the size of the struct is still the same. Reported-by: Coverity Signed-off-by: Roger Pau Monné --- xen/include/xen/vpci.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)

[Xen-devel] [PATCH for-4.11 2/3] vpci/msix: fix incorrect usage of bitmask

2018-03-26 Thread Roger Pau Monne
The bitmask to clear the low bits of the address field should be ~0xull, the current mask clears both the low and the high bits of the address field, which is a bug. Reported-by: Coverity Signed-off-by: Roger Pau Monné --- xen/drivers/vpci/msix.c | 2 +- 1 file changed, 1 insertion(+), 1

[Xen-devel] [PATCH for-4.11 1/3] vpci/bars: fix error message

2018-03-26 Thread Roger Pau Monne
Error message is incorrectly using map when it should be using map->map instead. Reported-by: Coverity Signed-off-by: Roger Pau Monné --- xen/drivers/vpci/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c index 91a7

[Xen-devel] [PATCH v1.1 for-4.11 1/3] vpci/bars: fix error message

2018-03-26 Thread Roger Pau Monne
Error message is incorrectly using map when it should be using map->map instead. Reported-by: Coverity Signed-off-by: Roger Pau Monné --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc

[Xen-devel] [PATCH v1.1 for-4.11 3/3] vpci/msi: fix size of the vectors fields

2018-03-26 Thread Roger Pau Monne
The current size (5bits) is not enough to store the maximum number of vectors (32), bump it by one bit. Note that the size of the struct is still the same. Reported-by: Coverity Signed-off-by: Roger Pau Monné --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Julien

[Xen-devel] [PATCH v1.1 for-4.11 0/3] vpci bugfixes

2018-03-26 Thread Roger Pau Monne
Hello, This tree patches are bugfixes for the vPCI code merged last week. They where spotted by Coverity. Version v1.1 is due to the fact that I've failed to Cc the maintainers in v1, sorry for the spam. Thanks, Roger. Roger Pau Monne (3): vpci/bars: fix error message vpci/msix

[Xen-devel] [PATCH v1.1 for-4.11 2/3] vpci/msix: fix incorrect usage of bitmask

2018-03-26 Thread Roger Pau Monne
The bitmask to clear the low bits of the address field should be ~0xull, the current mask clears both the low and the high bits of the address field, which is a bug. Reported-by: Coverity Signed-off-by: Roger Pau Monné --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beu

[Xen-devel] [PATCH v2 for-4.11 2/2] vpci: make sure handlers can deal with size == 0

2018-03-26 Thread Roger Pau Monne
The code is not prepared to handle such case, so just return early. In the debug case add an assert. Reported-by: Coverity Coverity ID: 1430809 Signed-off-by: Roger Pau Monné --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Julien Grall Cc: Konrad Rzeszutek Wilk C

[Xen-devel] [PATCH v2 for-4.11 1/2] vpci/msi: fix size of the vectors fields

2018-03-26 Thread Roger Pau Monne
The current size (5bits) is not enough to store the maximum number of vectors (32), bump it by one bit. Also change the layout so that 'vectors' is aligned to a 8bit boundary. Note that the size of the struct is still the same. Reported-by: Coverity Coverity ID: 1430810 Signed-off-by: Roger Pau

<    1   2   3   4   5   6   7   8   9   10   >