]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
s390: clean .bss before running uncompressed kernel
authorVasily Gorbik <gor@linux.ibm.com>
Sun, 11 Aug 2019 18:55:18 +0000 (20:55 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Wed, 21 Aug 2019 10:58:52 +0000 (12:58 +0200)
Clean uncompressed kernel .bss section in the startup code before
the uncompressed kernel is executed. At this point of time initrd and
certificates have been already rescued. Uncompressed kernel .bss size
is known from vmlinux_info. It is also taken into consideration during
uncompressed kernel positioning by kaslr (so it is safe to clean it).

With that uncompressed kernel is starting with .bss section zeroed and
no .bss section usage restrictions apply. Which makes chkbss checks for
uncompressed kernel objects obsolete and they can be removed.

early_nobss.c is also not needed anymore. Parts of it which are still
relevant are moved to early.c. Kasan initialization code is now called
directly from head64 (early.c is instrumented and should not be
executed before kasan shadow memory is set up).

Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/boot/startup.c
arch/s390/kernel/Makefile
arch/s390/kernel/early.c
arch/s390/kernel/early_nobss.c [deleted file]
arch/s390/kernel/head64.S
arch/s390/lib/Makefile
drivers/s390/char/Makefile

index 7b0d05414618be9e992f96298b1b92b38fea898c..596ca7cc4d7b88a7c37b93cc58d87651ffe4bd9d 100644 (file)
@@ -112,6 +112,11 @@ static void handle_relocs(unsigned long offset)
        }
 }
 
+static void clear_bss_section(void)
+{
+       memset((void *)vmlinux.default_lma + vmlinux.image_size, 0, vmlinux.bss_size);
+}
+
 void startup_kernel(void)
 {
        unsigned long random_lma;
@@ -151,6 +156,7 @@ void startup_kernel(void)
        } else if (__kaslr_offset)
                memcpy((void *)vmlinux.default_lma, img, vmlinux.image_size);
 
+       clear_bss_section();
        copy_bootdata();
        if (IS_ENABLED(CONFIG_RELOCATABLE))
                handle_relocs(__kaslr_offset);
index 0f255b54b0512a4d996704081a1cda97bf91576e..7edbbcd8228ab14775a36be2a12206adb257f493 100644 (file)
@@ -10,20 +10,12 @@ CFLAGS_REMOVE_ftrace.o              = $(CC_FLAGS_FTRACE)
 
 # Do not trace early setup code
 CFLAGS_REMOVE_early.o          = $(CC_FLAGS_FTRACE)
-CFLAGS_REMOVE_early_nobss.o    = $(CC_FLAGS_FTRACE)
 
 endif
 
 GCOV_PROFILE_early.o           := n
-GCOV_PROFILE_early_nobss.o     := n
-
 KCOV_INSTRUMENT_early.o                := n
-KCOV_INSTRUMENT_early_nobss.o  := n
-
 UBSAN_SANITIZE_early.o         := n
-UBSAN_SANITIZE_early_nobss.o   := n
-
-KASAN_SANITIZE_early_nobss.o   := n
 KASAN_SANITIZE_ipl.o           := n
 KASAN_SANITIZE_machine_kexec.o := n
 
@@ -48,7 +40,7 @@ CFLAGS_ptrace.o               += -DUTS_MACHINE='"$(UTS_MACHINE)"'
 
 obj-y  := traps.o time.o process.o base.o early.o setup.o idle.o vtime.o
 obj-y  += processor.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
-obj-y  += debug.o irq.o ipl.o dis.o diag.o vdso.o early_nobss.o
+obj-y  += debug.o irq.o ipl.o dis.o diag.o vdso.o
 obj-y  += sysinfo.o lgr.o os_info.o machine_kexec.o pgm_check.o
 obj-y  += runtime_instr.o cache.o fpu.o dumpstack.o guarded_storage.o sthyi.o
 obj-y  += entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o
@@ -90,6 +82,3 @@ obj-$(CONFIG_TRACEPOINTS)     += trace.o
 # vdso
 obj-y                          += vdso64/
 obj-$(CONFIG_COMPAT_VDSO)      += vdso32/
-
-chkbss := head64.o early_nobss.o
-include $(srctree)/arch/s390/scripts/Makefile.chkbss
index 6312fed48530b830e850c59627a643895592a90c..b432d63d0b373fa0d5abd62860f8e9fde54151c4 100644 (file)
 #include <asm/boot_data.h>
 #include "entry.h"
 
