2022-05-31 03:04:11 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#include <linux/sizes.h>
|
|
|
|
#include <asm/asm-offsets.h>
|
|
|
|
#include <asm/thread_info.h>
|
2024-03-11 07:23:47 -07:00
|
|
|
#include <asm/orc_lookup.h>
|
2022-05-31 03:04:11 -07:00
|
|
|
|
|
|
|
#define PAGE_SIZE _PAGE_SIZE
|
2022-12-10 07:39:59 -07:00
|
|
|
#define RO_EXCEPTION_TABLE_ALIGN 4
|
2024-06-03 00:45:53 -07:00
|
|
|
#define PHYSADDR_MASK 0xffffffffffff /* 48-bit */
|
2022-05-31 03:04:11 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 03:20:37 -07:00
|
|
|
#include "image-vars.h"
|
2022-05-31 03:04:11 -07: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 01:55:41 -07:00
|
|
|
_stext = .;
|
2022-05-31 03:04:11 -07:00
|
|
|
.text : {
|
|
|
|
TEXT_TEXT
|
|
|
|
SCHED_TEXT
|
|
|
|
LOCK_TEXT
|
|
|
|
KPROBES_TEXT
|
|
|
|
IRQENTRY_TEXT
|
|
|
|
SOFTIRQENTRY_TEXT
|
|
|
|
*(.fixup)
|
|
|
|
*(.gnu.warning)
|
|
|
|
} :text = 0
|
|
|
|
. = ALIGN(PECOFF_SEGMENT_ALIGN);
|
|
|
|
_etext = .;
|
|
|
|
|
|
|
|
. = 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 = .;
|
|
|
|
|
2023-09-19 23:26:28 -07:00
|
|
|
/*
|
|
|
|
* struct alt_inst entries. From the header (alternative.h):
|
|
|
|
* "Alternative instructions for different CPU types or capabilities"
|
|
|
|
* Think locking instructions on spinlocks.
|
|
|
|
*/
|
|
|
|
. = ALIGN(4);
|
|
|
|
.altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
|
|
|
|
__alt_instructions = .;
|
|
|
|
*(.altinstructions)
|
|
|
|
__alt_instructions_end = .;
|
|
|
|
}
|
|
|
|
|
2022-05-31 03:04:11 -07:00
|
|
|
INIT_DATA_SECTION(16)
|
|
|
|
.exit.data : {
|
|
|
|
EXIT_DATA
|
|
|
|
}
|
|
|
|
|
2022-05-31 03:04:12 -07:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
PERCPU_SECTION(1 << CONFIG_L1_CACHE_SHIFT)
|
|
|
|
#endif
|
|
|
|
|
2022-05-31 03:04:11 -07:00
|
|
|
.init.bss : {
|
|
|
|
*(.init.bss)
|
|
|
|
}
|
|
|
|
. = ALIGN(PECOFF_SEGMENT_ALIGN);
|
|
|
|
__initdata_end = .;
|
|
|
|
|
|
|
|
__init_end = .;
|
|
|
|
|
|
|
|
_sdata = .;
|
|
|
|
RO_DATA(4096)
|
2023-09-19 23:26:28 -07:00
|
|
|
|
|
|
|
.got : ALIGN(16) { *(.got) }
|
|
|
|
.plt : ALIGN(16) { *(.plt) }
|
|
|
|
.got.plt : ALIGN(16) { *(.got.plt) }
|
|
|
|
|
2022-05-31 03:04:11 -07:00
|
|
|
RW_DATA(1 << CONFIG_L1_CACHE_SHIFT, PAGE_SIZE, THREAD_SIZE)
|
|
|
|
|
2023-02-25 00:52:56 -07:00
|
|
|
.rela.dyn : ALIGN(8) {
|
|
|
|
__rela_dyn_begin = .;
|
|
|
|
*(.rela.dyn) *(.rela*)
|
|
|
|
__rela_dyn_end = .;
|
|
|
|
}
|
|
|
|
|
2024-07-20 07:41:07 -07:00
|
|
|
#ifdef CONFIG_RELR
|
|
|
|
.relr.dyn : ALIGN(8) {
|
|
|
|
__relr_dyn_begin = .;
|
|
|
|
*(.relr.dyn)
|
|
|
|
__relr_dyn_end = .;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-09-19 23:26:28 -07:00
|
|
|
.data.rel : { *(.data.rel*) }
|
|
|
|
|
|
|
|
#ifdef CONFIG_RELOCATABLE
|
|
|
|
. = ALIGN(8);
|
|
|
|
.la_abs : AT(ADDR(.la_abs) - LOAD_OFFSET) {
|
|
|
|
__la_abs_begin = .;
|
|
|
|
*(.la_abs)
|
|
|
|
__la_abs_end = .;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-03-11 07:23:47 -07:00
|
|
|
ORC_UNWIND_TABLE
|
|
|
|
|
2022-05-31 03:04:11 -07:00
|
|
|
.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 03:54:12 -07:00
|
|
|
ELF_DETAILS
|
2022-05-31 03:04:11 -07:00
|
|
|
|
2023-06-29 05:58:42 -07:00
|
|
|
#ifdef CONFIG_EFI_STUB
|
|
|
|
/* header symbols */
|
2024-06-03 00:45:53 -07:00
|
|
|
_kernel_entry = ABSOLUTE(kernel_entry & PHYSADDR_MASK);
|
|
|
|
_kernel_asize = ABSOLUTE(_end - _text);
|
|
|
|
_kernel_fsize = ABSOLUTE(_edata - _text);
|
|
|
|
_kernel_vsize = ABSOLUTE(_end - __initdata_begin);
|
|
|
|
_kernel_rsize = ABSOLUTE(_edata - __initdata_begin);
|
2023-06-29 05:58:42 -07:00
|
|
|
#endif
|
|
|
|
|
2022-05-31 03:04:11 -07:00
|
|
|
.gptab.sdata : {
|
|
|
|
*(.gptab.data)
|
|
|
|
*(.gptab.sdata)
|
|
|
|
}
|
|
|
|
.gptab.sbss : {
|
|
|
|
*(.gptab.bss)
|
|
|
|
*(.gptab.sbss)
|
|
|
|
}
|
|
|
|
|
|
|
|
DISCARDS
|
|
|
|
/DISCARD/ : {
|
2023-02-25 00:52:56 -07:00
|
|
|
*(.dynamic .dynsym .dynstr .hash .gnu.hash)
|
2022-05-31 03:04:11 -07:00
|
|
|
*(.gnu.attributes)
|
|
|
|
*(.options)
|
|
|
|
*(.eh_frame)
|
|
|
|
}
|
|
|
|
}
|