Re: [PATCH v4 4/5] KVM: introduce kvm_arch functions for IRQ bypass

2015-08-10 Thread Eric Auger
On 08/07/2015 10:09 PM, Alex Williamson wrote: On Mon, 2015-08-03 at 19:20 +0200, Eric Auger wrote: This patch introduces - kvm_arch_irq_bypass_add_producer - kvm_arch_irq_bypass_del_producer - kvm_arch_irq_bypass_stop - kvm_arch_irq_bypass_start They make possible to specialize the KVM

Re: [PATCH v4 5/5] KVM: eventfd: add irq bypass consumer management

2015-08-10 Thread Eric Auger
Hi Alex, On 08/07/2015 10:09 PM, Alex Williamson wrote: On Mon, 2015-08-03 at 19:20 +0200, Eric Auger wrote: This patch adds the registration/unregistration of an irq_bypass_consumer on irqfd assignment/deassignment. Signed-off-by: Eric Auger eric.au...@linaro.org Signed-off-by: Feng Wu

[PATCH v3 01/10] VFIO: platform: registration of a dummy IRQ bypass producer

2015-08-10 Thread Eric Auger
Register a dummy producer with void callbacks Signed-off-by: Eric Auger eric.au...@linaro.org --- v2 - v3: - rename vfio_platform_irq_bypass_resume into *_start --- drivers/vfio/platform/vfio_platform_irq.c | 32 +++ drivers/vfio/platform/vfio_platform_private.h |

[PATCH v3 06/10] VFIO: platform: add irq bypass producer management

2015-08-10 Thread Eric Auger
This patch populates the IRQ bypass callacks: - stop/start producer simply consist in disabling/enabling the host irq - add/del consumer: basically set the automasked flag to false/true Signed-off-by: Eric Auger eric.au...@linaro.org --- v2 - v3: - vfio_platform_irq_bypass_add_consumer now

[PATCH v3 09/10] KVM: arm/arm64: vgic: forwarding control

2015-08-10 Thread Eric Auger
Implements kvm_vgic_[set|unset]_forward. Handle low-level VGIC programming: physical IRQ/guest IRQ mapping, list register cleanup, VGIC state machine. Also interacts with the irqchip. Signed-off-by: Eric Auger eric.au...@linaro.org --- v2 - v3: - on unforward, we do not compute output the

[PATCH v3 10/10] KVM: arm/arm64: implement IRQ bypass consumer functions

2015-08-10 Thread Eric Auger
Implement IRQ bypass callbacks for arm/arm64 IRQ forwarding: - kvm_arch_irq_bypass_add_producer: perform VGIC/irqchip settings for forwarding - kvm_arch_irq_bypass_del_producer: same for inverse operation - kvm_arch_irq_bypass_stop: halt guest execution - kvm_arch_irq_bypass_start: resume guest

[PATCH v3 07/10] KVM: arm/arm64: vgic: Allow HW interrupts for non-shared devices

2015-08-10 Thread Eric Auger
From: Marc Zyngier marc.zyng...@arm.com So far, the only use of the HW interrupt facility was the timer, implying that the active state is context-switched for each vcpu, as the device is is shared across all vcpus. This does not work for a device that has been assigned to a VM, as the guest is

[PATCH v3 05/10] VFIO: platform: add vfio_platform_is_active

2015-08-10 Thread Eric Auger
This function returns whether the IRQ is active at irqchip level or VFIO masked. If either is true, it is considered the IRQ is active. Currently there is no way to differentiate userspace masked IRQ from automasked IRQ. There might be false detection of activity. However it is currently

[PATCH v3 03/10] VFIO: platform: single handler using function pointer

2015-08-10 Thread Eric Auger
A single handler now is registered whatever the use case: automasked or not. A function pointer is set according to the wished behavior and the handler calls this function. The irq lock is taken/released in the root handler. eventfd_signal can be called in regions not allowed to sleep.

[PATCH v4 01/15] KVM: arm: plug guest debug exploit

2015-08-10 Thread Zhichao Huang
Hardware debugging in guests is not intercepted currently, it means that a malicious guest can bring down the entire machine by writing to the debug registers. This patch enable trapping of all debug registers, preventing the guests to access the debug registers. This patch also disable the

[PATCH v4 00/15] KVM: arm: debug infrastructure support

2015-08-10 Thread Zhichao Huang
This patch series adds debug support, a key feature missing from the KVM/armv7 port. The main idea is to keep track of whether the host and the guest have any break/watch points enabled or not. We only do the world switch for debug registers when the host or the guest is actually using it. We

[PATCH v4 02/15] KVM: arm: rename pm_fake handler to trap_raz_wi

2015-08-10 Thread Zhichao Huang
pm_fake doesn't quite describe what the handler does (ignoring writes and returning 0 for reads). As we're about to use it (a lot) in a different context, rename it with a (admitedly cryptic) name that make sense for all users. Signed-off-by: Zhichao Huang zhichao.hu...@linaro.org Reviewed-by:

[PATCH v4 03/15] KVM: arm: enable to use the ARM_DSCR_MDBGEN macro from KVM assembly code

2015-08-10 Thread Zhichao Huang
Add #ifndef __ASSEMBLY__ in hw_breakpoint.h, in order to use the ARM_DSCR_MDBGEN macro from KVM assembly code. Signed-off-by: Zhichao Huang zhichao.hu...@linaro.org Reviewed-by: Alex Bennee alex.ben...@linaro.org Acked-by: Christoffer Dall christoffer.d...@linaro.org ---

