[PATCH 00/13] Add VT-d Posted-Interrupts support for KVM

2014-11-09 Thread Feng Wu
the following URL: http://www.intel.com/content/www/us/en/intelligent-systems/intel-technology/vt-directed-io-spec.html Feng Wu (13): iommu/vt-d: VT-d Posted-Interrupts feature detection KVM: Initialize VT-d Posted-Interrtups Descriptor KVM: Add KVM_CAP_PI to detect VT-d Posted-Interrtups

[PATCH 08/13] KVM: Update Posted-Interrupts descriptor during VCPU scheduling

2014-11-09 Thread Feng Wu
Update Posted-Interrupts descriptor according to the following rules: - Before VCPU block, set 'NV' to POSTED_INTR_WAKEUP_VECTOR - After VCPU block, set 'NV' back to POSTED_INTR_VECTOR Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h |5 ++ arch/x86/kvm/vmx.c

[PATCH 06/13] KVM: Add some helper functions for Posted-Interrupts

2014-11-09 Thread Feng Wu
This patch adds three helper functions to manipulate the Posted- Interrtups Decriptor. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 18 ++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index ae91b72..f4f 100644

[PATCH 13/13] iommu/vt-d: Add a command line parameter for VT-d posted-interrupts

2014-11-09 Thread Feng Wu
Enable VT-d Posted-Interrtups and add a command line parameter for it. Signed-off-by: Feng Wu --- drivers/iommu/irq_remapping.c |9 - 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c index 0e36860..3cb9429

[PATCH 12/13] iommu/vt-d: No need to migrating irq for VT-d Posted-Interrtups

2014-11-09 Thread Feng Wu
VCPU scheduling. Signed-off-by: Feng Wu --- drivers/iommu/intel_irq_remapping.c |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c index 87c02fe..249e2b1 100644 --- a/drivers/iommu/intel_irq_remapping.

[PATCH 07/13] x86, irq: Define a global vector for VT-d Posted-Interrupts

2014-11-09 Thread Feng Wu
that VCPU. Signed-off-by: Feng Wu --- arch/x86/include/asm/entry_arch.h |2 ++ arch/x86/include/asm/hardirq.h |1 + arch/x86/include/asm/hw_irq.h |2 ++ arch/x86/include/asm/irq_vectors.h |1 + arch/x86/kernel/entry_64.S |2 ++ arch/x86/kernel/irq.c

[PATCH 11/13] KVM: Suppress posted-interrupt when 'SN' is set

2014-11-09 Thread Feng Wu
Currently, we don't support urgent interrupt, all interrupts are recognized as non-urgent interrupt, so we cannot send posted-interrupt when 'SN' is set. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 11 +-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git

[PATCH 10/13] KVM: Add the handler for Wake-up Vector

2014-11-09 Thread Feng Wu
When VCPU is blocked and an external interrupts from assigned devices is delivered to it, VT-d Posted-Interrupts mechanism will deliver a interrrupt to the associated physical CPU with Wake-up Vector. In its handler, we find the destination VCPU and wake up it. Signed-off-by: Feng Wu --- arch

[PATCH] Add VT-d Posted-Interrupts support in QEMU

2014-11-09 Thread Feng Wu
KVM side. You can find the VT-d Posted-Interrtups Spec. in the following URL: http://www.intel.com/content/www/us/en/intelligent-systems/intel-technology/vt-directed-io-spec.html Feng Wu (1): x86: Update VT-d Posted-Interrupts related information hw/i386/kvm/pci-assign.c | 24

[PATCH 05/13] KVM: Update IRTE according to guest interrupt configuration changes

2014-11-09 Thread Feng Wu
se the VCPU with smallest 'round_robin_counter' as the destination, then increase it. Signed-off-by: Feng Wu --- arch/x86/include/asm/irq_remapping.h |6 ++ arch/x86/include/asm/kvm_host.h |2 + arch/x86/kvm/vmx.c | 12 +++ arch/x86/kvm/x86.c

[PATCH 09/13] KVM: Change NDST field after VCPU scheduling

2014-11-09 Thread Feng Wu
This patch changes the NDST filed of Posted-Interrupts Descriptor after VCPU is scheduled to another physical CPU. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 25 + 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm

[PATCH] x86: Update VT-d Posted-Interrupts related information

2014-11-09 Thread Feng Wu
update the IRTE with the new guest interrtup configuration. Signed-off-by: Feng Wu --- hw/i386/kvm/pci-assign.c | 24 linux-headers/linux/kvm.h |2 ++ target-i386/kvm.c |5 + target-i386/kvm_i386.h|1 + 4 files changed, 32 insertions(+), 0

[PATCH 02/13] KVM: Initialize VT-d Posted-Interrtups Descriptor

