Re: [kvm-unit-tests PATCH] arm64: add micro test

2017-12-19 Thread Christoffer Dall
On Mon, Dec 18, 2017 at 08:31:21PM +0300, Yury Norov wrote: > On Fri, Dec 15, 2017 at 04:15:39PM -0500, Shih-Wei Li wrote: > > Here we provide the support for measuring various micro level > > operations on arm64. We iterate each of the tests for millions of > > times and output their average, mini

Re: [kvm-unit-tests PATCH] Support micro operation measurement on arm64

2017-12-19 Thread Christoffer Dall
On Mon, Dec 18, 2017 at 03:58:49PM -0500, Shih-Wei Li wrote: > On Mon, Dec 18, 2017 at 1:14 PM, Andrew Jones wrote: > > Hi Shih-Wei, > > > > Thanks for doing this! Porting Christoffer's selftests to kvm-unit-tests > > has been on the kvm-unit-tests' TODO list since it was first introduced. > > > >

[PULL 1/5] arm64: kvm: Prevent restoring stale PMSCR_EL1 for vcpu

2017-12-18 Thread Christoffer Dall
read during the first save. Make sure __debug_save_spe_nvhe clears the value of the saved PMSCR_EL1 when the guest cannot use SPE. Signed-off-by: Julien Thierry Cc: Christoffer Dall Cc: Marc Zyngier Cc: Catalin Marinas Cc: Reviewed-by: Will Deacon Reviewed-by: Christoffer Dall Signed-off-by

[PULL 2/5] KVM: arm/arm64: Fix HYP unmapping going off limits

2017-12-18 Thread Christoffer Dall
high_memory is defined as the linear map address of the last byte of DRAM, plus one. The size of the vmalloc region is given trivially by VMALLOC_END - VMALLOC_START. Cc: sta...@vger.kernel.org Reported-by: Andre Przywara Tested-by: Andre Przywara Reviewed-by: Christoffer Dall Signed-off-by: Marc Zyngier

[PULL 4/5] KVM: arm/arm64: Properly handle arch-timer IRQs after vtimer_save_state

2017-12-18 Thread Christoffer Dall
arify the intention of the implementation, and reduce the risk of unwanted interrupts. Fixes: b103cc3f10c0 ("KVM: arm/arm64: Avoid timer save/restore in vcpu entry/exit") Reported-by: Marc Zyngier Reported-by: Jia He Reviewed-by: Marc Zyngier Tested-by: Marc Zyngier Signed-off-by: C

[PULL 0/5] KVM/ARM Fixes for v4.15 - Round 2

2017-12-18 Thread Christoffer Dall
ou to fetch changes up to 0eb7c33cadf6b2f1a94e58ded8b0eb89b4eba382: KVM: arm/arm64: Fix timer enable flow (2017-12-18 10:53:24 +0100) Thanks, -Christoffer Christoffer Dall (2): KVM: arm/arm64: Properly handle arch-timer IRQs after vtimer_save_state KVM: arm/arm64: Fix timer enable

[PULL 5/5] KVM: arm/arm64: Fix timer enable flow

2017-12-18 Thread Christoffer Dall
timer state when enabling the timer") Reported-by: Marc Zyngier Reviewed-by: Marc Zyngier Tested-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/arch_timer.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/ar

[PULL 3/5] KVM: arm/arm64: timer: Don't set irq as forwarded if no usable GIC

2017-12-18 Thread Christoffer Dall
From: Marc Zyngier If we don't have a usable GIC, do not try to set the vcpu affinity as this is guaranteed to fail. Reported-by: Andre Przywara Reviewed-by: Andre Przywara Tested-by: Andre Przywara Reviewed-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Christoffer

Re: [PATCH v2 26/36] KVM: arm64: Defer saving/restoring system registers to vcpu load/put on VHE

2017-12-15 Thread Christoffer Dall
On Mon, Dec 11, 2017 at 01:20:03PM +, Marc Zyngier wrote: > On 07/12/17 17:06, Christoffer Dall wrote: > > Some system registers do not affect the host kernel's execution and can > > therefore be loaded when we are about to run a VCPU and we don't have to > >

[PATCH 1/2] KVM: arm/arm64: Properly handle arch-timer IRQs after vtimer_save_state

2017-12-15 Thread Christoffer Dall
arify the intention of the implementation, and reduce the risk of unwanted interrupts. Fixes: b103cc3f10c0 ("KVM: arm/arm64: Avoid timer save/restore in vcpu entry/exit") Reported-by: Marc Zyngier Reported-by: Jia He Signed-off-by: Christoffer Dall --- virt/kvm/arm/ar

[PATCH 0/2] KVM: arm/arm64: Fix two problems with the arch timer introduced in v4.15-rc1

2017-12-15 Thread Christoffer Dall
r platform. Thanks, -Christoffer Christoffer Dall (2): KVM: arm/arm64: Properly handle arch-timer IRQs after vtimer_save_state KVM: arm/arm64: Fix timer enable flow virt/kvm/arm/arch_timer.c | 27 --- 1 file changed, 16 insertions(+), 11 deletions(-)

[PATCH 2/2] KVM: arm/arm64: Fix timer enable flow

2017-12-15 Thread Christoffer Dall
timer state when enabling the timer") Reported-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/arch_timer.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 14c018f990a7..cc29a8148328 100644

Re: [PATCH] KVM: arm/arm64: don't set vtimer->cnt_ctl in kvm_arch_timer_handler