[PATCH v4 08/15] KVM: arm: add a trace event for cp14 traps

2015-08-10 Thread Zhichao Huang
There are too many cp15 traps, so we don't reuse the cp15 trace event but add a new trace event to trace the access of debug registers. Signed-off-by: Zhichao Huang zhichao.hu...@linaro.org Acked-by: Christoffer Dall christoffer.d...@linaro.org --- arch/arm/kvm/coproc.c | 14 ++

[PATCH v4 06/15] KVM: arm: add trap handlers for 32-bit debug registers

2015-08-10 Thread Zhichao Huang
Add handlers for all the 32-bit debug registers. Signed-off-by: Zhichao Huang zhichao.hu...@linaro.org --- arch/arm/include/asm/kvm_asm.h | 12 arch/arm/include/asm/kvm_host.h | 3 + arch/arm/kernel/asm-offsets.c | 1 + arch/arm/kvm/coproc.c | 124

[PATCH v4 14/15] KVM: arm: implement lazy world switch for debug registers

2015-08-10 Thread Zhichao Huang
Avoid world-switching all the debug registers when neither the host nor the guest has configured any [WB]points. Signed-off-by: Zhichao Huang zhichao.hu...@linaro.org --- arch/arm/kvm/interrupts_head.S | 23 +-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git

[PATCH v4 15/15] KVM: arm: enable trapping of all debug registers

2015-08-10 Thread Zhichao Huang
Enable trapping of the debug registers unconditionally, allowing guests to use the debug infrastructure. Signed-off-by: Zhichao Huang zhichao.hu...@linaro.org Reviewed-by: Christoffer Dall christoffer.d...@linaro.org --- arch/arm/kvm/interrupts_head.S | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH v5 0/5] KVM: irqfd consumer based on IRQ bypass manager

2015-08-10 Thread Eric Auger
This series transforms irqfd into an IRQ bypass consumer and introduce the infrastructure shared by Intel posted-interrupts and ARM forwarded IRQ series. The bypass manager gets compiled for x86 and arm/arm64 when KVM is used. A new kvm_irqfd.h header is created to externalize some irqfd

[PATCH v5 3/5] KVM: create kvm_irqfd.h

2015-08-10 Thread Eric Auger
Move _irqfd_resampler and _irqfd struct declarations in a new public header: kvm_irqfd.h. They are respectively renamed into kvm_kernel_irqfd_resampler and kvm_kernel_irqfd. Those datatypes will be used by architecture specific code, in the context of IRQ bypass manager integration.

[PATCH v5 5/5] KVM: eventfd: add irq bypass consumer management

2015-08-10 Thread Eric Auger
This patch adds the registration/unregistration of an irq_bypass_consumer on irqfd assignment/deassignment. Signed-off-by: Eric Auger eric.au...@linaro.org Signed-off-by: Feng Wu feng...@intel.com --- v4 - v5: - due to removal of static inline stubs, add #ifdef CONFIG_HAVE_KVM_IRQ_BYPASS

[PATCH v5 2/5] KVM: arm/arm64: select IRQ_BYPASS_MANAGER

2015-08-10 Thread Eric Auger
Select IRQ_BYPASS_MANAGER when CONFIG_KVM is set Also add compilation of virt/lib. Signed-off-by: Eric Auger eric.au...@linaro.org Signed-off-by: Feng Wu feng...@intel.com --- v3 - v4: - add compilation of virt/lib in arm/arm64 KVM v2 - v3: - [Feng Wu] Correct a typo in

[PATCH v4 04/15] KVM: arm: common infrastructure for handling AArch32 CP14/CP15

2015-08-10 Thread Zhichao Huang
As we're about to trap a bunch of CP14 registers, let's rework the CP15 handling so it can be generalized and work with multiple tables. We stop trapping access here, because we haven't finished our trap handlers. We will enable trapping agian until everything is OK. Signed-off-by: Zhichao Huang

[PATCH v4 12/15] KVM: arm: keep track of host use of the debug registers

2015-08-10 Thread Zhichao Huang
Every guest entry, we need to keep track of host use of the debug registers. We only call the function upon guest entry, after preempt_disable() and local_irq_disable(), so there is no race for it. Signed-off-by: Zhichao Huang zhichao.hu...@linaro.org --- arch/arm/include/asm/kvm_asm.h| 3

[PATCH v4 13/15] KVM: arm: keep track of guest use of the debug registers

2015-08-10 Thread Zhichao Huang
We trap debug register accesses from guest all the time, and read the BCR/WCR to indicate whether the guest has enabled any break/watch points or not. Signed-off-by: Zhichao Huang zhichao.hu...@linaro.org --- arch/arm/include/asm/kvm_asm.h | 2 ++ arch/arm/kvm/coproc.c | 75

[PATCH v4 11/15] KVM: arm: add a function to keep track of host use of the debug registers

2015-08-10 Thread Zhichao Huang
As we're about to implement a lazy world switch for debug registers, we add a function reading the break/watch control variables directly to indicate whether the host has enabled any break/watch points or not. Signed-off-by: Zhichao Huang zhichao.hu...@linaro.org ---