2022-05-31 18:04:11 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#include <linux/sizes.h>
|
|
|
|
#include <asm/asm-offsets.h>
|
|
|
|
#include <asm/thread_info.h>
|
|
|
|
|
|
|
|
#define PAGE_SIZE _PAGE_SIZE
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Put .bss..swapper_pg_dir as the first thing in .bss. This will
|
|
|
|
* ensure that it has .bss alignment (64K).
|
|
|
|
*/
|
|
|
|
#define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir)
|
|
|
|
|
|
|
|
#include <asm-generic/vmlinux.lds.h>
|
efi/loongarch: Add efistub booting support
This patch adds efistub booting support, which is the standard UEFI boot
protocol for LoongArch to use.
We use generic efistub, which means we can pass boot information (i.e.,
system table, memory map, kernel command line, initrd) via a light FDT
and drop a lot of non-standard code.
We use a flat mapping to map the efi runtime in the kernel's address
space. In efi, VA = PA; in kernel, VA = PA + PAGE_OFFSET. As a result,
flat mapping is not identity mapping, SetVirtualAddressMap() is still
needed for the efi runtime.
Tested-by: Xi Ruoyao <xry111@xry111.site>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
[ardb: change fpic to fpie as suggested by Xi Ruoyao]
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2022-08-19 18:20:37 +08:00
|
|
|
#include "image-vars.h"
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Max avaliable Page Size is 64K, so we set SectionAlignment
|
|
|
|
* field of EFI application to 64K.
|
|
|
|
*/
|
|
|
|
PECOFF_FILE_ALIGN = 0x200;
|
|
|
|
PECOFF_SEGMENT_ALIGN = 0x10000;
|
|
|
|
|
|
|
|
OUTPUT_ARCH(loongarch)
|
|
|
|
ENTRY(kernel_entry)
|
|
|
|
PHDRS {
|
|
|
|
text PT_LOAD FLAGS(7); /* RWX */
|
|
|
|
note PT_NOTE FLAGS(4); /* R__ */
|
|
|
|
}
|
|
|
|
|
|
|
|
jiffies = jiffies_64;
|
|
|
|
|
|
|
|
SECTIONS
|
|
|
|
{
|
|
|
|
. = VMLINUX_LOAD_ADDRESS;
|
|
|
|
|
|
|
|
_text = .;
|
|
|
|
HEAD_TEXT_SECTION
|
|
|
|
|
|
|
|
. = ALIGN(PECOFF_SEGMENT_ALIGN);
|
2022-06-25 16:55:41 +08:00
|
|
|
_stext = .;
|
2022-05-31 18:04:11 +08:00
|
|
|
.text : {
|
|
|
|
TEXT_TEXT
|
|
|
|
SCHED_TEXT
|
|
|
|
CPUIDLE_TEXT
|
|
|
|
LOCK_TEXT
|
|
|
|
KPROBES_TEXT
|
|
|
|
IRQENTRY_TEXT
|
|
|
|
SOFTIRQENTRY_TEXT
|
|
|
|
*(.fixup)
|
|
|
|
*(.gnu.warning)
|
|
|
|
} :text = 0
|
|
|
|
. = ALIGN(PECOFF_SEGMENT_ALIGN);
|
|
|
|
_etext = .;
|
|
|
|
|
|
|
|
EXCEPTION_TABLE(16)
|
|
|
|
|
2022-10-12 16:36:08 +08:00
|
|
|
.got : ALIGN(16) { *(.got) }
|
|
|
|
.plt : ALIGN(16) { *(.plt) }
|
|
|
|
.got.plt : ALIGN(16) { *(.got.plt) }
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
. = ALIGN(PECOFF_SEGMENT_ALIGN);
|
|
|
|
__init_begin = .;
|
|
|
|
__inittext_begin = .;
|
|
|
|
|
|
|
|
INIT_TEXT_SECTION(PAGE_SIZE)
|
|
|
|
.exit.text : {
|
|
|
|
EXIT_TEXT
|
|
|
|
}
|
|
|
|
|
|
|
|
. = ALIGN(PECOFF_SEGMENT_ALIGN);
|
|
|
|
__inittext_end = .;
|
|
|
|
|
|
|
|
__initdata_begin = .;
|
|
|
|
|
|
|
|
INIT_DATA_SECTION(16)
|
|
|
|
.exit.data : {
|
|
|
|
EXIT_DATA
|
|
|
|
}
|
|
|
|
|
2022-05-31 18:04:12 +08:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
PERCPU_SECTION(1 << CONFIG_L1_CACHE_SHIFT)
|
|
|
|
#endif
|
|
|
|
|
2022-08-24 23:31:10 +08:00
|
|
|
.rela.dyn : ALIGN(8) { *(.rela.dyn) *(.rela*) }
|
|
|
|
|
2022-05-31 18:04:11 +08:00
|
|
|
.init.bss : {
|
|
|
|
*(.init.bss)
|
|
|
|
}
|
|
|
|
. = ALIGN(PECOFF_SEGMENT_ALIGN);
|
|
|
|
__initdata_end = .;
|
|
|
|
|
|
|
|
__init_end = .;
|
|
|
|
|
|
|
|
_sdata = .;
|
|
|
|
RO_DATA(4096)
|
|
|
|
RW_DATA(1 << CONFIG_L1_CACHE_SHIFT, PAGE_SIZE, THREAD_SIZE)
|
|
|
|
|
|
|
|
.sdata : {
|
|
|
|
*(.sdata)
|
|
|
|
}
|
|
|
|
.edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGN); }
|
|
|
|
_edata = .;
|
|
|
|
|
|
|
|
BSS_SECTION(0, SZ_64K, 8)
|
|
|
|
. = ALIGN(PECOFF_SEGMENT_ALIGN);
|
|
|
|
|
|
|
|
_end = .;
|
|
|
|
|
|
|
|
STABS_DEBUG
|
|
|
|
DWARF_DEBUG
|
2022-06-13 18:54:12 +08:00
|
|
|
ELF_DETAILS
|
2022-05-31 18:04:11 +08:00
|
|
|
|
|
|
|
.gptab.sdata : {
|
|
|
|
*(.gptab.data)
|
|
|
|
*(.gptab.sdata)
|
|
|
|
}
|
|
|
|
.gptab.sbss : {
|
|
|
|
*(.gptab.bss)
|
|
|
|
*(.gptab.sbss)
|
|
|
|
}
|
|
|
|
|
|
|
|
DISCARDS
|
|
|
|
/DISCARD/ : {
|
|
|
|
*(.gnu.attributes)
|
|
|
|
*(.options)
|
|
|
|
*(.eh_frame)
|
|
|
|
}
|
|
|
|
}
|