aboutsummaryrefslogtreecommitdiff
path: root/arch/x86/boot/compressed/misc.c
AgeCommit message (Collapse)AuthorFilesLines
2013-08-07x86, relocs: Move ELF relocation handling to CKees Cook1-1/+76
Moves the relocation handling into C, after decompression. This requires that the decompressed size is passed to the decompression routine as well so that relocations can be found. Only kernels that need relocation support will use the code (currently just x86_32), but this is laying the ground work for 64-bit using it in support of KASLR. Based on work by Neill Clift and Michael Davidson. Signed-off-by: Kees Cook <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Acked-by: Zhang Yanfei <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
2013-07-09arm: add support for LZ4-compressed kernelKyungsik Lee1-0/+4
Integrates the LZ4 decompression code to the arm pre-boot code. Signed-off-by: Kyungsik Lee <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Russell King <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Florian Fainelli <[email protected]> Cc: Yann Collet <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2013-01-29x86, boot: Sanitize boot_params if not zeroed on creationH. Peter Anvin1-0/+2
Use the new sentinel field to detect bootloaders which fail to follow protocol and don't initialize fields in struct boot_params that they do not explicitly initialize to zero. Based on an original patch and research by Yinghai Lu. Changed by hpa to be invoked both in the decompression path and in the kernel proper; the latter for the case where a bootloader takes over decompression. Originally-by: Yinghai Lu <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: H. Peter Anvin <[email protected]>
2012-07-21x86, boot: Removed unused debug flag and set codeJoe Millenbach1-4/+0
As we're no longer using the flag we don't need to extract the value from the command line and store it. This is a step towards removing command line parameter code. Signed-off-by: Joe Millenbach <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Gokul Caushik <[email protected]> Reviewed-by: Josh Triplett <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
2012-07-21x86, boot: Switch output functions from command-line flags to conditional ↵Joe Millenbach1-11/+1
compilation Changed putstr flagging from parameter to conditional compilation for puts, debug_putstr, and error_putstr. This allows for space savings since most configurations won't use this feature. Signed-off-by: Joe Millenbach <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Gokul Caushik <[email protected]> Reviewed-by: Josh Triplett <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
2012-07-21x86, boot: Changed error putstr path to match new debug_putstr formatJoe Millenbach1-3/+3
For consistency we changed the error output path to match the new debug path. Signed-off-by: Joe Millenbach <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Gokul Caushik <[email protected]> Reviewed-by: Josh Triplett <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
2012-07-21x86, boot: Wrap debug printing in a new debug_putstr functionJoe Millenbach1-8/+10
Change all instances of if (debug) putstr(...) to a new debug_putstr(...). This allows a future change to conditionally stub out debug_putstr to save space. Signed-off-by: Joe Millenbach <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Gokul Caushik <[email protected]> Reviewed-by: Josh Triplett <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
2012-07-21x86, boot: Removed quiet flag and switched quiet output to debug flagJoe Millenbach1-6/+3
There are only 3 uses of the quiet flag and they all protect output that is only useful for debugging the stub, therefore we switched to using the debug flag for all extra output. Signed-off-by: Joe Millenbach <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Gokul Caushik <[email protected]> Reviewed-by: Josh Triplett <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
2012-01-26x86/boot-image: Don't leak phdrs in arch/x86/boot/compressed/misc.c::Parse_elf()Jesper Juhl1-0/+2
We allocate memory with malloc(), but neglect to free it before the variable 'phdrs' goes out of scope --> leak. Signed-off-by: Jesper Juhl <[email protected]> Link: http://lkml.kernel.org/r/[email protected] [ Mostly harmless. ] Signed-off-by: Ingo Molnar <[email protected]>
2011-01-13x86: support XZ-compressed kernelLasse Collin1-0/+4
This integrates the XZ decompression code to the x86 pre-boot code. mkpiggy.c is updated to reserve about 32 KiB more buffer safety margin for kernel decompression. It is done unconditionally for all decompressors to keep the code simpler. The XZ decompressor needs around 30 KiB of heap, so the heap size is increased to 32 KiB on both x86-32 and x86-64. Documentation/x86/boot.txt is updated to list the XZ magic number. With the x86 BCJ filter in XZ, XZ-compressed x86 kernel tends to be a few percent smaller than the equivalent LZMA-compressed kernel. Signed-off-by: Lasse Collin <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Alain Knaff <[email protected]> Cc: Albin Tonnerre <[email protected]> Cc: Phillip Lougher <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2010-12-16x86-32: Make sure we can map all of lowmem if we need toH. Peter Anvin1-1/+1
A relocatable kernel can be anywhere in lowmem -- and in the case of a kdump kernel, is likely to be fairly high. Since the early page tables map everything from address zero up we need to make sure we allocate enough brk that we can map all of lowmem if we need to. Reported-by: Stanislaw Gruszka <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]> Tested-by: Yinghai Lu <[email protected]> LKML-Reference: <[email protected]>
2010-10-07x86, setup: Use string copy operation to optimze copy in kernel compressionZhao Yakui1-6/+23
The kernel decompression code parses the ELF header and then copies the segment to the corresponding destination. Currently it uses slow byte-copy code. This patch makes it use the string copy operations instead. In the test the copy performance can be improved very significantly after using the string copy operation mechanism. 1. The copy time can be reduced from 150ms to 20ms on one Atom machine 2. The copy time can be reduced about 80% on another machine The time is reduced from 7ms to 1.5ms when using 32-bit kernel. The time is reduced from 10ms to 2ms when using 64-bit kernel. Signed-off-by: Zhao Yakui <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
2010-08-02x86, setup: enable early console output from the decompressorYinghai Lu1-23/+33
This enables the decompressor output to be seen on the serial console. Most of the code is shared with the regular boot code. We could add printf to the decompressor if needed, but currently there is no sufficiently compelling user. -v2: define BOOT_BOOT_H to avoid include boot.h -v3: early_serial_base need to be static in misc.c ? -v4: create seperate string.c printf.c cmdline.c early_serial_console.c after hpa's patch that allow global variables in compressed/misc stage -v5: remove printf.c related Signed-off-by: Yinghai Lu <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
2010-02-28Merge branch 'x86-setup-for-linus' of ↵Linus Torvalds1-2/+0
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip * 'x86-setup-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: x86, setup: Don't skip mode setting for the standard VGA modes x86-64, setup: Inhibit decompressor output if video info is invalid x86, setup: When restoring the screen, update boot_params.screen_info
2010-02-18x86-64, setup: Inhibit decompressor output if video info is invalidH. Peter Anvin1-2/+0
Inhibit output from the kernel decompressor if the video information is invalid. This was already the case for 32 bits, make 64 bits match. Signed-off-by: H. Peter Anvin <[email protected]> LKML-Reference: <tip-*@git.kernel.org>
2010-02-05x86: Clean up mem*io functions.Brian Gerst1-9/+4
Iomem has no special significance on x86. Use the standard mem* functions instead of trying to call other versions. Some fixups are needed to match the function prototypes. Signed-off-by: Brian Gerst <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
2010-01-11x86: add support for LZO-compressed kernelsAlbin Tonnerre1-0/+4
The necessary changes to the x86 Kconfig and boot/compressed to allow the use of this new compression method Signed-off-by: Albin Tonnerre <[email protected]> Acked-by: H. Peter Anvin <[email protected]> Tested-by: Wu Zhangjin <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Tested-by: Russell King <[email protected]> Acked-by: Russell King <[email protected]> Cc: Ralf Baechle <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-05-12x86, boot: correct sanity checks in boot/compressed/misc.cH. Peter Anvin1-7/+5
arch/x86/boot/compressed/misc.c contains several sanity checks on the output address. Correct constraints that are no longer correct: - the alignment test should be MIN_KERNEL_ALIGN on both 32 and 64 bits. - the 64 bit maximum address was set to 2^40, which was the limit of one specific x86-64 implementation. Change the test to 2^46, the current Linux limit, and at least try to test the end rather than the beginning. - for non-relocatable kernels, test against LOAD_PHYSICAL_ADDR on both 32 and 64 bits. [ Impact: fix potential boot failure due to invalid tests ] Signed-off-by: H. Peter Anvin <[email protected]>
2009-01-04bzip2/lzma: x86 kernel compression supportAlain Knaff1-104/+14
Impact: Replaces x86 kernel decompressor with new code This is the third part of the bzip2/lzma patch The bzip patch is based on an idea by Christian Ludwig, includes support for compressing the kernel with bzip2 or lzma rather than gzip. Both compressors give smaller sizes than gzip. Lzma's decompresses faster than bzip2. It also supports ramdisks and initramfs' compressed using these two compressors. The functionality has been successfully used for a couple of years by the udpcast project This version applies to "tip" kernel 2.6.28 This part contains: - support for new bzip2 and lzma kernel compression for x86 Signed-off-by: Alain Knaff <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
2008-10-22x86: Fix ASM_X86__ header guardsH. Peter Anvin1-1/+1
Change header guards named "ASM_X86__*" to "_ASM_X86_*" since: a. the double underscore is ugly and pointless. b. no leading underscore violates namespace constraints. Signed-off-by: H. Peter Anvin <[email protected]>
2008-10-06Merge branches 'x86/alternatives', 'x86/cleanups', 'x86/commandline', ↵Ingo Molnar1-4/+6
'x86/crashdump', 'x86/debug', 'x86/defconfig', 'x86/doc', 'x86/exports', 'x86/fpu', 'x86/gart', 'x86/idle', 'x86/mm', 'x86/mtrr', 'x86/nmi-watchdog', 'x86/oprofile', 'x86/paravirt', 'x86/reboot', 'x86/sparse-fixes', 'x86/tsc', 'x86/urgent' and 'x86/vmalloc' into x86-v28-for-linus-phase1
2008-08-15x86: coding style fixes to arch/x86/boot/compressed/misc.cPaolo Ciarrocchi1-4/+6
Before: total: 4 errors, 6 warnings, 439 lines checked After: total: 1 errors, 5 warnings, 441 lines checked Before -#include <asm/io.h> +#include <linux/io.h> paolo@paolo-desktop:~/linux.trees.git$ md5sum /tmp/misc.o.* 8b2394e1fe519a9542e9a7e3e7b69c39 /tmp/misc.o.after 8b2394e1fe519a9542e9a7e3e7b69c39 /tmp/misc.o.before After -#include <asm/io.h> +#include <linux/io.h> paolo@paolo-desktop:~/linux.trees.git$ md5sum /tmp/misc.o.* 59a2d264284be5e72b5af4f3a8ccfb47 /tmp/misc.o.after 8b2394e1fe519a9542e9a7e3e7b69c39 /tmp/misc.o.before Signed-off-by: Paolo Ciarrocchi <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-07-26Merge branch 'linus' into x86/header-guardsIngo Molnar1-39/+0
Conflicts: include/asm-x86/gpio.h include/asm-x86/ide.h Signed-off-by: Ingo Molnar <[email protected]>
2008-07-25inflate: refactor inflate malloc codeThomas Petazzoni1-39/+0
Inflate requires some dynamic memory allocation very early in the boot process and this is provided with a set of four functions: malloc/free/gzip_mark/gzip_release. The old inflate code used a mark/release strategy rather than implement free. This new version instead keeps a count on the number of outstanding allocations and when it hits zero, it resets the malloc arena. This allows removing all the mark and release implementations and unifying all the malloc/free implementations. The architecture-dependent code must define two addresses: - free_mem_ptr, the address of the beginning of the area in which allocations should be made - free_mem_end_ptr, the address of the end of the area in which allocations should be made. If set to 0, then no check is made on the number of allocations, it just grows as much as needed The architecture-dependent code can also provide an arch_decomp_wdog() function call. This function will be called several times during the decompression process, and allow to notify the watchdog that the system is still running. If an architecture provides such a call, then it must define ARCH_HAS_DECOMP_WDOG so that the generic inflate code calls arch_decomp_wdog(). Work initially done by Matt Mackall, updated to a recent version of the kernel and improved by me. [[email protected]: coding-style fixes] Signed-off-by: Thomas Petazzoni <[email protected]> Cc: Matt Mackall <[email protected]> Cc: Richard Henderson <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Cc: Mikael Starvik <[email protected]> Cc: Jesper Nilsson <[email protected]> Cc: Haavard Skinnemoen <[email protected]> Cc: David Howells <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Andi Kleen <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Acked-by: Paul Mundt <[email protected]> Acked-by: Yoshinori Sato <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-07-22x86: consolidate header guardsVegard Nossum1-1/+1
This patch consolidates the header guard names which are also used externally, i.e. in .c files. Signed-off-by: Vegard Nossum <[email protected]>
2008-07-08Merge branch 'x86/mpparse' into x86/develIngo Molnar1-4/+0
Conflicts: arch/x86/Kconfig arch/x86/kernel/io_apic_32.c arch/x86/kernel/setup_64.c arch/x86/mm/init_32.c Signed-off-by: Ingo Molnar <[email protected]>
2008-07-03x86: config option to disable info from decompression of the kernelBen Collins1-5/+11
This patch allows the disabling of decompression messages during x86 bootup. Signed-off-by: Ben Collins <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-06-10x86: make generic arch support NUMAQYinghai Lu1-4/+0
... so it could fall back to normal numa and we'd reduce the impact of the NUMAQ subarch. NUMAQ depends on GENERICARCH also decouple genericarch numa from acpi. also make it fall back to bigsmp if apicid > 8. Signed-off-by: Yinghai Lu <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-05-30x86: Honor 'quiet' command line option in real mode boot decompressor.Kristian Høgsberg1-3/+10
This patch lets the early real mode code look for the 'quiet' option on the kernel command line and pass a loadflag to the decompressor. When this flag is set, we suppress the "Decompressing Linux... Parsing ELF... done." messages. Signed-off-by: Kristian Høgsberg <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
2008-05-30x86: Use structs instead of hardcoded offsets in x86 boot decompressor.Kristian Høgsberg1-15/+11
Replace hardcoded offsets embedded in macros in arch/x86/boot/compressed with proper structure references. Signed-off-by: Kristian Høgsberg <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
2008-04-19x86: cleanup boot-heap usageAlexander van Heukelum1-7/+1
The kernel decompressor wrapper uses memory located beyond the end of the image. This might lead to hard to debug problems, but even if it can be proven to be safe, it is at the very least unclean. I don't see any advantages either, unless you count it not being zeroed out as an advantage. This patch moves the boot-heap area to the bss segment. Signed-off-by: Alexander van Heukelum <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
2008-04-17x86: remove superfluous initialisation in boot code.Alexander van Heukelum1-1/+1
In arch/x86/boot/compressed/misc.c, the variable vidmem is the only variable that ends up in de data segment. It's also superfluous, because the first thing the code does is: if (RM_SCREEN_INFO.orig_video_mode == 7) { vidmem = (char *) 0xb0000; vidport = 0x3b4; } else { vidmem = (char *) 0xb8000; vidport = 0x3d4; } This patch removes the initialisation. Signed-off-by: Ingo Molnar <[email protected]>
2008-04-17x86: more cleanups in arch/x86/boot/compressed/misc.cIngo Molnar1-46/+54
Before: total: 7 errors, 8 warnings, 471 lines checked After: total: 5 errors, 5 warnings, 479 lines checked ( the rest cannot be eliminated due to zlib interface cruftiness. ) No code changed: arch/x86/boot/compressed/misc.o: text data bss dec hex filename 10716 8 2152 12876 324c misc.o.before 10716 8 2152 12876 324c misc.o.after md5: 2c20c903986a3c9bca44306c6646067e misc.o.before.asm 2c20c903986a3c9bca44306c6646067e misc.o.after.asm Signed-off-by: Ingo Molnar <[email protected]>
2008-04-17x86: coding style fixes to arch/x86/boot/compressed/misc.cPaolo Ciarrocchi1-32/+34
Fix lots of style errors and warnings. Before: total: 58 errors, 9 warnings, 469 lines checked After: total: 7 errors, 8 warnings, 471 lines checked No code changed: arch/x86/boot/compressed/misc.o: text data bss dec hex filename 10716 8 2152 12876 324c misc.o.before 10716 8 2152 12876 324c misc.o.after md5: 2c20c903986a3c9bca44306c6646067e misc.o.before.asm 2c20c903986a3c9bca44306c6646067e misc.o.after.asm Signed-off-by: Paolo Ciarrocchi <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-04-17x86: use ELF format in compressed images.Ian Campbell1-0/+56
Signed-off-by: Ian Campbell <[email protected]> Cc: Ian Campbell <[email protected]> Cc: Jeremy Fitzhardinge <[email protected]> Cc: [email protected] Cc: H. Peter Anvin <[email protected]> Cc: Jeremy Fitzhardinge <[email protected]> Cc: [email protected] Signed-off-by: Ingo Molnar <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
2008-01-30x86: unify arch/x86/boot/compressed/misc_??.cIan Campbell1-0/+413
Remainder of unification can occur inplace. size reports no change in arch/x86/boot/compressed/vmlinux. Signed-off-by: Ian Campbell <[email protected]> Cc: H. Peter Anvin <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>