mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-27 03:45:28 +07:00
5ac47f7a6e
The ppc64 kernel can get loaded at any address which means our very early init code in prom_init.c must be relocatable. We do this with a pretty nasty RELOC() macro that we wrap accesses of variables with. It is very fragile and sometimes we forget to add a RELOC() to an uncommon path or sometimes a compiler change breaks it. 32bit has a much more elegant solution where we build prom_init.c with -mrelocatable and then process the relocations manually. Unfortunately we can't do the equivalent on 64bit and we would have to build the entire kernel relocatable (-pie), resulting in a large increase in kernel footprint (megabytes of relocation data). The relocation data will be marked __initdata but it still creates more pressure on our already tight memory layout at boot. Alan Modra pointed out that the 64bit ABI is relocatable even if we don't build with -pie, we just need to relocate the TOC. This patch implements that idea and relocates the TOC entries of prom_init.c. An added bonus is there are very few relocations to process which helps keep boot times on simulators down. gcc does not put 64bit integer constants into the TOC but to be safe we may want a build time script which passes through the prom_init.c TOC entries to make sure everything looks reasonable. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
45 lines
906 B
C
45 lines
906 B
C
#ifndef _ASM_POWERPC_SECTIONS_H
|
|
#define _ASM_POWERPC_SECTIONS_H
|
|
#ifdef __KERNEL__
|
|
|
|
#include <linux/elf.h>
|
|
#include <linux/uaccess.h>
|
|
#include <asm-generic/sections.h>
|
|
|
|
#ifdef __powerpc64__
|
|
|
|
extern char __end_interrupts[];
|
|
|
|
extern char __prom_init_toc_start[];
|
|
extern char __prom_init_toc_end[];
|
|
|
|
static inline int in_kernel_text(unsigned long addr)
|
|
{
|
|
if (addr >= (unsigned long)_stext && addr < (unsigned long)__init_end)
|
|
return 1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static inline int overlaps_kernel_text(unsigned long start, unsigned long end)
|
|
{
|
|
return start < (unsigned long)__init_end &&
|
|
(unsigned long)_stext < end;
|
|
}
|
|
|
|
#undef dereference_function_descriptor
|
|
static inline void *dereference_function_descriptor(void *ptr)
|
|
{
|
|
struct ppc64_opd_entry *desc = ptr;
|
|
void *p;
|
|
|
|
if (!probe_kernel_address(&desc->funcaddr, p))
|
|
ptr = p;
|
|
return ptr;
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* __KERNEL__ */
|
|
#endif /* _ASM_POWERPC_SECTIONS_H */
|