summaryrefslogtreecommitdiff
path: root/kexec/arch/arm/kexec-zImage-arm.c
AgeCommit message (Collapse)Author
2018-03-20ARM: Include stack and malloc space in zImage sizeRussell King
Include the stack and malloc space in our calculation of the zImage size, both of which must be avoided when locating the dtb. Signed-off-by: Russell King <rmk@armlinux.org.uk>
2018-03-20ARM: add further debugRussell King
Add further debugging of the kernel size Signed-off-by: Russell King <rmk@armlinux.org.uk>
2018-03-20ARM: read kernel size from zImageRussell King
Signed-off-by: Russell King <rmk@armlinux.org.uk>
2017-11-01ARM: read kernel size from zImageRussell King
Read the new extension data which tells the boot agent about the requirements for booting the kernel image, such as how much RAM will be consumed by the kernel through decompression and booting. This is necessary to control the placement of the DTB and compressed RAM disk to avoid these objects being corrupted. Tested-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Russell King <rmk@armlinux.org.uk> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-11-01ARM: cleanup initrd and dtb handingRussell King
There is no difference in the way the initrd is handled between an ATAG-based kernel and a DTB-based kernel. Therefore, this should be handled identically in both cases. Rearrange the code to achieve this. Signed-off-by: Russell King <rmk@armlinux.org.uk> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-07-15arm: use zImage size from headerRussell King
We do not support zImage with an appended DTB as we need to supply our own DTB to the kernel, and an appended DTB will override any that we try to supply. To ensure that we do not load an appended DTB, clamp the kernel size to the size specified in the zImage header. Signed-off-by: Russell King <rmk@armlinux.org.uk> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-07-15arm: plug a zImage corner caseRussell King
If a zImage is built with ARM_APPENDED_DTB enabled, the zImage will look at the word following the zImage and check whether it contains the DTB magic number. Generally, kexec will clear the destination pages before copying the zImage, but there is a corner case where the zImage is a multiple of the page size, where the following page will not be touched. Should the first word in this page contain the DTB magic number, the data following will be interpreted as a DTB image. In order to make this bullet-proof, we must always initialise the word following the zImage. Arrange this by specifying the zImage memory size one word bigger than the buffer size. Signed-off-by: Russell King <rmk@armlinux.org.uk> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-06-23arm: fix kernel image sizeRussell King
If we want to assume that the compressed image will expand by a maximum of 4x, we actually need to reserve 5x the space, since we need to keep a copy of the compessed image around while decompressing. Signed-off-by: Russell King <rmk@armlinux.org.uk> Reviewed-by: Pratyush Anand <panand@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-06-23arm: take account of TEXT_OFFSET for subsequent imagesRussell King
The ARM kexec code was not taking account of the 32k text offset when applying the size(s) of the kernel image. We need to take account of this so when we decide to place the initrd at 4x the compressed image length, it is appropriately placed. Signed-off-by: Russell King <rmk@armlinux.org.uk> Reviewed-by: Pratyush Anand <panand@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-06-08arm: crashdump needs boot alias of crash kernel regionRussell King
When crashdumping, we need the boot memory alias of the crash kernel region rather than the system view. Arrange to check for the boot alias of the crash kernel region first, and if found, use it instead of the main alias. Reviewed-by: Pratyush Anand <panand@redhat.com> Signed-off-by: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-06-08arm: return proper error for missing crash kernelRussell King
Return the proper error code (ENOCRASHKERNEL) for a missing crash kernel region in /proc/iomem, so the error handling in kexec.c can print the appropriate message. Reviewed-by: Pratyush Anand <panand@redhat.com> Signed-off-by: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-05-04arm: Change setup_dtb_prop to create nodes by offset and node nameNikolaus Schulz
setup_dtb_prop looks like a generic function that can find and add any nodes, which need not be top-level in the DT. In practice though, the function is only used for the top-level /chosen node, and it can't add nodes for which the parent doesn't exist. So far, so good - but for adding a new node to the DT, the parent offset need be passed to fdt_add_subnode. Currently in setup_dtb_prop the parent offset is unknown, and instead a bogus error code is passed to fdt_add_subnode. Fix that by adding the parent offset as an extra function argument to setup_dtb_prop, and change the handling of the /chosen node to operate on a relative path plus (zero) offset instead of an absolute path. This aligns setup_dtb_prop to the libfdt API, where functions commonly operate with a parent offset plus child node name. Signed-off-by: Nikolaus Schulz <nikolaus.schulz@avionic-design.de> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-05-04zImage-arm: Add support for booting android imagesAlban Bedel
Add very basic support for booting an android image. The ramdisk and command line from the image are only used if none has been given on the command line. Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-05-04zImage-arm: Fix a return value check that use the wrong variableAlban Bedel
When looking for a hole to put the initrd in the error check used the wrong variable. Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de> Signed-off-by: Simon Horman <horms@verge.net.au>
2015-11-24arm: use /sys/firmware/fdt in case without --atags and --dtbDave Young
Latest linux kernel will create /sys/firmware/fdt file. It will be convenient to use it in case one does not specify --atags and --dtb options. Signed-off-by: Dave Young <dyoung@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2015-11-24kexex: arm: create ATAGS_MEM tag from devicetree memory nodeAndreas Fenkart
booting a non-devicetree kernel from a devicetree kernel failed, since the memory layout wasn't passed. Signed-off-by: Andreas Fenkart <andreas.fenkart@dev.digitalstrom.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2014-07-24kexec: align the extended size of dtbLiu Hua
When loading dtb on arm platform, we may need change strings in dtb in function setup_dtb_prop. If length of new string is larger than that of the old one. We should extend the dtb by "FDT_TAGALIGN"ed size. If not, kexec may fail to load the capture kernel. Signed-off-by: Liu Hua <sdu.liu@huawei.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2014-05-30kexec-tools: add --page-offset option for ARMWang Nan
When KALLSYMS is disabled or /proc is not mounted, this patch allows --page-offset cmdline option for user to setup correct page_offset. Signed-off-by: Wang Nan <wangnan0@huawei.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2014-05-11zImage-arm: init modified_cmdline with zeroWang Nan
This patch memset modified_cmdline after it alloced. Without this patch, the header of command line always contains random value like following example: kernel: 0x765fd008 kernel_size: 0x23b610 memory range: [0x60000000 - 0x6fffffff] (256M) memory range: [0x78000000 - 0x9fffffff] (640M) ... kernel command line: "°¥氥䐶# elfcorehdr=0x77f00000 mem=130048K" Signed-off-by: Wang Nan <wangnan0@huawei.com> Cc: Geng Hui <hui.geng@huawei.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2014-05-11zImage-arm: bugfix: kernel offset must be 0x8000Wang Nan
This patch fixs a problem introduced by commit e5d6a55 which make ARM kexec fails. Due to that commit, kernel is loaded at a dynamically offset: it computes extra_size using size of dtb, and load zImage at base + extra_size. When dtb size small (for example, 0x3000 bytes), kernel will be loaded at address like 0x60003000. For ARM zImage such address is incorrect. In kernel code arch/arm/boot/compressed/head.S, zImage builds a temporary page table at (pc & 0xf8000000) + TEXT_OFFSET - 0x4000. The related instructions sequence is: mov r4, pc and r4, r4, #0xf8000000 add r4, r4, #TEXT_OFFSET @ (TEXT_OFFSET == 0x8000 on most platforms) call cache_on ... call __armv7_mmu_cache_on ... call __setup_mmu sub r3, r4, #16384 @ Page directory size r3 becomes page table pointer. When kernel is loaded at 0x60003000, page table is still built at 0x60004000, which destroys kernel. This patch make extra_size a fix value (0x8000) to avoid the failure. For the problem commit e5d6a55 tries solve, this patch uses locate_holes() to find a place can hold initrd and dtb. Change from v1: - Coding style enhancements. Signed-off-by: Wang Nan <wangnan0@huawei.com> Tested-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2014-05-02zImage-arm: get rid of static offsetDaniel Mack
The code in arch/arm/kexec-zImage-arm.c currently enforces a hard limit on the maximum size a dtb blob can occupy. This limit is set to 32k, which is quite low for device tree blobs nowadays. Get rid of this assumption, and calculate the added size dynamically. For this, we need to slurp in the dtb file earlier in order to determine its size, because the memory hole allocation for 'base' takes this size into account. For ATAGs, we keep the current value of 32k, which should in fact be enough. With this change in place, the 'DTB too large!' error message can go away. Successfully tested on a AM335x board. Signed-off-by: Daniel Mack <zonque@gmail.com> [s.neumann@raumfeld.com: Fix ATAGs case] Reported-and-tested-by: Sven Neumann <s.neumann@raumfeld.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2014-03-28Pass initrd position by dtbWang Nan
This patch append the position of initrd to dtb when loading arm kernel and initrd without using atag. Signed-off-by: Wang Nan <wangnan0@huawei.com> Acked-by: Dave Young <dyoung@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2014-03-28Introduce setup_dtb_prop to make code clearWang Nan
This patch introduces setup_dtb_prop(), which is used for dtb operations. The code is extracted from zImage_arm_load, and this patch makes memory grown computation more accurate. Signed-off-by: Wang Nan <wangnan0@huawei.com> Acked-by: Dave Young <dyoung@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2014-03-20kexec: align initrd when no --image-size passedWang Nan
Before this patch, when no --image-size passed, initrd_base is caculated using base + len * 4, which is unaligned, and unable to pass check in add_segment_phys_virt(): if (base & (pagesize -1)) { die("Base address: 0x%lx is not page aligned\n", base); } This patch also uses getpagesize() instead of hard encoded 4096. Signed-off-by: Wang Nan <wangnan0@huawei.com> Acked-by: Dave Young <dyoung@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-11-14arm: add command line option for the total image sizeDaniel Mack
Currently, kexec on arm assumes that it's safe to place binary images such as atags, dtb or initrd at an estimated offset after the load address. That estimated offset is set to 4 times the size of the compressed image, hence assuming a minimum compression ratio of 1:4. While that assumption matches what the in-kernel compressors are able to achive, it doesn't take into account the .bss section the kernel image carries, and which can grow to arbitrary sizes while not accounting to the compressed image size. After decompression, and before the execution of the compressed kernel, the .bss area is initialized to zeros, trampeling over the binary images in case they happen to live in that piece of memory. Unfortunately, determining the full image size is not easiliy possible at runtime, as it would include doing all possible ways of decompression and then walk the ELF sections by hand. For now, allow users to override the static offset with a new, arm specific command line argument. Users are supposed to set this, and determine a sane value by using 'arm-linux-size vmlinux'. Signed-off-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-10-03kexec: Remove unused -? option handlingGeoff Levand
The main kexec option code handles the -? option. Remove all the duplicate -? handlers in the arch code which are never used. Signed-off-by: Geoff Levand <geoff@infradead.org> for Huawei, Linaro Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-14kexec: arm: use _ALIGN* to make the logic clearZhang Yanfei
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2012-12-23kexec-zImage-arm: simply cmdline-related DTB resizingStephen Warren
When resizing a dtb to add the command-line, only resize the DTB once, rather than once to add the /chosen node, and once to add the bootargs property. Also, simply add 1K of overhead (beyond strlen(cmdline)) to the buffer, to avoid requiring precise knowledge of the size impact of the requested FTB changes. In particular, some padding is performed when setting property values, which was not accounted for in the current code, which caused failures to set the bootargs values in some cases. Cc: Daniel Mack <zonque@gmail.com> Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2012-12-14kexec-zImage-arm: add code to support --command-line along with --dtbDaniel Mack
If --dtb is called together with --command-line, we need to modify the binary dtb buffer. Luckily, we have libfdt functions available, so this is straight forward. Signed-off-by: Daniel Mack <zonque@gmail.com> Tested-by: Sven Neumann <s.neumann@raumfeld.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2012-09-12ARM: Add device tree support to the ARM platformMatthew Leach
To allow newer ARM platforms to use kexec, pass device tree information to the kernel during boot. By default the dtb is found from /proc/device-tree. A user can specify a dtb file or use legacy ATAGs Signed-off-by: Matthew Leach <matthew.leach@arm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-05-19kexec-tools: Fix option/argument parsingMatt Evans
The argument parsing is currently a bit broken as main()'s getopt_long() knows nothing about either the architecture-specific options or, even more specifically, the architecture-and-loader-specific options. This patch introduces new #defines for all architectures, KEXEC_ALL_OPTIONS and KEXEC_ALL_OPT_STR. These contain all possible options for a given build, and the getopt_long() passes in main() and arch_process_options() will now recognise arch- and loader-specific options; these will not be re-ordered in argv[], there is no confusion over which argv[] entry is the kernel filename, and using '--opt=foo' and '--opt foo' both work. All architectures have command line options (and #define OPT_BLAHs) consolidated into their include/arch/option.h files. x86_64 builds parts of i386/ as well, so now both share a single option.h file (with a symlink). Signed-off-by: Matt Evans <matt@ozlabs.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-05-19kexec: implement ARM crashdump supportMika Westerberg
Implement support for loading dump capture kernels for ARM architecture. ARM doesn't need any backup memory regions so only elfcore header is allocated from the top of the reserved memory region. Only zImages are supported. The dump capture kernel needs to be loaded to physical address corresponding to the memory region reserved with 'crashkernel=size@start' kernel command line parameter. Signed-off-by: Mika Westerberg <ext-mika.1.westerberg@nokia.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-05-11arm: place initrd to safer place according to zImage lengthEric Miao
The original fixed address of 0x800000 may be overwritten after the kernel is decompressed. Assume a maximum decompression ratio of 4 and place initrd right after that, just to be safer. Signed-off-by: Eric Miao <eric.miao@canonical.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-03-24kexec-tools: Fix unused return value warning for freadAmeya Palande
Signed-off-by: Ameya Palande <ameya.palande@nokia.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-02-02arm: Initialise initrd_start in zImage_arm_load()Simon Horman
Although the following compiler warning is bogus it seems harmless to initialise initrd_start to NULL. # arm-unknown-linux-gnu-gcc --version arm-unknown-linux-gnu-gcc (GCC) 4.1.1 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # make kexec/arch/arm/kexec-zImage-arm.c: In function 'zImage_arm_load': kexec/arch/arm/kexec-zImage-arm.c:135: warning: 'initrd_start' may be used uninitialized in this function Signed-off-by: Simon Horman <horms@verge.net.au>
2010-02-02arm: Include unistd.h for getpagesize()Simon Horman
Signed-off-by: Simon Horman <horms@verge.net.au>
2010-02-02Mark unused parametersSimon Horman
Signed-off-by: Simon Horman <horms@verge.net.au>
2008-08-27arm: asm/page.h is no longer exported to userspaceMarc Kleine-Budde
In recent kernels "asm/page.h" isn't exported to userspace anymore, thus the include is removed. Further this patch defines _XOPEN_SOURCE, in order to use getpagesize. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-02-19Add ARM support to kexecRichard Purdie
Add ARM support to kexec including commandline support through ATAGs. The kernel syscall support has already been merged and kernel ATAG exporting is queued for 2.6.25 (its optional for kexec). Based on work by various people, notably Uli Luckas <u.luckas@road.de> for adding ATAG support. Signed-off-by: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Simon Horman <horms@verge.net.au>