aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/kvm
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2015-10-28 10:15:45 -0400
committerMarc Zyngier <marc.zyngier@arm.com>2016-02-29 13:34:17 -0500
commit328762247cd33b4533f9dd89a4faf40288f359b7 (patch)
tree59d51bc3be01fa15432ffe4d54eb593391ac3e9c /arch/arm64/kvm
parentd1526e5efc3978efe8c9c37a2396d91e4702251b (diff)
arm64: KVM: VHE: Make __fpsimd_enabled VHE aware
As non-VHE and VHE have different ways to express the trapping of FPSIMD registers to EL2, make __fpsimd_enabled a patchable predicate and provide a VHE implementation. Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'arch/arm64/kvm')
-rw-r--r--arch/arm64/kvm/hyp/hyp.h5
-rw-r--r--arch/arm64/kvm/hyp/switch.c19
2 files changed, 20 insertions, 4 deletions
diff --git a/arch/arm64/kvm/hyp/hyp.h b/arch/arm64/kvm/hyp/hyp.h
index 5dfa8838a3e1..44eaff70da6a 100644
--- a/arch/arm64/kvm/hyp/hyp.h
+++ b/arch/arm64/kvm/hyp/hyp.h
@@ -171,10 +171,7 @@ void __debug_cond_restore_host_state(struct kvm_vcpu *vcpu);
171 171
172void __fpsimd_save_state(struct user_fpsimd_state *fp_regs); 172void __fpsimd_save_state(struct user_fpsimd_state *fp_regs);
173void __fpsimd_restore_state(struct user_fpsimd_state *fp_regs); 173void __fpsimd_restore_state(struct user_fpsimd_state *fp_regs);
174static inline bool __fpsimd_enabled(void) 174bool __fpsimd_enabled(void);
175{
176 return !(read_sysreg(cptr_el2) & CPTR_EL2_TFP);
177}
178 175
179u64 __guest_enter(struct kvm_vcpu *vcpu, struct kvm_cpu_context *host_ctxt); 176u64 __guest_enter(struct kvm_vcpu *vcpu, struct kvm_cpu_context *host_ctxt);
180void __noreturn __hyp_do_panic(unsigned long, ...); 177void __noreturn __hyp_do_panic(unsigned long, ...);
diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c
index 68f3cba25910..0d82ae921b9c 100644
--- a/arch/arm64/kvm/hyp/switch.c
+++ b/arch/arm64/kvm/hyp/switch.c
@@ -17,6 +17,25 @@
17 17
18#include "hyp.h" 18#include "hyp.h"
19 19
20static bool __hyp_text __fpsimd_enabled_nvhe(void)
21{
22 return !(read_sysreg(cptr_el2) & CPTR_EL2_TFP);
23}
24
25static bool __hyp_text __fpsimd_enabled_vhe(void)
26{
27 return !!(read_sysreg(cpacr_el1) & CPACR_EL1_FPEN);
28}
29
30static hyp_alternate_select(__fpsimd_is_enabled,
31 __fpsimd_enabled_nvhe, __fpsimd_enabled_vhe,
32 ARM64_HAS_VIRT_HOST_EXTN);
33
34bool __hyp_text __fpsimd_enabled(void)
35{
36 return __fpsimd_is_enabled()();
37}
38
20static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu) 39static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu)
21{ 40{
22 u64 val; 41 u64 val;