linux/arch/arm64/kvm/hyp
Christoffer Dall 4464e210de KVM: arm64: Avoid storing the vcpu pointer on the stack
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 on
every context switch.  We can be a little more clever and just use
tpidr_el2 for the percpu offset and load the VCPU pointer from the host
context.

This has the benefit of being able to retrieve the host context even
when our stack is corrupted, and it has a potential performance benefit
because we trade a store plus a load for an mrs and a load on a round
trip to the guest.

This does require us to calculate the percpu offset without including
the offset from the kernel mapping of the percpu array to the linear
mapping of the array (which is what we store in tpidr_el1), because a
PC-relative generated address in EL2 is already giving us the hyp alias
of the linear mapping of a kernel address.  We do this in
__cpu_init_hyp_mode() by using kvm_ksym_ref().

The code that accesses ESR_EL2 was previously using an alternative to
use 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 <ard.biesheuvel@linaro.org>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
2018-03-19 10:53:09 +00:00
..
debug-sr.c Merge branch 'x86/hyperv' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2018-02-01 15:04:17 +01:00
entry.S KVM: arm64: Avoid storing the vcpu pointer on the stack 2018-03-19 10:53:09 +00:00
fpsimd.S arm64: KVM: Implement fpsimd save/restore 2015-12-14 11:30:41 +00:00
hyp-entry.S KVM: arm64: Avoid storing the vcpu pointer on the stack 2018-03-19 10:53:09 +00:00
Makefile Fixes for interrupt controller emulation in ARM/ARM64 and x86, plus a one-liner 2017-11-04 11:44:55 -07:00
s2-setup.c KVM: arm64: Stop save/restoring host tpidr_el1 on VHE 2018-01-13 10:44:40 +00:00
switch.c KVM: arm64: Avoid storing the vcpu pointer on the stack 2018-03-19 10:53:09 +00:00
sysreg-sr.c KVM: arm64: Avoid storing the vcpu pointer on the stack 2018-03-19 10:53:09 +00:00
tlb.c KVM: arm/arm64: Detangle kvm_mmu.h from kvm_hyp.h 2018-01-08 15:20:43 +01:00