Thread (3 messages) flat view 3 messages, 2 authors, 2018-10-03

Re: [PATCH] powerpc: use PTRRELOC during early init

From: Christophe LEROY <hidden>
Date: 2018-10-03 06:43:16

Hi Andreas,

Le 03/10/2018 à 00:33, Andreas Schwab a écrit :
quoted hunk ↗ jump to hunk
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 <redacted>
---
  arch/powerpc/lib/code-patching.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index 6ae2777c22..6192fdae36 100644
--- a/arch/powerpc/lib/code-patching.c
+++ b/arch/powerpc/lib/code-patching.c
@@ -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
  		pr_debug("Skipping init section patching addr: 0x%px\n", exec_addr);
  		return 0;
  	}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help