Kexec support for PPC440x
Subsystems (3)
RFC PATCH 1/1 Kexec support for PPC440x
KEXEC Support for ppc440X
The patch adds kexec support for PPC440x based boards. This work is based on the KEXEC patches for FSL BookE.
The FSL BookE patch and the code flow could be found at the link below:
http://patchwork.ozlabs.org/patch/49359/
We invalidate all the TLB entries except the one this code is run from, and create a 1:1 mapping for 0-2GiB in blocks of 256M. Later we jump to the 1:1 mapping.
I have tested this patches on Ebony and Sequoia boards. It would be great if somebody could test this on the other boards.
--- arch/powerpc/Kconfig | 2 arch/powerpc/include/asm/kexec.h | 2 arch/powerpc/kernel/44x_kexec_mapping.S | 66 ++++++++++++++++++++++++++++++++ arch/powerpc/kernel/misc_32.S | 22 ++++++++++ 4 files changed, 90 insertions(+), 2 deletions(-)
arch/powerpc/Kconfig +1 -1
@@ -349,7 +349,7 @@ config ARCH_ENABLE_MEMORY_HOTREMOVE config KEXEC bool "kexec system call (EXPERIMENTAL)" - depends on (PPC_BOOK3S || FSL_BOOKE) && EXPERIMENTAL + depends on (PPC_BOOK3S || FSL_BOOKE || (44x && !SMP && !47x)) && EXPERIMENTAL help kexec is a system call that implements the ability to shutdown your current kernel, and to start another kernel. It is like a reboot
arch/powerpc/include/asm/kexec.h +1 -1
@@ -2,7 +2,7 @@#define _ASM_POWERPC_KEXEC_H#ifdef __KERNEL__ -#ifdef CONFIG_FSL_BOOKE +#if defined(CONFIG_FSL_BOOKE ) || defined(CONFIG_44x)/* * On FSL-BookE we setup a 1:1 mapping which covers the first 2GiB of memory
arch/powerpc/kernel/44x_kexec_mapping.S new file +66 -0
66 lines not on this page · raw message
arch/powerpc/kernel/misc_32.S +22 -0
@@ -736,6 +736,28 @@ relocate_new_kernel: mr r5, r31 li r0, 0 +#elif defined(CONFIG_44x) && !defined(CONFIG_47x) + + mr r29, r3 + mr r30, r4 + mr r31, r5 + +#include "44x_kexec_mapping.S" + + mr r3, r29 + mr r4, r30 + mr r5, r31 + + li r0, 0 + + /* Jump back to the 1:1 address */ + mr r8, r0 + mtspr SPRN_SRR1, r8 + addi r8, r4, 1f - relocate_new_kernel + mtspr SPRN_SRR0, r8 + sync + rfi +1: #else li r0, 0
Quoted 4 lines · Suzuki Poulose
Index:
powerpc/arch/powerpc/kernel/44x_kexec_mapping.S
===================================================================arch/powerpc/kernel/44x_kexec_mapping.S new file +0
-0
....
arch/powerpc/kernel/44x_kexec_mapping.S line 24
Quoted 4 lines
+ *
+ */arch/powerpc/kernel/44x_kexec_mapping.S new file +2
-0+ bl nxtins /* Find our address */ +nxtins: mflr r5 /* Make it accessible */
Please don't mix labels and instructions.
Quoted 1 line
+ tlbsx r23,0,r5 /* Find entry we are in */
using tabs instead of spaces would make it look nice. Please also separate the arguments of the instruction i.e.
tlbsx r23, 0, r5
Quoted 5 lines
Index:
powerpc/arch/powerpc/kernel/misc_32.S
===================================================================
arch/powerpc/kernel/misc_32.S relocate_new_kernel: · line 745
Quoted 10 lines
arch/powerpc/kernel/misc_32.S +7
-0@@ -736,6 +736,28 @@ relocate_new_kernel: mr r5, r31 li r0, 0 +#elif defined(CONFIG_44x) && !defined(CONFIG_47x) + + mr r29, r3 + mr r30, r4 + mr r31, r5 + +#include "44x_kexec_mapping.S"
The way you setup the 1:1 mapping should be close to what you are doing on kernel entry. Isn't it possible to include the file here and in the entry code?
Sebastian
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 8 lines · Sebastian Andrzej Siewior
Quoted 4 lines · Suzuki Poulose
Index:
powerpc/arch/powerpc/kernel/44x_kexec_mapping.S
===================================================================arch/powerpc/kernel/44x_kexec_mapping.S new file +0
-0....
Quoted 6 lines
Quoted 4 lines
+ *
+ */
+ bl nxtins /* Find our address */
+nxtins: mflr r5 /* Make it accessible */Please don't mix labels and instructions.
OK.
Quoted 5 lines
Quoted 2 lines
+ tlbsx r23,0,r5 /* Find entry we are in */
using tabs instead of spaces would make it look nice. Please also separate the arguments of the instruction i.e. tlbsx r23, 0, r5
Sure.
Quoted 9 lines
Quoted 9 lines
Index:
powerpc/arch/powerpc/kernel/misc_32.S
===================================================================arch/powerpc/kernel/misc_32.S +0
-0@@ -736,6 +736,28 @@ relocate_new_kernel:mr r5, r31
Quoted 12 lines
arch/powerpc/kernel/misc_32.S relocate_new_kernel: · line 745
Quoted 8 lines
li r0, 0
arch/powerpc/kernel/misc_32.S +7
-0+#elif defined(CONFIG_44x) && !defined(CONFIG_47x) + + mr r29, r3 + mr r30, r4 + mr r31, r5 + +#include "44x_kexec_mapping.S"The way you setup the 1:1 mapping should be close to what you are doing on kernel entry.Isn't it possible to include the file here and in the entry code?
I will make this change and resend the patch.
Thanks
Suzuki
Quoted 45 lines · Suzuki Poulose
Quoted 8 lines · Sebastian Andrzej Siewior
Quoted 4 lines · Suzuki Poulose
Index:
powerpc/arch/powerpc/kernel/44x_kexec_mapping.S
===================================================================arch/powerpc/kernel/44x_kexec_mapping.S new file +0
-0....
Quoted 6 lines
Quoted 4 lines
+ *
+ */
+ bl nxtins /* Find our address */
+nxtins: mflr r5 /* Make it accessible */Please don't mix labels and instructions.
OK.
Quoted 5 lines
Quoted 2 lines
+ tlbsx r23,0,r5 /* Find entry we are in */
using tabs instead of spaces would make it look nice. Please also separate the arguments of the instruction i.e. tlbsx r23, 0, r5
Sure.
Quoted 9 lines
Quoted 9 lines
Index:
powerpc/arch/powerpc/kernel/misc_32.S
===================================================================arch/powerpc/kernel/misc_32.S +0
-0@@ -736,6 +736,28 @@ relocate_new_kernel:mr r5, r31
Quoted 12 lines
arch/powerpc/kernel/misc_32.S relocate_new_kernel: · line 745
Quoted 8 lines
li r0, 0
arch/powerpc/kernel/misc_32.S +7
-0+#elif defined(CONFIG_44x) && !defined(CONFIG_47x) + + mr r29, r3 + mr r30, r4 + mr r31, r5 + +#include "44x_kexec_mapping.S"The way you setup the 1:1 mapping should be close to what you are doing on kernel entry.Isn't it possible to include the file here and in the entry code?
Quoted 1 line
I will make this change and resend the patch.
I took a look at the way we do it at kernel entry. It looks more cleaner to leave it untouched. Especially, when we add the support for 47x in the future, the code
will become more unreadable.
What do you think ?
Thanks
Suzuki
Quoted 8 lines
Thanks
Suzuki
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Quoted 11 lines · Suzuki Poulose
Quoted 5 lines
Quoted 3 lines
The way you setup the 1:1 mapping should be close to what you are doing on kernel entry.Isn't it possible to include the file here and in the entry code?
I will make this change and resend the patch.
I took a look at the way we do it at kernel entry. It looks more cleaner to leave it untouched. Especially, when we add the support for 47x in the future, the code
will become more unreadable.What do you think ?
So the entry code has one 256MiB mapping, you need 8 of those. Entry goes for TLB 63 and you need to be flexible and avoid TLB 63 :). So after all you don't have that much in common with the entry code. If
you look at the FSL-book code then you will notice that I tried to share
some code.
I don't understand why you don't flip the address space bit. On fsl we setup the tmp mapping in the "other address" space so we don't have two mappings for the same address. The entry code could be doing this with STS bit, I'm not sure.
If you want to keep your tiny mmu flip code instead of merging with the entry code then please don't put it into a separate file. The only reason why I did it, is to have the code once since I can't branch to it and I wanted to share code.
Quoted 4 lines
Thanks
Suzuki
Sebastian
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 18 lines · Sebastian Andrzej Siewior
Quoted 11 lines · Suzuki Poulose
Quoted 5 lines
Quoted 3 lines
The way you setup the 1:1 mapping should be close to what you are doing on kernel entry.Isn't it possible to include the file here and in the entry code?
I will make this change and resend the patch.
I took a look at the way we do it at kernel entry. It looks more cleaner to leave it untouched. Especially, when we add the support for 47x in the future, the code will become more unreadable.
What do you think ?
So the entry code has one 256MiB mapping, you need 8 of those. Entry goes for TLB 63 and you need to be flexible and avoid TLB 63 :). So after all you don't have that much in common with the entry code. If
you look at the FSL-book code then you will notice that I tried to share
some code.
Quoted 4 lines
I don't understand why you don't flip the address space bit. On fsl we setup the tmp mapping in the "other address" space so we don't have two mappings for the same address. The entry code could be doing this with STS bit, I'm not sure.
I am not sure if I understood this correctly.
Could you explain how could there be two mappings for the same address ? We are setting up 1:1 mapping for 0-2GiB and the only mapping that could exist (in other words, not invalidated) is PAGE_OFFSET mapping. Since PAGE_OFFSET < 2GiB we won't have multiple mappings. Or in other words we could limit KEXEC_*_MEMORY_LIMIT to PAGE_OFFSET to make sure the crossing doesn't occur.
The kernel entry code sets up the mapping without a tmp mapping in 44x. i.e, it uses the mapping setup by the firmware/boot loader.
Thanks
Suzuki
Quoted 7 lines · Sebastian Andrzej Siewior
Quoted 4 lines · Suzuki Poulose
Index:
powerpc/arch/powerpc/kernel/44x_kexec_mapping.S
===================================================================arch/powerpc/kernel/44x_kexec_mapping.S new file +0
-0....
Quoted 6 lines
arch/powerpc/kernel/44x_kexec_mapping.S line 24
Quoted 4 lines
+ *
+ */arch/powerpc/kernel/44x_kexec_mapping.S new file +2
-0+ bl nxtins /* Find our address */ +nxtins: mflr r5 /* Make it accessible */Please don't mix labels and instructions.
With proper indent it's fine as long as he uses numerical relative labels which should be the case here. For example, the above, it should look like:
bl 1f
1: mflr r5
Quoted 5 lines
Quoted 1 line
+ tlbsx r23,0,r5 /* Find entry we are in */
using tabs instead of spaces would make it look nice. Please also separate the arguments of the instruction i.e.
tlbsx r23, 0, r5
That's arguable. If you look at arch/powerpc, we tend not to separate the arguments ;-)
Actually I used to, others didn't and I changed my own style.
Quoted 7 lines
Quoted 7 lines
Index:
powerpc/arch/powerpc/kernel/misc_32.S
===================================================================arch/powerpc/kernel/misc_32.S +0
-0@@ -736,6 +736,28 @@ relocate_new_kernel: mr r5, r31
Quoted 12 lines
arch/powerpc/kernel/misc_32.S relocate_new_kernel: · line 745
Quoted 8 lines
arch/powerpc/kernel/misc_32.S +7
-0li r0, 0 +#elif defined(CONFIG_44x) && !defined(CONFIG_47x) + + mr r29, r3 + mr r30, r4 + mr r31, r5 + +#include "44x_kexec_mapping.S"The way you setup the 1:1 mapping should be close to what you are doing on kernel entry. Isn't it possible to include the file here and in the entry code?
It should just not be #included, what about branching out instead ?
Cheers,
Ben.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 53 lines · Benjamin Herrenschmidt
Quoted 7 lines · Sebastian Andrzej Siewior
Quoted 4 lines · Suzuki Poulose
Index:
powerpc/arch/powerpc/kernel/44x_kexec_mapping.S
===================================================================arch/powerpc/kernel/44x_kexec_mapping.S new file +0
-0....
Quoted 6 lines
arch/powerpc/kernel/44x_kexec_mapping.S line 24
Quoted 4 lines
+ *
+ */arch/powerpc/kernel/44x_kexec_mapping.S new file +2
-0+ bl nxtins /* Find our address */ +nxtins: mflr r5 /* Make it accessible */Please don't mix labels and instructions.
With proper indent it's fine as long as he uses numerical relative labels which should be the case here. For example, the above, it should look like:
bl 1f1: mflr r5
Quoted 5 lines
Quoted 1 line
+ tlbsx r23,0,r5 /* Find entry we are in */
using tabs instead of spaces would make it look nice. Please also separate the arguments of the instruction i.e.
tlbsx r23, 0, r5That's arguable. If you look at
arch/powerpc, we tend not to separate the arguments ;-)Actually I used to, others didn't and I changed my own style.
Quoted 7 lines
Quoted 7 lines
Index:
powerpc/arch/powerpc/kernel/misc_32.S
===================================================================arch/powerpc/kernel/misc_32.S +0
-0@@ -736,6 +736,28 @@ relocate_new_kernel: mr r5, r31Quoted 12 lines
arch/powerpc/kernel/misc_32.S relocate_new_kernel: · line 745
Quoted 8 lines
arch/powerpc/kernel/misc_32.S +7
-0li r0, 0 +#elif defined(CONFIG_44x)&& !defined(CONFIG_47x) + + mr r29, r3 + mr r30, r4 + mr r31, r5 + +#include "44x_kexec_mapping.S"The way you setup the 1:1 mapping should be close to what you are doing on kernel entry. Isn't it possible to include the file here and in the entry code?
Quoted 1 line
It should just not be #included, what about branching out instead ?
This code, i.e, relocate_new_kernel is copied into the control buffer, which will get the first chance to execute before the purgatory. So we may not be able to branch to the code, since we are executing this from a different address and we would invalidate the mapping for the code except the control buffer.
Thanks
Suzuki