]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: Access CNTHCTL_EL2 bit fields correctly on VHE systems
authorJintack Lim <jintack@cs.columbia.edu>
Thu, 1 Dec 2016 19:32:05 +0000 (14:32 -0500)
committerMarc Zyngier <marc.zyngier@arm.com>
Fri, 13 Jan 2017 11:19:25 +0000 (11:19 +0000)
commit89b61fbdc754e9131707a44f439d3bf23ae38209
tree92ea732034f13a0de44c5ec928b6be2d23cde32f
parent09c630ffc1cb002590f9a7981999aca0d1696251
KVM: arm64: Access CNTHCTL_EL2 bit fields correctly on VHE systems

Current KVM world switch code is unintentionally setting wrong bits to
CNTHCTL_EL2 when E2H == 1, which may allow guest OS to access physical
timer.  Bit positions of CNTHCTL_EL2 are changing depending on
HCR_EL2.E2H bit.  EL1PCEN and EL1PCTEN are 1st and 0th bits when E2H is
not set, but they are 11th and 10th bits respectively when E2H is set.

In fact, on VHE we only need to set those bits once, not for every world
switch. This is because the host kernel runs in EL2 with HCR_EL2.TGE ==
1, which makes those bits have no effect for the host kernel execution.
So we just set those bits once for guests, and that's it.

Signed-off-by: Jintack Lim <jintack@cs.columbia.edu>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
arch/arm/include/asm/virt.h
arch/arm/kvm/arm.c
arch/arm64/include/asm/virt.h
include/kvm/arm_arch_timer.h
virt/kvm/arm/arch_timer.c
virt/kvm/arm/hyp/timer-sr.c