[PATCH] KVM: arm/arm64: BUG: Fix losing level-sensitive interrupts

2015-08-25 Thread Pavel Fedin
Commit 71760950bf3dc796e5e53ea3300dec724a09f593 ("arm/arm64: KVM: add a common vgic_queue_irq_to_lr fn") introduced vgic_queue_irq_to_lr() function which checks vgic_dist_irq_is_pending() before setting LR_STATE_PENDING bit. However, in some cases, the following race condition is possible: 1. Userl

Re: [PATCH V2 1/3] kvm: use kmalloc() instead of kzalloc() during iodev register/unregister

2015-08-25 Thread Jason Wang
On 08/26/2015 01:45 PM, Joe Perches wrote: > On Wed, 2015-08-26 at 13:39 +0800, Jason Wang wrote: >> > >> > On 08/25/2015 11:29 PM, Joe Perches wrote: >>> > > On Tue, 2015-08-25 at 15:47 +0800, Jason Wang wrote: > > >> > All fields of kvm_io_range were initialized or copied explicitly >

Re: [PATCH V2 1/3] kvm: use kmalloc() instead of kzalloc() during iodev register/unregister

2015-08-25 Thread Joe Perches
On Wed, 2015-08-26 at 13:39 +0800, Jason Wang wrote: > > On 08/25/2015 11:29 PM, Joe Perches wrote: > > On Tue, 2015-08-25 at 15:47 +0800, Jason Wang wrote: > >> > All fields of kvm_io_range were initialized or copied explicitly > >> > afterwards. So switch to use kmalloc(). > > Is there any compi

Re: [PATCH V2 1/3] kvm: use kmalloc() instead of kzalloc() during iodev register/unregister

2015-08-25 Thread Jason Wang
On 08/25/2015 11:29 PM, Joe Perches wrote: > On Tue, 2015-08-25 at 15:47 +0800, Jason Wang wrote: >> > All fields of kvm_io_range were initialized or copied explicitly >> > afterwards. So switch to use kmalloc(). > Is there any compiler added alignment padding > in either structure? If so, those

Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two buses

2015-08-25 Thread Jason Wang
On 08/25/2015 07:51 PM, Michael S. Tsirkin wrote: > On Tue, Aug 25, 2015 at 05:05:47PM +0800, Jason Wang wrote: >> > We register wildcard mmio eventfd on two buses, one for KVM_MMIO_BUS >> > and another is KVM_FAST_MMIO_BUS. This leads to issue: >> > >> > - kvm_io_bus_destroy() knows nothing abo

Re: [PATCH V2 3/3] kvm: add tracepoint for fast mmio

2015-08-25 Thread Jason Wang
On 08/25/2015 07:34 PM, Michael S. Tsirkin wrote: > On Tue, Aug 25, 2015 at 03:47:15PM +0800, Jason Wang wrote: >> > Cc: Gleb Natapov >> > Cc: Paolo Bonzini >> > Cc: Michael S. Tsirkin >> > Signed-off-by: Jason Wang >> > --- >> > arch/x86/kvm/trace.h | 17 + >> > arch/x86/kvm

Re: [PATCH V2 2/3] kvm: don't register wildcard MMIO EVENTFD on two buses

2015-08-25 Thread Jason Wang
On 08/25/2015 07:33 PM, Michael S. Tsirkin wrote: > On Tue, Aug 25, 2015 at 03:47:14PM +0800, Jason Wang wrote: >> > We register wildcard mmio eventfd on two buses, one for KVM_MMIO_BUS >> > and another is KVM_FAST_MMIO_BUS. This leads to issue: >> > >> > - kvm_io_bus_destroy() knows nothing abo

Re: I'm now looking into kvm-unit-tests and encounted with some problems.

2015-08-25 Thread Jinjian (Ken)
To Peter, Thank you very much! I'm sorry this is my first kvm mail, and have no experience. On 2015/8/26 8:40, Huangpeng (Peter) wrote: You should add kvm maillinglist too. -邮件原件- 发件人: Jinjian (Ken) 发送时间: 2015年8月25日 21:42 收件人: drjo...@redhat.com; pbonz...@redhat.com 抄送: Huangpeng

