aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Leroy <christophe.leroy@c-s.fr>2017-11-24 02:31:09 -0500
committerMichael Ellerman <mpe@ellerman.id.au>2018-01-20 23:06:25 -0500
commit8183d99f4a22c2abbc543847a588df3666ef0c0c (patch)
tree4fa8acc3ff00f162c9eedf29ec9607f4aa0acf6d
parent8cf4c05712f04a405f0dacebcca8f042b391694a (diff)
powerpc/lib/feature-fixups: use raw_patch_instruction()
feature fixups need to use patch_instruction() early in the boot, even before the code is relocated to its final address, requiring patch_instruction() to use PTRRELOC() in order to address data. But feature fixups applies on code before it is set to read only, even for modules. Therefore, feature fixups can use raw_patch_instruction() instead. Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--arch/powerpc/include/asm/code-patching.h1
-rw-r--r--arch/powerpc/lib/code-patching.c4
-rw-r--r--arch/powerpc/lib/feature-fixups.c8
3 files changed, 7 insertions, 6 deletions
diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/include/asm/code-patching.h
index 2c895e8d07f7..812535f40124 100644
--- a/arch/powerpc/include/asm/code-patching.h
+++ b/arch/powerpc/include/asm/code-patching.h
@@ -31,6 +31,7 @@ unsigned int create_cond_branch(const unsigned int *addr,
31 unsigned long target, int flags); 31 unsigned long target, int flags);
32int patch_branch(unsigned int *addr, unsigned long target, int flags); 32int patch_branch(unsigned int *addr, unsigned long target, int flags);
33int patch_instruction(unsigned int *addr, unsigned int instr); 33int patch_instruction(unsigned int *addr, unsigned int instr);
34int raw_patch_instruction(unsigned int *addr, unsigned int instr);
34 35
35int instr_is_relative_branch(unsigned int instr); 36int instr_is_relative_branch(unsigned int instr);
36int instr_is_relative_link_branch(unsigned int instr); 37int instr_is_relative_link_branch(unsigned int instr);
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index e1c58937281f..e0d881ab304e 100644
--- a/arch/powerpc/lib/code-patching.c
+++ b/arch/powerpc/lib/code-patching.c
@@ -38,7 +38,7 @@ static int __patch_instruction(unsigned int *exec_addr, unsigned int instr,
38 return 0; 38 return 0;
39} 39}
40 40
41static int raw_patch_instruction(unsigned int *addr, unsigned int instr) 41int raw_patch_instruction(unsigned int *addr, unsigned int instr)
42{ 42{
43 return __patch_instruction(addr, instr, addr); 43 return __patch_instruction(addr, instr, addr);
44} 44}
@@ -155,7 +155,7 @@ int patch_instruction(unsigned int *addr, unsigned int instr)
155 * when text_poke_area is not ready, but we still need 155 * when text_poke_area is not ready, but we still need
156 * to allow patching. We just do the plain old patching 156 * to allow patching. We just do the plain old patching
157 */ 157 */
158 if (!this_cpu_read(*PTRRELOC(&text_poke_area))) 158 if (!this_cpu_read(text_poke_area))
159 return raw_patch_instruction(addr, instr); 159 return raw_patch_instruction(addr, instr);
160 160
161 local_irq_save(flags); 161 local_irq_save(flags);
diff --git a/arch/powerpc/lib/feature-fixups.c b/arch/powerpc/lib/feature-fixups.c
index 41cf5ae273cf..0872d60ede10 100644
--- a/arch/powerpc/lib/feature-fixups.c
+++ b/arch/powerpc/lib/feature-fixups.c
@@ -62,7 +62,7 @@ static int patch_alt_instruction(unsigned int *src, unsigned int *dest,
62 } 62 }
63 } 63 }
64 64
65 patch_instruction(dest, instr); 65 raw_patch_instruction(dest, instr);
66 66
67 return 0; 67 return 0;
68} 68}
@@ -91,7 +91,7 @@ static int patch_feature_section(unsigned long value, struct fixup_entry *fcur)
91 } 91 }
92 92
93 for (; dest < end; dest++) 93 for (; dest < end; dest++)
94 patch_instruction(dest, PPC_INST_NOP); 94 raw_patch_instruction(dest, PPC_INST_NOP);
95 95
96 return 0; 96 return 0;
97} 97}
@@ -129,7 +129,7 @@ void do_lwsync_fixups(unsigned long value, void *fixup_start, void *fixup_end)
129 129
130 for (; start < end; start++) { 130 for (; start < end; start++) {
131 dest = (void *)start + *start; 131 dest = (void *)start + *start;
132 patch_instruction(dest, PPC_INST_LWSYNC); 132 raw_patch_instruction(dest, PPC_INST_LWSYNC);
133 } 133 }
134} 134}
135 135
@@ -147,7 +147,7 @@ static void do_final_fixups(void)
147 length = (__end_interrupts - _stext) / sizeof(int); 147 length = (__end_interrupts - _stext) / sizeof(int);
148 148
149 while (length--) { 149 while (length--) {
150 patch_instruction(dest, *src); 150 raw_patch_instruction(dest, *src);
151 src++; 151 src++;
152 dest++; 152 dest++;
153 } 153 }