* [PATCH 0/2] ARM: kexec: Add dtb kexce support
@ 2012-09-07 8:40 Matthew Leach
2012-09-07 8:40 ` [PATCH 1/2] ARM: kexec: scan for dtb magic in segments Matthew Leach
2012-09-07 8:41 ` [PATCH 2/2] ARM: kexec: Check segment memory addresses Matthew Leach
0 siblings, 2 replies; 5+ messages in thread
From: Matthew Leach @ 2012-09-07 8:40 UTC (permalink / raw)
To: linux-arm-kernel
Currently the value of r2 that is passed to the new kernel when
performing a kexec() is hard coded to an address that is 16Kb before
the kernel image. A dtb file may be much larger and thus get corrupted
by the decompressor's page tables.
These patches, along with a set of kexec-tools patches, move the dtb
to a more sane location. The kernel will scan each segment for the dtb
magic within the first four bytes of each segment to identify the
physical address to pass through to the new kernel in r2.
Matthew Leach (2):
ARM: kexec: scan for dtb magic in segments
ARM: kexec: Check segment memory addresses
arch/arm/kernel/machine_kexec.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
--
1.7.12
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] ARM: kexec: scan for dtb magic in segments
2012-09-07 8:40 [PATCH 0/2] ARM: kexec: Add dtb kexce support Matthew Leach
@ 2012-09-07 8:40 ` Matthew Leach
2012-09-07 8:41 ` [PATCH 2/2] ARM: kexec: Check segment memory addresses Matthew Leach
1 sibling, 0 replies; 5+ messages in thread
From: Matthew Leach @ 2012-09-07 8:40 UTC (permalink / raw)
To: linux-arm-kernel
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>
---
arch/arm/kernel/machine_kexec.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index dfcdb9f..a6bbc0f 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -9,6 +9,7 @@
#include <linux/io.h>
#include <linux/irq.h>
#include <asm/pgtable.h>
+#include <linux/of_fdt.h>
#include <asm/pgalloc.h>
#include <asm/mmu_context.h>
#include <asm/cacheflush.h>
@@ -32,6 +33,22 @@ static atomic_t waiting_for_crash_ipi;
int machine_kexec_prepare(struct kimage *image)
{
+ struct kexec_segment *current_segment;
+ __be32 header;
+ int i, err;
+
+ /* No segment at default ATAGs address. try to locate
+ * a dtb using magic */
+ for (i = 0; i < image->nr_segments; i++) {
+ current_segment = &image->segment[i];
+
+ err = get_user(header, (__be32*)current_segment->buf);
+ if (err)
+ return err;
+
+ if (be32_to_cpu(header) == OF_DT_HEADER)
+ kexec_boot_atags = current_segment->mem;
+ }
return 0;
}
@@ -122,7 +139,9 @@ void machine_kexec(struct kimage *image)
kexec_start_address = image->start;
kexec_indirection_page = page_list;
kexec_mach_type = machine_arch_type;
- kexec_boot_atags = image->start - KEXEC_ARM_ZIMAGE_OFFSET + KEXEC_ARM_ATAGS_OFFSET;
+ if (!kexec_boot_atags)
+ kexec_boot_atags = image->start - KEXEC_ARM_ZIMAGE_OFFSET + KEXEC_ARM_ATAGS_OFFSET;
+
/* copy our kernel relocation code to the control code page */
memcpy(reboot_code_buffer,
--
1.7.12
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] ARM: kexec: Check segment memory addresses
2012-09-07 8:40 [PATCH 0/2] ARM: kexec: Add dtb kexce support Matthew Leach
2012-09-07 8:40 ` [PATCH 1/2] ARM: kexec: scan for dtb magic in segments Matthew Leach
@ 2012-09-07 8:41 ` Matthew Leach
2012-09-07 8:49 ` Russell King - ARM Linux
1 sibling, 1 reply; 5+ messages in thread
From: Matthew Leach @ 2012-09-07 8:41 UTC (permalink / raw)
To: linux-arm-kernel
Ensure that the memory regions that are set within the segments
correspond to physical contiguous memory regions.
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>
---
arch/arm/kernel/machine_kexec.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index a6bbc0f..524139a 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -8,6 +8,7 @@
#include <linux/reboot.h>
#include <linux/io.h>
#include <linux/irq.h>
+#include <linux/memblock.h>
#include <asm/pgtable.h>
#include <linux/of_fdt.h>
#include <asm/pgalloc.h>
@@ -42,6 +43,12 @@ int machine_kexec_prepare(struct kimage *image)
for (i = 0; i < image->nr_segments; i++) {
current_segment = &image->segment[i];
+ err = memblock_is_region_memory(current_segment->mem,
+ current_segment->memsz);
+ if (err)
+ return - EINVAL;
+
+
err = get_user(header, (__be32*)current_segment->buf);
if (err)
return err;
--
1.7.12
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] ARM: kexec: Check segment memory addresses
2012-09-07 8:41 ` [PATCH 2/2] ARM: kexec: Check segment memory addresses Matthew Leach
@ 2012-09-07 8:49 ` Russell King - ARM Linux
2012-09-07 10:04 ` Will Deacon
0 siblings, 1 reply; 5+ messages in thread
From: Russell King - ARM Linux @ 2012-09-07 8:49 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Sep 07, 2012 at 09:41:00AM +0100, Matthew Leach wrote:
> Ensure that the memory regions that are set within the segments
> correspond to physical contiguous memory regions.
>
> 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>
What about platforms which pull out bits of physical RAM from memblock
via arm_memblock_steal() ? Doesn't this mean such platforms will reduce
their available memory on each subsequent kexec?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] ARM: kexec: Check segment memory addresses
2012-09-07 8:49 ` Russell King - ARM Linux
@ 2012-09-07 10:04 ` Will Deacon
0 siblings, 0 replies; 5+ messages in thread
From: Will Deacon @ 2012-09-07 10:04 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Sep 07, 2012 at 09:49:38AM +0100, Russell King - ARM Linux wrote:
> On Fri, Sep 07, 2012 at 09:41:00AM +0100, Matthew Leach wrote:
> > Ensure that the memory regions that are set within the segments
> > correspond to physical contiguous memory regions.
> >
> > 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>
>
> What about platforms which pull out bits of physical RAM from memblock
> via arm_memblock_steal() ? Doesn't this mean such platforms will reduce
> their available memory on each subsequent kexec?
I don't think that will happen. All that kexec does is check that the
location where it wants to load the new kernel is physically contiguous -- the
memblock configuration is not inherited by the target kernel.
What *might* happen is that a memblock_steal on the host kernel could cause
the kexec to fail with -EINVAL if the area removed corresponds to the area
where the target kernel wants to be loaded. I think this is correct
behaviour, because we have no idea what the stolen region is being used for.
Will
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-09-07 10:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-07 8:40 [PATCH 0/2] ARM: kexec: Add dtb kexce support Matthew Leach
2012-09-07 8:40 ` [PATCH 1/2] ARM: kexec: scan for dtb magic in segments Matthew Leach
2012-09-07 8:41 ` [PATCH 2/2] ARM: kexec: Check segment memory addresses Matthew Leach
2012-09-07 8:49 ` Russell King - ARM Linux
2012-09-07 10:04 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).