2014-11-09 Thread Feng Wu
This patch initialize the VT-d Posted-interrupt Descritpor. Signed-off-by: Feng Wu --- arch/x86/include/asm/irq_remapping.h |1 + arch/x86/kernel/apic/apic.c |1 + arch/x86/kvm/vmx.c | 56 - 3 files changed, 56 insertions

[PATCH 01/13] iommu/vt-d: VT-d Posted-Interrupts feature detection

2014-11-09 Thread Feng Wu
posted-interrupt. Signed-off-by: Feng Wu --- drivers/iommu/intel_irq_remapping.c | 13 + drivers/iommu/irq_remapping.c |4 drivers/iommu/irq_remapping.h |5 + include/linux/intel-iommu.h |1 + 4 files changed, 23 insertions(+), 0 deletions

[PATCH 03/13] KVM: Add KVM_CAP_PI to detect VT-d Posted-Interrtups

2014-11-09 Thread Feng Wu
This patch adds KVM_CAP_PI to detect VT-d Posted-Interrtups feature for QEMU. Signed-off-by: Feng Wu --- arch/x86/kvm/x86.c |4 include/uapi/linux/kvm.h |1 + 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 0033df3

[PATCH 04/13] iommu/vt-d: Adjust 'struct irte' to better suit for VT-d Posted-Interrupts

2014-11-09 Thread Feng Wu
This patch adjusts the definition of 'struct irte', so that we can add the VT-d Posted-Interrtups format in this structure later. Signed-off-by: Feng Wu --- drivers/iommu/intel_irq_remapping.c | 35 +++ include/linux/dmar.h|4 ++-

[RFC PATCH v1 0/2] Define some VFIO interfaces for VT-d Posted-Interrupts

2014-11-20 Thread Feng Wu
ce to configure VT-d PI when guest updates the interrupt configuration (MSI/MSI-X configuration). - Define a new VFIO API: vfio_msi_get_irq(), which can be used by KVM to get the host irq of the assigned devices. Then KVM can update the associated IRTE for VT-d PI. Feng Wu (2): vfio: Ad

[RFC PATCH v1 2/2] vfio: Add VFIO API vfio_msi_get_irq

2014-11-20 Thread Feng Wu
This API returns the host irq for the MSI/MSI-X interrrupts. Signed-off-by: Feng Wu --- drivers/vfio/pci/vfio_pci.c | 10 ++ include/linux/vfio.h|2 ++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c

[RFC PATCH v1 1/2] vfio: Add new interrupt group for VFIO

2014-11-20 Thread Feng Wu
Add new group KVM_DEV_VFIO_INTERRUPT and command KVM_DEV_VFIO_DEVIE_POSTING_IRQ related to it. This is used for VT-d Posted-Interrupts setup. Signed-off-by: Feng Wu --- Documentation/virtual/kvm/devices/vfio.txt |8 include/uapi/linux/kvm.h | 14

[RFC PATCH v2 1/2] KVM: kvm-vfio: User API for VT-d Posted-Interrupts

2014-11-25 Thread Feng Wu
IRQ attribute to tell KVM to update the related IRTE according the VT-d Posted-Interrrupts Specification, such as, the guest vector should be updated in the related IRTE. Signed-off-by: Feng Wu --- Documentation/virtual/kvm/devices/vfio.txt |9 + include/uapi/linux/kvm.h

[RFC PATCH v2 0/2] kvm-vfio: implement the vfio skeleton for VT-d Posted-Interrupts

2014-11-25 Thread Feng Wu
VT-d PI. - Define a new attribute in KVM_DEV_VFIO_DEVICE group. - Teach KVM about sturct pci_dev, and get host irq from it. Feng Wu (2): KVM: kvm-vfio: User API for VT-d Posted-Interrupts KVM: kvm-vfio: implement the VFIO skeleton for VT-d Posted-Interrupts Documentation/virtual/kvm/devices/

[RFC PATCH v2 2/2] KVM: kvm-vfio: implement the VFIO skeleton for VT-d Posted-Interrupts

2014-11-25 Thread Feng Wu
This patch adds the kvm-vfio interface for VT-d Posted-Interrrupts. When guests updates MSI/MSI-x information for an assigned-device, QEMU will use KVM_DEV_VFIO_DEVICE_POSTING_IRQ attribute to setup IRTE for VT-d PI. This patch implement this IRQ attribute. Signed-off-by: Feng Wu --- virt/kvm

[v2 16/25] KVM: make kvm_set_msi_irq() public

2014-12-02 Thread Feng Wu
Make kvm_set_msi_irq() public, we can use this function outside. Signed-off-by: Feng Wu --- include/linux/kvm_host.h |2 ++ virt/kvm/irq_comm.c |2 +- 2 files changed, 3 insertions(+), 1 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index cfa85ac