答复: I'm now looking into kvm-unit-tests and encounted with some problems.

2015-08-25 Thread Huangpeng (Peter)
You should add kvm maillinglist too. -邮件原件- 发件人: Jinjian (Ken) 发送时间: 2015年8月25日 21:42 收件人: drjo...@redhat.com; pbonz...@redhat.com 抄送: Huangpeng (Peter); Gonglei (Arei); Zhanghailiang 主题: I'm now looking into kvm-unit-tests and encounted with some problems. Hi all: I'm now looking in

RE: [PATCH v7 10/17] KVM: x86: Update IRTE for posted-interrupts

2015-08-25 Thread Wu, Feng
> -Original Message- > From: Alex Williamson [mailto:alex.william...@redhat.com] > Sent: Wednesday, August 26, 2015 3:58 AM > To: Wu, Feng > Cc: pbonz...@redhat.com; j...@8bytes.org; mtosa...@redhat.com; > eric.au...@linaro.org; kvm@vger.kernel.org; > io...@lists.linux-foundation.org; lin

Re: KVM slow LAMP guest

2015-08-25 Thread Wanpeng Li
On 8/26/15 6:41 AM, Hansa wrote: On 26-8-2015 0:33, Wanpeng Li wrote: On the VM server I issued the command below every eleven minutes: date >> curltest-file; _ top -b -n 1 | sed -n '7,12p' >> curltest-file; _ curl -o /dev/null -s -w"time_total: %{time_total}\\n" https://my.domain.com | perl -

Re: KVM slow LAMP guest

2015-08-25 Thread Hansa
On 26-8-2015 0:33, Wanpeng Li wrote: On the VM server I issued the command below every eleven minutes: date >> curltest-file; _ top -b -n 1 | sed -n '7,12p' >> curltest-file; _ curl -o /dev/null -s -w"time_total: %{time_total}\\n" https://my.domain.com | perl -pe 'BEGIN {use POSIX;} print strf

Re: KVM slow LAMP guest

2015-08-25 Thread Wanpeng Li
On 8/25/15 11:42 PM, Hansa wrote: On 24-8-2015 1:26, Wanpeng Li wrote: On 8/24/15 3:18 AM, Hansa wrote: On 16-7-2015 13:27, Paolo Bonzini wrote: On 15/07/2015 22:02, "C. Bröcker" wrote: What OS is this? Is it RHEL/CentOS? If so, halt_poll_ns will be in 6.7 which will be out in a few days/we

Fwd: [ERROR] INIT: PANIC: segmentation violation! sleeping for 30 seconds.

2015-08-25 Thread Jon Panozzo
KVM Team, We have a user that is experiencing an odd issue when trying to create VMs on his system which causes the entire host to crash, printing the following message to the console: [ERROR] INIT: PANIC: segmentation violation! sleeping for 30 seconds. We have never seen this issue before, but

Re: [PATCH v7 10/17] KVM: x86: Update IRTE for posted-interrupts

2015-08-25 Thread Alex Williamson
On Tue, 2015-08-25 at 16:50 +0800, Feng Wu wrote: > 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 ch

Re: [PATCH v2 2/3] KVM: dynamic halt_poll_ns adjustment

2015-08-25 Thread David Matlack
Thanks for writing v2, Wanpeng. On Mon, Aug 24, 2015 at 11:35 PM, Wanpeng Li wrote: > There is a downside of halt_poll_ns since poll is still happen for idle > VCPU which can waste cpu usage. This patch adds the ability to adjust > halt_poll_ns dynamically. What testing have you done with these

Re: [PATCH v3 3/4] irqchip: GIC: Convert to EOImode == 1

