Re: [PATCH v4 31/40] KVM: arm64: Move common VHE/non-VHE trap config in separate functions

2018-02-25 Thread Christoffer Dall
On Wed, Feb 21, 2018 at 05:59:37PM +, Marc Zyngier wrote: > On Thu, 15 Feb 2018 21:03:23 +, > Christoffer Dall wrote: > > > > As we are about to be more lazy with some of the trap configuration > > register read/writes for VHE systems, move the logic that is curr

Re: [PATCH v4 10/40] KVM: arm64: Slightly improve debug save/restore functions

2018-02-24 Thread Christoffer Dall
On Wed, Feb 21, 2018 at 05:52:41PM +, Marc Zyngier wrote: > On 21/02/18 17:39, Andrew Jones wrote: > > On Thu, Feb 15, 2018 at 10:03:02PM +0100, Christoffer Dall wrote: > >> The debug save/restore functions can be improved by using the has_vhe() > >> static key

Re: [PATCH v4 28/40] KVM: arm64: Defer saving/restoring 64-bit sysregs to vcpu load/put on VHE

2018-02-23 Thread Christoffer Dall
On Wed, Feb 21, 2018 at 03:33:47PM +, Marc Zyngier wrote: > On Thu, 15 Feb 2018 21:03:20 +, > 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

[PULL 2/2] ARM: kvm: fix building with gcc-8

2018-02-23 Thread Christoffer Dall
cgi?id=84129 Fixes: 33280b4cd1dc ("ARM: KVM: Add banked registers save/restore") Cc: sta...@vger.kernel.org Signed-off-by: Arnd Bergmann Signed-off-by: Christoffer Dall --- arch/arm/kvm/hyp/Makefile| 5 + arch/arm/kvm/hyp/banked-sr.c | 4 2 files changed, 9 inserti

[PULL 1/2] KVM: arm/arm64: Fix arch timers with userspace irqchips

2018-02-23 Thread Christoffer Dall
: Marc Zyngier Cc: # v4.12+ Fixes: d9e139778376 ("KVM: arm/arm64: Support arch timers with a userspace gic") Signed-off-by: Christoffer Dall --- virt/kvm/arm/arch_timer.c | 116 +- 1 file changed, 64 insertions(+), 52 deletions(-) diff --git

[PULL 0/2] KVM/ARM Fixes for v4.16

2018-02-23 Thread Christoffer Dall
gcc-8 (2018-02-15 20:58:36 +0100) Thanks, -Christoffer Arnd Bergmann (1): ARM: kvm: fix building with gcc-8 Christoffer Dall (1): KVM: arm/arm64: Fix arch timers with userspace irqchips arch/arm/kvm/hyp/Makefile| 5 ++ arch/arm/kvm/hyp/banked-sr.c | 4 ++ virt/kvm/arm/arch_timer.c

Re: [PATCH v4 35/40] KVM: arm/arm64: Get rid of vgic_elrsr

2018-02-23 Thread Christoffer Dall
On Fri, Feb 23, 2018 at 02:44:30PM +, Julien Grall wrote: > Hi Christoffer, > > On 15/02/18 21:03, Christoffer Dall wrote: > >There is really no need to store the vgic_elrsr on the VGIC data > >structures as the only need we have for the elrsr is to figure out if an >

Re: [PATCH v4 31/40] KVM: arm64: Move common VHE/non-VHE trap config in separate functions

