entry.S (7c2e76d87f9ce7af47a07ca803343fd5f4aa4ab5) entry.S (7db21530479f071ee0e0a4d5fcf5e6bc6c0352ba)
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2015 - ARM Ltd
4 * Author: Marc Zyngier <marc.zyngier@arm.com>
5 */
6
7#include <linux/linkage.h>
8

--- 72 unchanged lines hidden (view full) ---

81 isb
82alternative_else_nop_endif
83 mrs x1, isr_el1
84 cbz x1, 1f
85 mov x0, #ARM_EXCEPTION_IRQ
86 ret
87
881:
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2015 - ARM Ltd
4 * Author: Marc Zyngier <marc.zyngier@arm.com>
5 */
6
7#include <linux/linkage.h>
8

--- 72 unchanged lines hidden (view full) ---

81 isb
82alternative_else_nop_endif
83 mrs x1, isr_el1
84 cbz x1, 1f
85 mov x0, #ARM_EXCEPTION_IRQ
86 ret
87
881:
89 set_loaded_vcpu x0, x1, x2
90
89 add x29, x0, #VCPU_CONTEXT
90
91 // Macro ptrauth_switch_to_guest format:
92 // ptrauth_switch_to_guest(guest cxt, tmp1, tmp2, tmp3)
93 // The below macro to restore guest keys is not implemented in C code
94 // as it may cause Pointer Authentication key signing mismatch errors
95 // when this feature is enabled for kernel code.
96 ptrauth_switch_to_guest x29, x0, x1, x2

--- 14 unchanged lines hidden (view full) ---

111
112 // Restore guest regs x18-x29, lr
113 restore_callee_saved_regs x29
114
115 // Do not touch any register after this!
116 eret
117 sb
118
91 add x29, x0, #VCPU_CONTEXT
92
93 // Macro ptrauth_switch_to_guest format:
94 // ptrauth_switch_to_guest(guest cxt, tmp1, tmp2, tmp3)
95 // The below macro to restore guest keys is not implemented in C code
96 // as it may cause Pointer Authentication key signing mismatch errors
97 // when this feature is enabled for kernel code.
98 ptrauth_switch_to_guest x29, x0, x1, x2

--- 14 unchanged lines hidden (view full) ---

113
114 // Restore guest regs x18-x29, lr
115 restore_callee_saved_regs x29
116
117 // Do not touch any register after this!
118 eret
119 sb
120
121SYM_INNER_LABEL(__guest_exit_panic, SYM_L_GLOBAL)
122 // x2-x29,lr: vcpu regs
123 // vcpu x0-x1 on the stack
124
125 // If the hyp context is loaded, go straight to hyp_panic
126 get_loaded_vcpu x0, x1
127 cbz x0, hyp_panic
128
129 // The hyp context is saved so make sure it is restored to allow
130 // hyp_panic to run at hyp and, subsequently, panic to run in the host.
131 // This makes use of __guest_exit to avoid duplication but sets the
132 // return address to tail call into hyp_panic. As a side effect, the
133 // current state is saved to the guest context but it will only be
134 // accurate if the guest had been completely restored.
135 hyp_adr_this_cpu x0, kvm_hyp_ctxt, x1
136 adr x1, hyp_panic
137 str x1, [x0, #CPU_XREG_OFFSET(30)]
138
139 get_vcpu_ptr x1, x0
140
119SYM_INNER_LABEL(__guest_exit, SYM_L_GLOBAL)
120 // x0: return code
121 // x1: vcpu
122 // x2-x29,lr: vcpu regs
123 // vcpu x0-x1 on the stack
124
125 add x1, x1, #VCPU_CONTEXT
126

--- 31 unchanged lines hidden (view full) ---

158 ptrauth_switch_to_hyp x1, x2, x3, x4, x5
159
160 // Restore hyp's sp_el0
161 restore_sp_el0 x2, x3
162
163 // Now restore the hyp regs
164 restore_callee_saved_regs x2
165
141SYM_INNER_LABEL(__guest_exit, SYM_L_GLOBAL)
142 // x0: return code
143 // x1: vcpu
144 // x2-x29,lr: vcpu regs
145 // vcpu x0-x1 on the stack
146
147 add x1, x1, #VCPU_CONTEXT
148

--- 31 unchanged lines hidden (view full) ---

180 ptrauth_switch_to_hyp x1, x2, x3, x4, x5
181
182 // Restore hyp's sp_el0
183 restore_sp_el0 x2, x3
184
185 // Now restore the hyp regs
186 restore_callee_saved_regs x2
187
188 set_loaded_vcpu xzr, x1, x2
189
166alternative_if ARM64_HAS_RAS_EXTN
167 // If we have the RAS extensions we can consume a pending error
168 // without an unmask-SError and isb. The ESB-instruction consumed any
169 // pending guest error when we took the exception from the guest.
170 mrs_s x2, SYS_DISR_EL1
171 str x2, [x1, #(VCPU_FAULT_DISR - VCPU_CONTEXT)]
172 cbz x2, 1f
173 msr_s SYS_DISR_EL1, xzr

--- 48 unchanged lines hidden ---
190alternative_if ARM64_HAS_RAS_EXTN
191 // If we have the RAS extensions we can consume a pending error
192 // without an unmask-SError and isb. The ESB-instruction consumed any
193 // pending guest error when we took the exception from the guest.
194 mrs_s x2, SYS_DISR_EL1
195 str x2, [x1, #(VCPU_FAULT_DISR - VCPU_CONTEXT)]
196 cbz x2, 1f
197 msr_s SYS_DISR_EL1, xzr

--- 48 unchanged lines hidden ---