diff options
author | Marc Zyngier <marc.zyngier@arm.com> | 2016-01-06 08:53:51 -0500 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2016-02-29 13:34:14 -0500 |
commit | 96e5e670cc681703c00eaf442c8796da6aa25ca0 (patch) | |
tree | cd94698dc26b77d6d1ca10c1092ae3822c2987b7 | |
parent | 89ef2b21ed2173e01995371261a9f9789bc1e47a (diff) |
ARM: KVM: Add VFP lazy save/restore handler
Similar to the arm64 version, add the code that deals with VFP traps,
re-enabling VFP, save/restoring the registers and resuming the guest.
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r-- | arch/arm/kvm/hyp/entry.S | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/arch/arm/kvm/hyp/entry.S b/arch/arm/kvm/hyp/entry.S index 32f79b090040..21c238871c9e 100644 --- a/arch/arm/kvm/hyp/entry.S +++ b/arch/arm/kvm/hyp/entry.S | |||
@@ -66,5 +66,36 @@ ENTRY(__guest_exit) | |||
66 | bx lr | 66 | bx lr |
67 | ENDPROC(__guest_exit) | 67 | ENDPROC(__guest_exit) |
68 | 68 | ||
69 | /* | ||
70 | * If VFPv3 support is not available, then we will not switch the VFP | ||
71 | * registers; however cp10 and cp11 accesses will still trap and fallback | ||
72 | * to the regular coprocessor emulation code, which currently will | ||
73 | * inject an undefined exception to the guest. | ||
74 | */ | ||
75 | #ifdef CONFIG_VFPv3 | ||
76 | ENTRY(__vfp_guest_restore) | ||
77 | push {r3, r4, lr} | ||
78 | |||
79 | @ NEON/VFP used. Turn on VFP access. | ||
80 | mrc p15, 4, r1, c1, c1, 2 @ HCPTR | ||
81 | bic r1, r1, #(HCPTR_TCP(10) | HCPTR_TCP(11)) | ||
82 | mcr p15, 4, r1, c1, c1, 2 @ HCPTR | ||
83 | isb | ||
84 | |||
85 | @ Switch VFP/NEON hardware state to the guest's | ||
86 | mov r4, r0 | ||
87 | ldr r0, [r0, #VCPU_HOST_CTXT] | ||
88 | add r0, r0, #CPU_CTXT_VFP | ||
89 | bl __vfp_save_state | ||
90 | add r0, r4, #(VCPU_GUEST_CTXT + CPU_CTXT_VFP) | ||
91 | bl __vfp_restore_state | ||
92 | |||
93 | pop {r3, r4, lr} | ||
94 | pop {r0, r1, r2} | ||
95 | clrex | ||
96 | eret | ||
97 | ENDPROC(__vfp_guest_restore) | ||
98 | #endif | ||
99 | |||
69 | .popsection | 100 | .popsection |
70 | 101 | ||