Skip to content

Commit 8183d99

Browse files
chleroympe
authored andcommitted
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>
1 parent 8cf4c05 commit 8183d99

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

arch/powerpc/include/asm/code-patching.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ unsigned int create_cond_branch(const unsigned int *addr,
3131
unsigned long target, int flags);
3232
int patch_branch(unsigned int *addr, unsigned long target, int flags);
3333
int patch_instruction(unsigned int *addr, unsigned int instr);
34+
int raw_patch_instruction(unsigned int *addr, unsigned int instr);
3435

3536
int instr_is_relative_branch(unsigned int instr);
3637
int instr_is_relative_link_branch(unsigned int instr);

arch/powerpc/lib/code-patching.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static int __patch_instruction(unsigned int *exec_addr, unsigned int instr,
3838
return 0;
3939
}
4040

41-
static int raw_patch_instruction(unsigned int *addr, unsigned int instr)
41+
int raw_patch_instruction(unsigned int *addr, unsigned int instr)
4242
{
4343
return __patch_instruction(addr, instr, addr);
4444
}
@@ -155,7 +155,7 @@ int patch_instruction(unsigned int *addr, unsigned int instr)
155155
* when text_poke_area is not ready, but we still need
156156
* to allow patching. We just do the plain old patching
157157
*/
158-
if (!this_cpu_read(*PTRRELOC(&text_poke_area)))
158+
if (!this_cpu_read(text_poke_area))
159159
return raw_patch_instruction(addr, instr);
160160

161161
local_irq_save(flags);

arch/powerpc/lib/feature-fixups.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static int patch_alt_instruction(unsigned int *src, unsigned int *dest,
6262
}
6363
}
6464

65-
patch_instruction(dest, instr);
65+
raw_patch_instruction(dest, instr);
6666

6767
return 0;
6868
}
@@ -91,7 +91,7 @@ static int patch_feature_section(unsigned long value, struct fixup_entry *fcur)
9191
}
9292

9393
for (; dest < end; dest++)
94-
patch_instruction(dest, PPC_INST_NOP);
94+
raw_patch_instruction(dest, PPC_INST_NOP);
9595

9696
return 0;
9797
}
@@ -129,7 +129,7 @@ void do_lwsync_fixups(unsigned long value, void *fixup_start, void *fixup_end)
129129

130130
for (; start < end; start++) {
131131
dest = (void *)start + *start;
132-
patch_instruction(dest, PPC_INST_LWSYNC);
132+
raw_patch_instruction(dest, PPC_INST_LWSYNC);
133133
}
134134
}
135135

@@ -147,7 +147,7 @@ static void do_final_fixups(void)
147147
length = (__end_interrupts - _stext) / sizeof(int);
148148

149149
while (length--) {
150-
patch_instruction(dest, *src);
150+
raw_patch_instruction(dest, *src);
151151
src++;
152152
dest++;
153153
}

0 commit comments

Comments
 (0)