blob: f3d8bed096f50a435d113a95a9f0f377cd5221a0 [file] [log] [blame]
Marc Zyngierbe901e92015-10-21 09:57:10 +01001/*
2 * Copyright (C) 2015 - ARM Ltd
3 * Author: Marc Zyngier <marc.zyngier@arm.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
Marc Zyngier5f05a722015-10-28 15:06:47 +000018#include <linux/types.h>
Vladimir Murzin5a7a8422016-09-12 15:49:15 +010019#include <linux/jump_label.h>
20
Marc Zyngier68908bf2015-01-29 15:47:55 +000021#include <asm/kvm_asm.h>
Marc Zyngierfb5ee362016-09-06 09:28:45 +010022#include <asm/kvm_emulate.h>
Marc Zyngier13720a52016-01-28 13:44:07 +000023#include <asm/kvm_hyp.h>
Marc Zyngierd6811982017-10-23 17:11:14 +010024#include <asm/kvm_mmu.h>
Suzuki K Poulose82e01912016-11-08 13:56:21 +000025#include <asm/fpsimd.h>
Alex Bennéee3feebf2017-11-23 12:11:34 +000026#include <asm/debug-monitors.h>
Marc Zyngierbe901e92015-10-21 09:57:10 +010027
Marc Zyngier32876222015-10-28 14:15:45 +000028static bool __hyp_text __fpsimd_enabled_nvhe(void)
29{
30 return !(read_sysreg(cptr_el2) & CPTR_EL2_TFP);
31}
32
33static bool __hyp_text __fpsimd_enabled_vhe(void)
34{
35 return !!(read_sysreg(cpacr_el1) & CPACR_EL1_FPEN);
36}
37
38static hyp_alternate_select(__fpsimd_is_enabled,
39 __fpsimd_enabled_nvhe, __fpsimd_enabled_vhe,
40 ARM64_HAS_VIRT_HOST_EXTN);
41
42bool __hyp_text __fpsimd_enabled(void)
43{
44 return __fpsimd_is_enabled()();
45}
46
Marc Zyngier68908bf2015-01-29 15:47:55 +000047static void __hyp_text __activate_traps_vhe(void)
48{
49 u64 val;
50
51 val = read_sysreg(cpacr_el1);
52 val |= CPACR_EL1_TTA;
Dave Martin17eed272017-10-31 15:51:16 +000053 val &= ~(CPACR_EL1_FPEN | CPACR_EL1_ZEN);
Marc Zyngier68908bf2015-01-29 15:47:55 +000054 write_sysreg(val, cpacr_el1);
55
56 write_sysreg(__kvm_hyp_vector, vbar_el1);
57}
58
59static void __hyp_text __activate_traps_nvhe(void)
60{
61 u64 val;
62
63 val = CPTR_EL2_DEFAULT;
Dave Martin17eed272017-10-31 15:51:16 +000064 val |= CPTR_EL2_TTA | CPTR_EL2_TFP | CPTR_EL2_TZ;
Marc Zyngier68908bf2015-01-29 15:47:55 +000065 write_sysreg(val, cptr_el2);
66}
67
68static hyp_alternate_select(__activate_traps_arch,
69 __activate_traps_nvhe, __activate_traps_vhe,
70 ARM64_HAS_VIRT_HOST_EXTN);
71
Marc Zyngierbe901e92015-10-21 09:57:10 +010072static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu)
73{
74 u64 val;
75
76 /*
77 * We are about to set CPTR_EL2.TFP to trap all floating point
78 * register accesses to EL2, however, the ARM ARM clearly states that
79 * traps are only taken to EL2 if the operation would not otherwise
80 * trap to EL1. Therefore, always make sure that for 32-bit guests,
81 * we set FPEXC.EN to prevent traps to EL1, when setting the TFP bit.
Suzuki K Poulose82e01912016-11-08 13:56:21 +000082 * If FP/ASIMD is not implemented, FPEXC is UNDEFINED and any access to
83 * it will cause an exception.
Marc Zyngierbe901e92015-10-21 09:57:10 +010084 */
85 val = vcpu->arch.hcr_el2;
Dave Martin93390c02017-10-31 15:50:56 +000086
Suzuki K Poulose82e01912016-11-08 13:56:21 +000087 if (!(val & HCR_RW) && system_supports_fpsimd()) {
Marc Zyngierbe901e92015-10-21 09:57:10 +010088 write_sysreg(1 << 30, fpexc32_el2);
89 isb();
90 }
Dave Martin93390c02017-10-31 15:50:56 +000091
92 if (val & HCR_RW) /* for AArch64 only: */
93 val |= HCR_TID3; /* TID3: trap feature register accesses */
94
Marc Zyngierbe901e92015-10-21 09:57:10 +010095 write_sysreg(val, hcr_el2);
Dave Martin93390c02017-10-31 15:50:56 +000096
Marc Zyngierbe901e92015-10-21 09:57:10 +010097 /* Trap on AArch32 cp15 c15 accesses (EL1 or EL0) */
98 write_sysreg(1 << 15, hstr_el2);
Marc Zyngier21cbe3c2016-12-06 14:34:22 +000099 /*
100 * Make sure we trap PMU access from EL0 to EL2. Also sanitize
101 * PMSELR_EL0 to make sure it never contains the cycle
102 * counter, which could make a PMXEVCNTR_EL0 access UNDEF at
103 * EL1 instead of being trapped to EL2.
104 */
105 write_sysreg(0, pmselr_el0);
Shannon Zhaod692b8a2015-09-08 15:15:56 +0800106 write_sysreg(ARMV8_PMU_USERENR_MASK, pmuserenr_el0);
Marc Zyngierbe901e92015-10-21 09:57:10 +0100107 write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2);
Marc Zyngier68908bf2015-01-29 15:47:55 +0000108 __activate_traps_arch()();
Marc Zyngierbe901e92015-10-21 09:57:10 +0100109}
110
Marc Zyngier68908bf2015-01-29 15:47:55 +0000111static void __hyp_text __deactivate_traps_vhe(void)
112{
113 extern char vectors[]; /* kernel exception vectors */
Will Deaconf85279b2016-09-22 11:35:43 +0100114 u64 mdcr_el2 = read_sysreg(mdcr_el2);
Marc Zyngier68908bf2015-01-29 15:47:55 +0000115
Will Deaconf85279b2016-09-22 11:35:43 +0100116 mdcr_el2 &= MDCR_EL2_HPMN_MASK |
117 MDCR_EL2_E2PB_MASK << MDCR_EL2_E2PB_SHIFT |
118 MDCR_EL2_TPMS;
119
120 write_sysreg(mdcr_el2, mdcr_el2);
Marc Zyngier68908bf2015-01-29 15:47:55 +0000121 write_sysreg(HCR_HOST_VHE_FLAGS, hcr_el2);
Dave Martin17eed272017-10-31 15:51:16 +0000122 write_sysreg(CPACR_EL1_DEFAULT, cpacr_el1);
Marc Zyngier68908bf2015-01-29 15:47:55 +0000123 write_sysreg(vectors, vbar_el1);
124}
125
126static void __hyp_text __deactivate_traps_nvhe(void)
127{
Will Deaconf85279b2016-09-22 11:35:43 +0100128 u64 mdcr_el2 = read_sysreg(mdcr_el2);
129
130 mdcr_el2 &= MDCR_EL2_HPMN_MASK;
131 mdcr_el2 |= MDCR_EL2_E2PB_MASK << MDCR_EL2_E2PB_SHIFT;
132
133 write_sysreg(mdcr_el2, mdcr_el2);
Marc Zyngier68908bf2015-01-29 15:47:55 +0000134 write_sysreg(HCR_RW, hcr_el2);
135 write_sysreg(CPTR_EL2_DEFAULT, cptr_el2);
136}
137
138static hyp_alternate_select(__deactivate_traps_arch,
139 __deactivate_traps_nvhe, __deactivate_traps_vhe,
140 ARM64_HAS_VIRT_HOST_EXTN);
141
Marc Zyngierbe901e92015-10-21 09:57:10 +0100142static void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu)
143{
Marc Zyngier44636f92016-09-06 14:02:00 +0100144 /*
145 * If we pended a virtual abort, preserve it until it gets
146 * cleared. See D1.14.3 (Virtual Interrupts) for details, but
147 * the crucial bit is "On taking a vSError interrupt,
148 * HCR_EL2.VSE is cleared to 0."
149 */
150 if (vcpu->arch.hcr_el2 & HCR_VSE)
151 vcpu->arch.hcr_el2 = read_sysreg(hcr_el2);
152
Marc Zyngier68908bf2015-01-29 15:47:55 +0000153 __deactivate_traps_arch()();
Marc Zyngierbe901e92015-10-21 09:57:10 +0100154 write_sysreg(0, hstr_el2);
Shannon Zhaod692b8a2015-09-08 15:15:56 +0800155 write_sysreg(0, pmuserenr_el0);
Marc Zyngierbe901e92015-10-21 09:57:10 +0100156}
157
158static void __hyp_text __activate_vm(struct kvm_vcpu *vcpu)
159{
160 struct kvm *kvm = kern_hyp_va(vcpu->kvm);
161 write_sysreg(kvm->arch.vttbr, vttbr_el2);
162}
163
164static void __hyp_text __deactivate_vm(struct kvm_vcpu *vcpu)
165{
166 write_sysreg(0, vttbr_el2);
167}
168
Marc Zyngierbe901e92015-10-21 09:57:10 +0100169static void __hyp_text __vgic_save_state(struct kvm_vcpu *vcpu)
170{
Vladimir Murzin5a7a8422016-09-12 15:49:15 +0100171 if (static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif))
172 __vgic_v3_save_state(vcpu);
173 else
174 __vgic_v2_save_state(vcpu);
175
Marc Zyngierbe901e92015-10-21 09:57:10 +0100176 write_sysreg(read_sysreg(hcr_el2) & ~HCR_INT_OVERRIDE, hcr_el2);
177}
178
179static void __hyp_text __vgic_restore_state(struct kvm_vcpu *vcpu)
180{
181 u64 val;
182
183 val = read_sysreg(hcr_el2);
184 val |= HCR_INT_OVERRIDE;
185 val |= vcpu->arch.irq_lines;
186 write_sysreg(val, hcr_el2);
187
Vladimir Murzin5a7a8422016-09-12 15:49:15 +0100188 if (static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif))
189 __vgic_v3_restore_state(vcpu);
190 else
191 __vgic_v2_restore_state(vcpu);
Marc Zyngierbe901e92015-10-21 09:57:10 +0100192}
193
Marc Zyngier5f05a722015-10-28 15:06:47 +0000194static bool __hyp_text __true_value(void)
195{
196 return true;
197}
198
199static bool __hyp_text __false_value(void)
200{
201 return false;
202}
203
204static hyp_alternate_select(__check_arm_834220,
205 __false_value, __true_value,
206 ARM64_WORKAROUND_834220);
207
208static bool __hyp_text __translate_far_to_hpfar(u64 far, u64 *hpfar)
209{
210 u64 par, tmp;
211
212 /*
213 * Resolve the IPA the hard way using the guest VA.
214 *
215 * Stage-1 translation already validated the memory access
216 * rights. As such, we can use the EL1 translation regime, and
217 * don't have to distinguish between EL0 and EL1 access.
218 *
219 * We do need to save/restore PAR_EL1 though, as we haven't
220 * saved the guest context yet, and we may return early...
221 */
222 par = read_sysreg(par_el1);
223 asm volatile("at s1e1r, %0" : : "r" (far));
224 isb();
225
226 tmp = read_sysreg(par_el1);
227 write_sysreg(par, par_el1);
228
229 if (unlikely(tmp & 1))
230 return false; /* Translation failed, back to guest */
231
232 /* Convert PAR to HPFAR format */
233 *hpfar = ((tmp >> 12) & ((1UL << 36) - 1)) << 4;
234 return true;
235}
236
237static bool __hyp_text __populate_fault_info(struct kvm_vcpu *vcpu)
238{
239 u64 esr = read_sysreg_el2(esr);
Mark Rutland561454e2016-05-31 12:33:02 +0100240 u8 ec = ESR_ELx_EC(esr);
Marc Zyngier5f05a722015-10-28 15:06:47 +0000241 u64 hpfar, far;
242
243 vcpu->arch.fault.esr_el2 = esr;
244
245 if (ec != ESR_ELx_EC_DABT_LOW && ec != ESR_ELx_EC_IABT_LOW)
246 return true;
247
248 far = read_sysreg_el2(far);
249
250 /*
251 * The HPFAR can be invalid if the stage 2 fault did not
252 * happen during a stage 1 page table walk (the ESR_EL2.S1PTW
253 * bit is clear) and one of the two following cases are true:
254 * 1. The fault was due to a permission fault
255 * 2. The processor carries errata 834220
256 *
257 * Therefore, for all non S1PTW faults where we either have a
258 * permission fault or the errata workaround is enabled, we
259 * resolve the IPA using the AT instruction.
260 */
261 if (!(esr & ESR_ELx_S1PTW) &&
262 (__check_arm_834220()() || (esr & ESR_ELx_FSC_TYPE) == FSC_PERM)) {
263 if (!__translate_far_to_hpfar(far, &hpfar))
264 return false;
265 } else {
266 hpfar = read_sysreg(hpfar_el2);
267 }
268
269 vcpu->arch.fault.far_el2 = far;
270 vcpu->arch.fault.hpfar_el2 = hpfar;
271 return true;
272}
273
Alex Bennéee3feebf2017-11-23 12:11:34 +0000274/* Skip an instruction which has been emulated. Returns true if
275 * execution can continue or false if we need to exit hyp mode because
276 * single-step was in effect.
277 */
278static bool __hyp_text __skip_instr(struct kvm_vcpu *vcpu)
Marc Zyngierfb5ee362016-09-06 09:28:45 +0100279{
280 *vcpu_pc(vcpu) = read_sysreg_el2(elr);
281
282 if (vcpu_mode_is_32bit(vcpu)) {
283 vcpu->arch.ctxt.gp_regs.regs.pstate = read_sysreg_el2(spsr);
284 kvm_skip_instr32(vcpu, kvm_vcpu_trap_il_is32bit(vcpu));
285 write_sysreg_el2(vcpu->arch.ctxt.gp_regs.regs.pstate, spsr);
286 } else {
287 *vcpu_pc(vcpu) += 4;
288 }
289
290 write_sysreg_el2(*vcpu_pc(vcpu), elr);
Alex Bennéee3feebf2017-11-23 12:11:34 +0000291
292 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) {
293 vcpu->arch.fault.esr_el2 =
294 (ESR_ELx_EC_SOFTSTP_LOW << ESR_ELx_EC_SHIFT) | 0x22;
295 return false;
296 } else {
297 return true;
298 }
Marc Zyngierfb5ee362016-09-06 09:28:45 +0100299}
300
Christoffer Dallcf0ba182016-09-01 13:16:03 +0200301int __hyp_text __kvm_vcpu_run(struct kvm_vcpu *vcpu)
Marc Zyngierbe901e92015-10-21 09:57:10 +0100302{
303 struct kvm_cpu_context *host_ctxt;
304 struct kvm_cpu_context *guest_ctxt;
Marc Zyngierc13d1682015-10-26 08:34:09 +0000305 bool fp_enabled;
Marc Zyngierbe901e92015-10-21 09:57:10 +0100306 u64 exit_code;
307
308 vcpu = kern_hyp_va(vcpu);
309 write_sysreg(vcpu, tpidr_el2);
310
311 host_ctxt = kern_hyp_va(vcpu->arch.host_cpu_context);
312 guest_ctxt = &vcpu->arch.ctxt;
313
Marc Zyngieredef5282015-10-28 12:17:35 +0000314 __sysreg_save_host_state(host_ctxt);
Marc Zyngierbe901e92015-10-21 09:57:10 +0100315 __debug_cond_save_host_state(vcpu);
316
317 __activate_traps(vcpu);
318 __activate_vm(vcpu);
319
320 __vgic_restore_state(vcpu);
Christoffer Dall688c50a2017-01-04 16:10:28 +0100321 __timer_enable_traps(vcpu);
Marc Zyngierbe901e92015-10-21 09:57:10 +0100322
323 /*
324 * We must restore the 32-bit state before the sysregs, thanks
Marc Zyngier674e7012016-08-16 15:03:01 +0100325 * to erratum #852523 (Cortex-A57) or #853709 (Cortex-A72).
Marc Zyngierbe901e92015-10-21 09:57:10 +0100326 */
327 __sysreg32_restore_state(vcpu);
Marc Zyngieredef5282015-10-28 12:17:35 +0000328 __sysreg_restore_guest_state(guest_ctxt);
Marc Zyngierbe901e92015-10-21 09:57:10 +0100329 __debug_restore_state(vcpu, kern_hyp_va(vcpu->arch.debug_ptr), guest_ctxt);
330
331 /* Jump in the fire! */
Marc Zyngier5f05a722015-10-28 15:06:47 +0000332again:
Marc Zyngierbe901e92015-10-21 09:57:10 +0100333 exit_code = __guest_enter(vcpu, host_ctxt);
334 /* And we're baaack! */
335
Marc Zyngier395ea792016-09-06 14:02:07 +0100336 /*
337 * We're using the raw exception code in order to only process
338 * the trap if no SError is pending. We will come back to the
339 * same PC once the SError has been injected, and replay the
340 * trapping instruction.
341 */
Marc Zyngier5f05a722015-10-28 15:06:47 +0000342 if (exit_code == ARM_EXCEPTION_TRAP && !__populate_fault_info(vcpu))
343 goto again;
344
Marc Zyngierfb5ee362016-09-06 09:28:45 +0100345 if (static_branch_unlikely(&vgic_v2_cpuif_trap) &&
346 exit_code == ARM_EXCEPTION_TRAP) {
347 bool valid;
348
349 valid = kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_DABT_LOW &&
350 kvm_vcpu_trap_get_fault_type(vcpu) == FSC_FAULT &&
351 kvm_vcpu_dabt_isvalid(vcpu) &&
352 !kvm_vcpu_dabt_isextabt(vcpu) &&
353 !kvm_vcpu_dabt_iss1tw(vcpu);
354
Marc Zyngier3272f0d2016-09-06 14:02:17 +0100355 if (valid) {
356 int ret = __vgic_v2_perform_cpuif_access(vcpu);
357
358 if (ret == 1) {
Alex Bennéee3feebf2017-11-23 12:11:34 +0000359 if (__skip_instr(vcpu))
360 goto again;
361 else
362 exit_code = ARM_EXCEPTION_TRAP;
Marc Zyngier3272f0d2016-09-06 14:02:17 +0100363 }
364
365 if (ret == -1) {
Alex Bennéee3feebf2017-11-23 12:11:34 +0000366 /* Promote an illegal access to an
367 * SError. If we would be returning
368 * due to single-step clear the SS
369 * bit so handle_exit knows what to
370 * do after dealing with the error.
371 */
372 if (!__skip_instr(vcpu))
373 *vcpu_cpsr(vcpu) &= ~DBG_SPSR_SS;
Marc Zyngier3272f0d2016-09-06 14:02:17 +0100374 exit_code = ARM_EXCEPTION_EL1_SERROR;
375 }
376
377 /* 0 falls through to be handler out of EL2 */
Marc Zyngierfb5ee362016-09-06 09:28:45 +0100378 }
379 }
380
Marc Zyngier59da1cb2017-06-09 12:49:33 +0100381 if (static_branch_unlikely(&vgic_v3_cpuif_trap) &&
382 exit_code == ARM_EXCEPTION_TRAP &&
383 (kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_SYS64 ||
384 kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_CP15_32)) {
385 int ret = __vgic_v3_perform_cpuif_access(vcpu);
386
387 if (ret == 1) {
Alex Bennéee3feebf2017-11-23 12:11:34 +0000388 if (__skip_instr(vcpu))
389 goto again;
390 else
391 exit_code = ARM_EXCEPTION_TRAP;
Marc Zyngier59da1cb2017-06-09 12:49:33 +0100392 }
393
394 /* 0 falls through to be handled out of EL2 */
395 }
396
Marc Zyngierc13d1682015-10-26 08:34:09 +0000397 fp_enabled = __fpsimd_enabled();
398
Marc Zyngieredef5282015-10-28 12:17:35 +0000399 __sysreg_save_guest_state(guest_ctxt);
Marc Zyngierbe901e92015-10-21 09:57:10 +0100400 __sysreg32_save_state(vcpu);
Christoffer Dall688c50a2017-01-04 16:10:28 +0100401 __timer_disable_traps(vcpu);
Marc Zyngierbe901e92015-10-21 09:57:10 +0100402 __vgic_save_state(vcpu);
403
404 __deactivate_traps(vcpu);
405 __deactivate_vm(vcpu);
406
Marc Zyngieredef5282015-10-28 12:17:35 +0000407 __sysreg_restore_host_state(host_ctxt);
Marc Zyngierbe901e92015-10-21 09:57:10 +0100408
Marc Zyngierc13d1682015-10-26 08:34:09 +0000409 if (fp_enabled) {
410 __fpsimd_save_state(&guest_ctxt->gp_regs.fp_regs);
411 __fpsimd_restore_state(&host_ctxt->gp_regs.fp_regs);
412 }
413
Marc Zyngierbe901e92015-10-21 09:57:10 +0100414 __debug_save_state(vcpu, kern_hyp_va(vcpu->arch.debug_ptr), guest_ctxt);
Will Deaconf85279b2016-09-22 11:35:43 +0100415 /*
416 * This must come after restoring the host sysregs, since a non-VHE
417 * system may enable SPE here and make use of the TTBRs.
418 */
Marc Zyngierbe901e92015-10-21 09:57:10 +0100419 __debug_cond_restore_host_state(vcpu);
420
421 return exit_code;
422}
Marc Zyngier53fd5b62015-10-25 15:21:52 +0000423
424static const char __hyp_panic_string[] = "HYP panic:\nPS:%08llx PC:%016llx ESR:%08llx\nFAR:%016llx HPFAR:%016llx PAR:%016llx\nVCPU:%p\n";
425
Marc Zyngier253dcbd2015-11-17 14:07:45 +0000426static void __hyp_text __hyp_call_panic_nvhe(u64 spsr, u64 elr, u64 par)
Marc Zyngier53fd5b62015-10-25 15:21:52 +0000427{
Marc Zyngiercf7df132016-06-30 18:40:35 +0100428 unsigned long str_va;
Marc Zyngier253dcbd2015-11-17 14:07:45 +0000429
Marc Zyngiercf7df132016-06-30 18:40:35 +0100430 /*
431 * Force the panic string to be loaded from the literal pool,
432 * making sure it is a kernel address and not a PC-relative
433 * reference.
434 */
435 asm volatile("ldr %0, =__hyp_panic_string" : "=r" (str_va));
436
437 __hyp_do_panic(str_va,
Marc Zyngier253dcbd2015-11-17 14:07:45 +0000438 spsr, elr,
439 read_sysreg(esr_el2), read_sysreg_el2(far),
440 read_sysreg(hpfar_el2), par,
441 (void *)read_sysreg(tpidr_el2));
442}
443
444static void __hyp_text __hyp_call_panic_vhe(u64 spsr, u64 elr, u64 par)
445{
446 panic(__hyp_panic_string,
447 spsr, elr,
448 read_sysreg_el2(esr), read_sysreg_el2(far),
449 read_sysreg(hpfar_el2), par,
450 (void *)read_sysreg(tpidr_el2));
451}
452
453static hyp_alternate_select(__hyp_call_panic,
454 __hyp_call_panic_nvhe, __hyp_call_panic_vhe,
455 ARM64_HAS_VIRT_HOST_EXTN);
456
457void __hyp_text __noreturn __hyp_panic(void)
458{
459 u64 spsr = read_sysreg_el2(spsr);
460 u64 elr = read_sysreg_el2(elr);
Marc Zyngier53fd5b62015-10-25 15:21:52 +0000461 u64 par = read_sysreg(par_el1);
462
463 if (read_sysreg(vttbr_el2)) {
464 struct kvm_vcpu *vcpu;
465 struct kvm_cpu_context *host_ctxt;
466
467 vcpu = (struct kvm_vcpu *)read_sysreg(tpidr_el2);
468 host_ctxt = kern_hyp_va(vcpu->arch.host_cpu_context);
Christoffer Dall688c50a2017-01-04 16:10:28 +0100469 __timer_disable_traps(vcpu);
Marc Zyngier53fd5b62015-10-25 15:21:52 +0000470 __deactivate_traps(vcpu);
471 __deactivate_vm(vcpu);
Marc Zyngieredef5282015-10-28 12:17:35 +0000472 __sysreg_restore_host_state(host_ctxt);
Marc Zyngier53fd5b62015-10-25 15:21:52 +0000473 }
474
475 /* Call panic for real */
Marc Zyngier253dcbd2015-11-17 14:07:45 +0000476 __hyp_call_panic()(spsr, elr, par);
Marc Zyngier53fd5b62015-10-25 15:21:52 +0000477
478 unreachable();
479}