blob: 9dbdff3a4fceaba29a62f8c79db031fac97435af [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
Philipp Tomsichd15592f2017-07-04 10:04:54 +020012.pushsection .text.armv8_switch_to_el2, "ax"
David Feng85fd5f12013-12-14 11:47:35 +080013ENTRY(armv8_switch_to_el2)
Alison Wangeb2088d2017-01-17 09:39:17 +080014 switch_el x6, 1f, 0f, 0f
Alison Wang73818d52016-11-10 10:49:03 +0800150:
Alison Wangeb2088d2017-01-17 09:39:17 +080016 cmp x5, #ES_TO_AARCH64
Alison Wangf547fca2016-11-10 10:49:05 +080017 b.eq 2f
18 /*
19 * When loading 32-bit kernel, it will jump
20 * to secure firmware again, and never return.
21 */
22 bl armv8_el2_to_aarch32
232:
Alison Wang73818d52016-11-10 10:49:03 +080024 /*
Alison Wangeb2088d2017-01-17 09:39:17 +080025 * x4 is kernel entry point or switch_to_el1
Alison Wang73818d52016-11-10 10:49:03 +080026 * if CONFIG_ARMV8_SWITCH_TO_EL1 is defined.
27 * When running in EL2 now, jump to the
Alison Wangeb2088d2017-01-17 09:39:17 +080028 * address saved in x4.
Alison Wang73818d52016-11-10 10:49:03 +080029 */
Alison Wangeb2088d2017-01-17 09:39:17 +080030 br x4
311: armv8_switch_to_el2_m x4, x5, x6
David Feng85fd5f12013-12-14 11:47:35 +080032ENDPROC(armv8_switch_to_el2)
Philipp Tomsichd15592f2017-07-04 10:04:54 +020033.popsection
David Feng85fd5f12013-12-14 11:47:35 +080034
Philipp Tomsichd15592f2017-07-04 10:04:54 +020035.pushsection .text.armv8_switch_to_el1, "ax"
David Feng85fd5f12013-12-14 11:47:35 +080036ENTRY(armv8_switch_to_el1)
Alison Wangeb2088d2017-01-17 09:39:17 +080037 switch_el x6, 0f, 1f, 0f
Alison Wang73818d52016-11-10 10:49:03 +0800380:
Alison Wangeb2088d2017-01-17 09:39:17 +080039 /* x4 is kernel entry point. When running in EL1
40 * now, jump to the address saved in x4.
Alison Wang73818d52016-11-10 10:49:03 +080041 */
Alison Wangeb2088d2017-01-17 09:39:17 +080042 br x4
Peter Hoyes6f4a27d2021-08-19 16:53:09 +0100431: armv8_switch_to_el1_m x4, x5, x6, x7
David Feng85fd5f12013-12-14 11:47:35 +080044ENDPROC(armv8_switch_to_el1)
Philipp Tomsichd15592f2017-07-04 10:04:54 +020045.popsection
Alison Wangf547fca2016-11-10 10:49:05 +080046
Philipp Tomsichd15592f2017-07-04 10:04:54 +020047.pushsection .text.armv8_el2_to_aarch32, "ax"
Alison Wangf547fca2016-11-10 10:49:05 +080048WEAK(armv8_el2_to_aarch32)
49 ret
50ENDPROC(armv8_el2_to_aarch32)
Philipp Tomsichd15592f2017-07-04 10:04:54 +020051.popsection