mirror of
				git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
				synced 2025-11-01 09:13:37 +00:00 
			
		
		
		
	For historical reasons, the legacy decompressor code on various architectures supports 7 different compression types for the compressed kernel image. EFI zboot is not a compression library museum, and so the options can be limited to what is likely to be useful in practice: - GZIP is tried and tested, and is still one of the fastest at decompression time, although the compression ratio is not very high; moreover, Fedora is already shipping EFI zboot kernels for arm64 that use GZIP, and QEMU implements direct support for it when booting a kernel without firmware loaded; - ZSTD has a very high compression ratio (although not the highest), and is almost as fast as GZIP at decompression time. Reducing the number of options makes it less of a hassle for other consumers of the EFI zboot format (such as QEMU today, and kexec in the future) to support it transparently without having to carry 7 different decompression libraries. Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
		
			
				
	
	
		
			57 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
# SPDX-License-Identifier: GPL-2.0
 | 
						|
 | 
						|
# to be include'd by arch/$(ARCH)/boot/Makefile after setting
 | 
						|
# EFI_ZBOOT_PAYLOAD, EFI_ZBOOT_BFD_TARGET, EFI_ZBOOT_MACH_TYPE and
 | 
						|
# EFI_ZBOOT_FORWARD_CFI
 | 
						|
 | 
						|
quiet_cmd_copy_and_pad = PAD     $@
 | 
						|
      cmd_copy_and_pad = cp $< $@; \
 | 
						|
			 truncate -s $$(hexdump -s16 -n4 -e '"%u"' $<) $@
 | 
						|
 | 
						|
# Pad the file to the size of the uncompressed image in memory, including BSS
 | 
						|
$(obj)/vmlinux.bin: $(obj)/$(EFI_ZBOOT_PAYLOAD) FORCE
 | 
						|
	$(call if_changed,copy_and_pad)
 | 
						|
 | 
						|
# in GZIP, the appended le32 carrying the uncompressed size is part of the
 | 
						|
# format, but in other cases, we just append it at the end for convenience,
 | 
						|
# causing the original tools to complain when checking image integrity.
 | 
						|
comp-type-y				:= gzip
 | 
						|
zboot-method-y				:= gzip
 | 
						|
zboot-size-len-y			:= 0
 | 
						|
 | 
						|
comp-type-$(CONFIG_KERNEL_ZSTD)		:= zstd
 | 
						|
zboot-method-$(CONFIG_KERNEL_ZSTD)	:= zstd22_with_size
 | 
						|
zboot-size-len-$(CONFIG_KERNEL_ZSTD)	:= 4
 | 
						|
 | 
						|
$(obj)/vmlinuz: $(obj)/vmlinux.bin FORCE
 | 
						|
	$(call if_changed,$(zboot-method-y))
 | 
						|
 | 
						|
# avoid eager evaluation to prevent references to non-existent build artifacts
 | 
						|
OBJCOPYFLAGS_vmlinuz.o = -I binary -O $(EFI_ZBOOT_BFD_TARGET) $(EFI_ZBOOT_OBJCOPY_FLAGS) \
 | 
						|
			  --rename-section .data=.gzdata,load,alloc,readonly,contents
 | 
						|
$(obj)/vmlinuz.o: $(obj)/vmlinuz FORCE
 | 
						|
	$(call if_changed,objcopy)
 | 
						|
 | 
						|
aflags-zboot-header-$(EFI_ZBOOT_FORWARD_CFI) := \
 | 
						|
		-DPE_DLL_CHAR_EX=IMAGE_DLLCHARACTERISTICS_EX_FORWARD_CFI_COMPAT
 | 
						|
 | 
						|
AFLAGS_zboot-header.o += -DMACHINE_TYPE=IMAGE_FILE_MACHINE_$(EFI_ZBOOT_MACH_TYPE) \
 | 
						|
			 -DZBOOT_EFI_PATH="\"$(realpath $(obj)/vmlinuz.efi.elf)\"" \
 | 
						|
			 -DZBOOT_SIZE_LEN=$(zboot-size-len-y) \
 | 
						|
			 -DCOMP_TYPE="\"$(comp-type-y)\"" \
 | 
						|
			 $(aflags-zboot-header-y)
 | 
						|
 | 
						|
$(obj)/zboot-header.o: $(srctree)/drivers/firmware/efi/libstub/zboot-header.S FORCE
 | 
						|
	$(call if_changed_rule,as_o_S)
 | 
						|
 | 
						|
ZBOOT_DEPS := $(obj)/zboot-header.o $(objtree)/drivers/firmware/efi/libstub/lib.a
 | 
						|
 | 
						|
LDFLAGS_vmlinuz.efi.elf := -T $(srctree)/drivers/firmware/efi/libstub/zboot.lds
 | 
						|
$(obj)/vmlinuz.efi.elf: $(obj)/vmlinuz.o $(ZBOOT_DEPS) FORCE
 | 
						|
	$(call if_changed,ld)
 | 
						|
 | 
						|
OBJCOPYFLAGS_vmlinuz.efi := -O binary
 | 
						|
$(obj)/vmlinuz.efi: $(obj)/vmlinuz.efi.elf FORCE
 | 
						|
	$(call if_changed,objcopy)
 | 
						|
 | 
						|
targets += zboot-header.o vmlinux.bin vmlinuz vmlinuz.o vmlinuz.efi.elf vmlinuz.efi
 |