summaryrefslogtreecommitdiff
path: root/kexec/arch/ppc
AgeCommit message (Collapse)Author
2017-08-10kexec-tools: powerpc: fix command line overflow errorHari Bathini
Since kernel commit a5980d064fe2 ("powerpc: Bump COMMAND_LINE_SIZE to 2048"), powerpc bumped command line size to 2048 but the size used here is still the default value of 512. Bump it to 2048 to fix command line overflow errors observed when command line length is above 512 bytes. Also, get rid of the multiple definitions of COMMAND_LINE_SIZE macro in ppc architecture. Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-20ppc: Fix format warning with die()Jussi Kukkonen
Enable compiling kexec-tools for ppc with -Werror=format-security. Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-13uImage: use 'char *' instead of 'unsigned char *' for uImage_load()David Woodhouse
This was only ever used on PPC, where they are equivalent and we never saw the resulting -Wpointer-sign warnings. Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-02crashdump/ppc: Add get_crash_kernel_load_range() functionDaniel Kiper
Implement get_crash_kernel_load_range() in support of print crash kernel region size option. Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-03-24Pass struct mem_sym into machine_apply_elf_rel()Anton Blanchard
On PowerPC64 ABIv2 we need to look at the symbol to determine if it has a local entry point. Pass struct mem_sym into machine_apply_elf_rel() so we can. Signed-off-by: Anton Blanchard <anton@samba.org> Tested-by: Dave Young <dyoung@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2015-11-26Improve device tree directory sortingCurt Brune
Previously when sorting the device tree directory entries, if both device tree entries contained the '@' character then comparison was made based on the length of the strings. This did not work in all cases and could result in odd orderings. This patch modifies the comparison function for the case when both strings contain the '@' character. First a lexical comparison is made between the prefix portions of the strings *before* the '@' character. Next, if the prefixes are equal, the lengths of the suffixes *after* the '@' character are compared. This preserves the intent of the original code. Next, if the suffix lengths are equal, a lexical comparison of the suffixes is made. This is still not strictly correct, as ideally the portion after the '@' should be compared numerically. However, determining what base to use for all case is difficult. Signed-off-by: Curt Brune <curt@cumulusnetworks.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2014-05-15kexec/ppc64: Fix up ELF header and dt for PowerNV platform.Mahesh Salgaonkar
On PowerNV platform, OPAL region is overlapped with crashkernel, need to create ELF Program header for the overlapped memory. The changes are similar to the way RTAS region was handled. Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2014-04-10kexec/ppc: cleanup crash regions creationNikita Yushchenko
Move filling crash_memory_range table entries into a separate routine, which saves quite a few lines of code. In this routine, if range spawns over lowmem-highmem border, split range into two. This is needed to get proper virtual address for lowmem part. Similar thing is already done for x86. Credits to Yadviga Grigorieva <yadviga@dev.rtsoft.ru> for tracking down this issue for ppc. Also this patch makes excluding crash kernel regoin a bit shorter, and removes unused variable to get rid of compiler warning. Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru> 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-09-25kexec/ppc: Check for a uImage initrd with ELF kernelSuzuki K. Poulose
We should check if the initrd is in uImage format, when the kernel might be in ELF. Signed-off-by : Suzuki K Poulose <suzuki@in.ibm.com> Signed-off-by : Athira Rajeev<atrajeev@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-09-25kexec/ppc: Add nodes for initrd in dtbSuzuki K. Poulose
If the primary kernel doesn't use an initrd, we may not have linux,initrd-* entries in the device-tree, and hence the initial flat tree may not contain them. Make sure we add the entries in the dtb if the second kernel needs an initrd. Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Signed-off-by: Athira Rajeev<atrajeev@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-06-10kexec-tools: ppc: Remove saved_max_memZhang Yanfei
saved_max_mem is used to calculate the amount of memory that the previous kernel used. And passed to the dump-capture kernel by kernel commandline parameter "savemaxmem=". But in the dump-capture kernel, we never use this parameter now, so remove saved_max_mem and don't add "savemaxmem=" to new kernel commandline. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Acked-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-05-26kexec-tools: ppc/ppc64: cleanup: Remove never reached returnZhang Yanfei
The return will never be reached, so remove it. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-04-25kexec/uImage: probe to identify a corrupted imageSuzuki K. Poulose
Teach uImage_probe_xxx() to return the information about a corrupted image. This is required to prevent the loading of a corrupted ramdisk, where we don't have strict checking for the other formats, unlike the kernel. So, we should abort the operation than causing a problem with the new kernel. Without this patch, a corrupted uImage ramdisk is treated as a plain ramdisk where there is no format check involved. # kexec -l uImage --initrd romfs-initrd.corrupt The data CRC does not match. Computed: 867e73f7 expected 8f097cc0 # echo $? 0 # kexec -e Starting new kernel Bye! Reserving 55MB of memory at 70MB for crashkernel (System RAM: 256MB) Using Xilinx Virtex440 machine description Linux version 3.6.0-rc3 (root@suzukikp) (gcc version 4.3.4 [gcc-4_3-branch revision 152973] (GCC) ) #66 Tue Apr 16 06:36:56 UTC 2013 Found initrd at 0xcf5f8000:0xcfff8040 ... NET: Registered protocol family 17 RAMDISK: Couldn't find valid RAM disk image starting at 0. List of all partitions: No filesystem could mount root, tried: ext2 cramfs Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0) With this patch : # kexec -l uImage --initrd romfs-initrd.corrupt uImage: The data CRC does not match. Computed: 867e73f7 expected 8f097cc0 uImage: Corrupted ramdisk file romfs-initrd With a corrupted kernel image(the behaviour remains the same) : # kexec -l uImage.corrupt --initrd romfs-initrd uImage: The data CRC does not match. Computed: 285787b7 expected e37f65ad Cannot determine the file type of uImage.corrupt Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-04-16kexec/powerpc: Handle buffer overflow in kernel command lineSuzuki K. Poulose
Enforce size check for kernel command line to make sure it doesn't overflow COMMAND_LINE_SIZE. Reported-by: Nathan D. Miller <nathanm2@us.ibm.com> Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-27kexec: ppc: Use die() instead of fatal()Zhang Yanfei
fatal() nearly does the same thing as die() does, so this is kind of duplicate. Remove fatal() and use die() instead. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-27kexec: Use die() to simplify codeZhang Yanfei
Use die() to simplify code. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-27kexec: ppc: uImage: fix memory leak caused by get_command_lineZhang Yanfei
Since get_command_line returns dynamically allocated memory, it is easy for the caller to forget freeing the memory. Here fixes a memory leak caused by this function. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-27kexec: ppc: uImage: fix possible memory leak in ppc_load_bare_bitsZhang Yanfei
In ppc_load_bare_bits, allocated memory may not be free'd if the code exits abnormally, by calling die() or return. So the patch fixes the possible memory leak. This patch is also a preparation for patch10. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-27kexec: ppc: elf: fix memory leak caused by get_command_lineZhang Yanfei
Since get_command_line returns dynamically allocated memory, it is easy for the caller to forget freeing the memory. Here fixes a memory leak caused by this function. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-27kexec: ppc: elf: fix possible memory leak in elf_ppc_loadZhang Yanfei
In elf_ppc_load, allocated memory may not be free'd if the code exits abnormally, by calling die() or return. So the patch fixes the possible memory leak. This patch is also a preparation for patch08. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-14kexec: ppc: 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. Besides, remove the duplicate _ALIGN_* definition in file kexec/arch/ppc/crashdump-powerpc.h. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-14kexec: ppc: remove duplicated _ALIGN_* macrosZhang Yanfei
We have defined the global align macros for use, so remove the duplicated macros here. And in file kexec/arch/ppc/include/page.h, we directly expand the align operation for marco PAGE_ALIGN since we have removed marco _ALIGN in this file. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-08ppc/uImage: Add support for RAM DisksSuzuki K. Poulose
Handle the RAM Disks in uImage format Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-08kexec/uImage: Introduce uImage_probe_kernelSuzuki K. Poulose
uImage supports different types of payloads, including kernel, ramdisks etc. uImage_probe() as of now checks whether the supplied payload is of type KERNEL ( i.e, IH_TYPE_KERNEL or IH_TYPE_KERNEL_NOLOAD ). Change this behaviour to return the image type, if it is one of the supported payloads. This change is in prepartion to support ramdisks in uImage format. Introduce a uImage_probe_kernel() which can be used by the archs to check if the supplied payload is one of the KERNEL types. Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-05kexec: Respect memory limit while building crash memory ranges on ppc32.Mahesh Salgaonkar
So far powerpc kernel never exported memory limit information which is reflected by mem= kernel cmdline option. Hence, kexec-tools always used to build ELF header for entire system RAM generating a dump bigger than the actual memory used by the first kernel. This patch now reads the memory limit information from device-tree file and limits the crash memory ranges accordingly. Suzuki tested this patch on ppc32(ppc440) with a kernel patch by Suzuki. The following are the upstream kernel commits that exports memory limit information through /proc/device-tree file: 4bc77a5ed - powerpc: Export memory limit via device tree a84fcd468 - powerpc: Change memory_limit from phys_addr_t to unsigned long long Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Tested-by: Suzuki K. Poulose <suzuki@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-05kexec/ppc: Fix kernel program entry point while changing the load addrSuzuki K. Poulose
uImage probe fills the entry point (ep) based on the load_addr from the uImage headers. If we change the load_addr, we should accordingly update the entry point. For ELF, calculate the offset of e_entry from the virtual start address and add it to the physical start address to find the physical address of kernel entry. i.e, pa (e_entry) = pa(phdr[0].p_vaddr) + (e_entry - phdr[0].p_vaddr) = kernel_addr + (e_entry - phdr[0].p_vaddr) Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Matthew McClintock <msm@freescale.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2012-12-23build: Restrict scope of per-arch compiler flagsSimon Horman
Restrict the scope of compiler flags set in per-arch Makefiles to the architecture the Makefile belongs to. Signed-off-by: Simon Horman <horms@verge.net.au>
2012-12-18kexec-elf-ppc: Fix crashkernel region overflow checkAnders Hedlund
Signed-off-by: Anders Hedlund <anders.j.hedlund@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2012-12-13ppc: exec stack fixDave Young
execstack shows ppc kexec has an executable stack, this leaves it vulnerable to buffer overflows. Fix it by adding ASFLAGS --noexecstack Tested on PowerMac G4 Macmini: Without the patch: dave@darkstar:~/kexec-tools$ execstack build/sbin/kexec X build/sbin/kexec With the patch: dave@darkstar:~/kexec-tools$ execstack build/sbin/kexec - build/sbin/kexec Signed-off-by: Dave Young <dyoung@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2012-11-08ppc/uImage: Find new kernel load_addr if the default addr is not availableSuzuki K. Poulose
If the kernel cannot be loaded at the default load_addr, provided by the image, we should try finding a free area using locate_hole(). This is usually applicable for the CRASH case, where the memory should be located in the reserved region. Without this patch, sometime the kernel fails to load for uImage formatted relocatable kernel images. Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Matthew McClintock <msm@freescale.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2012-09-12libfdt: Move from kexec/arch/ppc/libfdt/ to kexec/libfdt/Simon Horman
This is in preparation for using the code on ARM as well as PPC. Signed-off-by: Simon Horman <horms@verge.net.au>
2012-08-02build: Avoid duplicate files in tarballSimon Horman
Signed-off-by: Simon Horman <horms@verge.net.au>
2012-07-13Do not reserve cpu spin-table for crash kernelSuzuki K. Poulose
As of now, the kexec reserves the spin-table for all the CPUs on an SMP machine. The spin-table is pointed to by the cpu-release-addr property in the device-tree. Reserving the spin-table in the crash kernel will cause a BUG(), if the table lies outside the memory reserved for the crashkernel. Disable reserving the spin-table regions and use maxcpus=1 to use only the crashing CPU to boot the crash kernel. Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2012-05-18ppc: move DEBUG code to --debugCong Wang
From: Cong Wang <xiyou.wangcong@gmail.com> V2: Fix a compile error Like commit 28d4ab53280853d2aeefdfb7c369331e89ab9ac2 ("Add generic debug option"), this one moves code under #if DEBUG to --debug on ppc arch. Sorry that I still can't find a ppc32 machine to test this. Cc: Simon Horman <horms@verge.net.au> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2012-03-15Add generic debug optionCong Wang
Currently the debugging code is under #ifdef DEBUG, which means when we want to debug, we have to re-compile the source code with -DDEBUG. This is not convenient, we want to have a generic --debug option so that we can enable debugging code without re-compiling. This patch moves the arch-specific --debug to generic place and moves code under #ifdef DEBUG to --debug on x86. BTW, the size of kexec binary increases very little after this patch. Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2012-02-08Fix out-of-tree buildTyler Hall
Use automatic variables for prerequisites when copying man pages and include a makefile relative to $(srcdir). Signed-off-by: Tyler Hall <tylerwhall@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2011-10-21kexec: powerpc: crash_dump: No backup region for PPC BookESuzuki K. Poulose
Disable backup regions for BookE in case of a CRASH Dump, as they can be run from anywhere. The patch introduces --with-booke option to support the BookE. With the patch, we get : ## On a 256M machine: # busybox cat /proc/cmdline init=/bin/init console=ttyS0,16550 crashkernel=128M@100M # kexec -p root/vmlinux usable memory rgns size:1 base:6400000 size:8000000 CRASH MEMORY RANGES 0000000000000000-0000000006400000 000000000e400000-0000000010000000 Command line after adding elfcorehdr: elfcorehdr=112380K Command line after adding elfcorehdr: elfcorehdr=112380K savemaxmem=256M Signed-off-by: Suzuki K. Poulose<suzuki@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2011-08-23kexec:ppc: Fix compilation failureSuzuki K. Poulose
commit 1ea7cfd435aba0e095886db367e9616271f56c28 broke the ppc build as it removes the declaration for two variables in use by the elf_ppc_load(). This patch reverts the particular hunk. Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Reported-by: Josh Boyer <jwboyer@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2011-08-04ppc: Remove some unused parameters and variablesSimon Horman
Signed-off-by: Simon Horman <horms@verge.net.au>
2011-07-13kexec-tools: ppc32: Fixup ThreadPointer for purgatory codeSuzuki K. Poulose
PPC32 ELF ABI expects r2 to be loaded with Thread Pointer, which is 0x7000 bytes past the end of TCB. Though the purgatory is single threaded, it uses TCB scratch space in vsnprintf(). This patch allocates a 1024byte TCB and populates the TP with the address accordingly. Changes from V2: Avoid address overflow in TP allocation. Changes from V1: Fixed the addr calculation for uImage support. Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Cc: Ryan S. Arnold <rsa@us.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2011-06-17kexec-tools: powerpc: Use the #address-cells information to parsememory/regSuzuki K. Poulose
The format of memory/reg is based on the #address-cells,#size-cells. Currently, the kexec-tools doesn't use the above values in parsing the memory/reg values. Hence the kexec cannot handle cases where #address-cells, #size-cells are different, (for e.g, PPC440X ). This patch introduces a read_memory_region_limits(), which parses the memory/reg contents based on the values of #address-cells and #size-cells. Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2011-04-29kexec: remove duplicated backup_src_start field from struct crash_elf_infoCong Wang
Signed-off-by: WANG Cong <amwang@redhat.com> Acked-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2011-04-27Fix memory errors on ppcSuzuki Poulose
Fixes buffer overflow and improper realloc() in realloc_memory_ranges(). Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> (manually applied) Signed-off-by: Simon Horman <horms@verge.net.au>
2011-04-27kexec: remove duplicated backup_src_start field from struct crash_elf_infoAmerigo Wang
Vivek pointed out that we have duplicated ->backup_src_start in struct crash_elf_info and struct kexec_info. This patch removes the ->backup_src_start and ->backup_src_end from struct crash_elf_info. I tested it on both i686 and ppc64, and used a test case from Dave Anderson to confirm the backup region is correct on i686. Signed-off-by: WANG Cong <amwang@redhat.com> Cc: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-09-22kexec/arch/ppc/fixup_dtb.c: Calcuate new FDT size correctlyMatthew McClintock
It was possible to not add enough space when we allocate more space for more memory reserve regions, this was because we were incorrectly accounting for the size of a reserve region. This corrects the assumed size for a resize region Signed-off-by: Matthew McClintock <msm@freescale.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-08-20Prevent initrd-start and initrd-end from appearing multiple timesMatthew McClintock
We always remove the old entry, and add it back if it is needed on for the kexec'ed kernel Signed-off-by: Matthew McClintock <msm@freescale.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-08-20Prevent multiple reservations for cpu-release-addrMatthew McClintock
Currently, we can add a lot of reservations over a small range, this does a simple check to verify the previous entry is not the same as the current one and skips it if so Signed-off-by: Matthew McClintock <msm@freescale.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-08-20Ramdisk address was not copied correctly on kexec'ed kernelMatthew McClintock
Signed-off-by: Matthew McClintock <msm@freescale.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-07-29Add support for reworking flat device tree supportMatthew McClintock
Currently, the device tree is passed as is. You can optionally update the command line and specifically listed nodes but nothing is updated automatically. This patch updates the memreserve regions, memory node, initrd nodes and attempts to make the device tree look as it should. Some code is borrowed from the u-boot routines which do similiar things Also, now if no flat device tree is passed to kexec it will attempt to rebuild one from the /proc/device-tree file system to use for the kexec'ed kernel for both uImage and elf formats [ horms@verge.net.au: kernel_addr is now outside #ifdef WITH_GAMECUBE ] Signed-off-by: Matthew McClintock <msm@freescale.com> Signed-off-by: Simon Horman <horms@verge.net.au>