[PATCH v8 06/13] powerpc: Generalize elf64_apply_relocate_add.

2016-09-06 Thread Thiago Jung Bauermann
When apply_relocate_add is called, modules are already loaded at their final location in memory so Elf64_Shdr.sh_addr can be used for accessing the section contents as well as the base address for relocations. This is not the case for kexec's purgatory, because it will only be copied to its final

[PATCH v8 05/13] powerpc: Factor out relocation code from module_64.c to elf_util_64.c.

2016-09-06 Thread Thiago Jung Bauermann
The kexec_file_load system call needs to relocate the purgatory, so factor out the module relocation code so that it can be shared. This patch's purpose is to move the ELF relocation logic from apply_relocate_add to elf_util_64.c with as few changes as possible. The following changes were needed:

[PATCH v8 00/13] kexec_file_load implementation for PowerPC

2016-09-06 Thread Thiago Jung Bauermann
When Stephen Rothwell added this patch series to the linux-next tree, he found out that it fails to cross build a ppc64 LE kernel using a ppc64 BE host. This version of the series fixes that problem with a change in arch/powerpc/purgatory/Makefile. While I was at it I noticed that it is not necess

[PATCH v8 11/13] powerpc: Add support for loading ELF kernels with kexec_file_load.

2016-09-06 Thread Thiago Jung Bauermann
This uses all the infrastructure built up by the previous patches in the series to load an ELF vmlinux file and an initrd. It uses the flattened device tree at initial_boot_params as a base and adjusts memory reservations and its /chosen node for the next kernel. Signed-off-by: Thiago Jung Bauerma

[PATCH v8 03/13] kexec_file: Factor out kexec_locate_mem_hole from kexec_add_buffer.

2016-09-06 Thread Thiago Jung Bauermann
kexec_locate_mem_hole will be used by the PowerPC kexec_file_load implementation to find free memory for the purgatory stack. Signed-off-by: Thiago Jung Bauermann Acked-by: Dave Young --- include/linux/kexec.h | 1 + kernel/kexec_file.c | 25 - 2 files changed, 21 ins

[PATCH v8 07/13] powerpc: Adapt elf64_apply_relocate_add for kexec_file_load.

2016-09-06 Thread Thiago Jung Bauermann
Extend elf64_apply_relocate_add to support relative symbols. This is necessary because there is a difference between how the module loading mechanism and the kexec purgatory loading code use Elf64_Sym.st_value at relocation time: the former changes st_value to point to the absolute memory address b

[PATCH v8 13/13] powerpc: Enable CONFIG_KEXEC_FILE in powerpc server defconfigs.

2016-09-06 Thread Thiago Jung Bauermann
Enable CONFIG_KEXEC_FILE in powernv_defconfig, ppc64_defconfig and pseries_defconfig. It depends on CONFIG_CRYPTO_SHA256=y, so add that as well. Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/configs/powernv_defconfig | 2 ++ arch/powerpc/configs/ppc64_defconfig | 2 ++ arch/powerpc/co

[PATCH v8 12/13] powerpc: Add purgatory for kexec_file_load implementation.

2016-09-06 Thread Thiago Jung Bauermann
This purgatory implementation comes from kexec-tools, almost unchanged. The only changes were that the sha256_regions global variable was renamed to sha_regions to match what kexec_file_load expects, and to use the sha256.c file from x86's purgatory to avoid adding yet another SHA-256 implementati

[PATCH v8 10/13] powerpc: Add code to work with device trees in kexec_file_load.

2016-09-06 Thread Thiago Jung Bauermann
kexec_file_load needs to set up the device tree that will be used by the next kernel and check whether it provides a console that can be used by the purgatory. [a...@linux-foundation.org: coding-style fixes] Signed-off-by: Thiago Jung Bauermann Signed-off-by: Andrew Morton --- arch/powerpc/incl

[PATCH v8 04/13] powerpc: Change places using CONFIG_KEXEC to use CONFIG_KEXEC_CORE instead.

2016-09-06 Thread Thiago Jung Bauermann
Commit 2965faa5e03d ("kexec: split kexec_load syscall from kexec core code") introduced CONFIG_KEXEC_CORE so that CONFIG_KEXEC means whether the kexec_load system call should be compiled-in and CONFIG_KEXEC_FILE means whether the kexec_file_load system call should be compiled-in. These options can

[PATCH v8 01/13] kexec_file: Allow arch-specific memory walking for kexec_add_buffer

2016-09-06 Thread Thiago Jung Bauermann
Allow architectures to specify a different memory walking function for kexec_add_buffer. x86 uses iomem to track reserved memory ranges, but PowerPC uses the memblock subsystem. Signed-off-by: Thiago Jung Bauermann Acked-by: Dave Young Acked-by: Balbir Singh --- include/linux/kexec.h | 29 ++

