powerpc/code-patching: Remove init_mem_is_free
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Thu, 2 Dec 2021 12:00:18 +0000 (13:00 +0100)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 23 Dec 2021 11:35:24 +0000 (22:35 +1100)
A new state has been added by commit d2635f2012a4 ("mm: create a new
system state and fix core_kernel_text()"). That state tells when
initmem is about to be released and is redundant with init_mem_is_free.

Remove init_mem_is_free.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/ad8c3ccb39c8edaa89fd3eda1cc7218baea1cde5.1638446239.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/setup.h
arch/powerpc/lib/code-patching.c
arch/powerpc/mm/mem.c

index 71658504daddb8b01c9537d14332c44962030442..d0d3dd531c7fc62fbc15a0be450b5e6ec0dddecc 100644 (file)
@@ -9,7 +9,6 @@ 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;
index 7334ea99efd0cc1473e6a61cdd51733c572f7e78..1c05fc725af8027875d58ab7b9dc13a7b91a571c 100644 (file)
@@ -15,7 +15,6 @@
 #include <asm/tlbflush.h>
 #include <asm/page.h>
 #include <asm/code-patching.h>
-#include <asm/setup.h>
 #include <asm/inst.h>
 
 static int __patch_instruction(u32 *exec_addr, ppc_inst_t instr, u32 *patch_addr)
@@ -187,7 +186,7 @@ static int do_patch_instruction(u32 *addr, ppc_inst_t instr)
 int patch_instruction(u32 *addr, ppc_inst_t instr)
 {
        /* Make sure we aren't patching a freed init section */
-       if (init_mem_is_free && init_section_contains(addr, 4))
+       if (system_state >= SYSTEM_FREEING_INITMEM && init_section_contains(addr, 4))
                return 0;
 
        return do_patch_instruction(addr, instr);
index bd5d91a31183b3c1101246c373b3975c242d6061..8e301cd8925b2bde870fd8cddd933a6128b4924e 100644 (file)
@@ -26,7 +26,6 @@
 #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);
@@ -312,7 +311,6 @@ void free_initmem(void)
 {
        ppc_md.progress = ppc_printk_progress;
        mark_initmem_nx();
-       init_mem_is_free = true;
        free_initmem_default(POISON_FREE_INITMEM);
 }