4.17-stable review patch. If anyone has any objections, please let me know.
------------------ From: Dave Hansen <dave.han...@linux.intel.com> commit 9f515cdb411ef34f1aaf4c40bb0c932cf6db5de1 upstream. The x86 code has several places where it frees parts of kernel image: 1. Unused SMP alternative 2. __init code 3. The hole between text and rodata 4. The hole between rodata and data We call free_init_pages() to do this. Strangely, we convert the symbol addresses to kernel direct map addresses in some cases (#3, #4) but not others (#1, #2). The virt_to_page() and the other code in free_reserved_area() now works fine for for symbol addresses on x86, so don't bother converting the addresses to direct map addresses before freeing them. Signed-off-by: Dave Hansen <dave.han...@linux.intel.com> Signed-off-by: Thomas Gleixner <t...@linutronix.de> Cc: keesc...@google.com Cc: aarca...@redhat.com Cc: jgr...@suse.com Cc: jpoim...@redhat.com Cc: gre...@linuxfoundation.org Cc: pet...@infradead.org Cc: hu...@google.com Cc: torva...@linux-foundation.org Cc: b...@alien8.de Cc: l...@kernel.org Cc: a...@linux.intel.com Cc: Kees Cook <keesc...@google.com> Cc: Andrea Arcangeli <aarca...@redhat.com> Cc: Juergen Gross <jgr...@suse.com> Cc: Josh Poimboeuf <jpoim...@redhat.com> Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org> Cc: Peter Zijlstra <pet...@infradead.org> Cc: Hugh Dickins <hu...@google.com> Cc: Linus Torvalds <torva...@linux-foundation.org> Cc: Borislav Petkov <b...@alien8.de> Cc: Andy Lutomirski <l...@kernel.org> Cc: Andi Kleen <a...@linux.intel.com> Link: https://lkml.kernel.org/r/20180802225828.89b2d...@viggo.jf.intel.com Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org> --- arch/x86/mm/init_64.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1283,12 +1283,8 @@ void mark_rodata_ro(void) set_memory_ro(start, (end-start) >> PAGE_SHIFT); #endif - free_init_pages("unused kernel", - (unsigned long) __va(__pa_symbol(text_end)), - (unsigned long) __va(__pa_symbol(rodata_start))); - free_init_pages("unused kernel", - (unsigned long) __va(__pa_symbol(rodata_end)), - (unsigned long) __va(__pa_symbol(_sdata))); + free_init_pages("unused kernel", text_end, rodata_start); + free_init_pages("unused kernel", rodata_end, _sdata); debug_checkwx();