2017-12-15 Thread Christoffer Dall
On Fri, Dec 15, 2017 at 10:33:48AM +, Marc Zyngier wrote: > On 15/12/17 10:10, Christoffer Dall wrote: > > On Fri, Dec 15, 2017 at 09:09:05AM +, Marc Zyngier wrote: > >> On 15/12/17 02:27, Jia He wrote: > >>> > >>> > >> >

Re: [PATCH] KVM: arm/arm64: don't set vtimer->cnt_ctl in kvm_arch_timer_handler

2017-12-15 Thread Christoffer Dall
On Fri, Dec 15, 2017 at 09:09:05AM +, Marc Zyngier wrote: > On 15/12/17 02:27, Jia He wrote: > > > > > > [...] > > >> @@ -367,6 +368,7 @@ static void vtimer_save_state(struct kvm_vcpu *vcpu) > >> > >>/* Disable the virtual timer */ > >>write_sysreg_el0(0, cntv_ctl); > >> + isb()

Re: [PATCH] KVM: arm/arm64: don't set vtimer->cnt_ctl in kvm_arch_timer_handler

2017-12-15 Thread Christoffer Dall
+if (kvm_timer_irq_can_fire(cnt_ctl)) > > kvm_timer_update_irq(vcpu, true, vtimer); > IIUC, your patch makes kvm_arch_timer_handler never changesvtimer->cnt_ctl Yes, that's the idea. Meanwhile, I think I thought of a cleaner way to do this. Could you test the foll

Re: [PATCH] KVM: arm/arm64: don't set vtimer->cnt_ctl in kvm_arch_timer_handler

2017-12-14 Thread Christoffer Dall
On Thu, Dec 14, 2017 at 11:28:04PM +0800, Jia He wrote: > > On 12/14/2017 9:09 PM, Christoffer Dall Wrote: > >On Thu, Dec 14, 2017 at 12:57:54PM +0800, Jia He wrote: > >Hi Jia, > > > >>I have tried your newer level-mapped-v7 branch, but bug is still there. >

Re: [PATCH v2 20/36] KVM: arm64: Don't save the host ELR_EL2 and SPSR_EL2 on VHE systems

2017-12-14 Thread Christoffer Dall
On Mon, Dec 11, 2017 at 10:44:59AM +, Marc Zyngier wrote: > On 07/12/17 17:06, Christoffer Dall wrote: > > On non-VHE systems we need to save the ELR_EL2 and SPSR_EL2 so that we > > can return to the host in EL1 in the same state and location where we > > issued a hyperc

Re: [PATCH] KVM: arm/arm64: don't set vtimer->cnt_ctl in kvm_arch_timer_handler

2017-12-14 Thread Christoffer Dall
On Thu, Dec 14, 2017 at 12:57:54PM +0800, Jia He wrote: Hi Jia, > > I have tried your newer level-mapped-v7 branch, but bug is still there. > > There is no special load in both host and guest. The guest (kernel > 4.14) is often hanging when booting > > the guest kernel log > > [ OK ] Reached t

Re: [PATCH v2 15/36] KVM: arm64: Move userspace system registers into separate function

2017-12-14 Thread Christoffer Dall
On Mon, Dec 11, 2017 at 10:14:23AM +, Marc Zyngier wrote: > On 07/12/17 17:06, Christoffer Dall wrote: > > There's a semantic difference between the EL1 registers that control > > operation of a kernel running in EL1 and EL1 registers that only control > > userspace e

Re: [PATCH v2 14/36] KVM: arm64: Remove noop calls to timer save/restore from VHE switch

2017-12-14 Thread Christoffer Dall
On Mon, Dec 11, 2017 at 10:02:58AM +, Marc Zyngier wrote: > On 07/12/17 17:06, Christoffer Dall wrote: > > The VHE switch function calls __timer_enable_traps and > > __timer_disable_traps which don't do anything on VHE systems. > > Therefore, simply remove these

Re: [PATCH v2 11/36] KVM: arm64: Introduce VHE-specific kvm_vcpu_run

2017-12-14 Thread Christoffer Dall
On Mon, Dec 11, 2017 at 09:53:13AM +, Marc Zyngier wrote: > On 07/12/17 17:06, Christoffer Dall wrote: > > So far this is just a copy of the legacy non-VHE switch function, where > > we only change the existing calls to has_vhe() in both the original and > > new functions

[PATCH v8 4/9] KVM: arm/arm64: vgic: Support level-triggered mapped interrupts

2017-12-13 Thread Christoffer Dall
st with an injected timer interrupt. Reviewed-by: Marc Zyngier Reviewed-by: Eric Auger Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-v2.c | 29 + virt/kvm/arm/vgic/vgic-v3.c | 29 + virt/kvm/arm/vgic/vgic

[PATCH v8 9/9] KVM: arm/arm64: Update timer and forwarded irq documentation

2017-12-13 Thread Christoffer Dall
Now when we've reworked how mapped level-triggered interrupts are processed for the timer interrupts, we update the documentation correspondingly. Signed-off-by: Christoffer Dall --- Documentation/virtual/kvm/arm/vgic-mapped-irqs.txt | 50 ++ 1 file changed, 23 inser

[PATCH v8 2/9] KVM: arm/arm64: Factor out functionality to get vgic mmio requester_vcpu

2017-12-13 Thread Christoffer Dall
document the semantics of the return value. Also take the chance to move the functionality outside of holding a spinlock and instead explicitly disable and enable preemption. This supports PREEMPT_RT kernels as well. Acked-by: Marc Zyngier Reviewed-by: Andre Przywara Signed-off-by: Christoffer

[PATCH v8 8/9] KVM: arm/arm64: Avoid work when userspace iqchips are not used

2017-12-13 Thread Christoffer Dall
Auger Signed-off-by: Christoffer Dall --- virt/kvm/arm/arch_timer.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index f8d09665ddce..73d262c4712b 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_ti

[PATCH v8 1/9] KVM: arm/arm64: Remove redundant preemptible checks

2017-12-13 Thread Christoffer Dall
o for other uses of per cpu variables either). Acked-by: Marc Zyngier Reviewed-by: Andre Przywara Signed-off-by: Christoffer Dall --- virt/kvm/arm/arm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index a6524ff27de4..859ff7e3a1eb 100644 --- a/vir

[PATCH v8 7/9] KVM: arm/arm64: Provide a get_input_level for the arch timer

2017-12-13 Thread Christoffer Dall
f the virtual interrupt is active, and otherwise we simply let the timer fire again and raise the virtual interrupt from the ISR. Reviewed-by: Eric Auger Signed-off-by: Christoffer Dall --- include/kvm/arm_arch_timer.h | 2 ++ virt/kvm/arm/arch_timer.c

[PATCH v8 0/9] Handle forwarded level-triggered interrupts

2017-12-13 Thread Christoffer Dall
ndling of guest MMIO accesses to the virtual distributor (Patch 4) - Addressed Marc's comments from the initial RFC (mostly renames) Thanks, -Christoffer [1]: https://lists.cs.columbia.edu/pipermail/kvmarm/2017-June/026072.html Christoffer Dall (9): KVM: arm/arm64: Remove redundant pree

[PATCH v8 5/9] KVM: arm/arm64: Support a vgic interrupt line level sample function

2017-12-13 Thread Christoffer Dall
to the good old method of poking the physical GIC if no callback is provided. Reviewed-by: Marc Zyngier Reviewed-by: Eric Auger Signed-off-by: Christoffer Dall --- include/kvm/arm_vgic.h| 13 - virt/kvm/arm/arch_timer.c | 3 ++- virt/kvm/arm/vgic/vgic.c | 13 + 3

[PATCH v8 6/9] KVM: arm/arm64: Support VGIC dist pend/active changes for mapped IRQs

2017-12-13 Thread Christoffer Dall
of mapped interrupts from userspace is not supported, and it's expected that userspace unmaps devices from VFIO before attempting to set the interrupt state, because the interrupt state is driven by hardware. Reviewed-by: Marc Zyngier Reviewed-by: Eric Auger Signed-off-by: Christoffer

[PATCH v8 3/9] KVM: arm/arm64: Don't cache the timer IRQ level

2017-12-13 Thread Christoffer Dall
the line level should be asserted from the timer ISR. The VGIC can ignore extra notifications using its validate mechanism. Reviewed-by: Andre Przywara Signed-off-by: Christoffer Dall --- virt/kvm/arm/arch_timer.c | 20 +--- 1 file changed, 13 insertions(+), 7 deletions(-) di

Re: [PATCH] KVM: arm/arm64: don't set vtimer->cnt_ctl in kvm_arch_timer_handler

2017-12-13 Thread Christoffer Dall
On Wed, Dec 13, 2017 at 10:27 AM, Marc Zyngier wrote: > On 13/12/17 09:08, Auger Eric wrote: >> Marc, >> On 13/12/17 09:56, Marc Zyngier wrote: >>> Hi Jia, >>> >>> On 13/12/17 07:00, Jia He wrote: In our Armv8a server (qualcomm Amberwing, non VHE), after applying Christoffer's timer opti

Re: [PATCH] KVM: arm/arm64: don't set vtimer->cnt_ctl in kvm_arch_timer_handler

2017-12-13 Thread Christoffer Dall
On Wed, Dec 13, 2017 at 08:56:12AM +, Marc Zyngier wrote: > Hi Jia, > > On 13/12/17 07:00, Jia He wrote: > > In our Armv8a server (qualcomm Amberwing, non VHE), after applying > > Christoffer's timer optimizing patchset(Optimize arch timer register > > handling), the guest is hang during kerne

Re: [PATCH] KVM: arm/arm64: don't set vtimer->cnt_ctl in kvm_arch_timer_handler

2017-12-13 Thread Christoffer Dall
On Tue, Dec 12, 2017 at 11:00:07PM -0800, Jia He wrote: > In our Armv8a server (qualcomm Amberwing, non VHE), after applying > Christoffer's timer optimizing patchset(Optimize arch timer register > handling), the guest is hang during kernel booting. > > The error root cause might be as follows: >

Re: [PATCH v7 3/8] KVM: arm/arm64: Don't cache the timer IRQ level

2017-12-12 Thread Christoffer Dall
On Tue, Dec 12, 2017 at 09:40:10AM +0100, Auger Eric wrote: > > > On 11/12/17 21:51, Auger Eric wrote: > > Hi Christoffer, > > On 07/12/17 11:54, Christoffer Dall wrote: > >> The timer was modeled after a strict idea of modelling an interrupt line > >&g

Re: [PATCH v2 22/36] KVM: arm64: Prepare to handle traps on deferred VM sysregs

2017-12-12 Thread Christoffer Dall
On Tue, Dec 12, 2017 at 01:08:30PM +, Marc Zyngier wrote: > On 11/12/17 11:24, Christoffer Dall wrote: > > On Mon, Dec 11, 2017 at 11:10:36AM +, Marc Zyngier wrote: > >> On 07/12/17 17:06, Christoffer Dall wrote: > >>> When we defer the save/restore of sys

Re: [RFC] KVM API extensions for SVE

