diff options
author | Marc Zyngier <marc.zyngier@arm.com> | 2015-10-28 10:15:45 -0400 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2016-02-29 13:34:17 -0500 |
commit | 328762247cd33b4533f9dd89a4faf40288f359b7 (patch) | |
tree | 59d51bc3be01fa15432ffe4d54eb593391ac3e9c /arch/arm64/kvm | |
parent | d1526e5efc3978efe8c9c37a2396d91e4702251b (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.h | 5 | ||||
-rw-r--r-- | arch/arm64/kvm/hyp/switch.c | 19 |
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 | ||
172 | void __fpsimd_save_state(struct user_fpsimd_state *fp_regs); | 172 | void __fpsimd_save_state(struct user_fpsimd_state *fp_regs); |
173 | void __fpsimd_restore_state(struct user_fpsimd_state *fp_regs); | 173 | void __fpsimd_restore_state(struct user_fpsimd_state *fp_regs); |
174 | static inline bool __fpsimd_enabled(void) | 174 | bool __fpsimd_enabled(void); |
175 | { | ||
176 | return !(read_sysreg(cptr_el2) & CPTR_EL2_TFP); | ||
177 | } | ||
178 | 175 | ||
179 | u64 __guest_enter(struct kvm_vcpu *vcpu, struct kvm_cpu_context *host_ctxt); | 176 | u64 __guest_enter(struct kvm_vcpu *vcpu, struct kvm_cpu_context *host_ctxt); |
180 | void __noreturn __hyp_do_panic(unsigned long, ...); | 177 | void __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 | ||
20 | static bool __hyp_text __fpsimd_enabled_nvhe(void) | ||
21 | { | ||
22 | return !(read_sysreg(cptr_el2) & CPTR_EL2_TFP); | ||
23 | } | ||
24 | |||
25 | static bool __hyp_text __fpsimd_enabled_vhe(void) | ||
26 | { | ||
27 | return !!(read_sysreg(cpacr_el1) & CPACR_EL1_FPEN); | ||
28 | } | ||
29 | |||
30 | static hyp_alternate_select(__fpsimd_is_enabled, | ||
31 | __fpsimd_enabled_nvhe, __fpsimd_enabled_vhe, | ||
32 | ARM64_HAS_VIRT_HOST_EXTN); | ||
33 | |||
34 | bool __hyp_text __fpsimd_enabled(void) | ||
35 | { | ||
36 | return __fpsimd_is_enabled()(); | ||
37 | } | ||
38 | |||
20 | static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu) | 39 | static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu) |
21 | { | 40 | { |
22 | u64 val; | 41 | u64 val; |