blob: 85f13ccd0d2316bbc3bba18d93873b911468e3cc [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
David Feng85fd5f12013-12-14 11:47:35 +08002/*
3 * (C) Copyright 2013
4 * David Feng <fenghua@phytium.com.cn>
David Feng85fd5f12013-12-14 11:47:35 +08005 */
6
7#include <asm-offsets.h>
8#include <config.h>
David Feng85fd5f12013-12-14 11:47:35 +08009#include <linux/linkage.h>
10#include <asm/macro.h>
11
Marek Vasutc1c63182025-01-29 22:59:18 +010012.pushsection .text.armv8_switch_to_el2_prep, "ax"
13WEAK(armv8_switch_to_el2_prep)
14 ret
15ENDPROC(armv8_switch_to_el2_prep)
16.popsection
17
Philipp Tomsichd15592f2017-07-04 10:04:54 +020018.pushsection .text.armv8_switch_to_el2, "ax"
David Feng85fd5f12013-12-14 11:47:35 +080019ENTRY(armv8_switch_to_el2)
Marek Vasutc1c63182025-01-29 22:59:18 +010020 bl armv8_switch_to_el2_prep
21 nop
Alison Wangeb2088d2017-01-17 09:39:17 +080022 switch_el x6, 1f, 0f, 0f
Alison Wang73818d52016-11-10 10:49:03 +0800230:
Alison Wangeb2088d2017-01-17 09:39:17 +080024 cmp x5, #ES_TO_AARCH64
Alison Wangf547fca2016-11-10 10:49:05 +080025 b.eq 2f
26 /*
27 * When loading 32-bit kernel, it will jump
28 * to secure firmware again, and never return.
29 */
30 bl armv8_el2_to_aarch32
312:
Alison Wang73818d52016-11-10 10:49:03 +080032 /*
Alison Wangeb2088d2017-01-17 09:39:17 +080033 * x4 is kernel entry point or switch_to_el1
Alison Wang73818d52016-11-10 10:49:03 +080034 * if CONFIG_ARMV8_SWITCH_TO_EL1 is defined.
35 * When running in EL2 now, jump to the
Alison Wangeb2088d2017-01-17 09:39:17 +080036 * address saved in x4.
Alison Wang73818d52016-11-10 10:49:03 +080037 */
Alison Wangeb2088d2017-01-17 09:39:17 +080038 br x4
391: armv8_switch_to_el2_m x4, x5, x6
David Feng85fd5f12013-12-14 11:47:35 +080040ENDPROC(armv8_switch_to_el2)
Philipp Tomsichd15592f2017-07-04 10:04:54 +020041.popsection
David Feng85fd5f12013-12-14 11:47:35 +080042
Philipp Tomsichd15592f2017-07-04 10:04:54 +020043.pushsection .text.armv8_switch_to_el1, "ax"
David Feng85fd5f12013-12-14 11:47:35 +080044ENTRY(armv8_switch_to_el1)
Alison Wangeb2088d2017-01-17 09:39:17 +080045 switch_el x6, 0f, 1f, 0f
Alison Wang73818d52016-11-10 10:49:03 +0800460:
Alison Wangeb2088d2017-01-17 09:39:17 +080047 /* x4 is kernel entry point. When running in EL1
48 * now, jump to the address saved in x4.
Alison Wang73818d52016-11-10 10:49:03 +080049 */
Alison Wangeb2088d2017-01-17 09:39:17 +080050 br x4
Peter Hoyes6f4a27d2021-08-19 16:53:09 +0100511: armv8_switch_to_el1_m x4, x5, x6, x7
David Feng85fd5f12013-12-14 11:47:35 +080052ENDPROC(armv8_switch_to_el1)
Philipp Tomsichd15592f2017-07-04 10:04:54 +020053.popsection
Alison Wangf547fca2016-11-10 10:49:05 +080054
Philipp Tomsichd15592f2017-07-04 10:04:54 +020055.pushsection .text.armv8_el2_to_aarch32, "ax"
Alison Wangf547fca2016-11-10 10:49:05 +080056WEAK(armv8_el2_to_aarch32)
57 ret
58ENDPROC(armv8_el2_to_aarch32)
Philipp Tomsichd15592f2017-07-04 10:04:54 +020059.popsection