2017-12-11 Thread Christoffer Dall
On Mon, Dec 11, 2017 at 02:51:36PM +, Dave Martin wrote: > On Fri, Nov 24, 2017 at 03:45:38PM +0100, Christoffer Dall wrote: > > On Thu, Nov 23, 2017 at 06:40:50PM +, Dave Martin wrote: > > > On Wed, Nov 22, 2017 at 08:52:30PM +0100, Christoffer Dall wrot

Re: [PATCH v2 00/36] Optimize KVM/ARM for VHE systems

2017-12-11 Thread Christoffer Dall
Hi Yury, On Mon, Dec 11, 2017 at 05:43:23PM +0300, Yury Norov wrote: > > On Thu, Dec 07, 2017 at 06:05:54PM +0100, Christoffer Dall wrote: > > This series redesigns parts of KVM/ARM to optimize the performance on > > VHE systems. The general approach is to try to do

Re: [PATCH v3 14/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl

2017-12-11 Thread Christoffer Dall
On Mon, Dec 11, 2017 at 02:12:41PM +0100, Cornelia Huck wrote: > On Mon, 4 Dec 2017 21:35:36 +0100 > Christoffer Dall wrote: > > > From: Christoffer Dall > > > > Move the calls to vcpu_load() and vcpu_put() in to the architecture > > specific implementatio

Re: [PATCH v3 11/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_guest_debug

2017-12-11 Thread Christoffer Dall
On Mon, Dec 11, 2017 at 01:39:43PM +0100, Cornelia Huck wrote: > On Mon, 4 Dec 2017 21:35:33 +0100 > Christoffer Dall wrote: > > > From: Christoffer Dall > > > > Move vcpu_load() and vcpu_put() into the architecture specific > > implementations of kv

Re: [PATCH v2 22/36] KVM: arm64: Prepare to handle traps on deferred VM sysregs

2017-12-11 Thread Christoffer Dall
On Mon, Dec 11, 2017 at 11:10:36AM +, Marc Zyngier wrote: > On 07/12/17 17:06, Christoffer Dall wrote: > > When we defer the save/restore of system registers to vcpu_load and > > vcpu_put, we need to take care of the emulation code that handles traps > > to these re

Re: [PATCH v2 06/36] KVM: arm64: Defer restoring host VFP state to vcpu_put

2017-12-11 Thread Christoffer Dall
On Sat, Dec 09, 2017 at 05:37:53PM +, Marc Zyngier wrote: > On Thu, 07 Dec 2017 17:06:00 +, > Christoffer Dall wrote: > > > > Avoid saving the guest VFP registers and restoring the host VFP > > registers on every exit from the VM. Only when we're about

Re: [PATCH v2 01/36] KVM: arm64: Avoid storing the vcpu pointer on the stack

2017-12-11 Thread Christoffer Dall
On Sat, Dec 09, 2017 at 05:19:41PM +, Marc Zyngier wrote: > On Thu, 07 Dec 2017 17:05:55 +, > Christoffer Dall wrote: > > > > We already have the percpu area for the host cpu state, which points to > > the VCPU, so there's no need to store the VCPU poin

Re: [PATCH v3 07/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_sregs

2017-12-11 Thread Christoffer Dall
On Fri, Dec 08, 2017 at 05:26:02PM +0100, David Hildenbrand wrote: > > > > > int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs > > *regs) > > diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c > > index f647e121070e..cdf0be02c95a 100644 > > --- a/arch/powerp

Re: [PATCH] KVM: arm/arm64: timer: Don't set irq as forwarded if no usable GIC

2017-12-11 Thread Christoffer Dall
On Thu, Dec 07, 2017 at 11:46:15AM +, Marc Zyngier wrote: > If we don't have a usable GIC, do not try to set the vcpu affinity > as this is guaranteed to fail. Reviewed-by: Christoffer Dall ... and applied. Thanks for fixing my broken code, -Christoffer > > Reported-b

Re: [PATCH] KVM: arm/arm64: Fix HYP unmapping going off limits

2017-12-11 Thread Christoffer Dall
OC_END - VMALLOC_START. Otherwise: Reviewed-by: Christoffer Dall > > Cc: sta...@vger.kernel.org > Reported-by: Andre Przywara > Signed-off-by: Marc Zyngier > --- > virt/kvm/arm/mmu.c | 10 -- > 1 file changed, 4 insertions(+), 6 deletions(-) > > d

[PATCH v2 35/36] KVM: arm/arm64: Move VGIC APR save/restore to vgic put/load

2017-12-07 Thread Christoffer Dall
for migration. To make sure this works, factor out the APR save/restore functionality into separate functions called from the VCPU (and by extension VGIC) put/load hooks. Signed-off-by: Christoffer Dall --- arch/arm/include/asm/kvm_hyp.h | 2 + arch/arm64/include/asm/kvm_hyp.h | 2 + virt

[PATCH v2 27/36] KVM: arm64: Move common VHE/non-VHE trap config in separate functions

2017-12-07 Thread Christoffer Dall
: Christoffer Dall --- arch/arm64/kvm/hyp/switch.c | 72 - 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index 2ac8af354de0..c01bcfc3fb52 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b

[PATCH v2 28/36] KVM: arm64: Configure FPSIMD traps on vcpu load/put for VHE

2017-12-07 Thread Christoffer Dall
these during vcpu load/put. Signed-off-by: Christoffer Dall --- arch/arm64/include/asm/kvm_hyp.h | 3 +++ arch/arm64/kvm/hyp/switch.c | 34 -- arch/arm64/kvm/hyp/sysreg-sr.c | 4 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/arch/arm64

[PATCH v2 25/36] KVM: arm64: Prepare to handle traps on deferred AArch32 sysregs

2017-12-07 Thread Christoffer Dall
Handle accesses to any AArch32 EL1 system registers where we can defer saving and restoring them to vcpu_load and vcpu_put, and which are stored in special EL2 registers only used support 32-bit guests. Signed-off-by: Christoffer Dall --- arch/arm64/include/asm/kvm_emulate.h | 9 - 1

[PATCH v2 33/36] KVM: arm/arm64: Move arm64-only vgic-v2-sr.c file to arm64

2017-12-07 Thread Christoffer Dall
remove the ifdef in the C file. Reviewed-by: Andre Przywara Signed-off-by: Christoffer Dall --- arch/arm/kvm/hyp/Makefile | 1 - arch/arm64/kvm/hyp/Makefile | 2 +- {virt/kvm/arm => arch/arm64/kvm}/hyp/vgic-v2-sr.c | 2 -- 3 files changed, 1 insert

[PATCH v2 29/36] KVM: arm64: Configure c15, PMU, and debug register traps on cpu load/put for VHE

2017-12-07 Thread Christoffer Dall
while executing KVM kernel code and KVM doesn't use floating point itself. Signed-off-by: Christoffer Dall --- arch/arm64/kvm/hyp/switch.c | 35 ++- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hy

[PATCH v2 30/36] KVM: arm64: Separate activate_traps and deactive_traps for VHE and non-VHE

2017-12-07 Thread Christoffer Dall
To make the code more readable and to avoid the overhead of a function call, let's get rid of a pair of the alternative function selectors and explicitly call the VHE and non-VHE functions instead, telling the compiler to try to inline the static function if it can. Signed-off-by: Christ

[PATCH v2 31/36] KVM: arm/arm64: Get rid of vgic_elrsr

2017-12-07 Thread Christoffer Dall
the endianness conversion in the VGIC save function, which is completely unnecessary and would actually result in incorrect functionality on big-endian systems, because we are only using typed values here and not converting pointers and reading different types here. Signed-off-by: Christoffer Dall

[PATCH v2 22/36] KVM: arm64: Prepare to handle traps on deferred VM sysregs

2017-12-07 Thread Christoffer Dall
from the physical CPU when we're on a VHE system that has loaded the system registers onto the physical CPU. Signed-off-by: Christoffer Dall --- Notes: Changes since v1: - Removed spurious white space arch/arm64/include/asm/kvm_host.h | 4 +++ arch/arm64/kvm/sys_regs.c

[PATCH v2 32/36] KVM: arm/arm64: Handle VGICv2 save/restore from the main VGIC code

2017-12-07 Thread Christoffer Dall
We can program the GICv2 hypervisor control interface logic directly from the core vgic code and can instead do the save/restore directly from the flush/sync functions, which can lead to a number of future optimizations. Signed-off-by: Christoffer Dall --- Notes: Changes since v1

[PATCH v2 23/36] KVM: arm64: Prepare to handle traps on deferred EL0 sysregs

2017-12-07 Thread Christoffer Dall
We can trap access to ACTLR_EL1 which we can later defer to only save/restore during vcpu_load and vcpu_put, so let's read the value directly from the CPU when necessary. Signed-off-by: Christoffer Dall --- Notes: Changes since v1: - Fix bug in access_actlr that read the actlr_el

[PATCH v2 24/36] KVM: arm64: Prepare to handle traps on remaining deferred EL1 sysregs

2017-12-07 Thread Christoffer Dall
Handle accesses during traps to any remaining EL1 registers which can be deferred to vcpu_load and vcpu_put, by either accessing them directly on the physical CPU when the latest version is stored there, or by synchronizing the memory representation with the CPU state. Signed-off-by: Christoffer

[PATCH v2 26/36] KVM: arm64: Defer saving/restoring system registers to vcpu load/put on VHE

2017-12-07 Thread Christoffer Dall
t can be deferred to vcpu_load and vcpu_put, respectively. We have already prepared the trap handling code which accesses any of these registers to directly access the registers on the physical CPU or to sync the registers when needed. Signed-off-by: Christoffer Dall --- arch/arm64/kvm/hyp/switch.c

[PATCH v2 34/36] KVM: arm/arm64: Handle VGICv3 save/restore from the main VGIC code on VHE

2017-12-07 Thread Christoffer Dall
function calls from the VHE world switch function. Signed-off-by: Christoffer Dall --- arch/arm64/kvm/hyp/switch.c | 3 --- virt/kvm/arm/vgic/vgic.c| 5 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index

[PATCH v2 36/36] KVM: arm/arm64: Avoid VGICv3 save/restore on VHE with no IRQs

2017-12-07 Thread Christoffer Dall
when running in the host), and doing the configuration on every round-trip on non-VHE systems. Signed-off-by: Christoffer Dall --- arch/arm/include/asm/kvm_hyp.h | 2 + arch/arm/kvm/hyp/switch.c| 8 ++- arch/arm64/include/asm/kvm_hyp.h | 2 + arch/arm64/kvm/hyp/switch.c | 8

[PATCH v2 16/36] KVM: arm64: Rewrite sysreg alternatives to static keys

2017-12-07 Thread Christoffer Dall
As we are about to move calls around in the sysreg save/restore logic, let's first rewrite the alternative function callers, because it is going to make the next patches much easier to read. Signed-off-by: Christoffer Dall --- arch/arm64/kvm/hyp/sysreg-sr.c | 17 - 1

[PATCH v2 21/36] KVM: arm64: Change 32-bit handling of VM system registers

2017-12-07 Thread Christoffer Dall
much easier when we have to start accessing system registers that use deferred save/restore and might have to be read directly from the physical CPU. Reviewed-by: Andrew Jones Signed-off-by: Christoffer Dall --- arch/arm64/include/asm/kvm_host.h | 8 arch/arm64/kvm/sys_regs.c | 20

[PATCH v2 17/36] KVM: arm64: Introduce separate VHE/non-VHE sysreg save/restore functions

2017-12-07 Thread Christoffer Dall
VHE and non-VHE functionality now that we have separate functions. Reviewed-by: Andrew Jones Signed-off-by: Christoffer Dall --- arch/arm64/include/asm/kvm_hyp.h | 12 arch/arm64/kvm/hyp/switch.c | 20 ++-- arch/arm64/kvm/hyp/sysreg-sr.c | 40

[PATCH v2 12/36] KVM: arm64: Remove kern_hyp_va() use in VHE switch function

2017-12-07 Thread Christoffer Dall
VHE kernels run completely in EL2 and therefore don't have a notion of kernel and hyp addresses, they are all just kernel addresses. Therefore don't call kern_hyp_va() in the VHE switch function. Reviewed-by: Andrew Jones Signed-off-by: Christoffer Dall --- arch/arm64/kvm/hyp/sw

[PATCH v2 14/36] KVM: arm64: Remove noop calls to timer save/restore from VHE switch

2017-12-07 Thread Christoffer Dall
ff-by: Christoffer Dall --- arch/arm64/kvm/hyp/switch.c | 2 -- virt/kvm/arm/hyp/timer-sr.c | 36 ++-- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index e783e2371b7c..09aafa0470f7 100644

[PATCH v2 13/36] KVM: arm64: Don't deactivate VM on VHE systems

2017-12-07 Thread Christoffer Dall
There is no need to reset the VTTBR to zero when exiting the guest on VHE systems. VHE systems don't use stage 2 translations for the EL2&0 translation regime used by the host. Reviewed-by: Andrew Jones Signed-off-by: Christoffer Dall --- Notes: Changes since v1:

[PATCH v2 18/36] KVM: arm/arm64: Remove leftover comment from kvm_vcpu_run_vhe

2017-12-07 Thread Christoffer Dall
The comment only applied to SPE on non-VHE systems, so we simply remove it. Suggested-by: Andrew Jones Signed-off-by: Christoffer Dall --- arch/arm64/kvm/hyp/switch.c | 4 1 file changed, 4 deletions(-) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index

[PATCH v2 19/36] KVM: arm64: Unify non-VHE host/guest sysreg save and restore functions

2017-12-07 Thread Christoffer Dall
e the other into simply save/restore. Reviewed-by: Andrew Jones Signed-off-by: Christoffer Dall --- arch/arm64/include/asm/kvm_hyp.h | 6 ++ arch/arm64/kvm/hyp/switch.c | 10 +- arch/arm64/kvm/hyp/sysreg-sr.c | 18 ++ 3 files changed, 9 insertions(+), 25 dele

[PATCH v2 15/36] KVM: arm64: Move userspace system registers into separate function

2017-12-07 Thread Christoffer Dall
e the function saving/restoring the remaining system register to make it clear this function deals with the EL1 system registers. No functional change. Reviewed-by: Andrew Jones Signed-off-by: Christoffer Dall --- Notes: Changes since v1: - Added comment about sp_el0 to common save sysreg

[PATCH v2 11/36] KVM: arm64: Introduce VHE-specific kvm_vcpu_run

2017-12-07 Thread Christoffer Dall
So far this is just a copy of the legacy non-VHE switch function, where we only change the existing calls to has_vhe() in both the original and new functions. Signed-off-by: Christoffer Dall --- Notes: Changes since v1: - Rename kvm_vcpu_run to kvm_vcpu_run_vhe and rename

[PATCH v2 20/36] KVM: arm64: Don't save the host ELR_EL2 and SPSR_EL2 on VHE systems

2017-12-07 Thread Christoffer Dall
these registers into separate save/restore functions, making it easy to exclude them from the VHE world-switch path later on. Signed-off-by: Christoffer Dall --- arch/arm64/kvm/hyp/sysreg-sr.c | 13 + 1 file changed, 13 insertions(+) diff --git a/arch/arm64/kvm/hyp/sysreg-sr.c b/arch/

[PATCH v2 08/36] KVM: arm64: Slightly improve debug save/restore functions

2017-12-07 Thread Christoffer Dall
s and function calls unless necessary). We also use a static key on the restore path, because it will be marginally faster than loading a value from memory. Finally, we don't have to conditionally clear the debug dirty flag if it's set, we can just clear it. Signed-off-by: Christoffer D

[PATCH v2 07/36] KVM: arm64: Move debug dirty flag calculation out of world switch

2017-12-07 Thread Christoffer Dall
There is no need to figure out inside the world-switch if we should save/restore the debug registers or not, we can might as well do that in the higher level debug setup code, making it easier to optimize down the line. Signed-off-by: Christoffer Dall --- arch/arm64/kvm/debug.c| 5

[PATCH v2 10/36] KVM: arm64: Factor out fault info population and gic workarounds

2017-12-07 Thread Christoffer Dall
switch functions. No functional change. Signed-off-by: Christoffer Dall --- Notes: Changes since v1: - Fixed typos in commit message - Changed comment in fixup_guest_exit - Us do-while instead of jumping to a label arch/arm64/kvm/hyp/switch.c | 99

[PATCH v2 06/36] KVM: arm64: Defer restoring host VFP state to vcpu_put

2017-12-07 Thread Christoffer Dall
drew Jones Signed-off-by: Christoffer Dall --- Notes: Changes since v1: - Cosmetic changes - Change the flags variable to a u8 - Expanded the commit message arch/arm64/include/asm/kvm_emulate.h | 5 arch/arm64/include/asm/kvm_host.h| 3 +++ arch/arm64/kernel/asm

[PATCH v2 05/36] KVM: arm/arm64: Add kvm_vcpu_load_sysregs and kvm_vcpu_put_sysregs

