diff options
author | Christophe Leroy <christophe.leroy@c-s.fr> | 2017-11-21 09:28:20 -0500 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2017-11-22 07:04:20 -0500 |
commit | 252eb55816a6f69ef9464cad303cdb3326cdc61d (patch) | |
tree | 82da0aef8fcf25b6696049d5cae17d175ff9c800 /arch/powerpc/lib/code-patching.c | |
parent | f3f1dfd600ff82b18b7ea73d80eb27f476a6aa97 (diff) |
powerpc: Fix boot on BOOK3S_32 with CONFIG_STRICT_KERNEL_RWX
On powerpc32, patch_instruction() is called by apply_feature_fixups()
which is called from early_init()
There is the following note in front of early_init():
* Note that the kernel may be running at an address which is different
* from the address that it was linked at, so we must use RELOC/PTRRELOC
* to access static data (including strings). -- paulus
Therefore, slab_is_available() cannot be called yet, and
text_poke_area must be addressed with PTRRELOC()
Fixes: 95902e6c8864 ("powerpc/mm: Implement STRICT_KERNEL_RWX on PPC32")
Cc: stable@vger.kernel.org # v4.14+
Reported-by: Meelis Roos <mroos@linux.ee>
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/lib/code-patching.c')
-rw-r--r-- | arch/powerpc/lib/code-patching.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c index c9de03e0c1f1..d469224c4ada 100644 --- a/arch/powerpc/lib/code-patching.c +++ b/arch/powerpc/lib/code-patching.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <asm/tlbflush.h> | 21 | #include <asm/tlbflush.h> |
22 | #include <asm/page.h> | 22 | #include <asm/page.h> |
23 | #include <asm/code-patching.h> | 23 | #include <asm/code-patching.h> |
24 | #include <asm/setup.h> | ||
24 | 25 | ||
25 | static int __patch_instruction(unsigned int *addr, unsigned int instr) | 26 | static int __patch_instruction(unsigned int *addr, unsigned int instr) |
26 | { | 27 | { |
@@ -146,11 +147,8 @@ int patch_instruction(unsigned int *addr, unsigned int instr) | |||
146 | * During early early boot patch_instruction is called | 147 | * During early early boot patch_instruction is called |
147 | * when text_poke_area is not ready, but we still need | 148 | * when text_poke_area is not ready, but we still need |
148 | * to allow patching. We just do the plain old patching | 149 | * to allow patching. We just do the plain old patching |
149 | * We use slab_is_available and per cpu read * via this_cpu_read | ||
150 | * of text_poke_area. Per-CPU areas might not be up early | ||
151 | * this can create problems with just using this_cpu_read() | ||
152 | */ | 150 | */ |
153 | if (!slab_is_available() || !this_cpu_read(text_poke_area)) | 151 | if (!this_cpu_read(*PTRRELOC(&text_poke_area))) |
154 | return __patch_instruction(addr, instr); | 152 | return __patch_instruction(addr, instr); |
155 | 153 | ||
156 | local_irq_save(flags); | 154 | local_irq_save(flags); |