[PATCH v8 08/13] powerpc: Add functions to read ELF files of any endianness.

2016-09-06 Thread Thiago Jung Bauermann
A little endian kernel might need to kexec a big endian kernel (the opposite is less likely but could happen as well), so we can't just cast the buffer with the binary to ELF structs and use them as is done elsewhere. This patch adds functions which do byte-swapping as necessary when populating th

[PATCH v8 02/13] kexec_file: Change kexec_add_buffer to take kexec_buf as argument.

2016-09-06 Thread Thiago Jung Bauermann
This is done to simplify the kexec_add_buffer argument list. Adapt all callers to set up a kexec_buf to pass to kexec_add_buffer. In addition, change the type of kexec_buf.buffer from char * to void *. There is no particular reason for it to be a char *, and the change allows us to get rid of 3 ex

[PATCH v8 09/13] powerpc: Implement kexec_file_load.

2016-09-06 Thread Thiago Jung Bauermann
arch_kexec_walk_mem and arch_kexec_apply_relocations_add are used by generic kexec code, while setup_purgatory is powerpc-specific and sets runtime variables needed by the powerpc purgatory implementation. Signed-off-by: Josh Sklar Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/Kconfig

[PATCH] Cleanup: Use a negative number for uninitialized file descriptors

2016-09-06 Thread Petr Tesarik
Do not use zero to denote an invalid file descriptor. First, zero is a valid value, although quite unlikely to be used for anything except standard input. Second, open(2) returns a negative value on failure, so there are already checks for a negative value in some places. The purpose of this pat

[PATCH v3 0/9] ima: carry the measurement list across kexec

2016-09-06 Thread Mimi Zohar
The TPM PCRs are only reset on a hard reboot. In order to validate a TPM's quote after a soft reboot (eg. kexec -e), the IMA measurement list of the running kernel must be saved and then restored on the subsequent boot, possibly of a different architecture. The existing securityfs binary_runtime_

[PATCH v3 2/9] ima: permit duplicate measurement list entries

2016-09-06 Thread Mimi Zohar
Measurements carried across kexec need to be added to the IMA measurement list, but should not prevent measurements of the newly booted kernel from being added to the measurement list. This patch adds support for allowing duplicate measurements. The "boot_aggregate" measurement entry is the delimi

[PATCH v3 3/9] ima: maintain memory size needed for serializing the measurement list

2016-09-06 Thread Mimi Zohar
In preparation for serializing the binary_runtime_measurements, this patch maintains the amount of memory required. Changelog v3: - include the ima_kexec_hdr size in the binary_runtime_measurement size. Signed-off-by: Mimi Zohar --- security/integrity/ima/Kconfig | 12 + security/in

[PATCH v3 5/9] ima: on soft reboot, save the measurement list

2016-09-06 Thread Mimi Zohar
From: Thiago Jung Bauermann This patch uses the kexec buffer passing mechanism to pass the serialized IMA binary_runtime_measurements to the next kernel. Changelog v3: - Request a kexec segment for storing the measurement list a half page, not a full page, more than needed for additional measure

[PATCH v3 9/9] ima: platform-independent hash value

2016-09-06 Thread Mimi Zohar
From: Andreas Steffen For remote attestion it is important for the ima measurement values to be platform-independent. Therefore integer fields to be hashed must be converted to canonical format. Changelog: - Define canonical format as little endian (Mimi) Signed-off-by: Andreas Steffen Signed-

[PATCH v3 8/9] ima: define a canonical binary_runtime_measurements list format

2016-09-06 Thread Mimi Zohar
The IMA binary_runtime_measurements list is currently in platform native format. To allow restoring a measurement list carried across kexec with a different endianness than the targeted kernel, this patch defines little-endian as the canonical format. For big endian systems wanting to save/restor

[PATCH v3 4/9] ima: serialize the binary_runtime_measurements

2016-09-06 Thread Mimi Zohar
The TPM PCRs are only reset on a hard reboot. In order to validate a TPM's quote after a soft reboot (eg. kexec -e), the IMA measurement list of the running kernel must be saved and restored on boot. This patch serializes the IMA measurement list in the binary_runtime_measurements format. Signed

[PATCH v3 6/9] ima: store the builtin/custom template definitions in a list

2016-09-06 Thread Mimi Zohar
The builtin and single custom templates are currently stored in an array. In preparation for being able to restore a measurement list containing multiple builtin/custom templates, this patch stores the builtin and custom templates as a linked list. This will permit defining more than one custom t

Re: [PATCH v24 0/9] arm64: add kdump support

2016-09-06 Thread Marc Zyngier
On 05/09/16 13:42, Manish Jaggi wrote: > > > On 09/05/2016 01:45 PM, AKASHI Takahiro wrote: >> [Cc: Marc] >> >> On Fri, Sep 02, 2016 at 06:23:25PM +0530, Manish Jaggi wrote: >>> >>> >>> On 08/31/2016 11:01 AM, AKASHI Takahiro wrote: Manish, Thank you for testing my kdump and report

