2008-01-30 19:32:30 +07:00
|
|
|
#
|
|
|
|
# linux/arch/x86/boot/compressed/Makefile
|
|
|
|
#
|
|
|
|
# create a compressed vmlinux image from the original vmlinux
|
|
|
|
#
|
2014-10-31 23:22:04 +07:00
|
|
|
# vmlinuz is:
|
|
|
|
# decompression code (*.o)
|
|
|
|
# asm globals (piggy.S), including:
|
|
|
|
# vmlinux.bin.(gz|bz2|lzma|...)
|
|
|
|
#
|
|
|
|
# vmlinux.bin is:
|
|
|
|
# vmlinux stripped of debugging and comments
|
|
|
|
# vmlinux.bin.all is:
|
|
|
|
# vmlinux.bin + vmlinux.relocs
|
|
|
|
# vmlinux.bin.(gz|bz2|lzma|...) is:
|
|
|
|
# (see scripts/Makefile.lib size_append)
|
|
|
|
# compressed vmlinux.bin.all + u32 size of vmlinux.bin.all
|
2008-01-30 19:32:30 +07:00
|
|
|
|
2015-02-14 05:39:25 +07:00
|
|
|
KASAN_SANITIZE := n
|
|
|
|
|
2013-07-09 06:01:48 +07:00
|
|
|
targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
|
|
|
|
vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
|
2008-01-30 19:32:30 +07:00
|
|
|
|
|
|
|
KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
|
|
|
|
KBUILD_CFLAGS += -fno-strict-aliasing -fPIC
|
2009-04-02 07:35:00 +07:00
|
|
|
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
|
2009-12-26 06:40:38 +07:00
|
|
|
cflags-$(CONFIG_X86_32) := -march=i386
|
2008-01-30 19:32:30 +07:00
|
|
|
cflags-$(CONFIG_X86_64) := -mcmodel=small
|
|
|
|
KBUILD_CFLAGS += $(cflags-y)
|
x86, build: Pass in additional -mno-mmx, -mno-sse options
In checkin
5551a34e5aea x86-64, build: Always pass in -mno-sse
we unconditionally added -mno-sse to the main build, to keep newer
compilers from generating SSE instructions from autovectorization.
However, this did not extend to the special environments
(arch/x86/boot, arch/x86/boot/compressed, and arch/x86/realmode/rm).
Add -mno-sse to the compiler command line for these environments, and
add -mno-mmx to all the environments as well, as we don't want a
compiler to generate MMX code either.
This patch also removes a $(cc-option) call for -m32, since we have
long since stopped supporting compilers too old for the -m32 option,
and in fact hardcode it in other places in the Makefiles.
Reported-by: Kevin B. Smith <kevin.b.smith@intel.com>
Cc: Sunil K. Pandey <sunil.k.pandey@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: H. J. Lu <hjl.tools@gmail.com>
Link: http://lkml.kernel.org/n/tip-j21wzqv790q834n7yc6g80j1@git.kernel.org
Cc: <stable@vger.kernel.org> # build fix only
2013-12-10 06:43:38 +07:00
|
|
|
KBUILD_CFLAGS += -mno-mmx -mno-sse
|
2008-01-30 19:32:30 +07:00
|
|
|
KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
|
|
|
|
KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
|
|
|
|
|
|
|
|
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
|
2009-06-18 06:28:09 +07:00
|
|
|
GCOV_PROFILE := n
|
2008-01-30 19:32:30 +07:00
|
|
|
|
|
|
|
LDFLAGS := -m elf_$(UTS_MACHINE)
|
|
|
|
LDFLAGS_vmlinux := -T
|
|
|
|
|
2009-05-09 07:42:16 +07:00
|
|
|
hostprogs-y := mkpiggy
|
2012-02-28 20:37:22 +07:00
|
|
|
HOST_EXTRACFLAGS += -I$(srctree)/tools/include
|
2009-05-09 07:42:16 +07:00
|
|
|
|
2014-03-11 03:03:10 +07:00
|
|
|
vmlinux-objs-y := $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \
|
2014-03-11 03:26:10 +07:00
|
|
|
$(obj)/string.o $(obj)/cmdline.o \
|
2014-03-11 03:11:26 +07:00
|
|
|
$(obj)/piggy.o $(obj)/cpuflags.o
|
|
|
|
|
2014-03-11 03:26:10 +07:00
|
|
|
vmlinux-objs-$(CONFIG_EARLY_PRINTK) += $(obj)/early_serial_console.o
|
2014-03-11 03:11:26 +07:00
|
|
|
vmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/aslr.o
|
x86, efi: EFI boot stub support
There is currently a large divide between kernel development and the
development of EFI boot loaders. The idea behind this patch is to give
the kernel developers full control over the EFI boot process. As
H. Peter Anvin put it,
"The 'kernel carries its own stub' approach been very successful in
dealing with BIOS, and would make a lot of sense to me for EFI as
well."
This patch introduces an EFI boot stub that allows an x86 bzImage to
be loaded and executed by EFI firmware. The bzImage appears to the
firmware as an EFI application. Luckily there are enough free bits
within the bzImage header so that it can masquerade as an EFI
application, thereby coercing the EFI firmware into loading it and
jumping to its entry point. The beauty of this masquerading approach
is that both BIOS and EFI boot loaders can still load and run the same
bzImage, thereby allowing a single kernel image to work in any boot
environment.
The EFI boot stub supports multiple initrds, but they must exist on
the same partition as the bzImage. Command-line arguments for the
kernel can be appended after the bzImage name when run from the EFI
shell, e.g.
Shell> bzImage console=ttyS0 root=/dev/sdb initrd=initrd.img
v7:
- Fix checkpatch warnings.
v6:
- Try to allocate initrd memory just below hdr->inird_addr_max.
v5:
- load_options_size is UTF-16, which needs dividing by 2 to convert
to the corresponding ASCII size.
v4:
- Don't read more than image->load_options_size
v3:
- Fix following warnings when compiling CONFIG_EFI_STUB=n
arch/x86/boot/tools/build.c: In function ‘main’:
arch/x86/boot/tools/build.c:138:24: warning: unused variable ‘pe_header’
arch/x86/boot/tools/build.c:138:15: warning: unused variable ‘file_sz’
- As reported by Matthew Garrett, some Apple machines have GOPs that
don't have hardware attached. We need to weed these out by
searching for ones that handle the PCIIO protocol.
- Don't allocate memory if no initrds are on cmdline
- Don't trust image->load_options_size
Maarten Lankhorst noted:
- Don't strip first argument when booted from efibootmgr
- Don't allocate too much memory for cmdline
- Don't update cmdline_size, the kernel considers it read-only
- Don't accept '\n' for initrd names
v2:
- File alignment was too large, was 8192 should be 512. Reported by
Maarten Lankhorst on LKML.
- Added UGA support for graphics
- Use VIDEO_TYPE_EFI instead of hard-coded number.
- Move linelength assignment until after we've assigned depth
- Dynamically fill out AddressOfEntryPoint in tools/build.c
- Don't use magic number for GDT/TSS stuff. Requested by Andi Kleen
- The bzImage may need to be relocated as it may have been loaded at
a high address address by the firmware. This was required to get my
macbook booting because the firmware loaded it at 0x7cxxxxxx, which
triggers this error in decompress_kernel(),
if (heap > ((-__PAGE_OFFSET-(128<<20)-1) & 0x7fffffff))
error("Destination address too large");
Cc: Mike Waychison <mikew@google.com>
Cc: Matthew Garrett <mjg@redhat.com>
Tested-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Link: http://lkml.kernel.org/r/1321383097.2657.9.camel@mfleming-mobl1.ger.corp.intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2011-12-13 04:27:52 +07:00
|
|
|
|
2012-07-27 05:00:00 +07:00
|
|
|
$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone
|
|
|
|
|
2014-11-05 23:00:56 +07:00
|
|
|
vmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o \
|
|
|
|
$(objtree)/drivers/firmware/efi/libstub/lib.a
|
x86/efi: Avoid triple faults during EFI mixed mode calls
Andy pointed out that if an NMI or MCE is received while we're in the
middle of an EFI mixed mode call a triple fault will occur. This can
happen, for example, when issuing an EFI mixed mode call while running
perf.
The reason for the triple fault is that we execute the mixed mode call
in 32-bit mode with paging disabled but with 64-bit kernel IDT handlers
installed throughout the call.
At Andy's suggestion, stop playing the games we currently do at runtime,
such as disabling paging and installing a 32-bit GDT for __KERNEL_CS. We
can simply switch to the __KERNEL32_CS descriptor before invoking
firmware services, and run in compatibility mode. This way, if an
NMI/MCE does occur the kernel IDT handler will execute correctly, since
it'll jump to __KERNEL_CS automatically.
However, this change is only possible post-ExitBootServices(). Before
then the firmware "owns" the machine and expects for its 32-bit IDT
handlers to be left intact to service interrupts, etc.
So, we now need to distinguish between early boot and runtime
invocations of EFI services. During early boot, we need to restore the
GDT that the firmware expects to be present. We can only jump to the
__KERNEL32_CS code segment for mixed mode calls after ExitBootServices()
has been invoked.
A liberal sprinkling of comments in the thunking code should make the
differences in early and late environments more apparent.
Reported-by: Andy Lutomirski <luto@amacapital.net>
Tested-by: Borislav Petkov <bp@suse.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2015-01-13 22:25:00 +07:00
|
|
|
vmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_thunk_$(BITS).o
|
x86, efi: EFI boot stub support
There is currently a large divide between kernel development and the
development of EFI boot loaders. The idea behind this patch is to give
the kernel developers full control over the EFI boot process. As
H. Peter Anvin put it,
"The 'kernel carries its own stub' approach been very successful in
dealing with BIOS, and would make a lot of sense to me for EFI as
well."
This patch introduces an EFI boot stub that allows an x86 bzImage to
be loaded and executed by EFI firmware. The bzImage appears to the
firmware as an EFI application. Luckily there are enough free bits
within the bzImage header so that it can masquerade as an EFI
application, thereby coercing the EFI firmware into loading it and
jumping to its entry point. The beauty of this masquerading approach
is that both BIOS and EFI boot loaders can still load and run the same
bzImage, thereby allowing a single kernel image to work in any boot
environment.
The EFI boot stub supports multiple initrds, but they must exist on
the same partition as the bzImage. Command-line arguments for the
kernel can be appended after the bzImage name when run from the EFI
shell, e.g.
Shell> bzImage console=ttyS0 root=/dev/sdb initrd=initrd.img
v7:
- Fix checkpatch warnings.
v6:
- Try to allocate initrd memory just below hdr->inird_addr_max.
v5:
- load_options_size is UTF-16, which needs dividing by 2 to convert
to the corresponding ASCII size.
v4:
- Don't read more than image->load_options_size
v3:
- Fix following warnings when compiling CONFIG_EFI_STUB=n
arch/x86/boot/tools/build.c: In function ‘main’:
arch/x86/boot/tools/build.c:138:24: warning: unused variable ‘pe_header’
arch/x86/boot/tools/build.c:138:15: warning: unused variable ‘file_sz’
- As reported by Matthew Garrett, some Apple machines have GOPs that
don't have hardware attached. We need to weed these out by
searching for ones that handle the PCIIO protocol.
- Don't allocate memory if no initrds are on cmdline
- Don't trust image->load_options_size
Maarten Lankhorst noted:
- Don't strip first argument when booted from efibootmgr
- Don't allocate too much memory for cmdline
- Don't update cmdline_size, the kernel considers it read-only
- Don't accept '\n' for initrd names
v2:
- File alignment was too large, was 8192 should be 512. Reported by
Maarten Lankhorst on LKML.
- Added UGA support for graphics
- Use VIDEO_TYPE_EFI instead of hard-coded number.
- Move linelength assignment until after we've assigned depth
- Dynamically fill out AddressOfEntryPoint in tools/build.c
- Don't use magic number for GDT/TSS stuff. Requested by Andi Kleen
- The bzImage may need to be relocated as it may have been loaded at
a high address address by the firmware. This was required to get my
macbook booting because the firmware loaded it at 0x7cxxxxxx, which
triggers this error in decompress_kernel(),
if (heap > ((-__PAGE_OFFSET-(128<<20)-1) & 0x7fffffff))
error("Destination address too large");
Cc: Mike Waychison <mikew@google.com>
Cc: Matthew Garrett <mjg@redhat.com>
Tested-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Link: http://lkml.kernel.org/r/1321383097.2657.9.camel@mfleming-mobl1.ger.corp.intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2011-12-13 04:27:52 +07:00
|
|
|
|
2014-03-11 03:03:10 +07:00
|
|
|
$(obj)/vmlinux: $(vmlinux-objs-y) FORCE
|
2008-01-30 19:32:30 +07:00
|
|
|
$(call if_changed,ld)
|
|
|
|
@:
|
|
|
|
|
2008-02-14 03:54:58 +07:00
|
|
|
OBJCOPYFLAGS_vmlinux.bin := -R .comment -S
|
2008-01-30 19:32:30 +07:00
|
|
|
$(obj)/vmlinux.bin: vmlinux FORCE
|
|
|
|
$(call if_changed,objcopy)
|
|
|
|
|
2014-03-11 03:03:10 +07:00
|
|
|
targets += $(patsubst $(obj)/%,%,$(vmlinux-objs-y)) vmlinux.bin.all vmlinux.relocs
|
2008-01-30 19:32:30 +07:00
|
|
|
|
2012-05-09 01:22:24 +07:00
|
|
|
CMD_RELOCS = arch/x86/tools/relocs
|
2008-01-30 19:32:30 +07:00
|
|
|
quiet_cmd_relocs = RELOCS $@
|
2012-05-09 01:22:24 +07:00
|
|
|
cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
|
|
|
|
$(obj)/vmlinux.relocs: vmlinux FORCE
|
2008-01-30 19:32:30 +07:00
|
|
|
$(call if_changed,relocs)
|
|
|
|
|
|
|
|
vmlinux.bin.all-y := $(obj)/vmlinux.bin
|
2009-05-06 12:53:11 +07:00
|
|
|
vmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs
|
2008-01-30 19:32:30 +07:00
|
|
|
|
2009-05-06 12:53:11 +07:00
|
|
|
$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE
|
2008-01-30 19:32:30 +07:00
|
|
|
$(call if_changed,gzip)
|
2009-05-06 12:53:11 +07:00
|
|
|
$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
|
2009-01-05 04:46:17 +07:00
|
|
|
$(call if_changed,bzip2)
|
2009-05-06 12:53:11 +07:00
|
|
|
$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
|
2009-01-05 04:46:17 +07:00
|
|
|
$(call if_changed,lzma)
|
2011-01-13 08:01:24 +07:00
|
|
|
$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
|
|
|
|
$(call if_changed,xzkern)
|
2010-01-09 05:42:45 +07:00
|
|
|
$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
|
|
|
|
$(call if_changed,lzo)
|
2013-07-09 06:01:48 +07:00
|
|
|
$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE
|
|
|
|
$(call if_changed,lz4)
|
2008-01-30 19:32:30 +07:00
|
|
|
|
2009-05-09 05:32:47 +07:00
|
|
|
suffix-$(CONFIG_KERNEL_GZIP) := gz
|
|
|
|
suffix-$(CONFIG_KERNEL_BZIP2) := bz2
|
|
|
|
suffix-$(CONFIG_KERNEL_LZMA) := lzma
|
2011-01-13 08:01:24 +07:00
|
|
|
suffix-$(CONFIG_KERNEL_XZ) := xz
|
2010-01-09 05:42:45 +07:00
|
|
|
suffix-$(CONFIG_KERNEL_LZO) := lzo
|
2013-07-09 06:01:48 +07:00
|
|
|
suffix-$(CONFIG_KERNEL_LZ4) := lz4
|
2009-01-05 04:46:17 +07:00
|
|
|
|
2014-11-22 16:51:10 +07:00
|
|
|
RUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \
|
2015-01-27 03:58:35 +07:00
|
|
|
$(CONFIG_SHELL) $(srctree)/arch/x86/tools/calc_run_size.sh)
|
2009-05-09 07:42:16 +07:00
|
|
|
quiet_cmd_mkpiggy = MKPIGGY $@
|
2014-10-31 20:40:38 +07:00
|
|
|
cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false )
|
2009-05-09 07:42:16 +07:00
|
|
|
|
|
|
|
targets += piggy.S
|
|
|
|
$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE
|
|
|
|
$(call if_changed,mkpiggy)
|