forked from luck/tmp_suning_uos_patched
s390: fix initrd corruptions with gcov/kcov instrumented kernels
The early C code within arch/s390/kernel/early.c saves ipl parameters before the bss section is cleared. When doing that it jumps to code that is potentially gcov/kcov instrumented. That code in turn will corrupt an initrd that potentially may reside in the not yet ready to be used bss section. Instead of excluding more and more code from gcov/kcov instrumentation provide an early memmove function which will be used to save ipl parameters. The verification if these parameters are actually valid will be done later. Reviewed-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
b5cb9bf8dd
commit
d543a106f9
@ -97,7 +97,7 @@ void __init save_area_add_vxrs(struct save_area *, __vector128 *vxrs);
|
|||||||
extern void do_reipl(void);
|
extern void do_reipl(void);
|
||||||
extern void do_halt(void);
|
extern void do_halt(void);
|
||||||
extern void do_poff(void);
|
extern void do_poff(void);
|
||||||
extern void ipl_save_parameters(void);
|
extern void ipl_verify_parameters(void);
|
||||||
extern void ipl_update_parameters(void);
|
extern void ipl_update_parameters(void);
|
||||||
extern size_t append_ipl_vmparm(char *, size_t);
|
extern size_t append_ipl_vmparm(char *, size_t);
|
||||||
extern size_t append_ipl_scpdata(char *, size_t);
|
extern size_t append_ipl_scpdata(char *, size_t);
|
||||||
|
@ -392,7 +392,49 @@ static int __init cad_init(void)
|
|||||||
}
|
}
|
||||||
early_initcall(cad_init);
|
early_initcall(cad_init);
|
||||||
|
|
||||||
static __init void rescue_initrd(void)
|
static __init void memmove_early(void *dst, const void *src, size_t n)
|
||||||
|
{
|
||||||
|
unsigned long addr;
|
||||||
|
long incr;
|
||||||
|
psw_t old;
|
||||||
|
|
||||||
|
if (!n)
|
||||||
|
return;
|
||||||
|
incr = 1;
|
||||||
|
if (dst > src) {
|
||||||
|
incr = -incr;
|
||||||
|
dst += n - 1;
|
||||||
|
src += n - 1;
|
||||||
|
}
|
||||||
|
old = S390_lowcore.program_new_psw;
|
||||||
|
S390_lowcore.program_new_psw.mask = __extract_psw();
|
||||||
|
asm volatile(
|
||||||
|
" larl %[addr],1f\n"
|
||||||
|
" stg %[addr],%[psw_pgm_addr]\n"
|
||||||
|
"0: mvc 0(1,%[dst]),0(%[src])\n"
|
||||||
|
" agr %[dst],%[incr]\n"
|
||||||
|
" agr %[src],%[incr]\n"
|
||||||
|
" brctg %[n],0b\n"
|
||||||
|
"1:\n"
|
||||||
|
: [addr] "=&d" (addr),
|
||||||
|
[psw_pgm_addr] "=&Q" (S390_lowcore.program_new_psw.addr),
|
||||||
|
[dst] "+&a" (dst), [src] "+&a" (src), [n] "+d" (n)
|
||||||
|
: [incr] "d" (incr)
|
||||||
|
: "cc", "memory");
|
||||||
|
S390_lowcore.program_new_psw = old;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __init noinline void ipl_save_parameters(void)
|
||||||
|
{
|
||||||
|
void *src, *dst;
|
||||||
|
|
||||||
|
src = (void *)(unsigned long) S390_lowcore.ipl_parmblock_ptr;
|
||||||
|
dst = (void *) IPL_PARMBLOCK_ORIGIN;
|
||||||
|
memmove_early(dst, src, PAGE_SIZE);
|
||||||
|
S390_lowcore.ipl_parmblock_ptr = IPL_PARMBLOCK_ORIGIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __init noinline void rescue_initrd(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_BLK_DEV_INITRD
|
#ifdef CONFIG_BLK_DEV_INITRD
|
||||||
unsigned long min_initrd_addr = (unsigned long) _end + (4UL << 20);
|
unsigned long min_initrd_addr = (unsigned long) _end + (4UL << 20);
|
||||||
@ -406,7 +448,7 @@ static __init void rescue_initrd(void)
|
|||||||
return;
|
return;
|
||||||
if (INITRD_START >= min_initrd_addr)
|
if (INITRD_START >= min_initrd_addr)
|
||||||
return;
|
return;
|
||||||
memmove((void *) min_initrd_addr, (void *) INITRD_START, INITRD_SIZE);
|
memmove_early((void *) min_initrd_addr, (void *) INITRD_START, INITRD_SIZE);
|
||||||
INITRD_START = min_initrd_addr;
|
INITRD_START = min_initrd_addr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -468,6 +510,7 @@ void __init startup_init(void)
|
|||||||
ipl_save_parameters();
|
ipl_save_parameters();
|
||||||
rescue_initrd();
|
rescue_initrd();
|
||||||
clear_bss_section();
|
clear_bss_section();
|
||||||
|
ipl_verify_parameters();
|
||||||
time_early_init();
|
time_early_init();
|
||||||
init_kernel_storage_key();
|
init_kernel_storage_key();
|
||||||
lockdep_off();
|
lockdep_off();
|
||||||
|
@ -1991,10 +1991,9 @@ void __init ipl_update_parameters(void)
|
|||||||
diag308_set_works = 1;
|
diag308_set_works = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __init ipl_save_parameters(void)
|
void __init ipl_verify_parameters(void)
|
||||||
{
|
{
|
||||||
struct cio_iplinfo iplinfo;
|
struct cio_iplinfo iplinfo;
|
||||||
void *src, *dst;
|
|
||||||
|
|
||||||
if (cio_get_iplinfo(&iplinfo))
|
if (cio_get_iplinfo(&iplinfo))
|
||||||
return;
|
return;
|
||||||
@ -2005,10 +2004,6 @@ void __init ipl_save_parameters(void)
|
|||||||
if (!iplinfo.is_qdio)
|
if (!iplinfo.is_qdio)
|
||||||
return;
|
return;
|
||||||
ipl_flags |= IPL_PARMBLOCK_VALID;
|
ipl_flags |= IPL_PARMBLOCK_VALID;
|
||||||
src = (void *)(unsigned long)S390_lowcore.ipl_parmblock_ptr;
|
|
||||||
dst = (void *)IPL_PARMBLOCK_ORIGIN;
|
|
||||||
memmove(dst, src, PAGE_SIZE);
|
|
||||||
S390_lowcore.ipl_parmblock_ptr = IPL_PARMBLOCK_ORIGIN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static LIST_HEAD(rcall);
|
static LIST_HEAD(rcall);
|
||||||
|
Loading…
Reference in New Issue
Block a user