mirror of
https://github.com/torvalds/linux.git
synced 2024-12-29 14:21:47 +00:00
s390: clean .bss before running uncompressed kernel
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>
This commit is contained in:
parent
19413fe04f
commit
2e83e0eb85
@ -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);
|
||||
|
@ -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
|
||||
|
@ -32,6 +32,21 @@
|
||||
#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();
|
||||
|
@ -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();
|
||||
}
|
@ -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.
|
||||
#
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user