2017-12-07 Thread Christoffer Dall
As we are about to move a bunch of save/restore logic for VHE kernels to the load and put functions, we need some infrastructure to do this. Reviewed-by: Andrew Jones Signed-off-by: Christoffer Dall --- Notes: Changes since v1: - Reworded comments as suggested by Drew arch/arm

[PATCH v2 09/36] KVM: arm64: Improve debug register save/restore flow

2017-12-07 Thread Christoffer Dall
e for switching to the host context, and we get the benefit of only having to evaluate the dirty flag once on each path, plus we give the compiler some more room to inline some of this functionality. Signed-off-by: Christoffer Dall --- Notes: Changes since v1: - Remove leading underscores

[PATCH v2 04/36] KVM: arm/arm64: Get rid of vcpu->arch.irq_lines

2017-12-07 Thread Christoffer Dall
odify the bits in the vcpu->arch.hcr[_el2] directly when needed. Acked-by: Marc Zyngier Reviewed-by: Andrew Jones Reviewed-by: Julien Thierry Signed-off-by: Christoffer Dall --- arch/arm/include/asm/kvm_emulate.h | 9 ++--- arch/arm/include/asm/kvm_host.h | 3 --- arch/arm/kvm/e

[PATCH v2 03/36] KVM: arm64: Move HCR_INT_OVERRIDE to default HCR_EL2 guest flag