2015-08-25 Thread Marc Zyngier
Hi Thomas, On 25/08/15 16:46, Thomas Gleixner wrote: > On Tue, 25 Aug 2015, Marc Zyngier wrote: >> +static struct static_key supports_deactivate = STATIC_KEY_INIT_TRUE; >> + >> #ifndef MAX_GIC_NR >> #define MAX_GIC_NR 1 >> #endif >> @@ -137,6 +140,14 @@ static inline unsigned int gic_irq(struc

Re: [Qemu-devel] [PATCH v2 00/18] implement vNVDIMM

2015-08-25 Thread Stefan Hajnoczi
On Fri, Aug 14, 2015 at 10:51:53PM +0800, Xiao Guangrong wrote: > Changlog: > - Use litten endian for DSM method, thanks for Stefan's suggestion > > - introduce a new parameter, @configdata, if it's false, Qemu will > build a static and readonly namespace in memory and use it serveing > for DS

Re: [PATCH v2 15/18] nvdimm: support NFIT_CMD_GET_CONFIG_SIZE function

2015-08-25 Thread Stefan Hajnoczi
On Fri, Aug 14, 2015 at 10:52:08PM +0800, Xiao Guangrong wrote: > Function 4 is used to get Namespace lable size s/lable/label/ -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/maj

Re: [PATCH v2 14/18] nvdimm: support NFIT_CMD_IMPLEMENTED function

