forked from AsahiLinux/m1n1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhv_asm.S
196 lines (167 loc) · 3.5 KB
/
hv_asm.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/* spDx-License-Identifier: MIT */
#include "exception.h"
.align 11
.globl _hv_vectors_start
_hv_vectors_start:
/* EL2 with SP_EL0 */
mov x9, '0'
b cpu_reset
.align 7
mov x9, '1'
b exc_unk
.align 7
mov x9, '2'
b exc_unk
.align 7
mov x9, '3'
b exc_unk
.align 7
/* EL2 with SP_EL2 */
b _v_sp0_sync
.align 7
b _v_sp0_irq
.align 7
b _v_sp0_fiq
.align 7
b _v_sp0_serr
.align 7
/* EL1/0 64-bit */
b _v_hv_sync
.align 7
b _v_hv_irq
.align 7
b _v_hv_fiq
.align 7
b _v_hv_serr
.align 7
/* EL1/0 32-bit */
mov x9, 'p'
b exc_unk
.align 7
mov x9, 'q'
b exc_unk
.align 7
mov x9, 'r'
b exc_unk
.align 7
mov x9, 's'
b exc_unk
.align 7
.globl _hv_entry
.type _hv_entry, @function
_hv_entry:
stp x28, x29, [sp, #-16]!
stp x26, x27, [sp, #-16]!
stp x24, x25, [sp, #-16]!
stp x22, x23, [sp, #-16]!
stp x20, x21, [sp, #-16]!
stp x18, x19, [sp, #-16]!
stp x16, x17, [sp, #-16]!
stp x14, x15, [sp, #-16]!
stp x12, x13, [sp, #-16]!
stp x10, x11, [sp, #-16]!
stp x8, x9, [sp, #-16]!
stp x6, x7, [sp, #-16]!
stp x4, x5, [sp, #-16]!
stp x2, x3, [sp, #-16]!
stp x0, x1, [sp, #-16]!
dsb sy
isb
mov x0, sp
ret
.globl _hv_return
.type _hv_return, @function
_hv_return:
ldp x0, x1, [sp], #16
ldp x2, x3, [sp], #16
ldp x4, x5, [sp], #16
ldp x6, x7, [sp], #16
ldp x8, x9, [sp], #16
ldp x10, x11, [sp], #16
ldp x12, x13, [sp], #16
ldp x14, x15, [sp], #16
ldp x16, x17, [sp], #16
ldp x18, x19, [sp], #16
ldp x20, x21, [sp], #16
ldp x22, x23, [sp], #16
ldp x24, x25, [sp], #16
ldp x26, x27, [sp], #16
ldp x28, x29, [sp], #16
ldr x30, [sp], #16
add sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
eret
.globl _v_hv_sync
.type _v_hv_sync, @function
_v_hv_sync:
msr pan, #0
sub sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
str x30, [sp, #-16]!
bl _hv_entry
bl hv_exc_sync
b _hv_return
.globl _v_hv_irq
.type _v_hv_irq, @function
_v_hv_irq:
msr pan, #0
sub sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
str x30, [sp, #-16]!
bl _hv_entry
bl hv_exc_irq
b _hv_return
.globl _v_hv_fiq
.type _v_hv_fiq, @function
_v_hv_fiq:
msr pan, #0
sub sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
str x30, [sp, #-16]!
bl _hv_entry
bl hv_exc_fiq
b _hv_return
.globl _v_hv_serr
.type _v_hv_serr, @function
_v_hv_serr:
msr pan, #0
sub sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
str x30, [sp, #-16]!
bl _hv_entry
bl hv_exc_serr
b _hv_return
.extern hv_saved_sp
.globl hv_enter_guest
.type hv_enter_guest, @function
hv_enter_guest:
stp x29, x30, [sp, #-16]!
stp x27, x28, [sp, #-16]!
stp x25, x26, [sp, #-16]!
stp x23, x24, [sp, #-16]!
stp x21, x22, [sp, #-16]!
stp x19, x20, [sp, #-16]!
str x18, [sp, #-16]!
mrs x7, tpidr_el2
ldr x6, =hv_saved_sp
mov x5, sp
str x5, [x6, x7, LSL #3]
mrs x5, daif
mov x6, #5
orr x5, x5, x6 // EL1h
msr spsr_el2, x5
msr elr_el2, x4
mov x5, #0
msr sp_el0, x5
msr sp_el1, x5
eret
.globl hv_exit_guest
.type hv_exit_guest, @function
hv_exit_guest:
mrs x7, tpidr_el2
ldr x6, =hv_saved_sp
ldr x5, [x6, x7, LSL #3]
mov sp, x5
ldr x18, [sp], #16
ldp x19, x20, [sp], #16
ldp x21, x22, [sp], #16
ldp x23, x24, [sp], #16
ldp x25, x26, [sp], #16
ldp x27, x28, [sp], #16
ldp x29, x30, [sp], #16
ret