1
2
3
4
5
6
7
8
9
10
11
12#include <linux/kexec.h>
13#include <linux/linkage.h>
14
15#include <asm/assembler.h>
16#include <asm/kexec.h>
17#include <asm/page.h>
18#include <asm/sysreg.h>
19
20
21
22
23
24
25
26
27
28
29
30
31
32ENTRY(arm64_relocate_new_kernel)
33
34
35 mov x18, x2
36 mov x17, x1
37 mov x16, x0
38 raw_dcache_line_size x15, x0
39 mov x14, xzr
40 mov x13, xzr
41
42
43 mrs x0, CurrentEL
44 cmp x0,
45 b.ne 1f
46 mrs x0, sctlr_el2
47 mov_q x1, SCTLR_ELx_FLAGS
48 bic x0, x0, x1
49 pre_disable_mmu_workaround
50 msr sctlr_el2, x0
51 isb
521:
53
54
55 tbnz x16, IND_DONE_BIT, .Ldone
56
57.Lloop:
58 and x12, x16, PAGE_MASK
59
60
61.Ltest_source:
62 tbz x16, IND_SOURCE_BIT, .Ltest_indirection
63
64
65 mov x0, x13
66 add x20, x0,
67 sub x1, x15,
68 bic x0, x0, x1
692: dc ivac, x0
70 add x0, x0, x15
71 cmp x0, x20
72 b.lo 2b
73 dsb sy
74
75 mov x20, x13
76 mov x21, x12
77 copy_page x20, x21, x0, x1, x2, x3, x4, x5, x6, x7
78
79
80 add x13, x13, PAGE_SIZE
81 b .Lnext
82
83.Ltest_indirection:
84 tbz x16, IND_INDIRECTION_BIT, .Ltest_destination
85
86
87 mov x14, x12
88 b .Lnext
89
90.Ltest_destination:
91 tbz x16, IND_DESTINATION_BIT, .Lnext
92
93
94 mov x13, x12
95
96.Lnext:
97
98 ldr x16, [x14],
99
100
101 tbz x16, IND_DONE_BIT, .Lloop
102
103.Ldone:
104
105 dsb nsh
106 ic iallu
107 dsb nsh
108 isb
109
110
111 mov x0, x18
112 mov x1, xzr
113 mov x2, xzr
114 mov x3, xzr
115 br x17
116
117ENDPROC(arm64_relocate_new_kernel)
118
119.align 3
120
121.Lcopy_end:
122.org KEXEC_CONTROL_PAGE_SIZE
123
124
125
126
127
128.globl arm64_relocate_new_kernel_size
129arm64_relocate_new_kernel_size:
130 .quad .Lcopy_end - arm64_relocate_new_kernel
131