Skip to content

Commit

Permalink
Revert "powerpc/code-patching: Improve verification of patchability"
Browse files Browse the repository at this point in the history
This reverts commit 8b8a8f0.

As reported[1] by Sachin this causes problems with ftrace, and it also
causes the code patching selftests to fail as reported[2] by Stephen.

So revert it for now.

1: https://lore.kernel.org/linuxppc-dev/[email protected]/
2: https://lore.kernel.org/linuxppc-dev/[email protected]/

Signed-off-by: Michael Ellerman <[email protected]>
  • Loading branch information
mpe committed Nov 29, 2021
1 parent 3d030e3 commit af3fdce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions arch/powerpc/include/asm/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ extern void ppc_printk_progress(char *s, unsigned short hex);

extern unsigned int rtas_data;
extern unsigned long long memory_limit;
extern bool init_mem_is_free;
extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);

struct device_node;
Expand Down
5 changes: 3 additions & 2 deletions arch/powerpc/lib/code-patching.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ static int do_patch_instruction(u32 *addr, struct ppc_inst instr)
int patch_instruction(u32 *addr, struct ppc_inst instr)
{
/* Make sure we aren't patching a freed init section */
if (!kernel_text_address((unsigned long)addr))
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);
Expand Down
2 changes: 2 additions & 0 deletions arch/powerpc/mm/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <mm/mmu_decl.h>

unsigned long long memory_limit;
bool init_mem_is_free;

unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;
EXPORT_SYMBOL(empty_zero_page);
Expand Down Expand Up @@ -311,6 +312,7 @@ void free_initmem(void)
{
ppc_md.progress = ppc_printk_progress;
mark_initmem_nx();
init_mem_is_free = true;
free_initmem_default(POISON_FREE_INITMEM);
}

Expand Down

0 comments on commit af3fdce

Please sign in to comment.