2015-08-25 Thread Stefan Hajnoczi
On Fri, Aug 14, 2015 at 10:52:07PM +0800, Xiao Guangrong wrote: > @@ -306,6 +354,18 @@ struct dsm_buffer { > static ram_addr_t dsm_addr; > static size_t dsm_size; > > +struct cmd_out_implemented { QEMU coding style uses typedef struct {} CamelCase. Please follow this convention in all user-de

Re: [Qemu-devel] [PATCH v2 13/18] nvdimm: build namespace config data

2015-08-25 Thread Stefan Hajnoczi
On Fri, Aug 14, 2015 at 10:52:06PM +0800, Xiao Guangrong wrote: > +#ifdef NVDIMM_DEBUG > +#define nvdebug(fmt, ...) fprintf(stderr, "nvdimm: " fmt, ## __VA_ARGS__) > +#else > +#define nvdebug(...) > +#endif The following allows the compiler to check format strings and syntax check the argument exp

Re: [PATCH v2 10/18] nvdimm: init the address region used by DSM method

2015-08-25 Thread Stefan Hajnoczi
On Fri, Aug 14, 2015 at 10:52:03PM +0800, Xiao Guangrong wrote: > @@ -257,14 +258,91 @@ static void build_nfit_table(GSList *device_list, char > *buf) > } > } > > +struct dsm_buffer { > +/* RAM page. */ > +uint32_t handle; > +uint8_t arg0[16]; > +uint32_t arg1; > +uint3

Re: [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-08-25 Thread Stefan Hajnoczi
On Fri, Aug 14, 2015 at 10:52:01PM +0800, Xiao Guangrong wrote: > The parameter @file is used as backed memory for NVDIMM which is > divided into two parts if @dataconfig is true: s/dataconfig/configdata/ > @@ -76,13 +109,87 @@ static void pc_nvdimm_init(Object *obj) >

Re: [PATCH v2 12/15] KVM: arm64: sync LPI configuration and pending tables

2015-08-25 Thread Andre Przywara
Hi Eric, On 14/08/15 13:35, Eric Auger wrote: > On 08/14/2015 01:58 PM, Eric Auger wrote: >> On 07/10/2015 04:21 PM, Andre Przywara wrote: >>> The LPI configuration and pending tables of the GICv3 LPIs are held >>> in tables in (guest) memory. To achieve reasonable performance, we >>> cache this d

Re: [PATCH v3 3/4] irqchip: GIC: Convert to EOImode == 1

2015-08-25 Thread Thomas Gleixner
On Tue, 25 Aug 2015, Marc Zyngier wrote: > +static struct static_key supports_deactivate = STATIC_KEY_INIT_TRUE; > + > #ifndef MAX_GIC_NR > #define MAX_GIC_NR 1 > #endif > @@ -137,6 +140,14 @@ static inline unsigned int gic_irq(struct irq_data *d) > return d->hwirq; > } > > +static in

Re: KVM slow LAMP guest

2015-08-25 Thread Hansa
On 24-8-2015 1:26, Wanpeng Li wrote: On 8/24/15 3:18 AM, Hansa wrote: On 16-7-2015 13:27, Paolo Bonzini wrote: On 15/07/2015 22:02, "C. Bröcker" wrote: What OS is this? Is it RHEL/CentOS? If so, halt_poll_ns will be in 6.7 which will be out in a few days/weeks. Paolo OK. As said CentOS 6.6.

Re: [PATCH v2 07/18] nvdimm: reserve address range for NVDIMM

2015-08-25 Thread Stefan Hajnoczi
On Fri, Aug 14, 2015 at 10:52:00PM +0800, Xiao Guangrong wrote: > NVDIMM reserves all the free range above 4G to do: > - Persistent Memory (PMEM) mapping > - implement NVDIMM ACPI device _DSM method > > Signed-off-by: Xiao Guangrong > --- > hw/i386/pc.c | 12 ++-- > hw/mem/

Re: [PATCH V2 1/3] kvm: use kmalloc() instead of kzalloc() during iodev register/unregister

2015-08-25 Thread Joe Perches
On Tue, 2015-08-25 at 15:47 +0800, Jason Wang wrote: > All fields of kvm_io_range were initialized or copied explicitly > afterwards. So switch to use kmalloc(). Is there any compiler added alignment padding in either structure? If so, those padding areas would now be uninitialized and may leak k

Re: [PATCH v2 12/15] KVM: arm64: sync LPI configuration and pending tables

2015-08-25 Thread Andre Przywara
Hi Eric, On 14/08/15 12:58, Eric Auger wrote: > On 07/10/2015 04:21 PM, Andre Przywara wrote: >> The LPI configuration and pending tables of the GICv3 LPIs are held >> in tables in (guest) memory. To achieve reasonable performance, we >> cache this data in our own data structures, so we need to sy

Re: [PATCH v2 07/18] nvdimm: reserve address range for NVDIMM

2015-08-25 Thread Stefan Hajnoczi
On Fri, Aug 14, 2015 at 10:52:00PM +0800, Xiao Guangrong wrote: > diff --git a/hw/mem/nvdimm/pc-nvdimm.c b/hw/mem/nvdimm/pc-nvdimm.c > index a53d235..7a270a8 100644 > --- a/hw/mem/nvdimm/pc-nvdimm.c > +++ b/hw/mem/nvdimm/pc-nvdimm.c > @@ -24,6 +24,19 @@ > > #include "hw/mem/pc-nvdimm.h" > > +#

Re: [Qemu-devel] [PATCH v2 06/18] pc: implement NVDIMM device abstract

2015-08-25 Thread Stefan Hajnoczi
On Fri, Aug 14, 2015 at 10:51:59PM +0800, Xiao Guangrong wrote: > +static void set_file(Object *obj, const char *str, Error **errp) > +{ > +PCNVDIMMDevice *nvdimm = PC_NVDIMM(obj); > + > +if (nvdimm->file) { > +g_free(nvdimm->file); > +} g_free(NULL) is a nop so it's safe to re

Re: [PATCH v2 11/15] KVM: arm64: handle pending bit for LPIs in ITS emulation

2015-08-25 Thread Andre Przywara
Hi Eric, On 14/08/15 12:58, Eric Auger wrote: > On 07/10/2015 04:21 PM, Andre Przywara wrote: >> As the actual LPI number in a guest can be quite high, but is mostly >> assigned using a very sparse allocation scheme, bitmaps and arrays >> for storing the virtual interrupt status are a waste of mem

Re: [PATCH] kvm/powerpc: fix a build error in e500_tlb.c

2015-08-25 Thread mani
Kevin Hao gmail.com> writes: > > We use the wrong number arguments when invoking trace_kvm_stlb_inval, > and cause the following build error. > arch/powerpc/kvm/e500_tlb.c: In function 'kvmppc_e500_stlbe_invalidate': > arch/powerpc/kvm/e500_tlb.c:230: error: too many arguments to function 'trac

[PATCH v3 0/4] irqchip: GICv2/v3: Add support for irq_vcpu_affinity

2015-08-25 Thread Marc Zyngier
The GICv2 and GICv3 architectures allow an active physical interrupt to be forwarded to a guest, and the guest to indirectly perform the deactivation of the interrupt by performing an EOI on the virtual interrupt (see for example the GICv2 spec, 3.2.1). This allows some substantial performance imp

[PATCH v3 4/4] irqchip: GIC: Don't deactivate interrupts forwarded to a guest

2015-08-25 Thread Marc Zyngier
Commit 0a4377de3056 ("genirq: Introduce irq_set_vcpu_affinity() to target an interrupt to a VCPU") added just what we needed at the lowest level to allow an interrupt to be deactivated by a guest. When such a request reaches the GIC, it knows it doesn't need to perform the deactivation anymore, an

[PATCH v3 1/4] irqchip: GICv3: Convert to EOImode == 1

2015-08-25 Thread Marc Zyngier
So far, GICv3 has been used in with EOImode == 0. The effect of this mode is to perform the priority drop and the deactivation of the interrupt at the same time. While this works perfectly for Linux (we only have a single priority), it causes issues when an interrupt is forwarded to a guest, and w

[PATCH v3 3/4] irqchip: GIC: Convert to EOImode == 1

2015-08-25 Thread Marc Zyngier
So far, GICv2 has been used with EOImode == 0. The effect of this mode is to perform the priority drop and the deactivation of the interrupt at the same time. While this works perfectly for Linux (we only have a single priority), it causes issues when an interrupt is forwarded to a guest, and when

[PATCH v3 2/4] irqchip: GICv3: Don't deactivate interrupts forwarded to a guest

2015-08-25 Thread Marc Zyngier
Commit 0a4377de3056 ("genirq: Introduce irq_set_vcpu_affinity() to target an interrupt to a VCPU") added just what we needed at the lowest level to allow an interrupt to be deactivated by a guest. When such a request reaches the GIC, it knows it doesn't need to perform the deactivation anymore, an

Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two buses

2015-08-25 Thread Michael S. Tsirkin
On Tue, Aug 25, 2015 at 05:05:47PM +0800, Jason Wang wrote: > We register wildcard mmio eventfd on two buses, one for KVM_MMIO_BUS > and another is KVM_FAST_MMIO_BUS. This leads to issue: > > - kvm_io_bus_destroy() knows nothing about the devices on two buses > points to a single dev. Which will

Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two buses

2015-08-25 Thread Michael S. Tsirkin
On Tue, Aug 25, 2015 at 05:05:47PM +0800, Jason Wang wrote: > We register wildcard mmio eventfd on two buses, one for KVM_MMIO_BUS > and another is KVM_FAST_MMIO_BUS. This leads to issue: > > - kvm_io_bus_destroy() knows nothing about the devices on two buses > points to a single dev. Which will

Re: [PATCH V3 3/3] kvm: add tracepoint for fast mmio

2015-08-25 Thread Michael S. Tsirkin
On Tue, Aug 25, 2015 at 05:05:48PM +0800, Jason Wang wrote: > Cc: Gleb Natapov > Cc: Paolo Bonzini > Cc: Michael S. Tsirkin > Signed-off-by: Jason Wang > --- > arch/x86/kvm/trace.h | 17 + > arch/x86/kvm/vmx.c | 1 + > arch/x86/kvm/x86.c | 1 + > 3 files changed, 19 inser

Re: [PATCH V2 3/3] kvm: add tracepoint for fast mmio

2015-08-25 Thread Michael S. Tsirkin
On Tue, Aug 25, 2015 at 03:47:15PM +0800, Jason Wang wrote: > Cc: Gleb Natapov > Cc: Paolo Bonzini > Cc: Michael S. Tsirkin > Signed-off-by: Jason Wang > --- > arch/x86/kvm/trace.h | 17 + > arch/x86/kvm/vmx.c | 1 + > arch/x86/kvm/x86.c | 1 + > 3 files changed, 19 inser

Re: [PATCH V2 2/3] kvm: don't register wildcard MMIO EVENTFD on two buses

2015-08-25 Thread Michael S. Tsirkin
On Tue, Aug 25, 2015 at 03:47:14PM +0800, Jason Wang wrote: > We register wildcard mmio eventfd on two buses, one for KVM_MMIO_BUS > and another is KVM_FAST_MMIO_BUS. This leads to issue: > > - kvm_io_bus_destroy() knows nothing about the devices on two buses > points to a single dev. Which will

Re: [PATCH v2 10/15] KVM: arm64: add data structures to model ITS interrupt translation

2015-08-25 Thread Andre Przywara
Hi Eric, On 13/08/15 16:46, Eric Auger wrote: > > On 07/10/2015 04:21 PM, Andre Przywara wrote: >> The GICv3 Interrupt Translation Service (ITS) uses tables in memory >> to allow a sophisticated interrupt routing. It features device tables, >> an interrupt table per device and a table connecting

Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two buses

2015-08-25 Thread Cornelia Huck
On Tue, 25 Aug 2015 17:05:47 +0800 Jason Wang wrote: > We register wildcard mmio eventfd on two buses, one for KVM_MMIO_BUS > and another is KVM_FAST_MMIO_BUS. This leads to issue: > > - kvm_io_bus_destroy() knows nothing about the devices on two buses > points to a single dev. Which will lead

Re: [PATCH v2 09/15] KVM: arm64: implement basic ITS register handlers

2015-08-25 Thread Andre Przywara
Hi Eric, >> diff --git a/virt/kvm/arm/its-emul.c b/virt/kvm/arm/its-emul.c >> index 659dd39..b498f06 100644 >> --- a/virt/kvm/arm/its-emul.c >> +++ b/virt/kvm/arm/its-emul.c >> @@ -32,10 +32,62 @@ >> #include "vgic.h" >> #include "its-emul.h" >> >> +#define BASER_BASE_ADDRESS(x) ((x) & 0xf

Re: [PATCH v2 08/15] KVM: arm64: introduce ITS emulation file with stub functions

2015-08-25 Thread Andre Przywara
Salut Eric, >> diff --git a/virt/kvm/arm/vgic-v3-emul.c b/virt/kvm/arm/vgic-v3-emul.c >> index 5269ad1..f5865e7 100644 >> --- a/virt/kvm/arm/vgic-v3-emul.c >> +++ b/virt/kvm/arm/vgic-v3-emul.c >> @@ -48,6 +48,7 @@ >> #include >> >> #include "vgic.h" >> +#include "its-emul.h" >> >> st

[PATCH v7 01/17] KVM: Extend struct pi_desc for VT-d Posted-Interrupts

2015-08-25 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 83b7b5c..271dd70 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/

[PATCH v7 02/17] KVM: Add some helper functions for Posted-Interrupts

2015-08-25 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 271dd70..316f9bf 100644 --- a/arch/x86

[PATCH v7 05/17] KVM: Add interfaces to control PI outside vmx

2015-08-25 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/kvm_h

[PATCH v7 00/17] Add VT-d Posted-Interrupts support

2015-08-25 Thread Feng Wu
VT-d Posted-Interrupts is an enhancement to CPU side Posted-Interrupt. With VT-d Posted-Interrupts enabled, external interrupts from direct-assigned devices can be delivered to guests without VMM intervention when guest is running in non-root mode. You can find the VT-d Posted-Interrtups Spec. in

[PATCH v7 03/17] KVM: Define a new interface kvm_intr_is_single_vcpu()

2015-08-25 Thread Feng Wu
This patch defines a new interface kvm_intr_is_single_vcpu(), which can returns whether the interrupt is for single-CPU or not. It is used by VT-d PI, since now we only support single-CPU interrupts, For lowest-priority interrupts, if user configures it via /proc/irq or uses irqbalance to make it

[PATCH v7 07/17] KVM: make kvm_set_msi_irq() public

2015-08-25 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/kv

[PATCH v7 06/17] KVM: Make struct kvm_irq_routing_table accessible

2015-08-25 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 | 14 ++ virt/kvm/irqchip.c | 10 -- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/linux

[PATCH v7 04/17] KVM: Get Posted-Interrupts descriptor address from 'struct kvm_vcpu'

2015-08-25 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/k

[PATCH v7 09/17] vfio: Register/unregister irq_bypass_producer

2015-08-25 Thread Feng Wu
This patch adds the registration/unregistration of an irq_bypass_producer for MSI/MSIx on vfio pci devices. v6: - Make the add_consumer and del_consumer callbacks static - Remove pointless INIT_LIST_HEAD to 'vdev->ctx[vector].producer.node)' - Use dev_info instead of WARN_ON() when irq_bypass_regi

[PATCH v7 14/17] KVM: Update Posted-Interrupts Descriptor when vCPU is preempted

2015-08-25 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_VECTOR Signed-off-by: Feng Wu -

[PATCH v7 11/17] KVM: Define two weak arch callbacks for irq bypass manager

2015-08-25 Thread Feng Wu
Define two weak arch callbacks so that archs that don't need them don't need define them. Signed-off-by: Feng Wu --- virt/kvm/eventfd.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index d7a230f..f3050b9 100644 --- a/virt/kvm/eventfd.c +

[PATCH v7 10/17] KVM: x86: Update IRTE for posted-interrupts

2015-08-25 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/x86

[PATCH v7 13/17] KVM: Add an arch specific hooks in 'struct kvm_kernel_irqfd'

2015-08-25 Thread Feng Wu
This patch adds an arch specific hooks 'arch_update' in 'struct kvm_kernel_irqfd'. On Intel side, it is used to update the IRTE when VT-d posted-interrupts is used. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/x86.c | 5 + include/linux/kvm_h

[PATCH v7 08/17] vfio: Select IRQ_BYPASS_MANAGER for vfio PCI devices

2015-08-25 Thread Feng Wu
Enable irq bypass manager for vfio PCI devices. Signed-off-by: Feng Wu --- drivers/vfio/pci/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig index 579d83b..02912f1 100644 --- a/drivers/vfio/pci/Kconfig +++ b/drivers/vfio/pci/Kconfig

[PATCH v7 12/17] KVM: Implement IRQ bypass consumer callbacks for x86

2015-08-25 Thread Feng Wu
Implement the following callbacks for x86: - kvm_arch_irq_bypass_add_producer - kvm_arch_irq_bypass_del_producer - kvm_arch_irq_bypass_stop: dummy callback - kvm_arch_irq_bypass_resume: dummy callback and set CONFIG_HAVE_KVM_IRQ_BYPASS for x86. Signed-off-by: Feng Wu --- arch/x86/include/asm/k

[PATCH v7 15/17] KVM: Update Posted-Interrupts Descriptor when vCPU is blocked

2015-08-25 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 | 5 ++ arch/

[PATCH V3 1/3] kvm: use kmalloc() instead of kzalloc() during iodev register/unregister

2015-08-25 Thread Jason Wang
All fields of kvm_io_range were initialized or copied explicitly afterwards. So switch to use kmalloc(). Cc: Gleb Natapov Cc: Paolo Bonzini Cc: Michael S. Tsirkin Signed-off-by: Jason Wang --- virt/kvm/kvm_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virt/kvm

[PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two buses

2015-08-25 Thread Jason Wang
We register wildcard mmio eventfd on two buses, one for KVM_MMIO_BUS and another is KVM_FAST_MMIO_BUS. This leads to issue: - kvm_io_bus_destroy() knows nothing about the devices on two buses points to a single dev. Which will lead double free [1] during exit. - wildcard eventfd ignores data len

[PATCH V3 3/3] kvm: add tracepoint for fast mmio

2015-08-25 Thread Jason Wang
Cc: Gleb Natapov Cc: Paolo Bonzini Cc: Michael S. Tsirkin Signed-off-by: Jason Wang --- arch/x86/kvm/trace.h | 17 + arch/x86/kvm/vmx.c | 1 + arch/x86/kvm/x86.c | 1 + 3 files changed, 19 insertions(+) diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h index 4eae7

Re: [PATCH V2 2/3] kvm: don't register wildcard MMIO EVENTFD on two buses

2015-08-25 Thread Jason Wang
On 08/25/2015 04:20 PM, Cornelia Huck wrote: > On Tue, 25 Aug 2015 15:47:14 +0800 > Jason Wang wrote: > >> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c >> index 9ff4193..95f2901 100644 >> --- a/virt/kvm/eventfd.c >> +++ b/virt/kvm/eventfd.c >> @@ -762,13 +762,15 @@ ioeventfd_check_collis

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

2015-08-25 Thread Feng Wu
Currently, we don't support urgent interrupt, all interrupts are recognized as non-urgent interrupt, so we cannot post interrupts when 'SN' is set. If the vcpu is in guest mode, it cannot have been scheduled out, and that's the only case when SN is set currently, warning if SN is set. Signed-off-

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

2015-08-25 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-parameters.txt

Re: [PATCH V2 2/3] kvm: don't register wildcard MMIO EVENTFD on two buses

2015-08-25 Thread Cornelia Huck
On Tue, 25 Aug 2015 15:47:14 +0800 Jason Wang wrote: > diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c > index 9ff4193..95f2901 100644 > --- a/virt/kvm/eventfd.c > +++ b/virt/kvm/eventfd.c > @@ -762,13 +762,15 @@ ioeventfd_check_collision(struct kvm *kvm, struct > _ioeventfd *p) > ret

[PATCH V2 1/3] kvm: use kmalloc() instead of kzalloc() during iodev register/unregister

2015-08-25 Thread Jason Wang
All fields of kvm_io_range were initialized or copied explicitly afterwards. So switch to use kmalloc(). Cc: Gleb Natapov Cc: Paolo Bonzini Cc: Michael S. Tsirkin Signed-off-by: Jason Wang --- virt/kvm/kvm_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virt/kvm

[PATCH V2 3/3] kvm: add tracepoint for fast mmio

2015-08-25 Thread Jason Wang
Cc: Gleb Natapov Cc: Paolo Bonzini Cc: Michael S. Tsirkin Signed-off-by: Jason Wang --- arch/x86/kvm/trace.h | 17 + arch/x86/kvm/vmx.c | 1 + arch/x86/kvm/x86.c | 1 + 3 files changed, 19 insertions(+) diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h index 4eae7

[PATCH V2 2/3] kvm: don't register wildcard MMIO EVENTFD on two buses

2015-08-25 Thread Jason Wang
We register wildcard mmio eventfd on two buses, one for KVM_MMIO_BUS and another is KVM_FAST_MMIO_BUS. This leads to issue: - kvm_io_bus_destroy() knows nothing about the devices on two buses points to a single dev. Which will lead double free [1] during exit. - wildcard eventfd ignores data len

Re: [PATCH 2/3] kvm: don't register wildcard MMIO EVENTFD on two buses

2015-08-25 Thread Jason Wang
On 08/25/2015 11:04 AM, Jason Wang wrote: [...] > @@ -900,10 +899,11 @@ kvm_deassign_ioeventfd(struct kvm *kvm, struct > kvm_ioeventfd *args) > if (!p->wildcard && p->datamatch != args->datamatch) > continue; > > -