[v2 25/25] iommu/vt-d: Add a command line parameter for VT-d posted-interrupts

2014-12-02 Thread Feng Wu
Enable VT-d Posted-Interrtups and add a command line parameter for it. Signed-off-by: Feng Wu --- Documentation/kernel-parameters.txt |1 + drivers/iommu/irq_remapping.c | 12 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Documentation/kernel

[v2 23/25] KVM: Add the handler for Wake-up Vector

2014-12-02 Thread Feng Wu
When vCPU is blocked and an external interrupts from assigned devices is delivered to it, VT-d Posted-Interrupts mechanism will deliver an interrupt to the associated physical CPU with Wake-up Vector. In its handler, we find the destination vCPU and wake up it. Signed-off-by: Feng Wu --- arch

[v2 24/25] KVM: Suppress posted-interrupt when 'SN' is set

2014-12-02 Thread Feng Wu
Currently, we don't support urgent interrupt, all interrupts are recognized as non-urgent interrupt, so we cannot send posted-interrupt when 'SN' is set. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 11 +-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git

[v2 21/25] KVM: Update Posted-Interrupts descriptor during vCPU scheduling

2014-12-02 Thread Feng Wu
Update Posted-Interrupts descriptor according to the following rules: - Before vCPU block, set 'NV' to POSTED_INTR_WAKEUP_VECTOR - After vCPU block, set 'NV' back to POSTED_INTR_VECTOR Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h |5 ++ arch/x86/kvm/vmx.c

[v2 22/25] KVM: Change NDST field after vCPU scheduling

2014-12-02 Thread Feng Wu
This patch changes the NDST filed of Posted-Interrupts Descriptor after vCPU is scheduled to another physical CPU. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 25 + 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm

[v2 19/25] KVM: x86: kvm-vfio: VT-d posted-interrupts setup

2014-12-02 Thread Feng Wu
This patch defines macro __KVM_HAVE_ARCH_KVM_VFIO_POSTING and implement kvm_arch_vfio_update_pi_irte for x86 architecture. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h |2 + arch/x86/kvm/Makefile |2 +- arch/x86/kvm/kvm_vfio_x86.c | 68

[v2 17/25] KVM: kvm-vfio: User API for VT-d Posted-Interrupts

2014-12-02 Thread Feng Wu
IRQ attribute to tell KVM to update the related IRTE according the VT-d Posted-Interrrupts Specification, such as, the guest vector should be updated in the related IRTE. Signed-off-by: Feng Wu --- Documentation/virtual/kvm/devices/vfio.txt |9 + include/uapi/linux/kvm.h

[v2 20/25] x86, irq: Define a global vector for VT-d Posted-Interrupts

2014-12-02 Thread Feng Wu
that vCPU. Signed-off-by: Feng Wu --- arch/x86/include/asm/entry_arch.h |2 ++ arch/x86/include/asm/hardirq.h |1 + arch/x86/include/asm/hw_irq.h |2 ++ arch/x86/include/asm/irq_vectors.h |1 + arch/x86/kernel/entry_64.S |2 ++ arch/x86/kernel/irq.c

[v2 18/25] KVM: kvm-vfio: implement the VFIO skeleton for VT-d Posted-Interrupts

2014-12-02 Thread Feng Wu
This patch adds the kvm-vfio interface for VT-d Posted-Interrrupts. When guests updates MSI/MSI-x information for an assigned-device, QEMU will use KVM_DEV_VFIO_DEVICE_POSTING_IRQ attribute to setup IRTE for VT-d PI. This patch implement this IRQ attribute. Signed-off-by: Feng Wu --- include

[v2 11/25] KVM: Add some helper functions for Posted-Interrupts

2014-12-02 Thread Feng Wu
This patch adds some helper functions to manipulate the Posted-Interrupts Descriptor. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 26 ++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index abdb84f..0b1383e

[v2 15/25] KVM: Make struct kvm_irq_routing_table accessible

2014-12-02 Thread Feng Wu
Move struct kvm_irq_routing_table from irqchip.c to kvm_host.h, so we can use it outside of irqchip.c. Signed-off-by: Feng Wu --- include/linux/kvm_host.h | 19 +++ virt/kvm/irqchip.c | 11 --- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a

[v2 14/25] KVM: Get Posted-Interrupts descriptor address from struct kvm_vcpu

2014-12-02 Thread Feng Wu
Define a interface to get PI descriptor address from the vCPU structure. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h |1 + arch/x86/kvm/vmx.c | 12 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b

[v2 12/25] KVM: Initialize VT-d Posted-Interrupts Descriptor

2014-12-02 Thread Feng Wu
This patch initializes the VT-d Posted-Interrupts Descriptor. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 27 +++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 0b1383e..66ca275 100644 --- a/arch/x86

