aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Leach <matthew.leach@arm.com>2012-09-21 13:56:02 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-09-26 17:58:36 -0400
commit4cabd1d9625c7d88acd143f4021fbef75394f154 (patch)
tree3c232277c6bd94c7c4f17714de2104652735bdfb
parent559a593905e583fca23229b916c016e5211c6766 (diff)
ARM: 7539/1: kexec: scan for dtb magic in segments
This patch allows a dtb to be passed to a new kernel using the kexec mechinism. When loading segments from userspace, scan each segment's first four bytes for the dtb magic. If this is found set the kexec_boot_atags parameter to the relocate_kernel code to the phyical address of this segment. Reviewed-by: Simon Horman <horms@verge.net.au> Reviewed-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Matthew Leach <matthew.leach@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/kernel/machine_kexec.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index dfcdb9f7c126..dee34efca748 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -9,6 +9,7 @@
9#include <linux/io.h> 9#include <linux/io.h>
10#include <linux/irq.h> 10#include <linux/irq.h>
11#include <asm/pgtable.h> 11#include <asm/pgtable.h>
12#include <linux/of_fdt.h>
12#include <asm/pgalloc.h> 13#include <asm/pgalloc.h>
13#include <asm/mmu_context.h> 14#include <asm/mmu_context.h>
14#include <asm/cacheflush.h> 15#include <asm/cacheflush.h>
@@ -32,6 +33,24 @@ static atomic_t waiting_for_crash_ipi;
32 33
33int machine_kexec_prepare(struct kimage *image) 34int machine_kexec_prepare(struct kimage *image)
34{ 35{
36 struct kexec_segment *current_segment;
37 __be32 header;
38 int i, err;
39
40 /*
41 * No segment at default ATAGs address. try to locate
42 * a dtb using magic.
43 */
44 for (i = 0; i < image->nr_segments; i++) {
45 current_segment = &image->segment[i];
46
47 err = get_user(header, (__be32*)current_segment->buf);
48 if (err)
49 return err;
50
51 if (be32_to_cpu(header) == OF_DT_HEADER)
52 kexec_boot_atags = current_segment->mem;
53 }
35 return 0; 54 return 0;
36} 55}
37 56
@@ -122,7 +141,9 @@ void machine_kexec(struct kimage *image)
122 kexec_start_address = image->start; 141 kexec_start_address = image->start;
123 kexec_indirection_page = page_list; 142 kexec_indirection_page = page_list;
124 kexec_mach_type = machine_arch_type; 143 kexec_mach_type = machine_arch_type;
125 kexec_boot_atags = image->start - KEXEC_ARM_ZIMAGE_OFFSET + KEXEC_ARM_ATAGS_OFFSET; 144 if (!kexec_boot_atags)
145 kexec_boot_atags = image->start - KEXEC_ARM_ZIMAGE_OFFSET + KEXEC_ARM_ATAGS_OFFSET;
146
126 147
127 /* copy our kernel relocation code to the control code page */ 148 /* copy our kernel relocation code to the control code page */
128 memcpy(reboot_code_buffer, 149 memcpy(reboot_code_buffer,