diff options
author | Julien Thierry <julien.thierry@arm.com> | 2017-12-06 12:09:49 -0500 |
---|---|---|
committer | Christoffer Dall <christoffer.dall@linaro.org> | 2017-12-18 04:53:22 -0500 |
commit | bfe766cf65fb65e68c4764f76158718560bdcee5 (patch) | |
tree | dbca7a94f09182a850f02f0d521c87b470eedfd8 | |
parent | 50c4c4e268a2d7a3e58ebb698ac74da0de40ae36 (diff) |
arm64: kvm: Prevent restoring stale PMSCR_EL1 for vcpu
When VHE is not present, KVM needs to save and restores PMSCR_EL1 when
possible. If SPE is used by the host, value of PMSCR_EL1 cannot be saved
for the guest.
If the host starts using SPE between two save+restore 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 <julien.thierry@arm.com>
Cc: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: <stable@vger.kernel.org>
Reviewed-by: Will Deacon <will.deacon@arm.com>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
-rw-r--r-- | arch/arm64/kvm/hyp/debug-sr.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/arm64/kvm/hyp/debug-sr.c b/arch/arm64/kvm/hyp/debug-sr.c index 321c9c05dd9e..f4363d40e2cd 100644 --- a/arch/arm64/kvm/hyp/debug-sr.c +++ b/arch/arm64/kvm/hyp/debug-sr.c | |||
@@ -74,6 +74,9 @@ static void __hyp_text __debug_save_spe_nvhe(u64 *pmscr_el1) | |||
74 | { | 74 | { |
75 | u64 reg; | 75 | u64 reg; |
76 | 76 | ||
77 | /* Clear pmscr in case of early return */ | ||
78 | *pmscr_el1 = 0; | ||
79 | |||
77 | /* SPE present on this CPU? */ | 80 | /* SPE present on this CPU? */ |
78 | if (!cpuid_feature_extract_unsigned_field(read_sysreg(id_aa64dfr0_el1), | 81 | if (!cpuid_feature_extract_unsigned_field(read_sysreg(id_aa64dfr0_el1), |
79 | ID_AA64DFR0_PMSVER_SHIFT)) | 82 | ID_AA64DFR0_PMSVER_SHIFT)) |