Zero BSS explicitly if not started by loader(8). Add a check for the magic

values that ePAPR-compliant loaders (like skiboot) put in the register
loader uses for the metadata pointer to avoid confusing them.
This commit is contained in:
Nathan Whitehorn 2015-01-20 05:28:03 +00:00
parent d1b1b60065
commit 3dcd1c9585

View File

@ -224,6 +224,10 @@ cpu_startup(void *dummy)
}
extern vm_offset_t __startkernel, __endkernel;
extern unsigned char __bss_start[];
extern unsigned char __sbss_start[];
extern unsigned char __sbss_end[];
extern unsigned char _end[];
#ifndef __powerpc64__
/* Bits for running on 64-bit systems in 32-bit mode. */
@ -272,9 +276,6 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp)
trap_offset = 0;
cacheline_warn = 0;
/* Store boot environment state */
OF_initial_setup((void *)fdt, NULL, (int (*)(void *))ofentry);
/* First guess at start/end kernel positions */
startkernel = __startkernel;
endkernel = __endkernel;
@ -289,6 +290,10 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp)
mdp = NULL;
#endif
/* Check for ePAPR loader, which puts a magic value into r6 */
if (mdp == (void *)0x65504150)
mdp = NULL;
/*
* Parse metadata if present and fetch parameters. Must be done
* before console is inited so cninit gets the right value of
@ -308,8 +313,14 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp)
db_fetch_ksymtab(ksym_start, ksym_end);
#endif
}
} else {
bzero(__sbss_start, __sbss_end - __sbss_start);
bzero(__bss_start, _end - __bss_start);
}
/* Store boot environment state */
OF_initial_setup((void *)fdt, NULL, (int (*)(void *))ofentry);
/*
* Init params/tunables that can be overridden by the loader
*/