powerpc: Avoid code patching freed init sections
A message that is not in the archive (sent off-list or not yet received): 20180914011411.3184-1-mikey__14553.8904158913$1536887645$gmane$org@neuling.org
Quoted 2 lines · Michael Neuling
This stops us from doing code patching in init sections after they've been freed.
This breaks booting on PowerBook6,7, crashing very early.
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
Quoted 6 lines · Andreas Schwab
Quoted 2 lines · Michael Neuling
This stops us from doing code patching in init sections after they've been freed.
This breaks booting on PowerBook6,7, crashing very early.
Sorry, Can you try?
http://patchwork.ozlabs.org/patch/977195/
Mikey
Michael Ellerman
reviewerQuoted 6 lines · Andreas Schwab
Quoted 2 lines · Michael Neuling
This stops us from doing code patching in init sections after they've been freed.
This breaks booting on PowerBook6,7, crashing very early.
Crud, sorry.
My CI setup tests with the mac99 qemu model, but that boots happily, not sure why.
cheers
Le 03/10/2018 à 05:20, Michael Ellerman a écrit :
Quoted 7 lines
Quoted 5 lines · Andreas Schwab
Quoted 2 lines · Michael Neuling
This stops us from doing code patching in init sections after they've been freed.
Quoted 6 lines
Quoted 1 line
This breaks booting on PowerBook6,7, crashing very early.
Crud, sorry.
My CI setup tests with the mac99 qemu model, but that boots happily, not sure why.
Maybe mac99 doesn't use relocation ?
The issue is that during early boot, 'init_mem_is_free' is not yet at its definitif address.
I sent a fix for it : https://patchwork.ozlabs.org/patch/977195/
Christophe
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 powerpc: use PTRRELOC during early init
This fixes a crash on powerpc32 when using global data during early init without relocating its address.
--- arch/powerpc/lib/code-patching.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/lib/code-patching.c +1 -1
@@ -29,7 +29,7 @@ static int __patch_instruction(unsigned int *exec_addr, unsigned int instr,int err;/* Make sure we aren't patching a freed init section */ -if (init_mem_is_free &&init_section_contains (exec_addr,4 )) { +if (*PTRRELOC (&init_mem_is_free) &&init_section_contains (exec_addr,4 )) {pr_debug ("Skipping init section patching addr: 0x%px\n" , exec_addr);return 0 ; }
Signature · 6 lines
2.19.0 -- Andreas Schwab, [email protected] GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
Re: [PATCH] powerpc: use PTRRELOC during early init
Hi Andreas,
Le 03/10/2018 à 00:33, Andreas Schwab a écrit :
Quoted 14 lines
This fixes a crash on powerpc32 when using global data during early init without relocating its address.
Fixes 51c3c62b58 (powerpc: Avoid code patching freed init sections)Signed-off-by Andreas Schwab <[email protected]>--- arch/powerpc/lib/code-patching.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/lib/code-patching.c +0
-0
arch/powerpc/lib/code-patching.c static int __patch_instruction(unsigned int *exec_addr, unsigned int instr, · line 32
Quoted 5 lines
arch/powerpc/lib/code-patching.c +1
-1@@ -29,7 +29,7 @@ static int __patch_instruction(unsigned int *exec_addr, unsigned int instr,int err;/* Make sure we aren't patching a freed init section */ -if (init_mem_is_free &&init_section_contains (exec_addr,4 )) { +if (*PTRRELOC (&init_mem_is_free) &&init_section_contains (exec_addr,4 )) {
That's not the best solution. In the past we already did our best to separate early use of patch_instruction() , that's how raw_patch_instruction() was born, see https://patchwork.ozlabs.org/patch/840974/
Here, it idea is similar, this test should not apply to raw_patch_instruction()
Did you try my proposed fix https://patchwork.ozlabs.org/patch/977195/ ?
Christophe
Quoted 4 lines
arch/powerpc/lib/code-patching.c +0
-0pr_debug ("Skipping init section patching addr: 0x%px\n" , exec_addr);return 0 ; }
Re: [PATCH] powerpc: use PTRRELOC during early init
Quoted 1 line · Christophe LEROY
Did you try my proposed fix https://patchwork.ozlabs.org/patch/977195/ ?
That works as well.
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."