[v2 09/25] iommu, x86: define irq_remapping_cap()

2014-12-02 Thread Feng Wu
This patch adds a new interface irq_remapping_cap() to detect whether irq remapping supports new features, such as VT-d Posted-Interrupts. We export this function out, so that KVM code can check this and use this mechanism properly. Signed-off-by: Feng Wu Reviewed-by: Jiang Liu --- arch/x86

[v2 13/25] KVM: Define a new interface kvm_find_dest_vcpu() for VT-d PI

2014-12-02 Thread Feng Wu
he vCPU with smallest 'round_robin_counter' as the destination, then increase it. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h |4 +++ virt/kvm/irq_comm.c | 41 +++ 2 files changed, 45 insertions(+), 0 deletions(-) diff --

[v2 10/25] KVM: change struct pi_desc for VT-d Posted-Interrupts

2014-12-02 Thread Feng Wu
Change struct pi_desc for VT-d Posted-Interrupts. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 15 +-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 3e556c6..abdb84f 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86

[v2 08/25] iommu, x86: Add intel_irq_remapping_capability() for Intel

2014-12-02 Thread Feng Wu
Add the Intel side implementation for capability in struct irq_remap_ops. Signed-off-by: Feng Wu Reviewed-by: Jiang Liu --- drivers/iommu/intel_irq_remapping.c | 27 +++ drivers/iommu/irq_remapping.c |2 ++ drivers/iommu/irq_remapping.h |4 3

[v2 07/25] iommu, x86: Add cap_pi_support() to detect VT-d PI capability

2014-12-02 Thread Feng Wu
Add helper function to detect VT-d Posted-Interrupts capability. Signed-off-by: Feng Wu Reviewed-by: Jiang Liu --- include/linux/intel-iommu.h |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h index ecaf3a9

[v2 04/25] iommu, x86: Implement irq_set_vcpu_affinity for intel_ir_chip

2014-12-02 Thread Feng Wu
Implement irq_set_vcpu_affinity for intel_ir_chip. Signed-off-by: Feng Wu Reviewed-by: Jiang Liu --- arch/x86/include/asm/irq_remapping.h |5 + drivers/iommu/intel_irq_remapping.c | 27 +++ 2 files changed, 32 insertions(+), 0 deletions(-) diff --git a/arch

[v2 06/25] iommu, x86: No need to migrating irq for VT-d Posted-Interrupts

2014-12-02 Thread Feng Wu
vCPU scheduling. Signed-off-by: Feng Wu Reviewed-by: Jiang Liu --- drivers/iommu/intel_irq_remapping.c | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c index 749cb93..01786a8 100644 ---

[v2 03/25] iommu, x86: Define new irte structure for VT-d Posted-Interrupts

2014-12-02 Thread Feng Wu
Add a new irte_pi structure for VT-d Posted-Interrupts. Signed-off-by: Feng Wu Reviewed-by: Jiang Liu --- include/linux/dmar.h | 32 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/include/linux/dmar.h b/include/linux/dmar.h index 8473756

[v2 05/25] x86, irq: Implement irq_set_vcpu_affinity for pci_msi_ir_controller

2014-12-02 Thread Feng Wu
Implement irq_set_vcpu_affinity for pci_msi_ir_controller. Signed-off-by: Feng Wu Reviewed-by: Jiang Liu --- arch/x86/kernel/apic/msi.c |1 + include/linux/irq.h|3 +++ 2 files changed, 4 insertions(+), 0 deletions(-) diff --git a/arch/x86/kernel/apic/msi.c b/arch/x86/kernel

[v2 02/25] iommu: Add new member capability to struct irq_remap_ops

2014-12-02 Thread Feng Wu
This patch adds a new member capability to struct irq_remap_ops, this new function ops can be used to check whether some features are supported, such as VT-d Posted-Interrupts. Signed-off-by: Feng Wu Reviewed-by: Jiang Liu --- arch/x86/include/asm/irq_remapping.h |4 drivers/iommu

[v2 01/25] genirq: Introduce irq_set_vcpu_affinity() to target an interrupt to a VCPU

2014-12-02 Thread Feng Wu
posted interrupts descriptor and guest vector) -->irq core will transfer the control to IOMMU -->IOMMU will do the real work of updating IRTE (IRTE has new format for VT-d Posted-Interrupts) Signed-off-by: Jiang Liu Signed-off-by: Feng Wu --- include/linux/

[v2 00/25] Add VT-d Posted-Interrupts support

2014-12-03 Thread Feng Wu
/2] kvm-vfio: implement the vfio skeleton for VT-d Posted-Interrupts" 20: x86 irq related changes Feng Wu (25): genirq: Introduce irq_set_vcpu_affinity() to target an interrupt to a VCPU iommu: Add new member capability to struct irq_remap_ops iommu, x86: Define new irte structur

