mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-26 05:34:13 +08:00
2b0e86cc5d
This patch add support to boot kernel from places other than KERNELBASE. Since CONFIG_RELOCATABLE has already supported, what we need to do is map or copy kernel to a proper place and relocate. Freescale Book-E parts expect lowmem to be mapped by fixed TLB entries(TLB1). The TLB1 entries are not suitable to map the kernel directly in a randomized region, so we chose to copy the kernel to a proper place and restart to relocate. The offset of the kernel was not randomized yet(a fixed 64M is set). We will randomize it in the next patch. Signed-off-by: Jason Yan <yanaijie@huawei.com> Tested-by: Diana Craciun <diana.craciun@nxp.com> Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Scott Wood <oss@buserror.net> [mpe: Use PTRRELOC() in early_init()] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
40 lines
920 B
C
40 lines
920 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
* Early init before relocation
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/kernel.h>
|
|
#include <asm/setup.h>
|
|
#include <asm/sections.h>
|
|
#include <asm/asm-prototypes.h>
|
|
|
|
/*
|
|
* We're called here very early in the boot.
|
|
*
|
|
* Note that the kernel may be running at an address which is different
|
|
* from the address that it was linked at, so we must use RELOC/PTRRELOC
|
|
* to access static data (including strings). -- paulus
|
|
*/
|
|
notrace unsigned long __init early_init(unsigned long dt_ptr)
|
|
{
|
|
unsigned long kva, offset = reloc_offset();
|
|
|
|
kva = *PTRRELOC(&kernstart_virt_addr);
|
|
|
|
/* First zero the BSS */
|
|
if (kva == KERNELBASE)
|
|
memset(PTRRELOC(&__bss_start), 0, __bss_stop - __bss_start);
|
|
|
|
/*
|
|
* Identify the CPU type and fix up code sections
|
|
* that depend on which cpu we have.
|
|
*/
|
|
identify_cpu(offset, mfspr(SPRN_PVR));
|
|
|
|
apply_feature_fixups();
|
|
|
|
return kva + offset;
|
|
}
|