Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-block.git] / arch / s390 / kernel / early_nobss.c
CommitLineData
971a9ca6
HC
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}