blob: 7aa6935318c6a95e8cf9cee28467af432c2fb6e6 [file] [log] [blame]
David Feng85fd5f12013-12-14 11:47:35 +08001/*
2 * (C) Copyright 2013
3 * David Feng <fenghua@phytium.com.cn>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <asm-offsets.h>
9#include <config.h>
David Feng85fd5f12013-12-14 11:47:35 +080010#include <linux/linkage.h>
11#include <asm/macro.h>
12
Philipp Tomsichd15592f2017-07-04 10:04:54 +020013.pushsection .text.armv8_switch_to_el2, "ax"
David Feng85fd5f12013-12-14 11:47:35 +080014ENTRY(armv8_switch_to_el2)
Alison Wangeb2088d2017-01-17 09:39:17 +080015 switch_el x6, 1f, 0f, 0f
Alison Wang73818d52016-11-10 10:49:03 +0800160:
Alison Wangeb2088d2017-01-17 09:39:17 +080017 cmp x5, #ES_TO_AARCH64
Alison Wangf547fca2016-11-10 10:49:05 +080018 b.eq 2f
19 /*
20 * When loading 32-bit kernel, it will jump
21 * to secure firmware again, and never return.
22 */
23 bl armv8_el2_to_aarch32
242:
Alison Wang73818d52016-11-10 10:49:03 +080025 /*
Alison Wangeb2088d2017-01-17 09:39:17 +080026 * x4 is kernel entry point or switch_to_el1
Alison Wang73818d52016-11-10 10:49:03 +080027 * if CONFIG_ARMV8_SWITCH_TO_EL1 is defined.
28 * When running in EL2 now, jump to the
Alison Wangeb2088d2017-01-17 09:39:17 +080029 * address saved in x4.
Alison Wang73818d52016-11-10 10:49:03 +080030 */
Alison Wangeb2088d2017-01-17 09:39:17 +080031 br x4
321: armv8_switch_to_el2_m x4, x5, x6
David Feng85fd5f12013-12-14 11:47:35 +080033ENDPROC(armv8_switch_to_el2)
Philipp Tomsichd15592f2017-07-04 10:04:54 +020034.popsection
David Feng85fd5f12013-12-14 11:47:35 +080035
Philipp Tomsichd15592f2017-07-04 10:04:54 +020036.pushsection .text.armv8_switch_to_el1, "ax"
David Feng85fd5f12013-12-14 11:47:35 +080037ENTRY(armv8_switch_to_el1)
Alison Wangeb2088d2017-01-17 09:39:17 +080038 switch_el x6, 0f, 1f, 0f
Alison Wang73818d52016-11-10 10:49:03 +0800390:
Alison Wangeb2088d2017-01-17 09:39:17 +080040 /* x4 is kernel entry point. When running in EL1
41 * now, jump to the address saved in x4.
Alison Wang73818d52016-11-10 10:49:03 +080042 */
Alison Wangeb2088d2017-01-17 09:39:17 +080043 br x4
441: armv8_switch_to_el1_m x4, x5, x6
David Feng85fd5f12013-12-14 11:47:35 +080045ENDPROC(armv8_switch_to_el1)
Philipp Tomsichd15592f2017-07-04 10:04:54 +020046.popsection
Alison Wangf547fca2016-11-10 10:49:05 +080047
Philipp Tomsichd15592f2017-07-04 10:04:54 +020048.pushsection .text.armv8_el2_to_aarch32, "ax"
Alison Wangf547fca2016-11-10 10:49:05 +080049WEAK(armv8_el2_to_aarch32)
50 ret
51ENDPROC(armv8_el2_to_aarch32)
Philipp Tomsichd15592f2017-07-04 10:04:54 +020052.popsection