+static void __init reset_tod_clock(void)
+{
+       u64 time;
+
+       if (store_tod_clock(&time) == 0)
+               return;
+       /* TOD clock not running. Set the clock to Unix Epoch. */
+       if (set_tod_clock(TOD_UNIX_EPOCH) != 0 || store_tod_clock(&time) != 0)
+               disabled_wait();
+
+       memset(tod_clock_base, 0, 16);
+       *(__u64 *) &tod_clock_base[1] = TOD_UNIX_EPOCH;
+       S390_lowcore.last_update_clock = TOD_UNIX_EPOCH;
+}
+
 /*
  * Initialize storage key for kernel pages
  */
@@ -301,6 +316,7 @@ static void __init check_image_bootable(void)
 
 void __init startup_init(void)
 {
+       reset_tod_clock();
        check_image_bootable();
        time_early_init();
        init_kernel_storage_key();
diff --git a/arch/s390/kernel/early_nobss.c b/arch/s390/kernel/early_nobss.c
deleted file mode 100644 (file)
index 52a3ef9..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- *    Copyright IBM Corp. 2007, 2018
- */
-
-/*
- * Early setup functions which may not rely on an initialized bss
- * section. The last thing that is supposed to happen here is
- * initialization of the bss section.
- */
-
-#include <linux/processor.h>
-#include <linux/string.h>
-#include <asm/sections.h>
-#include <asm/lowcore.h>
-#include <asm/timex.h>
-#include <asm/kasan.h>
-#include "entry.h"
-
-static void __init reset_tod_clock(void)
-{
-       u64 time;
-
-       if (store_tod_clock(&time) == 0)
-               return;
-       /* TOD clock not running. Set the clock to Unix Epoch. */
-       if (set_tod_clock(TOD_UNIX_EPOCH) != 0 || store_tod_clock(&time) != 0)
-               disabled_wait();
-
-       memset(tod_clock_base, 0, 16);
-       *(__u64 *) &tod_clock_base[1] = TOD_UNIX_EPOCH;
-       S390_lowcore.last_update_clock = TOD_UNIX_EPOCH;
-}
-
-static void __init clear_bss_section(void)
-{
-       memset(__bss_start, 0, __bss_stop - __bss_start);
-}
-
-void __init startup_init_nobss(void)
-{
-       reset_tod_clock();
-       clear_bss_section();
-       kasan_early_init();
-}
index 5aea1a527443004f455f56637f017d023077ab19..143ed71221fefebf5459bf56fac54374663c5d0d 100644 (file)
@@ -34,11 +34,9 @@ ENTRY(startup_continue)
        larl    %r14,init_task
        stg     %r14,__LC_CURRENT
        larl    %r15,init_thread_union+THREAD_SIZE-STACK_FRAME_OVERHEAD
-#
-# Early setup functions that may not rely on an initialized bss section,
-# like moving the initrd. Returns with an initialized bss section.
-#
-       brasl   %r14,startup_init_nobss
+#ifdef CONFIG_KASAN
+       brasl   %r14,kasan_early_init
+#endif
 #
 # Early machine initialization and detection functions.
 #
index a1ec63abfb956d7ab4590c435221fe3b1d674e06..d7c218e8b559b1ce4af8bd3ed6ccd21a328babad 100644 (file)
@@ -11,6 +11,3 @@ lib-$(CONFIG_UPROBES) += probes.o
 # Instrumenting memory accesses to __user data (in different address space)
 # produce false positives
 KASAN_SANITIZE_uaccess.o := n
-
-chkbss := mem.o
-include $(srctree)/arch/s390/scripts/Makefile.chkbss
index b8a8816d94e74f5df222f32bc2086454576e188f..845e12ac595497c4c6cf363028b6a0136a48ee39 100644 (file)
@@ -49,6 +49,3 @@ obj-$(CONFIG_CRASH_DUMP) += sclp_sdias.o zcore.o
 
 hmcdrv-objs := hmcdrv_mod.o hmcdrv_dev.o hmcdrv_ftp.o hmcdrv_cache.o diag_ftp.o sclp_ftp.o
 obj-$(CONFIG_HMC_DRV) += hmcdrv.o
-
-chkbss := sclp_early_core.o
-include $(srctree)/arch/s390/scripts/Makefile.chkbss