[PATCH 3/4] KVM: Add SMAP support when setting CR4

2014-03-26 Thread Feng Wu
This patch adds SMAP handling logic when setting CR4 for guests Signed-off-by: Feng Wu --- arch/x86/kvm/cpuid.h | 8 arch/x86/kvm/mmu.c | 22 +++--- arch/x86/kvm/mmu.h | 2 ++ arch/x86/kvm/x86.c | 6 ++ 4 files changed, 35 insertions(+), 3 deletions

[PATCH 2/4] KVM: Remove SMAP bit from CR4_RESERVED_BITS.

2014-03-26 Thread Feng Wu
This patch removes SMAP bit from CR4_RESERVED_BITS. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index ae5d783..b673925 100644 --- a/arch/x86

[PATCH 4/4] KVM: Disable SMAP for guests in EPT realmode and EPT unpaging mode

2014-03-26 Thread Feng Wu
SMAP is disabled if CPU is in non-paging mode in hardware. However KVM always uses paging mode to emulate guest non-paging mode with TDP. To emulate this behavior, SMAP needs to be manually disabled when guest switches to non-paging mode. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 10

[PATCH 0/4] KVM: enable Intel SMAP for KVM

2014-03-26 Thread Feng Wu
ode data accesses (these are implicit supervisor accesses) regardless of the value of EFLAGS.AC. This patchset pass-through SMAP feature to guests, and let guests benefit from it. Feng Wu (4): KVM: expose SMAP feature to guest KVM: Remove SMAP bit from CR4_RESERVED_BITS. KVM: Add SMAP supp

[PATCH 1/4] KVM: expose SMAP feature to guest

2014-03-26 Thread Feng Wu
This patch exposes SMAP feature to guest Signed-off-by: Feng Wu --- arch/x86/kvm/cpuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index c697625..deb5f9b 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -303,7

[PATCH 3/4] KVM: Disable SMAP for guests in EPT realmode and EPT unpaging mode

2014-03-28 Thread Feng Wu
SMAP is disabled if CPU is in non-paging mode in hardware. However KVM always uses paging mode to emulate guest non-paging mode with TDP. To emulate this behavior, SMAP needs to be manually disabled when guest switches to non-paging mode. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 11

[PATCH 1/4] KVM: Remove SMAP bit from CR4_RESERVED_BITS.

2014-03-28 Thread Feng Wu
This patch removes SMAP bit from CR4_RESERVED_BITS. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index fdf83af..4eeb049 100644 --- a/arch/x86

[PATCH 0/4] KVM: enable Intel SMAP for KVM

2014-03-28 Thread Feng Wu
in EPT realmode and EPT unpaging mode * Expose SMAP feature to guest Version 1: * Change the logic of updatinng mmu permission bitmap for SMAP violation * Expose SMAP feature to guest in the last patch of this series. Feng Wu (4): KVM: Remove SMAP bit from CR4_RESERVED_BITS. KVM: Add S

[PATCH 4/4] KVM: expose SMAP feature to guest

2014-03-28 Thread Feng Wu
This patch exposes SMAP feature to guest Signed-off-by: Feng Wu --- arch/x86/kvm/cpuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index c697625..deb5f9b 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -303,7

[PATCH 2/4] KVM: Add SMAP support when setting CR4

2014-03-28 Thread Feng Wu
This patch adds SMAP handling logic when setting CR4 for guests Signed-off-by: Feng Wu --- arch/x86/kvm/cpuid.h | 8 arch/x86/kvm/mmu.c | 24 +--- arch/x86/kvm/mmu.h | 26 +++--- arch/x86/kvm/paging_tmpl.h | 2 +- arch/x86

[PATCH v3 0/4] KVM: enable Intel SMAP for KVM

2014-03-31 Thread Feng Wu
ess way suggested by Paolo Bonzini to detect SMAP violation in permission_fault(). Feng Wu (4): KVM: Remove SMAP bit from CR4_RESERVED_BITS. KVM: Add SMAP support when setting CR4 KVM: Disable SMAP for guests in EPT realmode and EPT unpaging mode KVM: expose SMAP feature to guest arch/

[PATCH v3 1/4] KVM: Remove SMAP bit from CR4_RESERVED_BITS.

2014-03-31 Thread Feng Wu
This patch removes SMAP bit from CR4_RESERVED_BITS. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index fdf83af..4eeb049 100644 --- a/arch/x86

[PATCH v3 3/4] KVM: Disable SMAP for guests in EPT realmode and EPT unpaging mode

2014-03-31 Thread Feng Wu
SMAP is disabled if CPU is in non-paging mode in hardware. However KVM always uses paging mode to emulate guest non-paging mode with TDP. To emulate this behavior, SMAP needs to be manually disabled when guest switches to non-paging mode. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 11

