xref: /linux/arch/arm64/kernel/cpu-reset.S (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
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>
11c50d3285SSami Tolvanen#include <linux/cfi_types.h>
12f9076ecfSGeoff Levand#include <asm/assembler.h>
13f9076ecfSGeoff Levand#include <asm/sysreg.h>
14f9076ecfSGeoff Levand#include <asm/virt.h>
15f9076ecfSGeoff Levand
16f9076ecfSGeoff Levand.text
17*4df69e0dSndesaulniers@google.com.pushsection    .idmap.text, "a"
18f9076ecfSGeoff Levand
19f9076ecfSGeoff Levand/*
207a2512faSPasha Tatashin * cpu_soft_restart(el2_switch, entry, arg0, arg1, arg2)
21f9076ecfSGeoff Levand *
224c9e7e64SAKASHI Takahiro * @el2_switch: Flag to indicate a switch to EL2 is needed.
23f9076ecfSGeoff Levand * @entry: Location to jump to for soft reset.
244c9e7e64SAKASHI Takahiro * arg0: First argument passed to @entry. (relocation list)
254c9e7e64SAKASHI Takahiro * arg1: Second argument passed to @entry.(physical kernel entry)
264c9e7e64SAKASHI Takahiro * arg2: Third argument passed to @entry. (physical dtb address)
27f9076ecfSGeoff Levand *
28f9076ecfSGeoff Levand * Put the CPU into the same state as it would be if it had been reset, and
29f9076ecfSGeoff Levand * branch to what would be the reset vector. It must be executed with the
30f9076ecfSGeoff Levand * flat identity mapping.
31f9076ecfSGeoff Levand */
32c50d3285SSami TolvanenSYM_TYPED_FUNC_START(cpu_soft_restart)
3345879a57SMarc Zyngier	mov_q	x12, INIT_SCTLR_EL1_MMU_OFF
343060e9f0SShanker Donthineni	pre_disable_mmu_workaround
3572789a4aSPingfan Liu	/*
3672789a4aSPingfan Liu	 * either disable EL1&0 translation regime or disable EL2&0 translation
3772789a4aSPingfan Liu	 * regime if HCR_EL2.E2H == 1
3872789a4aSPingfan Liu	 */
39f9076ecfSGeoff Levand	msr	sctlr_el1, x12
40f9076ecfSGeoff Levand	isb
41f9076ecfSGeoff Levand
42f9076ecfSGeoff Levand	cbz	x0, 1f				// el2_switch?
43f9076ecfSGeoff Levand	mov	x0, #HVC_SOFT_RESTART
44f9076ecfSGeoff Levand	hvc	#0				// no return
45f9076ecfSGeoff Levand
46500d14afSArd Biesheuvel1:	mov	x8, x1				// entry
47f9076ecfSGeoff Levand	mov	x0, x2				// arg0
48f9076ecfSGeoff Levand	mov	x1, x3				// arg1
49f9076ecfSGeoff Levand	mov	x2, x4				// arg2
50500d14afSArd Biesheuvel	br	x8
51c50d3285SSami TolvanenSYM_FUNC_END(cpu_soft_restart)
52f9076ecfSGeoff Levand
53f9076ecfSGeoff Levand.popsection
54