2018-02-23 Thread Christoffer Dall
On Fri, Feb 23, 2018 at 02:30:54PM +, Julien Grall wrote: > Hi Christoffer, > > On 15/02/18 21:03, Christoffer Dall wrote: > >@@ -85,37 +123,14 @@ static void __hyp_text __activate_traps(struct kvm_vcpu > >*vcpu) > > { > > u64 hcr = vcpu->arch.hcr_el2

Re: [RFC PATCH 2/2] KVM: arm64: Eliminate most redundant FPSIMD saves and restores

2018-02-23 Thread Christoffer Dall
set_thread_flag(TIF_FOREIGN_FPSTATE); > + fpsimd_bind_state_to_cpu(&vcpu->arch.ctxt.fpsimd_state); > + > + /* > + * Protect ourselves against a softirq splatting the > + * FPSIMD state on

Re: [RFC PATCH 0.9/2] arm64: fpsimd: Expose CPU / FPSIMD state association helpers

2018-02-23 Thread Christoffer Dall
On Fri, Feb 16, 2018 at 06:39:30PM +, Dave Martin wrote: > Oops, forgot to post this patch that goes before patch 1 in the series. > > --8<-- > > Expose an interface for associating an FPSIMD context with a CPU and > checking the association, for use by KVM. > > Signed-off-by: Dave Martin >

Re: [PATCH v4 28/40] KVM: arm64: Defer saving/restoring 64-bit sysregs to vcpu load/put on VHE

2018-02-22 Thread Christoffer Dall
On Thu, Feb 22, 2018 at 06:31:08PM +, Julien Grall wrote: > > > On 22/02/18 18:30, Julien Grall wrote: > >Hi Christoffer, > > > >On 15/02/18 21:03, Christoffer Dall wrote: > >>Some system registers do not affect the host kernel's execution and can >

Re: [PATCH v4 28/40] KVM: arm64: Defer saving/restoring 64-bit sysregs to vcpu load/put on VHE

2018-02-22 Thread Christoffer Dall
On Thu, Feb 22, 2018 at 06:30:11PM +, Julien Grall wrote: > Hi Christoffer, > > On 15/02/18 21:03, 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

Re: [PATCH v4 38/40] KVM: arm/arm64: Handle VGICv3 save/restore from the main VGIC code on VHE

2018-02-22 Thread Christoffer Dall
On Thu, Feb 22, 2018 at 05:21:20PM +, Marc Zyngier wrote: > On 22/02/18 16:02, Christoffer Dall wrote: > > On Thu, Feb 22, 2018 at 03:01:17PM +, Marc Zyngier wrote: > >> On Thu, 22 Feb 2018 14:42:27 +, > >> Christoffer Dall wrote: > >>> > &g

Re: [PATCH v4 34/40] KVM: arm64: Cleanup __activate_traps and __deactive_traps for VHE and non-VHE

2018-02-22 Thread Christoffer Dall
On Wed, Feb 21, 2018 at 06:26:39PM +, Marc Zyngier wrote: > On Thu, 15 Feb 2018 21:03:26 +, > Christoffer Dall wrote: > > > > 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

Re: [PATCH v4 33/40] KVM: arm64: Configure c15, PMU, and debug register traps on cpu load/put for VHE

2018-02-22 Thread Christoffer Dall
On Wed, Feb 21, 2018 at 06:20:54PM +, Marc Zyngier wrote: > On Thu, 15 Feb 2018 21:03:25 +, > Christoffer Dall wrote: > > > > We do not have to change the c15 trap setting on each switch to/from the > > guest on VHE systems, because this setting only affects EL

Re: [PATCH v4 31/40] KVM: arm64: Move common VHE/non-VHE trap config in separate functions

2018-02-22 Thread Christoffer Dall
On Wed, Feb 21, 2018 at 05:59:37PM +, Marc Zyngier wrote: > On Thu, 15 Feb 2018 21:03:23 +, > Christoffer Dall wrote: > > > > As we are about to be more lazy with some of the trap configuration > > register read/writes for VHE systems, move the logic that is curr

Re: [PATCH v4 30/40] KVM: arm64: Defer saving/restoring 32-bit sysregs to vcpu load/put

2018-02-22 Thread Christoffer Dall
On Wed, Feb 21, 2018 at 04:27:25PM +, Marc Zyngier wrote: > On Thu, 15 Feb 2018 21:03:22 +, > Christoffer Dall wrote: > > > > When running a 32-bit VM (EL1 in AArch32), the AArch32 system registers > > can be deferred to vcpu load/put on VHE systems because neither

Re: [PATCH v4 38/40] KVM: arm/arm64: Handle VGICv3 save/restore from the main VGIC code on VHE

2018-02-22 Thread Christoffer Dall
On Thu, Feb 22, 2018 at 03:01:17PM +, Marc Zyngier wrote: > On Thu, 22 Feb 2018 14:42:27 +, > Christoffer Dall wrote: > > > > On Thu, Feb 22, 2018 at 12:32:11PM +, Marc Zyngier wrote: > > > On 15/02/18 21:03, Christoffer Dall wrote: > > >

Re: [PATCH v4 24/40] KVM: arm64: Rewrite system register accessors to read/write functions

2018-02-22 Thread Christoffer Dall
On Thu, Feb 22, 2018 at 04:11:38PM +0100, Andrew Jones wrote: > > Hi Christoffer, > > I'm just pointing out some broken lines that we could maybe cheat the > 80-char limit on. Naturally feel free to ignore. Thanks. I'll go over them as I respin. -Christoffer ___

Re: [PATCH v4 30/40] KVM: arm64: Defer saving/restoring 32-bit sysregs to vcpu load/put

2018-02-22 Thread Christoffer Dall
On Thu, Feb 22, 2018 at 03:35:06PM +0100, Andrew Jones wrote: > On Thu, Feb 15, 2018 at 10:03:22PM +0100, Christoffer Dall wrote: > > When running a 32-bit VM (EL1 in AArch32), the AArch32 system registers > > can be deferred to vcpu load/put on VHE systems because neither > >

Re: [PATCH v4 25/40] KVM: arm64: Introduce framework for accessing deferred sysregs

2018-02-22 Thread Christoffer Dall
On Thu, Feb 22, 2018 at 02:40:52PM +0100, Andrew Jones wrote: > On Thu, Feb 15, 2018 at 10:03:17PM +0100, Christoffer Dall wrote: > > We are about to defer saving and restoring some groups of system > > registers to vcpu_put and vcpu_load on supported systems. This means > &

Re: [PATCH v4 39/40] KVM: arm/arm64: Move VGIC APR save/restore to vgic put/load

2018-02-22 Thread Christoffer Dall
On Thu, Feb 22, 2018 at 01:11:55PM +, Marc Zyngier wrote: > On 15/02/18 21:03, Christoffer Dall wrote: > > The APRs can only have bits set when the guest acknowledges an interrupt > > in the LR and can only have a bit cleared when the guest EOIs an > > interrupt in the

Re: [PATCH v4 38/40] KVM: arm/arm64: Handle VGICv3 save/restore from the main VGIC code on VHE

2018-02-22 Thread Christoffer Dall
On Thu, Feb 22, 2018 at 12:32:11PM +, Marc Zyngier wrote: > On 15/02/18 21:03, Christoffer Dall wrote: > > Just like we can program the GICv2 hypervisor control interface directly > > from the core vgic code, we can do the same for the GICv3 hypervisor > > control int

Re: [PATCH v4 37/40] KVM: arm/arm64: Move arm64-only vgic-v2-sr.c file to arm64

2018-02-22 Thread Christoffer Dall
On Thu, Feb 22, 2018 at 12:33:20PM +, Marc Zyngier wrote: > On 15/02/18 21:03, Christoffer Dall wrote: > > The vgic-v2-sr.c file now only contains the logic to replay unaligned > > accesses to the virtual CPU interface on 16K and 64K page systems, which > > is only relevan

Re: [PATCH v4 24/40] KVM: arm64: Rewrite system register accessors to read/write functions

2018-02-22 Thread Christoffer Dall
On Thu, Feb 22, 2018 at 02:34:21PM +0100, Andrew Jones wrote: > On Thu, Feb 15, 2018 at 10:03:16PM +0100, Christoffer Dall wrote: > > From: Christoffer Dall > > > > Currently we access the system registers array via the vcpu_sys_reg() > > macro. However, we are abou

Re: [PATCH v4 24/40] KVM: arm64: Rewrite system register accessors to read/write functions

2018-02-22 Thread Christoffer Dall
On Thu, Feb 22, 2018 at 10:48:10AM +, Marc Zyngier wrote: > On Thu, 22 Feb 2018 09:22:37 +, > Christoffer Dall wrote: > > > > On Wed, Feb 21, 2018 at 01:32:45PM +, Marc Zyngier wrote: > > > On Thu, 15 Feb 2018 21:03:16 +0000, > > > Christoff

Re: [PATCH v4 03/40] KVM: arm64: Avoid storing the vcpu pointer on the stack

2018-02-22 Thread Christoffer Dall
On Thu, Feb 22, 2018 at 10:56:41AM +0100, Andrew Jones wrote: > On Thu, Feb 22, 2018 at 10:10:34AM +0100, Christoffer Dall wrote: > > On Wed, Feb 21, 2018 at 06:32:00PM +0100, Andrew Jones wrote: > > > > > > Besides my confusion on motivation, it looks good to me &

Re: [PATCH v4 26/40] KVM: arm/arm64: Prepare to handle deferred save/restore of SPSR_EL1

2018-02-22 Thread Christoffer Dall
On Wed, Feb 21, 2018 at 02:47:44PM +, Marc Zyngier wrote: > On Thu, 15 Feb 2018 21:03:18 +, > Christoffer Dall wrote: > > > > SPSR_EL1 is not used by a VHE host kernel and can be deferred, but we > > need to rework the accesses to this register to access the lates

Re: [PATCH v4 24/40] KVM: arm64: Rewrite system register accessors to read/write functions

2018-02-22 Thread Christoffer Dall
On Mon, Feb 19, 2018 at 06:12:29PM +, Julien Grall wrote: > Hi Christoffer, > > On 15/02/18 21:03, Christoffer Dall wrote: > >From: Christoffer Dall > > > >Currently we access the system registers array via the vcpu_sys_reg() > >macro. However, we are abo

Re: [PATCH v4 17/40] KVM: arm64: Move userspace system registers into separate function

2018-02-22 Thread Christoffer Dall
On Mon, Feb 19, 2018 at 05:21:17PM +, Julien Grall wrote: > Hi Christoffer, > > On 15/02/18 21:03, 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 cont

Re: [PATCH v4 24/40] KVM: arm64: Rewrite system register accessors to read/write functions

2018-02-22 Thread Christoffer Dall
On Wed, Feb 21, 2018 at 01:32:45PM +, Marc Zyngier wrote: > On Thu, 15 Feb 2018 21:03:16 +, > Christoffer Dall wrote: > > > > From: Christoffer Dall > > > > Currently we access the system registers array via the vcpu_sys_reg() > > macro. However, we

Re: [PATCH v4 13/40] KVM: arm64: Introduce VHE-specific kvm_vcpu_run

2018-02-22 Thread Christoffer Dall
On Wed, Feb 21, 2018 at 07:18:32PM +0100, Andrew Jones wrote: > On Wed, Feb 21, 2018 at 06:43:00PM +0100, Andrew Jones wrote: > > On Thu, Feb 15, 2018 at 10:03:05PM +0100, Christoffer Dall wrote: > > > So far this is mostly (see below) a copy of the legacy non-VHE switch >

Re: [PATCH v4 08/40] KVM: arm/arm64: Introduce vcpu_el1_is_32bit

2018-02-22 Thread Christoffer Dall
On Wed, Feb 21, 2018 at 12:05:27PM +, Marc Zyngier wrote: > On Thu, 15 Feb 2018 21:03:00 +, > Christoffer Dall wrote: > > > > We have numerous checks around that checks if the HCR_EL2 has the RW bit > > set to figure out if we're running an AArch64 or A

Re: [PATCH v4 03/40] KVM: arm64: Avoid storing the vcpu pointer on the stack

2018-02-22 Thread Christoffer Dall
On Wed, Feb 21, 2018 at 06:32:00PM +0100, Andrew Jones wrote: > On Thu, Feb 15, 2018 at 10:02:55PM +0100, 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 pointer on the stack

Re: [PATCH v4 03/40] KVM: arm64: Avoid storing the vcpu pointer on the stack

2018-02-22 Thread Christoffer Dall
On Wed, Feb 21, 2018 at 11:34:07AM +, Marc Zyngier wrote: > On Thu, 15 Feb 2018 21:02: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 v4 03/40] KVM: arm64: Avoid storing the vcpu pointer on the stack

2018-02-22 Thread Christoffer Dall
On Mon, Feb 19, 2018 at 03:50:20PM +, Julien Grall wrote: > Hi Christoffer, > > On 15/02/18 21:02, 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 pointer on the

Re: [PATCH] KVM: arm/arm64: No need to zero CNTVOFF in kvm_timer_vcpu_put() for VHE

2018-02-22 Thread Christoffer Dall
Hi Shanker, On Mon, Feb 19, 2018 at 09:38:07AM -0600, Shanker Donthineni wrote: > In AArch64/AArch32, the virtual counter uses a fixed virtual offset > of zero in the following situations as per ARMv8 specifications: > > 1) HCR_EL2.E2H is 1, and CNTVCT_EL0/CNTVCT are read from EL2. > 2) HCR_EL2.{

Re: [PATCH v4 10/19] KVM: arm/arm64: Do not use kern_hyp_va() with kvm_vgic_global_state

2018-02-19 Thread Christoffer Dall
On Fri, Feb 16, 2018 at 09:33:39AM +, Marc Zyngier wrote: > On 16/02/18 09:05, Christoffer Dall wrote: > > On Thu, Feb 15, 2018 at 01:22:56PM +, Marc Zyngier wrote: > >> On 15/01/18 15:36, Christoffer Dall wrote: > >>> On Thu, Jan 04, 2018 at 06:43:

Re: [PATCH v4 18/19] arm64: KVM: Introduce EL2 VA randomisation

2018-02-16 Thread Christoffer Dall
On Thu, Feb 15, 2018 at 03:32:52PM +, Marc Zyngier wrote: > On 18/01/18 20:28, Christoffer Dall wrote: > > On Thu, Jan 04, 2018 at 06:43:33PM +, Marc Zyngier wrote: > >> The main idea behind randomising the EL2 VA is that we usually have > >> a few spare bits b

Re: [PATCH v4 14/19] KVM: arm/arm64: Move HYP IO VAs to the "idmap" range

2018-02-16 Thread Christoffer Dall
On Thu, Feb 15, 2018 at 01:52:05PM +, Marc Zyngier wrote: > On 18/01/18 14:39, Christoffer Dall wrote: > > On Thu, Jan 04, 2018 at 06:43:29PM +, Marc Zyngier wrote: > >> We so far mapped our HYP IO (which is essencially the GICv2 control > >> registers) using th

Re: [PATCH v4 10/19] KVM: arm/arm64: Do not use kern_hyp_va() with kvm_vgic_global_state

2018-02-16 Thread Christoffer Dall
On Thu, Feb 15, 2018 at 01:22:56PM +, Marc Zyngier wrote: > On 15/01/18 15:36, Christoffer Dall wrote: > > On Thu, Jan 04, 2018 at 06:43:25PM +, Marc Zyngier wrote: > >> kvm_vgic_global_state is part of the read-only section, and is > >> usually accessed

Re: [PATCH v4 08/19] arm64: KVM: Dynamically patch the kernel/hyp VA mask

2018-02-16 Thread Christoffer Dall
On Thu, Feb 15, 2018 at 01:11:02PM +, Marc Zyngier wrote: > On 15/01/18 11:47, Christoffer Dall wrote: > > On Thu, Jan 04, 2018 at 06:43:23PM +, Marc Zyngier wrote: > >> So far, we're using a complicated sequence of alternatives to > >> patch the kernel/hyp

Re: [PATCH] KVM: arm: Enable emulation of the physical timer

2018-02-16 Thread Christoffer Dall
On Tue, Feb 13, 2018 at 11:41:16AM +0100, Jérémy Fanguède wrote: > Set the handlers to emulate read and write operations for CNTP_CTL, > CNTP_CVAL and CNTP_TVAL registers in such a way that VMs can use the > physical timer. > > Signed-off-by: Jérémy Fanguède > --- > > This patch is the equivalen

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

2018-02-15 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 --- Notes: Changes since v3: - Removed extra blank line arch/arm/include/asm/kvm_hyp.h | 2 + arch/arm/kvm/hyp/switch.c| 8 ++- arch/arm64/include

[PATCH v4 39/40] KVM: arm/arm64: Move VGIC APR save/restore to vgic put/load

2018-02-15 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 v4 38/40] KVM: arm/arm64: Handle VGICv3 save/restore from the main VGIC code on VHE

2018-02-15 Thread Christoffer Dall
though we have never actually run the guest with the newly written GIC state. We solve this by inserting an ISB in the early exit path. Signed-off-by: Christoffer Dall --- Notes: Changes since v2: - Added ISB in the early exit path in the run loop as explained in the commit message

[PATCH v4 37/40] KVM: arm/arm64: Move arm64-only vgic-v2-sr.c file to arm64

2018-02-15 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 v4 36/40] KVM: arm/arm64: Handle VGICv2 save/restore from the main VGIC code

2018-02-15 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 v4 35/40] KVM: arm/arm64: Get rid of vgic_elrsr

2018-02-15 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 v4 34/40] KVM: arm64: Cleanup __activate_traps and __deactive_traps for VHE and non-VHE

2018-02-15 Thread Christoffer Dall
tatic function if it can. Signed-off-by: Christoffer Dall --- arch/arm64/kvm/hyp/switch.c | 30 ++ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index 5e94955b89ea..0e54fe2aab1c 100644 --- a/arch/

[PATCH v4 33/40] KVM: arm64: Configure c15, PMU, and debug register traps on cpu load/put for VHE

2018-02-15 Thread Christoffer Dall
while executing KVM kernel code. Signed-off-by: Christoffer Dall --- arch/arm64/include/asm/kvm_hyp.h | 3 +++ arch/arm64/kvm/hyp/switch.c | 31 ++- arch/arm64/kvm/hyp/sysreg-sr.c | 4 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/arch/

[PATCH v4 32/40] KVM: arm64: Directly call VHE and non-VHE FPSIMD enabled functions

2018-02-15 Thread Christoffer Dall
There is no longer a need for an alternative to choose the right function to tell us whether or not FPSIMD was enabled for the VM, because we can simply cann the appropriate functions directly fromwithin the _vhe and _nvhe run functions. Signed-off-by: Christoffer Dall --- Notes: Changes

[PATCH v4 31/40] KVM: arm64: Move common VHE/non-VHE trap config in separate functions

2018-02-15 Thread Christoffer Dall
: Christoffer Dall --- Notes: Changes since v3: - Separate fpsimd32 trap configuration into a separate function which is still called from __activate_traps, because we no longer defer saving/restoring of VFP registers to load/put. arch/arm64/kvm/hyp/switch.c | 76

[PATCH v4 30/40] KVM: arm64: Defer saving/restoring 32-bit sysregs to vcpu load/put

2018-02-15 Thread Christoffer Dall
assembly handler from taking the EL2 fault, and therefore we have to check if fpsimd is enabled for the guest in the exit path and save the register then, for both VHE and non-VHE guests. Signed-off-by: Christoffer Dall --- Notes: Changes since v3: - Rework the FPEXC32 save/restore logic to

[PATCH v4 29/40] KVM: arm64: Prepare to handle deferred save/restore of 32-bit registers

2018-02-15 Thread Christoffer Dall
32-bit registers are not used by a 64-bit host kernel and can be deferred, but we need to rework the accesses to this register to access the latest value depending on whether or not guest system registers are loaded on the CPU or only reside in memory. Signed-off-by: Christoffer Dall --- Notes

[PATCH v4 28/40] KVM: arm64: Defer saving/restoring 64-bit sysregs to vcpu load/put on VHE

2018-02-15 Thread Christoffer Dall
this value. The 32-bit sysregs can also be deferred but we do this in a separate patch as it requires a bit more infrastructure. Signed-off-by: Christoffer Dall --- Notes: Changes since v3: - Changed to switch-based sysreg approach arch/arm64/kvm/

[PATCH v4 26/40] KVM: arm/arm64: Prepare to handle deferred save/restore of SPSR_EL1

2018-02-15 Thread Christoffer Dall
32-bit VMs is a bit clunky, but this will be improved in following patches which will first prepare and subsequently implement deferred save/restore of the 32-bit registers, including the 32-bit SPSRs. Signed-off-by: Christoffer Dall --- Notes: Changes since v2: - New patch (deferred

[PATCH v4 27/40] KVM: arm64: Prepare to handle deferred save/restore of ELR_EL1

2018-02-15 Thread Christoffer Dall
ELR_EL1 is not used by a VHE host kernel and can be deferred, but we need to rework the accesses to this register to access the latest value depending on whether or not guest system registers are loaded on the CPU or only reside in memory. Signed-off-by: Christoffer Dall --- Notes: Changes

[PATCH v4 23/40] KVM: arm64: Change 32-bit handling of VM system registers

2018-02-15 Thread Christoffer Dall
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 Reviewed-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm64/include/asm/kvm_host.h | 8 arch/arm64

[PATCH v4 25/40] KVM: arm64: Introduce framework for accessing deferred sysregs

2018-02-15 Thread Christoffer Dall
s where it is clear which registers become deferred. Signed-off-by: Christoffer Dall --- Notes: Changes since v3: - Changed to a switch-statement based approach to improve readability. Changes since v2: - New patch (deferred register handling has been reworked)

[PATCH v4 24/40] KVM: arm64: Rewrite system register accessors to read/write functions

2018-02-15 Thread Christoffer Dall
From: Christoffer Dall Currently we access the system registers array via the vcpu_sys_reg() macro. However, we are about to change the behavior to some times modify the register file directly, so let's change this to two primitives: * Accessor macros vcpu_write_sys_reg(

[PATCH v4 21/40] KVM: arm64: Unify non-VHE host/guest sysreg save and restore functions

2018-02-15 Thread Christoffer Dall
e the other into simply save/restore. Reviewed-by: Andrew Jones Reviewed-by: Marc Zyngier 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 chang

[PATCH v4 22/40] KVM: arm64: Don't save the host ELR_EL2 and SPSR_EL2 on VHE systems

2018-02-15 Thread Christoffer Dall
-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/arm64/kvm/hyp/sysreg-sr.c index d35b3aa680ab..906606dc4e2c 100644 --- a/arch/arm64/kvm/hyp/sysreg-sr.c +++ b/arch/arm64/kvm/hyp/sysreg

[PATCH v4 20/40] KVM: arm/arm64: Remove leftover comment from kvm_vcpu_run_vhe

2018-02-15 Thread Christoffer Dall
The comment only applied to SPE on non-VHE systems, so we simply remove it. Suggested-by: Andrew Jones Acked-by: Marc Zyngier 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

[PATCH v4 19/40] KVM: arm64: Introduce separate VHE/non-VHE sysreg save/restore functions

2018-02-15 Thread Christoffer Dall
VHE and non-VHE functionality now that we have separate functions. Reviewed-by: Andrew Jones Reviewed-by: Marc Zyngier 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

[PATCH v4 18/40] KVM: arm64: Rewrite sysreg alternatives to static keys

2018-02-15 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. Acked-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm64/kvm/hyp/sysreg-sr.c

[PATCH v4 17/40] KVM: arm64: Move userspace system registers into separate function

2018-02-15 Thread Christoffer Dall
ff-by: Christoffer Dall --- Notes: Changes since v3: - Correct the comment about ACTLR_EL1 and adjust commit text. Changes since v2: - Save restore ACTLR_EL1 as part of the EL1 registers state instead of the user register state, as ACTLR_EL1 can't affect the host&#

[PATCH v4 16/40] KVM: arm64: Remove noop calls to timer save/restore from VHE switch

2018-02-15 Thread Christoffer Dall
Marc Zyngier Signed-off-by: Christoffer Dall --- Notes: Changes since v2: - Added comment explaining the timer enable/disable functions are for !VHE only. arch/arm64/kvm/hyp/switch.c | 2 -- virt/kvm/arm/hyp/timer-sr.c | 44 ++-- 2 files ch

[PATCH v4 15/40] KVM: arm64: Don't deactivate VM on VHE systems

2018-02-15 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 Acked-by: Marc Zyngier Signed-off-by: Christoffer Dall --- Notes: Changes

[PATCH v4 12/40] KVM: arm64: Factor out fault info population and gic workarounds

2018-02-15 Thread Christoffer Dall
switch functions. No functional change. Reviewed-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm64/kvm/hyp/switch.c | 104 1 file changed, 57 insertions(+), 47 deletions(-) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp

[PATCH v4 14/40] KVM: arm64: Remove kern_hyp_va() use in VHE switch function

2018-02-15 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 Reviewed-by: Marc Zyngier Signed-off-by: Christoffer Dall

[PATCH v4 13/40] KVM: arm64: Introduce VHE-specific kvm_vcpu_run

2018-02-15 Thread Christoffer Dall
that we omit the branch-predictor variant-2 hardening for QC Falkor CPUs, because this workaround is specific to a series of non-VHE ARMv8.0 CPUs. Reviewed-by: Marc Zyngier Signed-off-by: Christoffer Dall --- Notes: Changes since v3: - Added BUG() to 32-bit ARM VHE run function

[PATCH v4 10/40] KVM: arm64: Slightly improve debug save/restore functions

2018-02-15 Thread Christoffer Dall
Signed-off-by: Christoffer Dall --- Notes: Changes since v1: - Change dot to comma in comment - Rename __debug_restore_spe to __debug_restore_spe_nvhe arch/arm64/kvm/hyp/debug-sr.c | 26 -- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/arch/arm6

[PATCH v4 11/40] KVM: arm64: Improve debug register save/restore flow

2018-02-15 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. Reviewed-by: Marc Zyngier Signed-off-by: Christoffer Dall --- Notes: Changes since v1: - R

[PATCH v4 08/40] KVM: arm/arm64: Introduce vcpu_el1_is_32bit

2018-02-15 Thread Christoffer Dall
nd for the following patches that optimize KVM on AArch64 hosts with VHE. Therefore, introduce a helper, vcpu_el1_is_32bit, and replace existing direct checks of HCR_EL2.RW with the helper. Reviewed-by: Julien Grall Reviewed-by: Julien Thierry Signed-off-by: Christoffer Dall --- Notes: Change

[PATCH v4 09/40] KVM: arm64: Move debug dirty flag calculation out of world switch

2018-02-15 Thread Christoffer Dall
: Christoffer Dall --- arch/arm64/kvm/debug.c| 5 + arch/arm64/kvm/hyp/debug-sr.c | 6 -- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c index fa63b28c65e0..feedb877cff8 100644 --- a/arch/arm64/kvm/debug.c +++ b/arch/arm64/kvm

[PATCH v4 06/40] KVM: arm/arm64: Get rid of vcpu->arch.irq_lines

2018-02-15 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 v4 07/40] KVM: arm/arm64: Add kvm_vcpu_load_sysregs and kvm_vcpu_put_sysregs

2018-02-15 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 Acked-by: Marc Zyngier Signed-off-by: Christoffer Dall --- Notes: Changes since v1: - Reworded comments as suggested

[PATCH v4 05/40] KVM: arm64: Move HCR_INT_OVERRIDE to default HCR_EL2 guest flag

2018-02-15 Thread Christoffer Dall
e the HCR_RW bit set when returning to EL1 on non-VHE systems. Reviewed-by: Marc Zyngier Signed-off-by: Shih-Wei Li Signed-off-by: Christoffer Dall --- Notes: Changes since v3: - Slightly reworded the commit message arch/arm64/include/asm/kvm_arm.h | 4 ++-- arch/arm64/kvm/hyp/swi

[PATCH v4 04/40] KVM: arm64: Rework hyp_panic for VHE and non-VHE

2018-02-15 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. Acked-by: Marc Zyngier Signed-off-by: Christoffer Dall --- Notes:

[PATCH v4 03/40] KVM: arm64: Avoid storing the vcpu pointer on the stack

2018-02-15 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 v3: - Reworked the assemb

[PATCH v4 02/40] KVM: arm/arm64: Move vcpu_load call after kvm_vcpu_first_run_init

2018-02-15 Thread Christoffer Dall
Moving the call to vcpu_load() in kvm_arch_vcpu_ioctl_run() to after we've called kvm_vcpu_first_run_init() simplifies some of the vgic and there is also no need to do vcpu_load() for things such as handling the immediate_exit flag. Reviewed-by: Julien Grall Signed-off-by: Christoffer

[PATCH v4 01/40] KVM: arm/arm64: Avoid vcpu_load for other vcpu ioctls than KVM_RUN

2018-02-15 Thread Christoffer Dall
ll Signed-off-by: Christoffer Dall --- arch/arm64/kvm/guest.c | 3 --- virt/kvm/arm/arm.c | 9 - 2 files changed, 12 deletions(-) diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index d7e3299a7734..959e50d2588c 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/k

[PATCH v4 00/40] Optimize KVM/ARM for VHE systems

2018-02-15 Thread Christoffer Dall
ernel/git/cdall/linux.git vhe-optimize-v4 Christoffer Dall (39): KVM: arm/arm64: Avoid vcpu_load for other vcpu ioctls than KVM_RUN KVM: arm/arm64: Move vcpu_load call after kvm_vcpu_first_run_init KVM: arm64: Avoid storing the vcpu pointer on the stack KVM: arm64: Rework hyp_panic for VH

Re: [PATCH v3 09/41] KVM: arm64: Defer restoring host VFP state to vcpu_put

2018-02-14 Thread Christoffer Dall
On Wed, Feb 14, 2018 at 02:43:42PM +, Dave Martin wrote: > [CC Ard, in case he has a view on how much we care about softirq NEON > performance regressions ... and whether my suggestions make sense] > > On Wed, Feb 14, 2018 at 11:15:54AM +0100, Christoffer Dall wrote: > > On

Re: [PATCH v3 18/41] KVM: arm64: Move userspace system registers into separate function

2018-02-14 Thread Christoffer Dall
On Fri, Feb 09, 2018 at 06:50:14PM +, Julien Grall wrote: > Hi Christoffer, > > On 01/12/2018 12:07 PM, 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

Re: [PATCHv2] arm64/kvm: Prohibit guest LOR accesses

2018-02-14 Thread Christoffer Dall
reRelease > respectively. We can ensure this by clearing LORC_EL1.EN when a CPU's > EL2 is first initialized, as the host kernel will not modify this. > > Signed-off-by: Mark Rutland > Cc: Vladimir Murzin > Cc: Catalin Marinas > Cc: Christoffer Dall > Cc: M

Re: [PATCH v3 09/41] KVM: arm64: Defer restoring host VFP state to vcpu_put

2018-02-14 Thread Christoffer Dall
On Tue, Feb 13, 2018 at 02:08:47PM +, Dave Martin wrote: > On Tue, Feb 13, 2018 at 09:51:30AM +0100, Christoffer Dall wrote: > > On Fri, Feb 09, 2018 at 03:59:30PM +, Dave Martin wrote: > > > On Wed, Feb 07, 2018 at 06:56:44PM +0100, Christoffer Dall wrote: > > >

Re: [PATCH v3 17/41] KVM: arm64: Remove noop calls to timer save/restore from VHE switch

2018-02-13 Thread Christoffer Dall
On Fri, Feb 09, 2018 at 05:53:43PM +, Julien Grall wrote: > Hi Christoffer, > > On 01/12/2018 12:07 PM, Christoffer Dall wrote: > >The VHE switch function calls __timer_enable_traps and > >__timer_disable_traps which don't do anything on VHE systems. > >Ther

Re: [PATCH v3 05/41] KVM: arm64: Move HCR_INT_OVERRIDE to default HCR_EL2 guest flag

2018-02-13 Thread Christoffer Dall
On Fri, Feb 09, 2018 at 11:38:50AM +, Julien Grall wrote: > Hi, > > On 01/12/2018 12:07 PM, Christoffer Dall wrote: > >From: Shih-Wei Li > > > >We always set the IMO and FMO bits in the HCR_EL2 when running the > >guest, regardless if we use the vgic

Re: [PATCH] arm64/kvm: Prohibit guest LOR accesses

2018-02-13 Thread Christoffer Dall
ensure this by clearing LORC_EL1.EN when a CPU's > EL2 is first initialized, as the host kernel will not modify this. > > Signed-off-by: Mark Rutland > Reviewed-by: Vladimir Murzin > Cc: Catalin Marinas > Cc: Christoffer Dall > Cc: Marc Zyngier > Cc: Wi

Re: [PATCH v3 26/41] KVM: arm64: Introduce framework for accessing deferred sysregs

2018-02-13 Thread Christoffer Dall
On Fri, Feb 09, 2018 at 04:17:39PM +, Dave Martin wrote: > On Thu, Jan 25, 2018 at 08:54:13PM +0100, Christoffer Dall wrote: > > On Tue, Jan 23, 2018 at 04:04:40PM +, Dave Martin wrote: > > > On Fri, Jan 12, 2018 at 01:07:32PM +0100, Christoffer Dall wrote: > > &

Re: [PATCH v3 17/41] KVM: arm64: Remove noop calls to timer save/restore from VHE switch

2018-02-13 Thread Christoffer Dall
On Fri, Feb 09, 2018 at 05:53:43PM +, Julien Grall wrote: > Hi Christoffer, > > On 01/12/2018 12:07 PM, Christoffer Dall wrote: > >The VHE switch function calls __timer_enable_traps and > >__timer_disable_traps which don't do anything on VHE systems. > >Ther

Re: [PATCH v3 14/41] KVM: arm64: Introduce VHE-specific kvm_vcpu_run

2018-02-13 Thread Christoffer Dall
On Fri, Feb 09, 2018 at 05:34:05PM +, Julien Grall wrote: > Hi Christoffer, > > On 01/12/2018 12:07 PM, Christoffer Dall wrote: > >So far this is just a copy of the legacy non-VHE switch function, but we > >will start reworking these functions in separate directions to w

Re: [PATCH v3 09/41] KVM: arm64: Defer restoring host VFP state to vcpu_put

2018-02-13 Thread Christoffer Dall
On Fri, Feb 09, 2018 at 03:26:59PM +, Julien Grall wrote: > Hi Christoffer, > > On 01/12/2018 12:07 PM, 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 to

Re: [PATCH v3 09/41] KVM: arm64: Defer restoring host VFP state to vcpu_put

2018-02-13 Thread Christoffer Dall
On Fri, Feb 09, 2018 at 03:59:30PM +, Dave Martin wrote: > On Wed, Feb 07, 2018 at 06:56:44PM +0100, Christoffer Dall wrote: > > On Wed, Feb 07, 2018 at 04:49:55PM +, Dave Martin wrote: > > > On Thu, Jan 25, 2018 at 08:46:53PM +0100, Christoffer Dall wrote: > > >

Re: [PATCH v1 15/16] kvm: arm64: Allow configuring physical address space size

2018-02-09 Thread Christoffer Dall
On Thu, Feb 08, 2018 at 05:53:17PM +, Suzuki K Poulose wrote: > On 08/02/18 11:14, Christoffer Dall wrote: > >On Tue, Jan 09, 2018 at 07:04:10PM +, Suzuki K Poulose wrote: > >>Allow the guests to choose a larger physical address space size. > >>The default an

Re: [PATCH v1 14/16] kvm: arm64: Switch to per VM IPA

2018-02-09 Thread Christoffer Dall
On Thu, Feb 08, 2018 at 05:22:29PM +, Suzuki K Poulose wrote: > On 08/02/18 11:00, Christoffer Dall wrote: > >On Tue, Jan 09, 2018 at 07:04:09PM +, Suzuki K Poulose wrote: > >>Now that we can manage the stage2 page table per VM, switch the > >>configuration det

Re: [PATCH v1 08/16] kvm: arm/arm64: Clean up stage2 pgd life time

2018-02-09 Thread Christoffer Dall
On Thu, Feb 08, 2018 at 05:19:22PM +, Suzuki K Poulose wrote: > On 08/02/18 11:00, Christoffer Dall wrote: > >On Tue, Jan 09, 2018 at 07:04:03PM +, Suzuki K Poulose wrote: > >>On arm/arm64 we pre-allocate the entry level page tables when > >>a VM is created an

Re: [PATCH v1 13/16] kvm: arm64: Configure VTCR per VM

2018-02-08 Thread Christoffer Dall
table. The common configuration for > VTCR is still performed during the early init. But the SL0 > and T0SZ are programmed for each VM and is cleared once we > exit the VM. > > Cc: Marc Zyngier > Cc: Christoffer Dall > Signed-off-by: Suzuki K Poulose > ---

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