[PATCH v3 4/4] KVM: expose SMAP feature to guest

2014-03-31 Thread Feng Wu
This patch exposes SMAP feature to guest Signed-off-by: Feng Wu --- arch/x86/kvm/cpuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index c697625..deb5f9b 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -303,7

[PATCH v3 2/4] KVM: Add SMAP support when setting CR4

2014-03-31 Thread Feng Wu
This patch adds SMAP handling logic when setting CR4 for guests Thanks a lot to Paolo Bonzini for his suggestion to use the branchless way to detect SMAP violation. Signed-off-by: Feng Wu --- arch/x86/kvm/cpuid.h | 8 arch/x86/kvm/mmu.c | 35

[PATCH v4 0/4] KVM: enable Intel SMAP for KVM

2014-03-31 Thread Feng Wu
ess way suggested by Paolo Bonzini to detect SMAP violation in permission_fault(). Version 4: * Changes to some comments and code style. Feng Wu (4): KVM: Remove SMAP bit from CR4_RESERVED_BITS. KVM: Add SMAP support when setting CR4 KVM: Disable SMAP for guests in EPT realmode and

[PATCH v4 4/4] KVM: expose SMAP feature to guest

2014-03-31 Thread Feng Wu
This patch exposes SMAP feature to guest Signed-off-by: Feng Wu --- arch/x86/kvm/cpuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index c697625..deb5f9b 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -303,7

[PATCH v4 3/4] KVM: Disable SMAP for guests in EPT realmode and EPT unpaging mode

2014-03-31 Thread Feng Wu
SMAP is disabled if CPU is in non-paging mode in hardware. However KVM always uses paging mode to emulate guest non-paging mode with TDP. To emulate this behavior, SMAP needs to be manually disabled when guest switches to non-paging mode. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 11

[PATCH v4 1/4] KVM: Remove SMAP bit from CR4_RESERVED_BITS.

2014-03-31 Thread Feng Wu
This patch removes SMAP bit from CR4_RESERVED_BITS. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index fdf83af..4eeb049 100644 --- a/arch/x86

[PATCH v4 2/4] KVM: Add SMAP support when setting CR4

2014-03-31 Thread Feng Wu
This patch adds SMAP handling logic when setting CR4 for guests Thanks a lot to Paolo Bonzini for his suggestion to use the branchless way to detect SMAP violation. Signed-off-by: Feng Wu --- arch/x86/kvm/cpuid.h | 8 arch/x86/kvm/mmu.c | 34

[PATCH] Rename variable smep to cr4_smep

2014-03-31 Thread Feng Wu
This patch is based on the smap patchset Feng Wu (1): Rename variable smep to cr4_smep arch/x86/kvm/mmu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message

[PATCH] Rename variable smep to cr4_smep

2014-03-31 Thread Feng Wu
Rename variable smep to cr4_smep, which can better reflect the meaning of the variable. Signed-off-by: Feng Wu --- arch/x86/kvm/mmu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index a183783..6000557 100644 --- a/arch/x86

[PATCH] KVM: x86: Add lowest-priority support for vt-d posted-interrupts

2015-11-08 Thread Feng Wu
Use vector-hashing to handle lowest-priority interrupts for posted-interrupts. As an example, modern Intel CPUs use this method to handle lowest-priority interrupts. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/irq_comm.c | 52

[PATCH v2 0/2] Add vector-hashing support for lowest-priority interrupts delivery

2015-12-15 Thread Feng Wu
module parameter to control the vector-hashing mechanism Feng Wu (2): KVM: x86: Use vector-hashing to deliver lowest-priority interrupts KVM: x86: Add lowest-priority support for vt-d posted-interrupts arch/x86/kvm/irq_comm.c | 27 +-- arch/x86/kvm/lapic.c| 124

[PATCH v2 2/2] KVM: x86: Add lowest-priority support for vt-d posted-interrupts

2015-12-15 Thread Feng Wu
Use vector-hashing to deliver lowest-priority interrupts for VT-d posted-interrupts. Signed-off-by: Feng Wu --- arch/x86/kvm/lapic.c | 67 arch/x86/kvm/lapic.h | 2 ++ arch/x86/kvm/vmx.c | 12 -- 3 files changed, 79 insertions

[PATCH v2 1/2] KVM: x86: Use vector-hashing to deliver lowest-priority interrupts

2015-12-15 Thread Feng Wu
Use vector-hashing to deliver lowest-priority interrupts, As an example, modern Intel CPUs in server platform use this method to handle lowest-priority interrupts. Signed-off-by: Feng Wu --- arch/x86/kvm/irq_comm.c | 27 ++- arch/x86/kvm/lapic.c| 57

