Fix kexec on ARM by properly calling the relocation function
From: Michael Casadevall <michael.casadevall@canonical.com>
The kexec syscall function is broken on ARM due to it not properly calling
the relocation stub with the correct arguments. This patch puts machine_kexec
in line with the other architectures, and allows kexec to work peroply on ARM.
It has been tested on the versatile kernel successfully.
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index 440dc62..d16f6f4 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -23,6 +23,11 @@ extern unsigned long kexec_indirection_page;
extern unsigned long kexec_mach_type;
extern unsigned long kexec_boot_atags;
+typedef NORET_TYPE void (*relocate_new_kernel_t)(
+ unsigned long indirection_page,
+ unsigned long reboot_code_buffer,
+ unsigned long start_address) ATTRIB_NORET;
+
/*
* Provide a dummy crash_notes definition while crash dump arrives to arm.
* This prevents breakage of crash_notes attribute in kernel/ksysfs.c.
@@ -50,7 +55,7 @@ void machine_kexec(struct kimage *image)
unsigned long page_list;
unsigned long reboot_code_buffer_phys;
void *reboot_code_buffer;
-
+ relocate_new_kernel_t rnk;
cpu_proc_fin();
setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/
- cpu_reset(reboot_code_buffer_phys);
+
+ rnk = (relocate_new_kernel_t) reboot_code_buffer;
+ (*rnk)(page_list, reboot_code_buffer_phys, image->start);
}
--
1.6.0.4
--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team
01-20-2009, 04:17 PM
Tim Gardner
Fix kexec on ARM by properly calling the relocation function
Michael Casadevall wrote:
> From: Michael Casadevall <michael.casadevall@canonical.com>
>
> The kexec syscall function is broken on ARM due to it not properly calling
> the relocation stub with the correct arguments. This patch puts machine_kexec
> in line with the other architectures, and allows kexec to work peroply on ARM.
> It has been tested on the versatile kernel successfully.
>
> Signed-off-by: Michael Casadevall <michael.casadevall@canonical.com>
> ---
> arch/arm/kernel/machine_kexec.c | 11 +++++++++--
> 1 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
> index 440dc62..d16f6f4 100644
> --- a/arch/arm/kernel/machine_kexec.c
> +++ b/arch/arm/kernel/machine_kexec.c
> @@ -23,6 +23,11 @@ extern unsigned long kexec_indirection_page;
> extern unsigned long kexec_mach_type;
> extern unsigned long kexec_boot_atags;
>
> +typedef NORET_TYPE void (*relocate_new_kernel_t)(
> + unsigned long indirection_page,
> + unsigned long reboot_code_buffer,
> + unsigned long start_address) ATTRIB_NORET;
> +
> /*
> * Provide a dummy crash_notes definition while crash dump arrives to arm.
> * This prevents breakage of crash_notes attribute in kernel/ksysfs.c.
> @@ -50,7 +55,7 @@ void machine_kexec(struct kimage *image)
> unsigned long page_list;
> unsigned long reboot_code_buffer_phys;
> void *reboot_code_buffer;
> -
> + relocate_new_kernel_t rnk;
>
> page_list = image->head & PAGE_MASK;
>
> @@ -76,5 +81,7 @@ void machine_kexec(struct kimage *image)
>
> cpu_proc_fin();
> setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/
> - cpu_reset(reboot_code_buffer_phys);
> +
> + rnk = (relocate_new_kernel_t) reboot_code_buffer;
> + (*rnk)(page_list, reboot_code_buffer_phys, image->start);
> }
applied
--
Tim Gardner tim.gardner@canonical.com
--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team
01-22-2009, 01:11 PM
Tim Gardner
Fix kexec on ARM by properly calling the relocation function
Amit Kucheria wrote:
> Forwarding a patch to fix kexec on ARM. Comments sought.
>
> /Amit
> ---------- Forwarded message ----------
> From: Michael Casadevall <sonicmctails@gmail.com>
> Date: Tue, Jan 20, 2009 at 4:43 PM
> Subject: [PATCH] UBUNTU: [arm] Fix kexec on ARM by properly calling
> the relocation function
> To: kernel-team@lists.ubuntu.com
> Cc: Michael Casadevall <michael.casadevall@canonical.com>
>
>
> From: Michael Casadevall <michael.casadevall@canonical.com>
>
> The kexec syscall function is broken on ARM due to it not properly calling
> the relocation stub with the correct arguments. This patch puts machine_kexec
> in line with the other architectures, and allows kexec to work peroply on ARM.
> It has been tested on the versatile kernel successfully.
>
> Signed-off-by: Michael Casadevall <michael.casadevall@canonical.com>
> ---
> arch/arm/kernel/machine_kexec.c | 11 +++++++++--
> 1 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
> index 440dc62..d16f6f4 100644
> --- a/arch/arm/kernel/machine_kexec.c
> +++ b/arch/arm/kernel/machine_kexec.c
> @@ -23,6 +23,11 @@ extern unsigned long kexec_indirection_page;
> extern unsigned long kexec_mach_type;
> extern unsigned long kexec_boot_atags;
>
> +typedef NORET_TYPE void (*relocate_new_kernel_t)(
> + unsigned long indirection_page,
> + unsigned long reboot_code_buffer,
> + unsigned long start_address) ATTRIB_NORET;
> +
> /*
> * Provide a dummy crash_notes definition while crash dump arrives to arm.
> * This prevents breakage of crash_notes attribute in kernel/ksysfs.c.
> @@ -50,7 +55,7 @@ void machine_kexec(struct kimage *image)
> unsigned long page_list;
> unsigned long reboot_code_buffer_phys;
> void *reboot_code_buffer;
> -
> + relocate_new_kernel_t rnk;
>
> page_list = image->head & PAGE_MASK;
>
> @@ -76,5 +81,7 @@ void machine_kexec(struct kimage *image)
>
> cpu_proc_fin();
> setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/
> - cpu_reset(reboot_code_buffer_phys);
> +
> + rnk = (relocate_new_kernel_t) reboot_code_buffer;
> + (*rnk)(page_list, reboot_code_buffer_phys, image->start);
> }
> --
> 1.6.0.4
>
--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team
01-24-2009, 07:02 PM
Russell King - ARM Linux
Fix kexec on ARM by properly calling the relocation function
On Thu, Jan 22, 2009 at 10:33:39AM +0200, Amit Kucheria wrote:
> Forwarding a patch to fix kexec on ARM. Comments sought.
This patch can't work - with how it is, you'll be booting a kernel with
the CPU MMU enabled. Kernels must be booted with the CPU MMU disabled
as per the 'booting.txt' documentation, which can be found in the kernel
source and on my website.
In fact, this patch looks entirely bogus. The reboot code
(arch/arm/kernel/relocate_kernel.S) does not take any arguments - in
fact, the first two instructions load into r0,r1 which, if arguments
were passed, would wipe out the first two arguments.
So no, this patch looks bogus.
--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team
01-24-2009, 07:10 PM
Russell King - ARM Linux
Fix kexec on ARM by properly calling the relocation function
On Sat, Jan 24, 2009 at 08:02:59PM +0000, Russell King - ARM Linux wrote:
> On Thu, Jan 22, 2009 at 10:33:39AM +0200, Amit Kucheria wrote:
> > Forwarding a patch to fix kexec on ARM. Comments sought.
>
> This patch can't work - with how it is, you'll be booting a kernel with
> the CPU MMU enabled. Kernels must be booted with the CPU MMU disabled
> as per the 'booting.txt' documentation, which can be found in the kernel
> source and on my website.
>
> In fact, this patch looks entirely bogus. The reboot code
> (arch/arm/kernel/relocate_kernel.S) does not take any arguments - in
> fact, the first two instructions load into r0,r1 which, if arguments
> were passed, would wipe out the first two arguments.
>
> So no, this patch looks bogus.
And having looked at the ubuntu git tree, relocate_kernel.S is no
different from the mainline version. So this patch is definitely
bogus.
--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team
01-26-2009, 03:40 PM
Michael Casadevall
Fix kexec on ARM by properly calling the relocation function
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Russell King - ARM Linux wrote:
> On Thu, Jan 22, 2009 at 10:33:39AM +0200, Amit Kucheria wrote:
>> Forwarding a patch to fix kexec on ARM. Comments sought.
>
> This patch can't work - with how it is, you'll be booting a kernel with
> the CPU MMU enabled. Kernels must be booted with the CPU MMU disabled
> as per the 'booting.txt' documentation, which can be found in the kernel
> source and on my website.
>
I was unaware of this document when I created the patch, I'll make sure to
refer to it when I take another stab at resolving this issue.
> In fact, this patch looks entirely bogus. The reboot code
> (arch/arm/kernel/relocate_kernel.S) does not take any arguments - in
> fact, the first two instructions load into r0,r1 which, if arguments
> were passed, would wipe out the first two arguments.
>
> So no, this patch looks bogus.
I tested the patch in QEMU as I have no way to debug against my current
hardware; it seems QEMU caused a false positive with respect to testing this
patch; both the baseline 2.6.28.1 kernel, and the Ubuntu git tree failed to
successfully use kexec without this patch. Once applied, I was able to
successfully use kexec to load a secondary kernel with both kernel trees.
As far as I can tell, debugging against QEMU, the baseline kernel never
manages to enter the relocation stub, so I'm not sure whats going on there at
all, and my patch only fixes it via a fluke, so I hope you accept my apology
for the bad patch.
Michael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team
01-28-2009, 01:17 PM
Daniel Silverstone
Fix kexec on ARM by properly calling the relocation function
On Mon, 2009-01-26 at 11:40 -0500, Michael Casadevall wrote:
> >> Forwarding a patch to fix kexec on ARM. Comments sought.
> > This patch can't work - with how it is, you'll be booting a kernel with
> > the CPU MMU enabled. Kernels must be booted with the CPU MMU disabled
> > as per the 'booting.txt' documentation, which can be found in the kernel
> > source and on my website.
> I was unaware of this document when I created the patch, I'll make sure to
> refer to it when I take another stab at resolving this issue.
Since that details register entry requirements etc. Specifically, check
out section 10 of the document.
Regards,
Daniel.
--
Daniel Silverstone http://www.simtec.co.uk/
PGP mail accepted and encouraged. Key Id: 2BC8 4016 2068 7895
--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team
01-28-2009, 01:30 PM
Russell King - ARM Linux
Fix kexec on ARM by properly calling the relocation function
On Wed, Jan 28, 2009 at 02:17:28PM +0000, Daniel Silverstone wrote:
> On Mon, 2009-01-26 at 11:40 -0500, Michael Casadevall wrote:
> > >> Forwarding a patch to fix kexec on ARM. Comments sought.
> > > This patch can't work - with how it is, you'll be booting a kernel with
> > > the CPU MMU enabled. Kernels must be booted with the CPU MMU disabled
> > > as per the 'booting.txt' documentation, which can be found in the kernel
> > > source and on my website.
> > I was unaware of this document when I created the patch, I'll make sure to
> > refer to it when I take another stab at resolving this issue.
>
> Also you should take a read of:
>
> http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html
>
> Since that details register entry requirements etc. Specifically, check
> out section 10 of the document.
And my version doesn't?
- CPU register settings
r0 = 0,
r1 = machine type number discovered in (3) above.
r2 = physical address of tagged list in system RAM.
--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team
01-28-2009, 02:59 PM
Daniel Silverstone
Fix kexec on ARM by properly calling the relocation function
On Wed, 2009-01-28 at 14:30 +0000, Russell King - ARM Linux wrote:
> > > > This patch can't work - with how it is, you'll be booting a kernel with
> > > > the CPU MMU enabled. Kernels must be booted with the CPU MMU disabled
> > > > as per the 'booting.txt' documentation, which can be found in the kernel
> > > > source and on my website.
> > > I was unaware of this document when I created the patch, I'll make sure to
> > > refer to it when I take another stab at resolving this issue.
> > Also you should take a read of:
> > http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html
> > Since that details register entry requirements etc. Specifically, check
> > out section 10 of the document.
> And my version doesn't?
> - CPU register settings
> r0 = 0,
> r1 = machine type number discovered in (3) above.
> r2 = physical address of tagged list in system RAM.
Sorry, I was just asked to punt the reference to the list :-) I
certainly didn't intend to suggest your document was incomplete.
D.
--
Daniel Silverstone http://www.simtec.co.uk/
PGP mail accepted and encouraged. Key Id: 2BC8 4016 2068 7895
--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team
01-28-2009, 07:41 PM
Loïc Minier
Fix kexec on ARM by properly calling the relocation function
Hi,
On Tue, Jan 20, 2009, Michael Casadevall wrote:
> The kexec syscall function is broken on ARM
According to this thread, the openmoko folks seem to have it working:
http://article.gmane.org/gmane.comp.handhelds.openmoko.devel/2521
--
Loïc Minier
--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team