Re: [PATCH v24 0/9] arm64: add kdump support

2016-09-06 Thread Manish Jaggi
On 09/06/2016 09:03 PM, Marc Zyngier wrote: > On 05/09/16 13:42, Manish Jaggi wrote: >> >> >> On 09/05/2016 01:45 PM, AKASHI Takahiro wrote: >>> [Cc: Marc] >>> >>> On Fri, Sep 02, 2016 at 06:23:25PM +0530, Manish Jaggi wrote: On 08/31/2016 11:01 AM, AKASHI Takahiro wrote: > Man

Re: [PATCH v24 0/9] arm64: add kdump support

2016-09-06 Thread Marc Zyngier
On 06/09/16 17:15, Manish Jaggi wrote: > >>> In my setup the GICD_CTRL[RWP] bit is not cleared in the >>> crashkernels' distributor init function. >> >> Which instance is failing? The initial one (just after the initial >> disable)? Or the one called from gic_dist_config()? >> > In crash kernel, w

Re: [PATCH v4 3/5] kexec_file: Allow skipping checksum calculation for some segments.

2016-09-06 Thread Eric W. Biederman
Thiago Jung Bauermann writes: 2> Add skip_checksum member to struct kexec_buf to specify whether the > corresponding segment should be part of the checksum calculation. > > The next patch will add a way to update segments after a kimage is loaded. > Segments that will be updated in this way shoul

[PATCH v26 0/7] arm64: add kdump support

2016-09-06 Thread AKASHI Takahiro
v26-specific note: After a comment from Rob[0], an idea of adding "linux,usable-memory-range" was dropped. Instead, an existing "reserved-memory" node will be used to limit usable memory ranges on crash dump kernel. This works not only on UEFI/ACPI systems but also on DT-only sy

[PATCH v26 2/7] arm64: kdump: implement machine_crash_shutdown()

2016-09-06 Thread AKASHI Takahiro
Primary kernel calls machine_crash_shutdown() to shut down non-boot cpus and save registers' status in per-cpu ELF notes before starting crash dump kernel. See kernel_kexec(). Even if not all secondary cpus have shut down, we do kdump anyway. As we don't have to make non-boot(crashed) cpus offline

[PATCH v26 1/7] arm64: kdump: reserve memory for crash dump kernel

2016-09-06 Thread AKASHI Takahiro
On the startup of primary kernel, the memory region used by crash dump kernel must be specified by "crashkernel=" kernel parameter. reserve_crashkernel() will allocate and reserve the region for later use. User space tools, like kexec-tools, will be able to find that region as - "Crash ker

[PATCH v26 4/7] arm64: kdump: add VMCOREINFO's for user-space coredump tools

2016-09-06 Thread AKASHI Takahiro
For the current crash utility, we need to know, at least, - kimage_voffset - PHYS_OFFSET to handle the contents of core dump file (/proc/vmcore) correctly due to the introduction of KASLR (CONFIG_RANDOMIZE_BASE) in v4.6. This patch puts them as VMCOREINFO's into the file. - VA_BITS is also a

[PATCH v26 3/7] arm64: kdump: add kdump support

2016-09-06 Thread AKASHI Takahiro
On crash dump kernel, all the information about primary kernel's system memory (core image) is available in elf core header. The primary kernel will set aside this header with reserve_elfcorehdr() at boot time and inform crash dump kernel of its location via a new device-tree property, "linux,elfco

[PATCH v26 5/7] arm64: kdump: enable kdump in the arm64 defconfig

2016-09-06 Thread AKASHI Takahiro
Signed-off-by: AKASHI Takahiro --- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index eadf485..e181132 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -77,6 +77,7 @@ CON

[PATCH v26 6/7] arm64: kdump: update a kernel doc

2016-09-06 Thread AKASHI Takahiro
This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt. Signed-off-by: AKASHI Takahiro Reviewed-by: Baoquan He Acked-by: Dave Young --- Documentation/kdump/kdump.txt | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Documentation/k

[PATCH v26 7/7] Documentation: dt: chosen properties for arm64 kdump

2016-09-06 Thread AKASHI Takahiro
From: James Morse Add documentation for linux,crashkernel-base and crashkernel-size, linux,elfcorehdr used by arm64 kexec/kdump to decribe the kdump reserved area, and the elfcorehdr's location within it. Signed-off-by: James Morse [takahiro.aka...@linaro.org: added "linux,crash

[PATCH v3 1/8] arm64: identify PHYS_OFFSET correctly

