hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/arch/x86/boot/compressed/Makefile
....@@ -17,49 +17,62 @@
1717 # (see scripts/Makefile.lib size_append)
1818 # compressed vmlinux.bin.all + u32 size of vmlinux.bin.all
1919
20
+# Sanitizer runtimes are unavailable and cannot be linked for early boot code.
2021 KASAN_SANITIZE := n
22
+KCSAN_SANITIZE := n
2123 OBJECT_FILES_NON_STANDARD := y
2224
2325 # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
2426 KCOV_INSTRUMENT := n
2527
2628 targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
27
- vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
29
+ vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4 vmlinux.bin.zst
2830
29
-KBUILD_CFLAGS := -m$(BITS) -O2
30
-KBUILD_CFLAGS += -fno-strict-aliasing $(call cc-option, -fPIE, -fPIC)
31
+# CLANG_FLAGS must come before any cc-disable-warning or cc-option calls in
32
+# case of cross compiling, as it has the '--target=' flag, which is needed to
33
+# avoid errors with '-march=i386', and future flags may depend on the target to
34
+# be valid.
35
+KBUILD_CFLAGS := -m$(BITS) -O2 $(CLANG_FLAGS)
36
+KBUILD_CFLAGS += -fno-strict-aliasing -fPIE
3137 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
3238 cflags-$(CONFIG_X86_32) := -march=i386
33
-cflags-$(CONFIG_X86_64) := -mcmodel=small
39
+cflags-$(CONFIG_X86_64) := -mcmodel=small -mno-red-zone
3440 KBUILD_CFLAGS += $(cflags-y)
3541 KBUILD_CFLAGS += -mno-mmx -mno-sse
36
-KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
37
-KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
42
+KBUILD_CFLAGS += -ffreestanding
43
+KBUILD_CFLAGS += -fno-stack-protector
3844 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
3945 KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
4046 KBUILD_CFLAGS += -Wno-pointer-sign
47
+KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
48
+KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
49
+KBUILD_CFLAGS += -D__DISABLE_EXPORTS
4150 # Disable relocation relaxation in case the link is not PIE.
4251 KBUILD_CFLAGS += $(call as-option,-Wa$(comma)-mrelax-relocations=no)
52
+KBUILD_CFLAGS += -include $(srctree)/include/linux/hidden.h
53
+
54
+# sev-es.c indirectly inludes inat-table.h which is generated during
55
+# compilation and stored in $(objtree). Add the directory to the includes so
56
+# that the compiler finds it even with out-of-tree builds (make O=/some/path).
57
+CFLAGS_sev-es.o += -I$(objtree)/arch/x86/lib/
4358
4459 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
4560 GCOV_PROFILE := n
4661 UBSAN_SANITIZE :=n
4762
4863 KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE)
64
+KBUILD_LDFLAGS += $(call ld-option,--no-ld-generated-unwind-info)
4965 # Compressed kernel should be built as PIE since it may be loaded at any
5066 # address by the bootloader.
51
-ifeq ($(CONFIG_X86_32),y)
52
-KBUILD_LDFLAGS += $(call ld-option, -pie) $(call ld-option, --no-dynamic-linker)
53
-else
54
-# To build 64-bit compressed kernel as PIE, we disable relocation
55
-# overflow check to avoid relocation overflow error with a new linker
56
-# command-line option, -z noreloc-overflow.
57
-KBUILD_LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \
58
- && echo "-z noreloc-overflow -pie --no-dynamic-linker")
67
+LDFLAGS_vmlinux := -pie $(call ld-option, --no-dynamic-linker)
68
+ifdef CONFIG_LD_ORPHAN_WARN
69
+LDFLAGS_vmlinux += --orphan-handling=warn
5970 endif
60
-LDFLAGS_vmlinux := -T
71
+LDFLAGS_vmlinux += -z noexecstack
72
+LDFLAGS_vmlinux += $(call ld-option,--no-warn-rwx-segments)
73
+LDFLAGS_vmlinux += -T
6174
62
-hostprogs-y := mkpiggy
75
+hostprogs := mkpiggy
6376 HOST_EXTRACFLAGS += -I$(srctree)/tools/include
6477
6578 sed-voffset := -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(_text\|__bss_start\|_end\)$$/\#define VO_\2 _AC(0x\1,UL)/p'
....@@ -74,48 +87,27 @@
7487
7588 $(obj)/misc.o: $(obj)/../voffset.h
7689
77
-vmlinux-objs-y := $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \
78
- $(obj)/string.o $(obj)/cmdline.o $(obj)/error.o \
90
+vmlinux-objs-y := $(obj)/vmlinux.lds $(obj)/kernel_info.o $(obj)/head_$(BITS).o \
91
+ $(obj)/misc.o $(obj)/string.o $(obj)/cmdline.o $(obj)/error.o \
7992 $(obj)/piggy.o $(obj)/cpuflags.o
8093
8194 vmlinux-objs-$(CONFIG_EARLY_PRINTK) += $(obj)/early_serial_console.o
8295 vmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/kaslr.o
8396 ifdef CONFIG_X86_64
84
- vmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/kaslr_64.o
97
+ vmlinux-objs-y += $(obj)/ident_map_64.o
98
+ vmlinux-objs-y += $(obj)/idt_64.o $(obj)/idt_handlers_64.o
8599 vmlinux-objs-y += $(obj)/mem_encrypt.o
86100 vmlinux-objs-y += $(obj)/pgtable_64.o
101
+ vmlinux-objs-$(CONFIG_AMD_MEM_ENCRYPT) += $(obj)/sev-es.o
87102 endif
88103
89
-$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone
104
+vmlinux-objs-$(CONFIG_ACPI) += $(obj)/acpi.o
90105
91
-vmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o \
92
- $(objtree)/drivers/firmware/efi/libstub/lib.a
93106 vmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_thunk_$(BITS).o
107
+efi-obj-$(CONFIG_EFI_STUB) = $(objtree)/drivers/firmware/efi/libstub/lib.a
94108
95
-# The compressed kernel is built with -fPIC/-fPIE so that a boot loader
96
-# can place it anywhere in memory and it will still run. However, since
97
-# it is executed as-is without any ELF relocation processing performed
98
-# (and has already had all relocation sections stripped from the binary),
99
-# none of the code can use data relocations (e.g. static assignments of
100
-# pointer values), since they will be meaningless at runtime. This check
101
-# will refuse to link the vmlinux if any of these relocations are found.
102
-quiet_cmd_check_data_rel = DATAREL $@
103
-define cmd_check_data_rel
104
- for obj in $(filter %.o,$^); do \
105
- $(READELF) -S $$obj | grep -qF .rel.local && { \
106
- echo "error: $$obj has data relocations!" >&2; \
107
- exit 1; \
108
- } || true; \
109
- done
110
-endef
111
-
112
-# We need to run two commands under "if_changed", so merge them into a
113
-# single invocation.
114
-quiet_cmd_check-and-link-vmlinux = LD $@
115
- cmd_check-and-link-vmlinux = $(cmd_check_data_rel); $(cmd_ld)
116
-
117
-$(obj)/vmlinux: $(vmlinux-objs-y) FORCE
118
- $(call if_changed,check-and-link-vmlinux)
109
+$(obj)/vmlinux: $(vmlinux-objs-y) $(efi-obj-y) FORCE
110
+ $(call if_changed,ld)
119111
120112 OBJCOPYFLAGS_vmlinux.bin := -R .comment -S
121113 $(obj)/vmlinux.bin: vmlinux FORCE
....@@ -144,6 +136,8 @@
144136 $(call if_changed,lzo)
145137 $(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE
146138 $(call if_changed,lz4)
139
+$(obj)/vmlinux.bin.zst: $(vmlinux.bin.all-y) FORCE
140
+ $(call if_changed,zstd22)
147141
148142 suffix-$(CONFIG_KERNEL_GZIP) := gz
149143 suffix-$(CONFIG_KERNEL_BZIP2) := bz2
....@@ -151,9 +145,10 @@
151145 suffix-$(CONFIG_KERNEL_XZ) := xz
152146 suffix-$(CONFIG_KERNEL_LZO) := lzo
153147 suffix-$(CONFIG_KERNEL_LZ4) := lz4
148
+suffix-$(CONFIG_KERNEL_ZSTD) := zst
154149
155150 quiet_cmd_mkpiggy = MKPIGGY $@
156
- cmd_mkpiggy = $(obj)/mkpiggy $< > $@ || ( rm -f $@ ; false )
151
+ cmd_mkpiggy = $(obj)/mkpiggy $< > $@
157152
158153 targets += piggy.S
159154 $(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE