Skip to content

Commit e261faa

Browse files
chleroygregkh
authored andcommitted
powerpc/lib/feature-fixups: use raw_patch_instruction()
commit 8183d99 upstream. 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> Reported-by: David Gounaris <david.gounaris@infinera.com> Tested-by: David Gounaris <david.gounaris@infinera.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f78ae31 commit e261faa

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

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
@@ -39,7 +39,7 @@ static int __patch_instruction(unsigned int *exec_addr, unsigned int instr,
3939
return 0;
4040
}
4141

42-
static int raw_patch_instruction(unsigned int *addr, unsigned int instr)
42+
int raw_patch_instruction(unsigned int *addr, unsigned int instr)
4343
{
4444
return __patch_instruction(addr, instr, addr);
4545
}
@@ -156,7 +156,7 @@ static int do_patch_instruction(unsigned int *addr, unsigned int instr)
156156
* when text_poke_area is not ready, but we still need
157157
* to allow patching. We just do the plain old patching
158158
*/
159-
if (!this_cpu_read(*PTRRELOC(&text_poke_area)))
159+
if (!this_cpu_read(text_poke_area))
160160
return raw_patch_instruction(addr, instr);
161161

162162
local_irq_save(flags);

arch/powerpc/lib/feature-fixups.c

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

66-
patch_instruction(dest, instr);
66+
raw_patch_instruction(dest, instr);
6767

6868
return 0;
6969
}
@@ -92,7 +92,7 @@ static int patch_feature_section(unsigned long value, struct fixup_entry *fcur)
9292
}
9393

9494
for (; dest < end; dest++)
95-
patch_instruction(dest, PPC_INST_NOP);
95+
raw_patch_instruction(dest, PPC_INST_NOP);
9696

9797
return 0;
9898
}
@@ -292,7 +292,7 @@ void do_lwsync_fixups(unsigned long value, void *fixup_start, void *fixup_end)
292292

293293
for (; start < end; start++) {
294294
dest = (void *)start + *start;
295-
patch_instruction(dest, PPC_INST_LWSYNC);
295+
raw_patch_instruction(dest, PPC_INST_LWSYNC);
296296
}
297297
}
298298

@@ -310,7 +310,7 @@ static void do_final_fixups(void)
310310
length = (__end_interrupts - _stext) / sizeof(int);
311311

312312
while (length--) {
313-
patch_instruction(dest, *src);
313+
raw_patch_instruction(dest, *src);
314314
src++;
315315
dest++;
316316
}

0 commit comments

Comments
 (0)