diff options
author | Mark Rutland <mark.rutland@arm.com> | 2018-10-17 12:42:10 -0400 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2018-10-17 13:32:46 -0400 |
commit | da5a3ce66b8bb51b0ea8a89f42aac153903f90fb (patch) | |
tree | 474db21720fe65162b016935cb55f6ec41287dbf /virt | |
parent | fd2ef358282c849c193aa36dadbf4f07f7dcd29b (diff) |
KVM: arm64: Fix caching of host MDCR_EL2 value
At boot time, KVM stashes the host MDCR_EL2 value, but only does this
when the kernel is not running in hyp mode (i.e. is non-VHE). In these
cases, the stashed value of MDCR_EL2.HPMN happens to be zero, which can
lead to CONSTRAINED UNPREDICTABLE behaviour.
Since we use this value to derive the MDCR_EL2 value when switching
to/from a guest, after a guest have been run, the performance counters
do not behave as expected. This has been observed to result in accesses
via PMXEVTYPER_EL0 and PMXEVCNTR_EL0 not affecting the relevant
counters, resulting in events not being counted. In these cases, only
the fixed-purpose cycle counter appears to work as expected.
Fix this by always stashing the host MDCR_EL2 value, regardless of VHE.
Cc: Christopher Dall <christoffer.dall@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: stable@vger.kernel.org
Fixes: 1e947bad0b63b351 ("arm64: KVM: Skip HYP setup when already running in HYP")
Tested-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/arm/arm.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index 4ce99bb223bc..4c5ff06b18f9 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c | |||
@@ -1296,8 +1296,6 @@ static void cpu_init_hyp_mode(void *dummy) | |||
1296 | 1296 | ||
1297 | __cpu_init_hyp_mode(pgd_ptr, hyp_stack_ptr, vector_ptr); | 1297 | __cpu_init_hyp_mode(pgd_ptr, hyp_stack_ptr, vector_ptr); |
1298 | __cpu_init_stage2(); | 1298 | __cpu_init_stage2(); |
1299 | |||
1300 | kvm_arm_init_debug(); | ||
1301 | } | 1299 | } |
1302 | 1300 | ||
1303 | static void cpu_hyp_reset(void) | 1301 | static void cpu_hyp_reset(void) |
@@ -1315,6 +1313,8 @@ static void cpu_hyp_reinit(void) | |||
1315 | else | 1313 | else |
1316 | cpu_init_hyp_mode(NULL); | 1314 | cpu_init_hyp_mode(NULL); |
1317 | 1315 | ||
1316 | kvm_arm_init_debug(); | ||
1317 | |||
1318 | if (vgic_present) | 1318 | if (vgic_present) |
1319 | kvm_vgic_init_cpu_hardware(); | 1319 | kvm_vgic_init_cpu_hardware(); |
1320 | } | 1320 | } |