2017-12-07 Thread Christoffer Dall
iewed-by: Marc Zyngier Signed-off-by: Shih-Wei Li Signed-off-by: Christoffer Dall --- arch/arm64/include/asm/kvm_arm.h | 4 ++-- arch/arm64/kvm/hyp/switch.c | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_

[PATCH v2 00/36] Optimize KVM/ARM for VHE systems

2017-12-07 Thread Christoffer Dall
/git.kernel.org/pub/scm/linux/kernel/git/cdall/linux.git vcpu-load-put-v3 [5]: git://git.kernel.org/pub/scm/linux/kernel/git/cdall/linux.git vhe-optimize-v2 Christoffer Dall (35): KVM: arm64: Avoid storing the vcpu pointer on the stack KVM: arm64: Rework hyp_panic for VHE and non-VHE KVM:

[PATCH v2 02/36] KVM: arm64: Rework hyp_panic for VHE and non-VHE

2017-12-07 Thread Christoffer Dall
n VBAR_EL2 has been set to the KVM exception vectors. On VHE, we can always safely disable the traps and restore the host registers at this point, so we simply do that unconditionally and call into the panic function directly. Signed-off-by: Christoffer Dall --- Notes: Changes since v1:

[PATCH v2 01/36] KVM: arm64: Avoid storing the vcpu pointer on the stack

2017-12-07 Thread Christoffer Dall
e the _EL1 accessor on VHE systems, but this was actually unnecessary as the _EL1 accessor aliases the ESR_EL2 register on VHE, and the _EL2 accessor does the same thing on both systems. Cc: Ard Biesheuvel Signed-off-by: Christoffer Dall --- Notes: Changes since v1: - Use PC-relative add

[PATCH v7 3/8] KVM: arm/arm64: Don't cache the timer IRQ level

2017-12-07 Thread Christoffer Dall
the line level should be asserted from the timer ISR. The VGIC can ignore extra notifications using its validate mechanism. Reviewed-by: Andre Przywara Signed-off-by: Christoffer Dall --- virt/kvm/arm/arch_timer.c | 20 +--- 1 file changed, 13 insertions(+), 7 deletions(-) di

[PATCH v7 6/8] KVM: arm/arm64: Support VGIC dist pend/active changes for mapped IRQs

2017-12-07 Thread Christoffer Dall
of mapped interrupts from userspace is not supported, and it's expected that userspace unmaps devices from VFIO before attempting to set the interrupt state, because the interrupt state is driven by hardware. Reviewed-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic

[PATCH v7 5/8] KVM: arm/arm64: Support a vgic interrupt line level sample function

2017-12-07 Thread Christoffer Dall
to the good old method of poking the physical GIC if no callback is provided. Reviewed-by: Marc Zyngier Signed-off-by: Christoffer Dall --- include/kvm/arm_vgic.h| 13 - virt/kvm/arm/arch_timer.c | 3 ++- virt/kvm/arm/vgic/vgic.c | 12 +--- 3 files changed, 23

[PATCH v7 8/8] KVM: arm/arm64: Avoid work when userspace iqchips are not used

2017-12-07 Thread Christoffer Dall
n ARM is mostly a developer or hobby feature, and is unlikely to be used in servers or other scenarios where performance is a priority, we can use a refcounted static key to only check the irqchip configuration when we have at least one VM that uses an irqchip in userspace. Signed-off-by: Christ

[PATCH v7 7/8] KVM: arm/arm64: Provide a get_input_level for the arch timer

2017-12-07 Thread Christoffer Dall
f the virtual interrupt is active, and otherwise we simply let the timer fire again and raise the virtual interrupt from the ISR. Signed-off-by: Christoffer Dall --- include/kvm/arm_arch_timer.h | 2 ++ virt/kvm/arm/arch_timer.c| 75 +--- 2 files ch

