xref: /linux/arch/arm64/kernel/cpu-reset.S (revision 4c9e7e649a3f291e1b939299458e6844c16afe70)
1f9076ecfSGeoff Levand/*
2f9076ecfSGeoff Levand * CPU reset routines
3f9076ecfSGeoff Levand *
4f9076ecfSGeoff Levand * Copyright (C) 2001 Deep Blue Solutions Ltd.
5f9076ecfSGeoff Levand * Copyright (C) 2012 ARM Ltd.
6f9076ecfSGeoff Levand * Copyright (C) 2015 Huawei Futurewei Technologies.
7f9076ecfSGeoff Levand *
8f9076ecfSGeoff Levand * This program is free software; you can redistribute it and/or modify
9f9076ecfSGeoff Levand * it under the terms of the GNU General Public License version 2 as
10f9076ecfSGeoff Levand * published by the Free Software Foundation.
11f9076ecfSGeoff Levand */
12f9076ecfSGeoff Levand
13f9076ecfSGeoff Levand#include <linux/linkage.h>
14f9076ecfSGeoff Levand#include <asm/assembler.h>
15f9076ecfSGeoff Levand#include <asm/sysreg.h>
16f9076ecfSGeoff Levand#include <asm/virt.h>
17f9076ecfSGeoff Levand
18f9076ecfSGeoff Levand.text
19439e70e2SWill Deacon.pushsection    .idmap.text, "awx"
20f9076ecfSGeoff Levand
21f9076ecfSGeoff Levand/*
22f9076ecfSGeoff Levand * __cpu_soft_restart(el2_switch, entry, arg0, arg1, arg2) - Helper for
23f9076ecfSGeoff Levand * cpu_soft_restart.
24f9076ecfSGeoff Levand *
25*4c9e7e64SAKASHI Takahiro * @el2_switch: Flag to indicate a switch to EL2 is needed.
26f9076ecfSGeoff Levand * @entry: Location to jump to for soft reset.
27*4c9e7e64SAKASHI Takahiro * arg0: First argument passed to @entry. (relocation list)
28*4c9e7e64SAKASHI Takahiro * arg1: Second argument passed to @entry.(physical kernel entry)
29*4c9e7e64SAKASHI Takahiro * arg2: Third argument passed to @entry. (physical dtb address)
30f9076ecfSGeoff Levand *
31f9076ecfSGeoff Levand * Put the CPU into the same state as it would be if it had been reset, and
32f9076ecfSGeoff Levand * branch to what would be the reset vector. It must be executed with the
33f9076ecfSGeoff Levand * flat identity mapping.
34f9076ecfSGeoff Levand */
35f9076ecfSGeoff LevandENTRY(__cpu_soft_restart)
36f9076ecfSGeoff Levand	/* Clear sctlr_el1 flags. */
37f9076ecfSGeoff Levand	mrs	x12, sctlr_el1
38f9076ecfSGeoff Levand	ldr	x13, =SCTLR_ELx_FLAGS
39f9076ecfSGeoff Levand	bic	x12, x12, x13
403060e9f0SShanker Donthineni	pre_disable_mmu_workaround
41f9076ecfSGeoff Levand	msr	sctlr_el1, x12
42f9076ecfSGeoff Levand	isb
43f9076ecfSGeoff Levand
44f9076ecfSGeoff Levand	cbz	x0, 1f				// el2_switch?
45f9076ecfSGeoff Levand	mov	x0, #HVC_SOFT_RESTART
46f9076ecfSGeoff Levand	hvc	#0				// no return
47f9076ecfSGeoff Levand
48f9076ecfSGeoff Levand1:	mov	x18, x1				// entry
49f9076ecfSGeoff Levand	mov	x0, x2				// arg0
50f9076ecfSGeoff Levand	mov	x1, x3				// arg1
51f9076ecfSGeoff Levand	mov	x2, x4				// arg2
52f9076ecfSGeoff Levand	br	x18
53f9076ecfSGeoff LevandENDPROC(__cpu_soft_restart)
54f9076ecfSGeoff Levand
55f9076ecfSGeoff Levand.popsection
56