1/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4 */
5
6#include <arch.h>
7#include <asm_macros.S>
8
9	.section ".text"
10
11	.macro ventry_unused error_message
12	.balign	0x80
13	wfe
14	b	.-4
15	.endm
16
17	.macro ventry label
18		.balign	0x80
19		b	\label
20	.endm
21
22	// VBAR_EL3[10:0] are hardwired to 0, align vector address accordingly
23	.balign 0x800
24
25ENTRY(el2_vectors):
26	ventry_unused	exc_sync_sp0
27	ventry_unused	exc_irq_sp0
28	ventry_unused	exc_fiq_sp0
29	ventry_unused	exc_serror_sp0
30
31	ventry		el2_sync_cel
32	ventry_unused	exc_irq_spx
33	ventry_unused	exc_fiq_spx
34	ventry_unused	exc_serror_spx
35
36	ventry		el2_sync_lel
37	ventry		el2_irq_lel
38	ventry		el2_fiq_lel
39	ventry		el2_serror_lel
40
41	ventry_unused	exc_sync_lel_32
42	ventry_unused	exc_irq_lel_32
43	ventry_unused	exc_fiq_lel_32
44	ventry_unused	exc_serror_lel_32
45ENDPROC(el2_vectors)
46
47el2_sync_lel:
48	stp	x0, x1, [sp, #-16]!
49	mov	x0, #ARM_EXCEPTION_SYNC_LEL
50	b	realm_exit
51ENDPROC(el2_sync_lel)
52
53el2_irq_lel:
54	stp	x0, x1, [sp, #-16]!
55	mov	x0, #ARM_EXCEPTION_IRQ_LEL
56	b	realm_exit
57ENDPROC(el2_sync_lel)
58
59el2_fiq_lel:
60	stp	x0, x1, [sp, #-16]!
61	mov	x0, #ARM_EXCEPTION_FIQ_LEL
62	b	realm_exit
63ENDPROC(el2_sync_lel)
64
65el2_serror_lel:
66	stp	x0, x1, [sp, #-16]!
67	mov	x0, #ARM_EXCEPTION_SERROR_LEL
68	b	realm_exit
69ENDPROC(el2_serror_lel)
70
71el2_sync_cel:
72	stp	x0, x1, [sp, #-16]!
73	stp	x2, x3, [sp, #-16]!
74	stp	x4, x5, [sp, #-16]!
75	stp	x6, x7, [sp, #-16]!
76	stp	x8, x9, [sp, #-16]!
77	stp	x10, x11, [sp, #-16]!
78	stp	x12, x13, [sp, #-16]!
79	stp	x14, x15, [sp, #-16]!
80	stp	x16, x17, [sp, #-16]!
81	stp	x18, xzr, [sp, #-16]!
82	stp	x29, lr, [sp, #-16]!
83
84	bl	handle_rmm_trap
85
86	/*
87	 * If it doesn't panic the RMM, handle_rmm_trap
88	 * returns the new value of PC in x0.
89	 */
90	msr	elr_el2, x0
91
92	ldp	x29, lr, [sp], #16
93	ldp	x18, xzr, [sp], #16
94	ldp	x16, x17, [sp], #16
95	ldp	x14, x15, [sp], #16
96	ldp	x12, x13, [sp], #16
97	ldp	x10, x11, [sp], #16
98	ldp	x8, x9, [sp], #16
99	ldp	x6, x7, [sp], #16
100	ldp	x4, x5, [sp], #16
101	ldp	x2, x3, [sp], #16
102	ldp	x0, x1, [sp], #16
103
104	eret
105	sb
106
107ENDPROC(el2_sync_cel)
108