xref: /linux/arch/arm64/kernel/cpu-reset.S (revision 7a2512fa649397c68127a480ef8fdd9dcf323045)
1d2912cb1SThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-only */
2f9076ecfSGeoff Levand/*
3f9076ecfSGeoff Levand * CPU reset routines
4f9076ecfSGeoff Levand *
5f9076ecfSGeoff Levand * Copyright (C) 2001 Deep Blue Solutions Ltd.
6f9076ecfSGeoff Levand * Copyright (C) 2012 ARM Ltd.
7f9076ecfSGeoff Levand * Copyright (C) 2015 Huawei Futurewei Technologies.
8f9076ecfSGeoff Levand */
9f9076ecfSGeoff Levand
10f9076ecfSGeoff Levand#include <linux/linkage.h>
11f9076ecfSGeoff Levand#include <asm/assembler.h>
12f9076ecfSGeoff Levand#include <asm/sysreg.h>
13f9076ecfSGeoff Levand#include <asm/virt.h>
14f9076ecfSGeoff Levand
15f9076ecfSGeoff Levand.text
16439e70e2SWill Deacon.pushsection    .idmap.text, "awx"
17f9076ecfSGeoff Levand
18f9076ecfSGeoff Levand/*
19*7a2512faSPasha Tatashin * cpu_soft_restart(el2_switch, entry, arg0, arg1, arg2)
20f9076ecfSGeoff Levand *
214c9e7e64SAKASHI Takahiro * @el2_switch: Flag to indicate a switch to EL2 is needed.
22f9076ecfSGeoff Levand * @entry: Location to jump to for soft reset.
234c9e7e64SAKASHI Takahiro * arg0: First argument passed to @entry. (relocation list)
244c9e7e64SAKASHI Takahiro * arg1: Second argument passed to @entry.(physical kernel entry)
254c9e7e64SAKASHI Takahiro * arg2: Third argument passed to @entry. (physical dtb address)
26f9076ecfSGeoff Levand *
27f9076ecfSGeoff Levand * Put the CPU into the same state as it would be if it had been reset, and
28f9076ecfSGeoff Levand * branch to what would be the reset vector. It must be executed with the
29f9076ecfSGeoff Levand * flat identity mapping.
30f9076ecfSGeoff Levand */
31*7a2512faSPasha TatashinSYM_CODE_START(cpu_soft_restart)
3245879a57SMarc Zyngier	mov_q	x12, INIT_SCTLR_EL1_MMU_OFF
333060e9f0SShanker Donthineni	pre_disable_mmu_workaround
3472789a4aSPingfan Liu	/*
3572789a4aSPingfan Liu	 * either disable EL1&0 translation regime or disable EL2&0 translation
3672789a4aSPingfan Liu	 * regime if HCR_EL2.E2H == 1
3772789a4aSPingfan Liu	 */
38f9076ecfSGeoff Levand	msr	sctlr_el1, x12
39f9076ecfSGeoff Levand	isb
40f9076ecfSGeoff Levand
41f9076ecfSGeoff Levand	cbz	x0, 1f				// el2_switch?
42f9076ecfSGeoff Levand	mov	x0, #HVC_SOFT_RESTART
43f9076ecfSGeoff Levand	hvc	#0				// no return
44f9076ecfSGeoff Levand
45500d14afSArd Biesheuvel1:	mov	x8, x1				// entry
46f9076ecfSGeoff Levand	mov	x0, x2				// arg0
47f9076ecfSGeoff Levand	mov	x1, x3				// arg1
48f9076ecfSGeoff Levand	mov	x2, x4				// arg2
49500d14afSArd Biesheuvel	br	x8
50*7a2512faSPasha TatashinSYM_CODE_END(cpu_soft_restart)
51f9076ecfSGeoff Levand
52f9076ecfSGeoff Levand.popsection
53