10ae76531SDavid Feng/* 20ae76531SDavid Feng * (C) Copyright 2013 30ae76531SDavid Feng * David Feng <fenghua@phytium.com.cn> 40ae76531SDavid Feng * 50ae76531SDavid Feng * SPDX-License-Identifier: GPL-2.0+ 60ae76531SDavid Feng */ 70ae76531SDavid Feng 80ae76531SDavid Feng#include <asm-offsets.h> 90ae76531SDavid Feng#include <config.h> 100ae76531SDavid Feng#include <linux/linkage.h> 110ae76531SDavid Feng#include <asm/macro.h> 120ae76531SDavid Feng 13*e6a05862SPhilipp Tomsich.pushsection .text.armv8_switch_to_el2, "ax" 140ae76531SDavid FengENTRY(armv8_switch_to_el2) 157c5e1febSAlison Wang switch_el x6, 1f, 0f, 0f 16ec6617c3SAlison Wang0: 177c5e1febSAlison Wang cmp x5, #ES_TO_AARCH64 183db86f4bSAlison Wang b.eq 2f 193db86f4bSAlison Wang /* 203db86f4bSAlison Wang * When loading 32-bit kernel, it will jump 213db86f4bSAlison Wang * to secure firmware again, and never return. 223db86f4bSAlison Wang */ 233db86f4bSAlison Wang bl armv8_el2_to_aarch32 243db86f4bSAlison Wang2: 25ec6617c3SAlison Wang /* 267c5e1febSAlison Wang * x4 is kernel entry point or switch_to_el1 27ec6617c3SAlison Wang * if CONFIG_ARMV8_SWITCH_TO_EL1 is defined. 28ec6617c3SAlison Wang * When running in EL2 now, jump to the 297c5e1febSAlison Wang * address saved in x4. 30ec6617c3SAlison Wang */ 317c5e1febSAlison Wang br x4 327c5e1febSAlison Wang1: armv8_switch_to_el2_m x4, x5, x6 330ae76531SDavid FengENDPROC(armv8_switch_to_el2) 34*e6a05862SPhilipp Tomsich.popsection 350ae76531SDavid Feng 36*e6a05862SPhilipp Tomsich.pushsection .text.armv8_switch_to_el1, "ax" 370ae76531SDavid FengENTRY(armv8_switch_to_el1) 387c5e1febSAlison Wang switch_el x6, 0f, 1f, 0f 39ec6617c3SAlison Wang0: 407c5e1febSAlison Wang /* x4 is kernel entry point. When running in EL1 417c5e1febSAlison Wang * now, jump to the address saved in x4. 42ec6617c3SAlison Wang */ 437c5e1febSAlison Wang br x4 447c5e1febSAlison Wang1: armv8_switch_to_el1_m x4, x5, x6 450ae76531SDavid FengENDPROC(armv8_switch_to_el1) 46*e6a05862SPhilipp Tomsich.popsection 473db86f4bSAlison Wang 48*e6a05862SPhilipp Tomsich.pushsection .text.armv8_el2_to_aarch32, "ax" 493db86f4bSAlison WangWEAK(armv8_el2_to_aarch32) 503db86f4bSAlison Wang ret 513db86f4bSAlison WangENDPROC(armv8_el2_to_aarch32) 52*e6a05862SPhilipp Tomsich.popsection 53