mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-13 16:14:26 +08:00
270315b823
This contains a handful of cleanups and new features, including: * A handful of cleanups for our page fault handling. * Improvements to how we fill out cacheinfo. * Support for EFI-based systems. --- This contains a merge from the EFI tree that was necessary as some of the EFI support landed over there. It's my first time doing something like this, I haven't included the set_fs stuff because the base branch it depends on hasn't been merged yet. I'll probably have another merge window PR, as there's more in flight (most notably the fix for new binutils I just sent out), but I figured there was no reason to delay this any longer. -----BEGIN PGP SIGNATURE----- iQJHBAABCgAxFiEEKzw3R0RoQ7JKlDp6LhMZ81+7GIkFAl+KQ6gTHHBhbG1lckBk YWJiZWx0LmNvbQAKCRAuExnzX7sYibmwD/4qWfOW7R/kUWi08ethcaAhNEWLvqIh 2/KjGLORw+NTZ1F4pEFyQG5LRd3yWDT/UXh/k8gXINqmdclNV01Z3T+O7WuRlISs 07i26W1qRpNeJ7lDVhr9foKpeOU/AXvidgoF330nGlyO4HZkYKhK2yB3t8uGWywr Zt/EpMJeBIRKzWiLhOgLAdYJthhZ9AlnouNnr9myHnO5Ksel+AZ/BKYvn7ZbHMns 6vFUxp6392/LERRRIfDqPsTuxPIYMHjuEsGSESLsjAIyq/shgN1knG/C+zwU5DcK zUDBt1DEP7Tb45w7VBASSjn1M+cUolz9/c2dBhlVcdBlk1GKF+KILSTmWUBpQ8oP ETVAuQK5HTcjy9bVcJMj0Oa3mFshVAAByOH+Wyrdo+qSLkb7y3spPvsL4dyjrKjL +pe6C7WvavaEFoQXVWO2sTUBGYt7qDLRdrDgOGBIHylTXhTxf2wYzAF4ZmDROECT Qfc7Ac3aIWYvWDmxE+x8OniuclfZ0DndKLKQj6FJWUTIxFZzTxsHK75d47D1ID0S ZwAmUd0eYjjwMTO/6AM/Aqu3o8IP4GOXjJf4ijxH9+LjpUhm/ibmHDAUY69sU1WX kdX51gQzoEuW7XMVz1HoTSvaGGKtyFDuRxs8RG/tSFaRtznRz0Sro6BpLCeG968n k/d5WL/vZZ/NDA== =FYs/ -----END PGP SIGNATURE----- Merge tag 'riscv-for-linus-5.10-mw0' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux Pull RISC-V updates from Palmer Dabbelt: "A handful of cleanups and new features: - A handful of cleanups for our page fault handling - Improvements to how we fill out cacheinfo - Support for EFI-based systems" * tag 'riscv-for-linus-5.10-mw0' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: (22 commits) RISC-V: Add page table dump support for uefi RISC-V: Add EFI runtime services RISC-V: Add EFI stub support. RISC-V: Add PE/COFF header for EFI stub RISC-V: Implement late mapping page table allocation functions RISC-V: Add early ioremap support RISC-V: Move DT mapping outof fixmap RISC-V: Fix duplicate included thread_info.h riscv/mm/fault: Set FAULT_FLAG_INSTRUCTION flag in do_page_fault() riscv/mm/fault: Fix inline placement in vmalloc_fault() declaration riscv: Add cache information in AUX vector riscv: Define AT_VECTOR_SIZE_ARCH for ARCH_DLINFO riscv: Set more data to cacheinfo riscv/mm/fault: Move access error check to function riscv/mm/fault: Move FAULT_FLAG_WRITE handling in do_page_fault() riscv/mm/fault: Simplify mm_fault_error() riscv/mm/fault: Move fault error handling to mm_fault_error() riscv/mm/fault: Simplify fault error handling riscv/mm/fault: Move vmalloc fault handling to vmalloc_fault() riscv/mm/fault: Move bad area handling to bad_area() ...
142 lines
5.7 KiB
Makefile
142 lines
5.7 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# The stub may be linked into the kernel proper or into a separate boot binary,
|
|
# but in either case, it executes before the kernel does (with MMU disabled) so
|
|
# things like ftrace and stack-protector are likely to cause trouble if left
|
|
# enabled, even if doing so doesn't break the build.
|
|
#
|
|
cflags-$(CONFIG_X86_32) := -march=i386
|
|
cflags-$(CONFIG_X86_64) := -mcmodel=small
|
|
cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ \
|
|
-fPIC -fno-strict-aliasing -mno-red-zone \
|
|
-mno-mmx -mno-sse -fshort-wchar \
|
|
-Wno-pointer-sign \
|
|
$(call cc-disable-warning, address-of-packed-member) \
|
|
$(call cc-disable-warning, gnu) \
|
|
-fno-asynchronous-unwind-tables
|
|
|
|
# arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly
|
|
# disable the stackleak plugin
|
|
cflags-$(CONFIG_ARM64) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
|
|
-fpie $(DISABLE_STACKLEAK_PLUGIN) \
|
|
$(call cc-option,-mbranch-protection=none)
|
|
cflags-$(CONFIG_ARM) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
|
|
-fno-builtin -fpic \
|
|
$(call cc-option,-mno-single-pic-base)
|
|
cflags-$(CONFIG_RISCV) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
|
|
-fpic
|
|
|
|
cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt
|
|
|
|
KBUILD_CFLAGS := $(cflags-y) -Os -DDISABLE_BRANCH_PROFILING \
|
|
-include $(srctree)/include/linux/hidden.h \
|
|
-D__NO_FORTIFY \
|
|
-ffreestanding \
|
|
-fno-stack-protector \
|
|
$(call cc-option,-fno-addrsig) \
|
|
-D__DISABLE_EXPORTS
|
|
|
|
# remove SCS flags from all objects in this directory
|
|
KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS))
|
|
|
|
GCOV_PROFILE := n
|
|
# Sanitizer runtimes are unavailable and cannot be linked here.
|
|
KASAN_SANITIZE := n
|
|
KCSAN_SANITIZE := n
|
|
UBSAN_SANITIZE := n
|
|
OBJECT_FILES_NON_STANDARD := y
|
|
|
|
# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
|
|
KCOV_INSTRUMENT := n
|
|
|
|
lib-y := efi-stub-helper.o gop.o secureboot.o tpm.o \
|
|
file.o mem.o random.o randomalloc.o pci.o \
|
|
skip_spaces.o lib-cmdline.o lib-ctype.o \
|
|
alignedmem.o relocate.o vsprintf.o
|
|
|
|
# include the stub's generic dependencies from lib/ when building for ARM/arm64
|
|
efi-deps-y := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c fdt_empty_tree.c fdt_sw.c
|
|
|
|
$(obj)/lib-%.o: $(srctree)/lib/%.c FORCE
|
|
$(call if_changed_rule,cc_o_c)
|
|
|
|
lib-$(CONFIG_EFI_GENERIC_STUB) += efi-stub.o fdt.o string.o \
|
|
$(patsubst %.c,lib-%.o,$(efi-deps-y))
|
|
|
|
lib-$(CONFIG_ARM) += arm32-stub.o
|
|
lib-$(CONFIG_ARM64) += arm64-stub.o
|
|
lib-$(CONFIG_X86) += x86-stub.o
|
|
lib-$(CONFIG_RISCV) += riscv-stub.o
|
|
CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
|
|
|
|
# Even when -mbranch-protection=none is set, Clang will generate a
|
|
# .note.gnu.property for code-less object files (like lib/ctype.c),
|
|
# so work around this by explicitly removing the unwanted section.
|
|
# https://bugs.llvm.org/show_bug.cgi?id=46480
|
|
STUBCOPY_FLAGS-y += --remove-section=.note.gnu.property
|
|
|
|
#
|
|
# For x86, bootloaders like systemd-boot or grub-efi do not zero-initialize the
|
|
# .bss section, so the .bss section of the EFI stub needs to be included in the
|
|
# .data section of the compressed kernel to ensure initialization. Rename the
|
|
# .bss section here so it's easy to pick out in the linker script.
|
|
#
|
|
STUBCOPY_FLAGS-$(CONFIG_X86) += --rename-section .bss=.bss.efistub,load,alloc
|
|
STUBCOPY_RELOC-$(CONFIG_X86_32) := R_386_32
|
|
STUBCOPY_RELOC-$(CONFIG_X86_64) := R_X86_64_64
|
|
|
|
#
|
|
# ARM discards the .data section because it disallows r/w data in the
|
|
# decompressor. So move our .data to .data.efistub and .bss to .bss.efistub,
|
|
# which are preserved explicitly by the decompressor linker script.
|
|
#
|
|
STUBCOPY_FLAGS-$(CONFIG_ARM) += --rename-section .data=.data.efistub \
|
|
--rename-section .bss=.bss.efistub,load,alloc
|
|
STUBCOPY_RELOC-$(CONFIG_ARM) := R_ARM_ABS
|
|
|
|
#
|
|
# arm64 puts the stub in the kernel proper, which will unnecessarily retain all
|
|
# code indefinitely unless it is annotated as __init/__initdata/__initconst etc.
|
|
# So let's apply the __init annotations at the section level, by prefixing
|
|
# the section names directly. This will ensure that even all the inline string
|
|
# literals are covered.
|
|
# The fact that the stub and the kernel proper are essentially the same binary
|
|
# also means that we need to be extra careful to make sure that the stub does
|
|
# not rely on any absolute symbol references, considering that the virtual
|
|
# kernel mapping that the linker uses is not active yet when the stub is
|
|
# executing. So build all C dependencies of the EFI stub into libstub, and do
|
|
# a verification pass to see if any absolute relocations exist in any of the
|
|
# object files.
|
|
#
|
|
extra-y := $(lib-y)
|
|
lib-y := $(patsubst %.o,%.stub.o,$(lib-y))
|
|
|
|
STUBCOPY_FLAGS-$(CONFIG_ARM64) += --prefix-alloc-sections=.init \
|
|
--prefix-symbols=__efistub_
|
|
STUBCOPY_RELOC-$(CONFIG_ARM64) := R_AARCH64_ABS
|
|
|
|
# For RISC-V, we don't need anything special other than arm64. Keep all the
|
|
# symbols in .init section and make sure that no absolute symbols references
|
|
# doesn't exist.
|
|
STUBCOPY_FLAGS-$(CONFIG_RISCV) += --prefix-alloc-sections=.init \
|
|
--prefix-symbols=__efistub_
|
|
STUBCOPY_RELOC-$(CONFIG_RISCV) := R_RISCV_HI20
|
|
|
|
$(obj)/%.stub.o: $(obj)/%.o FORCE
|
|
$(call if_changed,stubcopy)
|
|
|
|
#
|
|
# Strip debug sections and some other sections that may legally contain
|
|
# absolute relocations, so that we can inspect the remaining sections for
|
|
# such relocations. If none are found, regenerate the output object, but
|
|
# this time, use objcopy and leave all sections in place.
|
|
#
|
|
quiet_cmd_stubcopy = STUBCPY $@
|
|
cmd_stubcopy = \
|
|
$(STRIP) --strip-debug -o $@ $<; \
|
|
if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); then \
|
|
echo "$@: absolute symbol references not allowed in the EFI stub" >&2; \
|
|
/bin/false; \
|
|
fi; \
|
|
$(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@
|