[v4 06/16] KVM: Make struct kvm_irq_routing_table accessible

2015-06-11 Thread Feng Wu
Move struct kvm_irq_routing_table from irqchip.c to kvm_host.h, so we can use it outside of irqchip.c. Signed-off-by: Feng Wu --- include/linux/kvm_host.h | 15 +++ virt/kvm/irqchip.c | 11 --- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include

[v4 08/16] KVM: kvm-vfio: User API for IRQ forwarding

2015-06-11 Thread Feng Wu
From: Eric Auger This patch adds and documents a new KVM_DEV_VFIO_DEVICE group and 2 device attributes: KVM_DEV_VFIO_DEVICE_FORWARD_IRQ, KVM_DEV_VFIO_DEVICE_UNFORWARD_IRQ. The purpose is to be able to set a VFIO device IRQ as forwarded or not forwarded. the command takes as argument a handle to a

[v4 00/16] Add VT-d Posted-Interrupts support

2015-06-11 Thread Feng Wu
VFIO: external user API for interaction KVM: kvm-vfio: wrappers to VFIO external API device helpers Feng Wu (13): KVM: Extend struct pi_desc for VT-d Posted-Interrupts KVM: Add some helper functions for Posted-Interrupts KVM: Define a new interface kvm_intr_is_single_vcpu() KVM: Get P

[v4 01/16] KVM: Extend struct pi_desc for VT-d Posted-Interrupts

2015-06-11 Thread Feng Wu
Extend struct pi_desc for VT-d Posted-Interrupts. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index f7b6168..bd26501 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86

[v4 03/16] KVM: Define a new interface kvm_intr_is_single_vcpu()

2015-06-11 Thread Feng Wu
single-CPU, we can use PI to deliver the interrupts to it. Full functionality of lowest-priority support will be added later. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/irq_comm.c | 24 2 files changed, 26 insertions(+) diff

[v4 05/16] KVM: Add interfaces to control PI outside vmx

2015-06-11 Thread Feng Wu
This patch adds pi_clear_sn and pi_set_sn to struct kvm_x86_ops, so we can set/clear SN outside vmx. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/kvm/vmx.c | 13 + 2 files changed, 16 insertions(+) diff --git a/arch/x86/include/asm

[v4 02/16] KVM: Add some helper functions for Posted-Interrupts

2015-06-11 Thread Feng Wu
This patch adds some helper functions to manipulate the Posted-Interrupts Descriptor. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 26 ++ 1 file changed, 26 insertions(+) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index bd26501..8be6aa4 100644 --- a/arch

[v4 15/16] KVM: Update Posted-Interrupts Descriptor when vCPU is blocked

2015-06-11 Thread Feng Wu
This patch updates the Posted-Interrupts Descriptor when vCPU is blocked. pre-block: - Add the vCPU to the blocked per-CPU list - Set 'NV' to POSTED_INTR_WAKEUP_VECTOR post-block: - Remove the vCPU from the per-CPU list Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h |

[v4 10/16] KVM: kvm-vfio: wrappers to VFIO external API device helpers

2015-06-11 Thread Feng Wu
From: Eric Auger Provide wrapper functions that allow KVM-VFIO device code to interact with a vfio device: - kvm_vfio_device_get_external_user gets a handle to a struct vfio_device from the vfio device file descriptor and increments its reference counter, - kvm_vfio_device_put_external_user d

[v4 16/16] KVM: Warn if 'SN' is set during posting interrupts by software

2015-06-11 Thread Feng Wu
is set. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 16 1 file changed, 16 insertions(+) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 7e8a800..f1daa8b 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4485,6 +4485,22 @

[v4 14/16] KVM: Update Posted-Interrupts Descriptor when vCPU is preempted

2015-06-11 Thread Feng Wu
This patch updates the Posted-Interrupts Descriptor when vCPU is preempted. sched out: - Set 'SN' to suppress furture non-urgent interrupts posted for the vCPU. sched in: - Clear 'SN' - Change NDST if vCPU is scheduled to a different CPU - Set 'NV' to POSTED_INTR_

[v4 12/16] KVM: kvm-vfio: implement the VFIO skeleton for VT-d Posted-Interrupts

2015-06-11 Thread Feng Wu
remapping mode. This patch implements these IRQ attributes. Signed-off-by: Feng Wu --- include/linux/kvm_host.h | 22 + virt/kvm/vfio.c | 126 +++ 2 files changed, 148 insertions(+) diff --git a/include/linux/kvm_host.h b/include/linux

[v4 07/16] KVM: make kvm_set_msi_irq() public

2015-06-11 Thread Feng Wu
Make kvm_set_msi_irq() public, we can use this function outside. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 4 arch/x86/kvm/irq_comm.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm

[v4 04/16] KVM: Get Posted-Interrupts descriptor address from struct kvm_vcpu

2015-06-11 Thread Feng Wu
Define an interface to get PI descriptor address from the vCPU structure. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/vmx.c | 11 +++ 2 files changed, 13 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm

[v4 13/16] KVM: x86: kvm-vfio: VT-d posted-interrupts setup

2015-06-11 Thread Feng Wu
This patch defines macro __KVM_HAVE_ARCH_KVM_VFIO_POST and implement kvm_arch_vfio_update_pi_irte for x86 architecture. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 2 + arch/x86/kvm/Makefile | 3 +- arch/x86/kvm/kvm_vfio_x86.c | 85

[v4 11/16] KVM: kvm-vfio: User API for VT-d Posted-Interrupts

2015-06-11 Thread Feng Wu
/address fields, QEMU will use this IRQ attribute to tell KVM to update the related IRTE according the VT-d Posted-Interrrupts Specification, such as, the guest vector should be updated in the related IRTE. Signed-off-by: Feng Wu --- Documentation/virtual/kvm/devices/vfio.txt | 9 + include

[v4 09/16] VFIO: external user API for interaction

2015-06-11 Thread Feng Wu
From: Eric Auger The VFIO external user API is enriched with 3 new functions that allows a kernel user external to VFIO to retrieve some information from a VFIO device. - vfio_device_get_external_user enables to get a vfio device from its fd and increments its reference counter - vfio_device_p

[RFC v1 1/5] vfio: Register/unregister irq_bypass_producer

2015-07-09 Thread Feng Wu
This patch adds the registration/unregistration of an irq_bypass_producer for MSI/MSIx on vfio pci devices. Signed-off-by: Feng Wu --- drivers/vfio/pci/vfio_pci_intrs.c | 8 ++-- drivers/vfio/pci/vfio_pci_private.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a

[RFC v1 0/5] irq bypass interface implementation for VT-d Posted-interrupts

2015-07-09 Thread Feng Wu
This series is based on Alex and Eric's irq bypass manager framework. To make things clear, I only send out the patches related to irq bypass manager, the purpose here is to show how certain callbacks are used in VT-d PI and help to improve the irqbypass manager itself. Feng Wu (5):

[RFC v1 3/5] KVM: Add pointer to 'struct irq_bypass_produce' in 'kvm_kernel_irqfd'

2015-07-09 Thread Feng Wu
Add reference to struct irq_bypass_produce so we can get the producer information from the consumer side. Signed-off-by: Feng Wu --- include/linux/kvm_irqfd.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h index 3c0bd07..0c1de05 100644

[RFC v1 5/5] Call irqbypass update routine when updating irqfd

2015-07-09 Thread Feng Wu
Call update routine when updating irqfd, this can update the IRTE for Intel posted-interrupts. Signed-off-by: Feng Wu --- virt/kvm/eventfd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index a32cf6c..1226835 100644 --- a/virt

[RFC v1 2/5] KVM: x86: Update IRTE for posted-interrupts

2015-07-09 Thread Feng Wu
This patch adds the routine to update IRTE for posted-interrupts when guest changes the interrupt configuration. Signed-off-by: Feng Wu --- arch/x86/kvm/x86.c | 73 ++ 1 file changed, 73 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch

[RFC v1 4/5] KVM: x86: Add arch specific routines for irqbypass manager

2015-07-09 Thread Feng Wu
Add the following x86 specific routines for irqbypass manger: - kvm_arch_irq_bypass_add_producer - kvm_arch_irq_bypass_del_producer - kvm_arch_irq_bypass_stop - kvm_arch_irq_bypass_resume - kvm_arch_irq_bypass_update Signed-off-by: Feng Wu --- arch/x86/kvm/Kconfig | 1 + arch/x86/kvm/x86.c

[v5 06/19] KVM: Make struct kvm_irq_routing_table accessible

2015-07-13 Thread Feng Wu
Move struct kvm_irq_routing_table from irqchip.c to kvm_host.h, so we can use it outside of irqchip.c. Signed-off-by: Feng Wu --- include/linux/kvm_host.h | 15 +++ virt/kvm/irqchip.c | 11 --- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include

[v5 13/19] KVM: x86: Update IRTE for posted-interrupts

2015-07-13 Thread Feng Wu
This patch adds the routine to update IRTE for posted-interrupts when guest changes the interrupt configuration. Signed-off-by: Feng Wu --- arch/x86/kvm/x86.c | 73 ++ 1 file changed, 73 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch

[v5 19/19] KVM: Warn if 'SN' is set during posting interrupts by software

2015-07-13 Thread Feng Wu
is set. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 16 1 file changed, 16 insertions(+) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index cecd018..d4d5abc 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4484,6 +4484,22 @

  1   2   3   >