2016-09-06 Thread AKASHI Takahiro
Due to the kernel patch[1], the current code will not be able to identify the correct value of PHYS_OFFSET if some "reserved" memory region, which is likely to be UEFI runtime services code/data, exists at an address below the first "System RAM" regions. This patch fixes this issue. Signed-off-by

[PATCH v3 0/8] (kexec-tools) arm64: add kdump support

2016-09-06 Thread AKASHI Takahiro
My kernel patches of kdump suport on arm64 are currently under reviews. This patchset is synced with them (v26 [1]) and provides necessary changes for kexec-tools. It should be applied on top of Geoff's kexec-tools patches v5[2] along with a bugfix[3]. [1] http://lists.infradead.org/pipermail/li

[PATCH v3 6/8] arm64: kdump: set up other segments

2016-09-06 Thread AKASHI Takahiro
We make sure that all the other segments, initrd and device-tree blob, also be loaded into the reserved memory of crash dump kernel. Signed-off-by: AKASHI Takahiro --- kexec/arch/arm64/kexec-arm64.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec/arch/arm64/kexec-ar

[PATCH v3 8/8] arm64: kdump: Add support for binary image files

2016-09-06 Thread AKASHI Takahiro
From: Pratyush Anand This patch adds support to use binary image ie arch/arm64/boot/Image with kdump. Signed-off-by: Pratyush Anand [takahiro.aka...@linaro.org: a bit reworked] Signed-off-by: AKASHI Takahiro --- kexec/arch/arm64/kexec-image-arm64.c | 12 1 file changed, 12 insert

[PATCH v3 7/8] arm64: kdump: add DT properties to crash dump kernel's dtb

2016-09-06 Thread AKASHI Takahiro
We pass the following properties to crash dump kernel: /chosen/linux,elfcorehdr: elf core header segment, same as "elfcorehdr=" as on other archs /reserved-memory/crash_dump@xx: any memory regions to be dumped into /proc/vmcore Then,

[PATCH v3 4/8] arm64: kdump: add elf core header segment

2016-09-06 Thread AKASHI Takahiro
Elf core header contains the information necessary for the coredump of the 1st kernel, including its physcal memory layout as well as cpu register states at the panic. The segment is allocated inside the reserved memory of crash dump kernel. Signed-off-by: AKASHI Takahiro --- kexec/arch/arm64/cr

[PATCH v3 3/8] arm64: kdump: identify memory regions

2016-09-06 Thread AKASHI Takahiro
The following regions need to be identified for later use: a) memory regions which belong to the 1st kernel b) usable memory reserved for crash dump kernel We go through /proc/iomem to find out a) and b) which are marked as "System RAM" and "Crash kernel", respectively. Signed-off-by: AKASHI Ta

[PATCH v3 2/8] kexec: generalize and rename get_kernel_stext_sym()

2016-09-06 Thread AKASHI Takahiro
From: Pratyush Anand get_kernel_stext_sym() has been defined for both arm and i386. Other architecture might need some other kernel symbol address. Therefore rewrite this function as generic function to get any kernel symbol address. More over, kallsyms is not arch specific representation, there

Re: [PATCH v26 0/7] arm64: add kdump support

2016-09-06 Thread AKASHI Takahiro
On Wed, Sep 07, 2016 at 01:29:02PM +0900, AKASHI Takahiro wrote: > v26-specific note: After a comment from Rob[0], an idea of adding > "linux,usable-memory-range" was dropped. Instead, an existing > "reserved-memory" node will be used to limit usable memory ranges > on crash dump ke

[PATCH v3 5/8] arm64: kdump: set up kernel image segment

2016-09-06 Thread AKASHI Takahiro
On arm64, we can use the same kernel image as 1st kernel, but we have to modify the entry point as well as segments' addresses in the kernel's elf header in order to load them into correct places. Signed-off-by: AKASHI Takahiro --- kexec/arch/arm64/crashdump-arm64.c | 23 +++

Re: [PATCH v1] kdump, vmcoreinfo: report memory sections virtual addresses

2016-09-06 Thread AKASHI Takahiro
On Mon, Aug 29, 2016 at 06:11:37PM +0800, Baoquan He wrote: > Hi Thomas, > > I used below code and it works. Since using VMCOREINFO_NUMBER can reuse > the existing struct number_table to import the data. It makes change > easier. But the place could be next to KERNEL_IMAGE_SIZE, or as your > patch

Re: [PATCH v1] kdump, vmcoreinfo: report memory sections virtual addresses

2016-09-06 Thread Baoquan He
On 09/07/16 at 03:09pm, AKASHI Takahiro wrote: > On Mon, Aug 29, 2016 at 06:11:37PM +0800, Baoquan He wrote: > > Hi Thomas, > > > > I used below code and it works. Since using VMCOREINFO_NUMBER can reuse > > the existing struct number_table to import the data. It makes change > > easier. But the p