aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2018-05-04 07:22:12 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2018-05-09 04:55:01 -0400
commit971a9ca6259752c04da09535707d08ccc5d1ed4b (patch)
treea2403ee27a33aa0d15e42f0ed451c70fe21288dd
parent32fd2b4bcf6bf68ec45c4ddc4f57056b17e22bd7 (diff)
s390/early: move functions which may not access bss section to extra file
Move functions which may not access bss section to extra file. This makes it easier to verify that all early functions which may not rely on an initialized bss section are not accessing it. Reviewed-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--arch/s390/kernel/Makefile24
-rw-r--r--arch/s390/kernel/early.c49
-rw-r--r--arch/s390/kernel/early_nobss.c65
-rw-r--r--arch/s390/kernel/entry.h1
-rw-r--r--arch/s390/kernel/head64.S8
5 files changed, 86 insertions, 61 deletions
diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
index f92dd8ed3884..b5146697ab50 100644
--- a/arch/s390/kernel/Makefile
+++ b/arch/s390/kernel/Makefile
@@ -6,22 +6,26 @@
6ifdef CONFIG_FUNCTION_TRACER 6ifdef CONFIG_FUNCTION_TRACER
7 7
8# Do not trace tracer code 8# Do not trace tracer code
9CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE) 9CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE)
10 10
11# Do not trace early setup code 11# Do not trace early setup code
12CFLAGS_REMOVE_als.o = $(CC_FLAGS_FTRACE) 12CFLAGS_REMOVE_als.o = $(CC_FLAGS_FTRACE)
13CFLAGS_REMOVE_early.o = $(CC_FLAGS_FTRACE) 13CFLAGS_REMOVE_early.o = $(CC_FLAGS_FTRACE)
14CFLAGS_REMOVE_early_nobss.o = $(CC_FLAGS_FTRACE)
14 15
15endif 16endif
16 17
17GCOV_PROFILE_als.o := n 18GCOV_PROFILE_als.o := n
18GCOV_PROFILE_early.o := n 19GCOV_PROFILE_early.o := n
20GCOV_PROFILE_early_nobss.o := n
19 21
20KCOV_INSTRUMENT_als.o := n 22KCOV_INSTRUMENT_als.o := n
21KCOV_INSTRUMENT_early.o := n 23KCOV_INSTRUMENT_early.o := n
24KCOV_INSTRUMENT_early_nobss.o := n
22 25
23UBSAN_SANITIZE_als.o := n 26UBSAN_SANITIZE_als.o := n
24UBSAN_SANITIZE_early.o := n 27UBSAN_SANITIZE_early.o := n
28UBSAN_SANITIZE_early_nobss.o := n
25 29
26# 30#
27# Use -march=z900 for als.c to be able to print an error 31# Use -march=z900 for als.c to be able to print an error
@@ -57,7 +61,7 @@ CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"'
57 61
58obj-y := traps.o time.o process.o base.o early.o setup.o idle.o vtime.o 62obj-y := traps.o time.o process.o base.o early.o setup.o idle.o vtime.o
59obj-y += processor.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o 63obj-y += processor.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
60obj-y += debug.o irq.o ipl.o dis.o diag.o vdso.o als.o 64obj-y += debug.o irq.o ipl.o dis.o diag.o vdso.o als.o early_nobss.o
61obj-y += sysinfo.o jump_label.o lgr.o os_info.o machine_kexec.o pgm_check.o 65obj-y += sysinfo.o jump_label.o lgr.o os_info.o machine_kexec.o pgm_check.o
62obj-y += runtime_instr.o cache.o fpu.o dumpstack.o guarded_storage.o sthyi.o 66obj-y += runtime_instr.o cache.o fpu.o dumpstack.o guarded_storage.o sthyi.o
63obj-y += entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o 67obj-y += entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o
diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c
index 4f6527d4747b..827699eb48fa 100644
--- a/arch/s390/kernel/early.c
+++ b/arch/s390/kernel/early.c
@@ -34,32 +34,6 @@
34static void __init setup_boot_command_line(void); 34static void __init setup_boot_command_line(void);
35 35
36/* 36/*
37 * Get the TOD clock running.
38 */
39static void __init reset_tod_clock(void)
40{
41 u64 time;
42
43 if (store_tod_clock(&time) == 0)
44 return;
45 /* TOD clock not running. Set the clock to Unix Epoch. */
46 if (set_tod_clock(TOD_UNIX_EPOCH) != 0 || store_tod_clock(&time) != 0)
47 disabled_wait(0);
48
49 memset(tod_clock_base, 0, 16);
50 *(__u64 *) &tod_clock_base[1] = TOD_UNIX_EPOCH;
51 S390_lowcore.last_update_clock = TOD_UNIX_EPOCH;
52}
53
54/*
55 * Clear bss memory
56 */
57static noinline __init void clear_bss_section(void)
58{
59 memset(__bss_start, 0, __bss_stop - __bss_start);
60}
61
62/*
63 * Initialize storage key for kernel pages 37 * Initialize storage key for kernel pages
64 */ 38 */
65static noinline __init void init_kernel_storage_key(void) 39static noinline __init void init_kernel_storage_key(void)
@@ -310,26 +284,6 @@ static int __init cad_setup(char *str)
310} 284}
311early_param("cad", cad_setup); 285early_param("cad", cad_setup);
312 286
313static __init noinline void rescue_initrd(void)
314{
315 unsigned long min_initrd_addr = (unsigned long) _end + (4UL << 20);
316
317 /*
318 * Just like in case of IPL from VM reader we make sure there is a
319 * gap of 4MB between end of kernel and start of initrd.
320 * That way we can also be sure that saving an NSS will succeed,
321 * which however only requires different segments.
322 */
323 if (!IS_ENABLED(CONFIG_BLK_DEV_INITRD))
324 return;
325 if (!INITRD_START || !INITRD_SIZE)
326 return;
327 if (INITRD_START >= min_initrd_addr)
328 return;
329 memmove((void *) min_initrd_addr, (void *) INITRD_START, INITRD_SIZE);
330 INITRD_START = min_initrd_addr;
331}
332
333/* Set up boot command line */ 287/* Set up boot command line */
334static void __init append_to_cmdline(size_t (*ipl_data)(char *, size_t)) 288static void __init append_to_cmdline(size_t (*ipl_data)(char *, size_t))
335{ 289{
@@ -379,9 +333,6 @@ static void __init setup_boot_command_line(void)
379 333
380void __init startup_init(void) 334void __init startup_init(void)
381{ 335{
382 reset_tod_clock();
383 rescue_initrd();
384 clear_bss_section();
385 time_early_init(); 336 time_early_init();
386 init_kernel_storage_key(); 337 init_kernel_storage_key();
387 lockdep_off(); 338 lockdep_off();
diff --git a/arch/s390/kernel/early_nobss.c b/arch/s390/kernel/early_nobss.c
new file mode 100644
index 000000000000..2d84fc48df3a
--- /dev/null
+++ b/arch/s390/kernel/early_nobss.c
@@ -0,0 +1,65 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright IBM Corp. 2007, 2018
4 */
5
6/*
7 * Early setup functions which may not rely on an initialized bss
8 * section. The last thing that is supposed to happen here is
9 * initialization of the bss section.
10 */
11
12#include <linux/processor.h>
13#include <linux/string.h>
14#include <asm/sections.h>
15#include <asm/lowcore.h>
16#include <asm/setup.h>
17#include <asm/timex.h>
18#include "entry.h"
19
20static void __init reset_tod_clock(void)
21{
22 u64 time;
23
24 if (store_tod_clock(&time) == 0)
25 return;
26 /* TOD clock not running. Set the clock to Unix Epoch. */
27 if (set_tod_clock(TOD_UNIX_EPOCH) != 0 || store_tod_clock(&time) != 0)
28 disabled_wait(0);
29
30 memset(tod_clock_base, 0, 16);
31 *(__u64 *) &tod_clock_base[1] = TOD_UNIX_EPOCH;
32 S390_lowcore.last_update_clock = TOD_UNIX_EPOCH;
33}
34
35static void __init rescue_initrd(void)
36{
37 unsigned long min_initrd_addr = (unsigned long) _end + (4UL << 20);
38
39 /*
40 * Just like in case of IPL from VM reader we make sure there is a
41 * gap of 4MB between end of kernel and start of initrd.
42 * That way we can also be sure that saving an NSS will succeed,
43 * which however only requires different segments.
44 */
45 if (!IS_ENABLED(CONFIG_BLK_DEV_INITRD))
46 return;
47 if (!INITRD_START || !INITRD_SIZE)
48 return;
49 if (INITRD_START >= min_initrd_addr)
50 return;
51 memmove((void *) min_initrd_addr, (void *) INITRD_START, INITRD_SIZE);
52 INITRD_START = min_initrd_addr;
53}
54
55static void __init clear_bss_section(void)
56{
57 memset(__bss_start, 0, __bss_stop - __bss_start);
58}
59
60void __init startup_init_nobss(void)
61{
62 reset_tod_clock();
63 rescue_initrd();
64 clear_bss_section();
65}
diff --git a/arch/s390/kernel/entry.h b/arch/s390/kernel/entry.h
index e87758f8fbdc..961abfac2c5f 100644
--- a/arch/s390/kernel/entry.h
+++ b/arch/s390/kernel/entry.h
@@ -58,6 +58,7 @@ void do_notify_resume(struct pt_regs *regs);
58void __init init_IRQ(void); 58void __init init_IRQ(void);
59void do_IRQ(struct pt_regs *regs, int irq); 59void do_IRQ(struct pt_regs *regs, int irq);
60void do_restart(void); 60void do_restart(void);
61void __init startup_init_nobss(void);
61void __init startup_init(void); 62void __init startup_init(void);
62void die(struct pt_regs *regs, const char *str); 63void die(struct pt_regs *regs, const char *str);
63int setup_profiling_timer(unsigned int multiplier); 64int setup_profiling_timer(unsigned int multiplier);
diff --git a/arch/s390/kernel/head64.S b/arch/s390/kernel/head64.S
index 38a973ccf501..791cb9000e86 100644
--- a/arch/s390/kernel/head64.S
+++ b/arch/s390/kernel/head64.S
@@ -40,8 +40,12 @@ ENTRY(startup_continue)
40 stg %r15,__LC_KERNEL_STACK # set end of kernel stack 40 stg %r15,__LC_KERNEL_STACK # set end of kernel stack
41 aghi %r15,-160 41 aghi %r15,-160
42# 42#
43# Save ipl parameters, clear bss memory, initialize storage key for kernel pages, 43# Early setup functions that may not rely on an initialized bss section,
44# and create a kernel NSS if the SAVESYS= parm is defined 44# like moving the initrd. Returns with an initialized bss section.
45#
46 brasl %r14,startup_init_nobss
47#
48# Early machine initialization and detection functions.
45# 49#
46 brasl %r14,startup_init 50 brasl %r14,startup_init
47 lpswe .Lentry-.LPG1(13) # jump to _stext in primary-space, 51 lpswe .Lentry-.LPG1(13) # jump to _stext in primary-space,