blob: 9dbdff3a4fceaba29a62f8c79db031fac97435af [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
David Feng0ae76532013-12-14 11:47:35 +08002/*
3 * (C) Copyright 2013
4 * David Feng <fenghua@phytium.com.cn>
David Feng0ae76532013-12-14 11:47:35 +08005 */
6
7#include <asm-offsets.h>
8#include <config.h>
David Feng0ae76532013-12-14 11:47:35 +08009#include <linux/linkage.h>
10#include <asm/macro.h>
11
Philipp Tomsiche6a05862017-07-04 10:04:54 +020012.pushsection .text.armv8_switch_to_el2, "ax"
David Feng0ae76532013-12-14 11:47:35 +080013ENTRY(armv8_switch_to_el2)
Alison Wang7c5e1fe2017-01-17 09:39:17 +080014 switch_el x6, 1f, 0f, 0f
Alison Wangec6617c2016-11-10 10:49:03 +0800150:
Alison Wang7c5e1fe2017-01-17 09:39:17 +080016 cmp x5, #ES_TO_AARCH64
Alison Wang3db86f42016-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 Wangec6617c2016-11-10 10:49:03 +080024 /*
Alison Wang7c5e1fe2017-01-17 09:39:17 +080025 * x4 is kernel entry point or switch_to_el1
Alison Wangec6617c2016-11-10 10:49:03 +080026 * if CONFIG_ARMV8_SWITCH_TO_EL1 is defined.
27 * When running in EL2 now, jump to the
Alison Wang7c5e1fe2017-01-17 09:39:17 +080028 * address saved in x4.
Alison Wangec6617c2016-11-10 10:49:03 +080029 */
Alison Wang7c5e1fe2017-01-17 09:39:17 +080030 br x4
311: armv8_switch_to_el2_m x4, x5, x6
David Feng0ae76532013-12-14 11:47:35 +080032ENDPROC(armv8_switch_to_el2)
Philipp Tomsiche6a05862017-07-04 10:04:54 +020033.popsection
David Feng0ae76532013-12-14 11:47:35 +080034
Philipp Tomsiche6a05862017-07-04 10:04:54 +020035.pushsection .text.armv8_switch_to_el1, "ax"
David Feng0ae76532013-12-14 11:47:35 +080036ENTRY(armv8_switch_to_el1)
Alison Wang7c5e1fe2017-01-17 09:39:17 +080037 switch_el x6, 0f, 1f, 0f
Alison Wangec6617c2016-11-10 10:49:03 +0800380:
Alison Wang7c5e1fe2017-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 Wangec6617c2016-11-10 10:49:03 +080041 */
Alison Wang7c5e1fe2017-01-17 09:39:17 +080042 br x4
Peter Hoyes53b40e82021-08-19 16:53:09 +0100431: armv8_switch_to_el1_m x4, x5, x6, x7
David Feng0ae76532013-12-14 11:47:35 +080044ENDPROC(armv8_switch_to_el1)
Philipp Tomsiche6a05862017-07-04 10:04:54 +020045.popsection
Alison Wang3db86f42016-11-10 10:49:05 +080046
Philipp Tomsiche6a05862017-07-04 10:04:54 +020047.pushsection .text.armv8_el2_to_aarch32, "ax"
Alison Wang3db86f42016-11-10 10:49:05 +080048WEAK(armv8_el2_to_aarch32)
49 ret
50ENDPROC(armv8_el2_to_aarch32)
Philipp Tomsiche6a05862017-07-04 10:04:54 +020051.popsection