diff options
Diffstat (limited to 'arch/powerpc/lib/code-patching.c')
| -rw-r--r-- | arch/powerpc/lib/code-patching.c | 17 | 
1 files changed, 13 insertions, 4 deletions
| diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c index 850f3b8f4da5..89502cbccb1b 100644 --- a/arch/powerpc/lib/code-patching.c +++ b/arch/powerpc/lib/code-patching.c @@ -98,8 +98,7 @@ static int map_patch_area(void *addr, unsigned long text_poke_addr)  	else  		pfn = __pa_symbol(addr) >> PAGE_SHIFT; -	err = map_kernel_page(text_poke_addr, (pfn << PAGE_SHIFT), -				pgprot_val(PAGE_KERNEL)); +	err = map_kernel_page(text_poke_addr, (pfn << PAGE_SHIFT), PAGE_KERNEL);  	pr_devel("Mapped addr %lx with pfn %lx:%d\n", text_poke_addr, pfn, err);  	if (err) @@ -142,7 +141,7 @@ static inline int unmap_patch_area(unsigned long addr)  	return 0;  } -int patch_instruction(unsigned int *addr, unsigned int instr) +static int do_patch_instruction(unsigned int *addr, unsigned int instr)  {  	int err;  	unsigned int *patch_addr = NULL; @@ -182,12 +181,22 @@ out:  }  #else /* !CONFIG_STRICT_KERNEL_RWX */ -int patch_instruction(unsigned int *addr, unsigned int instr) +static int do_patch_instruction(unsigned int *addr, unsigned int instr)  {  	return raw_patch_instruction(addr, instr);  }  #endif /* CONFIG_STRICT_KERNEL_RWX */ + +int patch_instruction(unsigned int *addr, unsigned int instr) +{ +	/* Make sure we aren't patching a freed init section */ +	if (init_mem_is_free && init_section_contains(addr, 4)) { +		pr_debug("Skipping init section patching addr: 0x%px\n", addr); +		return 0; +	} +	return do_patch_instruction(addr, instr); +}  NOKPROBE_SYMBOL(patch_instruction);  int patch_branch(unsigned int *addr, unsigned long target, int flags) | 