[PATCH v7 4/8] KVM: arm/arm64: vgic: Support level-triggered mapped interrupts

2017-12-07 Thread Christoffer Dall
st with an injected timer interrupt. Reviewed-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-v2.c | 29 + virt/kvm/arm/vgic/vgic-v3.c | 29 + virt/kvm/arm/vgic/vgic.c| 23 +++ virt/kv

[PATCH v7 2/8] KVM: arm/arm64: Factor out functionality to get vgic mmio requester_vcpu

2017-12-07 Thread Christoffer Dall
document the semantics of the return value. Also take the chance to move the functionality outside of holding a spinlock and instead explicitly disable and enable preemption. This supports PREEMPT_RT kernels as well. Acked-by: Marc Zyngier Reviewed-by: Andre Przywara Signed-off-by: Christoffer

[PATCH v7 0/8] Handle forwarded level-triggered interrupts

2017-12-07 Thread Christoffer Dall
enames) Thanks, -Christoffer [1]: https://lists.cs.columbia.edu/pipermail/kvmarm/2017-June/026072.html Christoffer Dall (8): KVM: arm/arm64: Remove redundant preemptible checks KVM: arm/arm64: Factor out functionality to get vgic mmio requester_vcpu KVM: arm/arm64: Don't cache the timer IRQ le

[PATCH v7 1/8] KVM: arm/arm64: Remove redundant preemptible checks

2017-12-07 Thread Christoffer Dall
o for other uses of per cpu variables either). Acked-by: Marc Zyngier Reviewed-by: Andre Przywara Signed-off-by: Christoffer Dall --- virt/kvm/arm/arm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index a6524ff27de4..859ff7e3a1eb 100644 --- a/vir

Re: [PATCH] arm64: kvm: Prevent restoring stale PMSCR_EL1 for vcpu

2017-12-07 Thread Christoffer Dall
on the same vcpu, > restore will write the value of PMSCR_EL1 read during the first save. > > Make sure __debug_save_spe_nvhe clears the value of the saved PMSCR_EL1 > when the guest cannot use SPE. > > Signed-off-by: Julien Thierry > Cc: Christoffer Dall > Cc: Marc Zyngie

Re: [PATCH v6 7/8] KVM: arm/arm64: Provide a get_input_level for the arch timer

2017-12-06 Thread Christoffer Dall
On Wed, Dec 06, 2017 at 05:17:28PM +0300, Yury Norov wrote: > On Wed, Dec 06, 2017 at 11:59:04AM +0100, Christoffer Dall wrote: > > On Tue, Dec 05, 2017 at 06:24:46PM +0300, Yury Norov wrote: > > > On Mon, Dec 04, 2017 at 09:05:05PM +0100, Christoffer Dall wrote: > > &g

Re: [PATCH v6 7/8] KVM: arm/arm64: Provide a get_input_level for the arch timer

2017-12-06 Thread Christoffer Dall
On Tue, Dec 05, 2017 at 06:24:46PM +0300, Yury Norov wrote: > On Mon, Dec 04, 2017 at 09:05:05PM +0100, Christoffer Dall wrote: > > From: Christoffer Dall > > > > The VGIC can now support the life-cycle of mapped level-triggered > > interrupts, and we no longer have t

Re: [PATCH v6 2/8] KVM: arm/arm64: Factor out functionality to get vgic mmio requester_vcpu

2017-12-06 Thread Christoffer Dall
On Tue, Dec 05, 2017 at 04:46:08PM +0300, Yury Norov wrote: > On Mon, Dec 04, 2017 at 09:05:00PM +0100, Christoffer Dall wrote: > > From: Christoffer Dall > > > > We are about to distinguish between userspace accesses and mmio traps > > for a number of the mmio handler

Re: [PATCH 1/3] arm64: KVM: Move CPU ID reg trap setup off the world switch path

2017-12-06 Thread Christoffer Dall
On Tue, Dec 05, 2017 at 12:31:51PM +, Dave Martin wrote: > On Tue, Dec 05, 2017 at 10:09:15AM +0100, Christoffer Dall wrote: > > On Fri, Dec 01, 2017 at 03:19:40PM +, Dave Martin wrote: > > > The HCR_EL2.TID3 flag needs to be set when trapping guest access to > > &

Re: [PATCH 3/3] arm64/sve: KVM: Avoid dereference of dead task during guest entry

2017-12-05 Thread Christoffer Dall
Hi Dave, On Mon, Dec 04, 2017 at 03:36:50PM +, Dave Martin wrote: > On Mon, Dec 04, 2017 at 01:53:21PM +, Ard Biesheuvel wrote: > > On 1 December 2017 at 15:19, Dave Martin wrote: > > > When deciding whether to invalidate FPSIMD state cached in the cpu, > > > the backend function sve_flus

Re: [PATCH 1/3] arm64: KVM: Move CPU ID reg trap setup off the world switch path

2017-12-05 Thread Christoffer Dall
thout the need for > conditional logic on the critical path. > > Signed-off-by: Dave Martin > Suggested-by: Christoffer Dall > Cc: Marc Zyngier Reviewed-by: Christoffer Dall > > --- > > Note to maintainers: this was discussed on-list [1] prior to the merge &

[PATCH v3 05/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_regs

2017-12-04 Thread Christoffer Dall
From: Christoffer Dall Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_set_regs(). Signed-off-by: Christoffer Dall --- arch/mips/kvm/mips.c | 3 +++ arch/powerpc/kvm/book3s.c | 3 +++ arch/powerpc/kvm/booke.c | 3 +++ arch/s390/kvm

<    4   5   6   7   8   9   10   11   12   13   >