* Kexec on FSL-Book-E, v4
@ 2010-04-04 20:19 Sebastian Andrzej Siewior
2010-04-04 20:19 ` [PATCH 1/3] powerpc/head fsl: fix the case where we are not in the first page Sebastian Andrzej Siewior
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-04-04 20:19 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev
The change from v3 is not to use TLB0 for the temporary 4KiB mapping.
Everything now hapens in TLB1. The equal mapping starts ESEL three since
ESEL one or two contains the temporary mapping.
Other bits are untouched.
Sebastian
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/3] powerpc/head fsl: fix the case where we are not in the first page
2010-04-04 20:19 Kexec on FSL-Book-E, v4 Sebastian Andrzej Siewior
@ 2010-04-04 20:19 ` Sebastian Andrzej Siewior
2010-05-24 19:01 ` Kumar Gala
2010-04-04 20:19 ` [PATCH 2/3] powerpc/fsl head: move the entry setup code into a seperate file Sebastian Andrzej Siewior
2010-04-04 20:19 ` [PATCH 3/3] powerpc/kexec: Add support for FSL-BookE Sebastian Andrzej Siewior
2 siblings, 1 reply; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-04-04 20:19 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev, Sebastian Andrzej Siewior
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
During boot we change the mapping a few times until we have a "defined"
mapping. During this procedure a small 4KiB mapping is created and after
that one a 64MiB. Currently the offset of the 4KiB page in that we run
is zero because the complete startup up code is in first page which
starts at RPN zero.
If the code is recycled and moved to another location then its execution
will fail because the start address in 64 MiB mapping is computed
wrongly. It does not consider the offset to the page from the begin of
the memory.
This patch fixes this. Usually (system boot) r25 is zero so this does
not change anything unless the code is recycled.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
arch/powerpc/kernel/head_fsl_booke.S | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
index 7255265..9d00418 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -275,6 +275,7 @@ skpinv: addi r6,r6,1 /* Increment */
1: mflr r9
rlwimi r6,r9,0,20,31
addi r6,r6,(2f - 1b)
+ add r6, r6, r25
mtspr SPRN_SRR0,r6
mtspr SPRN_SRR1,r7
rfi /* start execution out of TLB1[0] entry */
--
1.6.6.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/3] powerpc/fsl head: move the entry setup code into a seperate file
2010-04-04 20:19 Kexec on FSL-Book-E, v4 Sebastian Andrzej Siewior
2010-04-04 20:19 ` [PATCH 1/3] powerpc/head fsl: fix the case where we are not in the first page Sebastian Andrzej Siewior
@ 2010-04-04 20:19 ` Sebastian Andrzej Siewior
2010-05-24 19:01 ` Kumar Gala
2010-04-04 20:19 ` [PATCH 3/3] powerpc/kexec: Add support for FSL-BookE Sebastian Andrzej Siewior
2 siblings, 1 reply; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-04-04 20:19 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev, Sebastian Andrzej Siewior
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
This patch only moves the initial entry code which setups the mapping
from what ever to KERNELBASE into a seperate file. No code change has
been made here.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
arch/powerpc/kernel/fsl_booke_entry_mapping.S | 200 +++++++++++++++++++++++++
arch/powerpc/kernel/head_fsl_booke.S | 199 +------------------------
2 files changed, 201 insertions(+), 198 deletions(-)
create mode 100644 arch/powerpc/kernel/fsl_booke_entry_mapping.S
diff --git a/arch/powerpc/kernel/fsl_booke_entry_mapping.S b/arch/powerpc/kernel/fsl_booke_entry_mapping.S
new file mode 100644
index 0000000..cdb1296
--- /dev/null
+++ b/arch/powerpc/kernel/fsl_booke_entry_mapping.S
@@ -0,0 +1,200 @@
+
+/* 1. Find the index of the entry we're executing in */
+ bl invstr /* Find our address */
+invstr: mflr r6 /* Make it accessible */
+ mfmsr r7
+ rlwinm r4,r7,27,31,31 /* extract MSR[IS] */
+ mfspr r7, SPRN_PID0
+ slwi r7,r7,16
+ or r7,r7,r4
+ mtspr SPRN_MAS6,r7
+ tlbsx 0,r6 /* search MSR[IS], SPID=PID0 */
+ mfspr r7,SPRN_MAS1
+ andis. r7,r7,MAS1_VALID@h
+ bne match_TLB
+
+ mfspr r7,SPRN_MMUCFG
+ rlwinm r7,r7,21,28,31 /* extract MMUCFG[NPIDS] */
+ cmpwi r7,3
+ bne match_TLB /* skip if NPIDS != 3 */
+
+ mfspr r7,SPRN_PID1
+ slwi r7,r7,16
+ or r7,r7,r4
+ mtspr SPRN_MAS6,r7
+ tlbsx 0,r6 /* search MSR[IS], SPID=PID1 */
+ mfspr r7,SPRN_MAS1
+ andis. r7,r7,MAS1_VALID@h
+ bne match_TLB
+ mfspr r7, SPRN_PID2
+ slwi r7,r7,16
+ or r7,r7,r4
+ mtspr SPRN_MAS6,r7
+ tlbsx 0,r6 /* Fall through, we had to match */
+
+match_TLB:
+ mfspr r7,SPRN_MAS0
+ rlwinm r3,r7,16,20,31 /* Extract MAS0(Entry) */
+
+ mfspr r7,SPRN_MAS1 /* Insure IPROT set */
+ oris r7,r7,MAS1_IPROT@h
+ mtspr SPRN_MAS1,r7
+ tlbwe
+
+/* 2. Invalidate all entries except the entry we're executing in */
+ mfspr r9,SPRN_TLB1CFG
+ andi. r9,r9,0xfff
+ li r6,0 /* Set Entry counter to 0 */
+1: lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
+ rlwimi r7,r6,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r6) */
+ mtspr SPRN_MAS0,r7
+ tlbre
+ mfspr r7,SPRN_MAS1
+ rlwinm r7,r7,0,2,31 /* Clear MAS1 Valid and IPROT */
+ cmpw r3,r6
+ beq skpinv /* Dont update the current execution TLB */
+ mtspr SPRN_MAS1,r7
+ tlbwe
+ isync
+skpinv: addi r6,r6,1 /* Increment */
+ cmpw r6,r9 /* Are we done? */
+ bne 1b /* If not, repeat */
+
+ /* Invalidate TLB0 */
+ li r6,0x04
+ tlbivax 0,r6
+ TLBSYNC
+ /* Invalidate TLB1 */
+ li r6,0x0c
+ tlbivax 0,r6
+ TLBSYNC
+
+/* 3. Setup a temp mapping and jump to it */
+ andi. r5, r3, 0x1 /* Find an entry not used and is non-zero */
+ addi r5, r5, 0x1
+ lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
+ rlwimi r7,r3,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r3) */
+ mtspr SPRN_MAS0,r7
+ tlbre
+
+ /* grab and fixup the RPN */
+ mfspr r6,SPRN_MAS1 /* extract MAS1[SIZE] */
+ rlwinm r6,r6,25,27,31
+ li r8,-1
+ addi r6,r6,10
+ slw r6,r8,r6 /* convert to mask */
+
+ bl 1f /* Find our address */
+1: mflr r7
+
+ mfspr r8,SPRN_MAS3
+#ifdef CONFIG_PHYS_64BIT
+ mfspr r23,SPRN_MAS7
+#endif
+ and r8,r6,r8
+ subfic r9,r6,-4096
+ and r9,r9,r7
+
+ or r25,r8,r9
+ ori r8,r25,(MAS3_SX|MAS3_SW|MAS3_SR)
+
+ /* Just modify the entry ID and EPN for the temp mapping */
+ lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
+ rlwimi r7,r5,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r5) */
+ mtspr SPRN_MAS0,r7
+ xori r6,r4,1 /* Setup TMP mapping in the other Address space */
+ slwi r6,r6,12
+ oris r6,r6,(MAS1_VALID|MAS1_IPROT)@h
+ ori r6,r6,(MAS1_TSIZE(BOOK3E_PAGESZ_4K))@l
+ mtspr SPRN_MAS1,r6
+ mfspr r6,SPRN_MAS2
+ li r7,0 /* temp EPN = 0 */
+ rlwimi r7,r6,0,20,31
+ mtspr SPRN_MAS2,r7
+ mtspr SPRN_MAS3,r8
+ tlbwe
+
+ xori r6,r4,1
+ slwi r6,r6,5 /* setup new context with other address space */
+ bl 1f /* Find our address */
+1: mflr r9
+ rlwimi r7,r9,0,20,31
+ addi r7,r7,(2f - 1b)
+ mtspr SPRN_SRR0,r7
+ mtspr SPRN_SRR1,r6
+ rfi
+2:
+/* 4. Clear out PIDs & Search info */
+ li r6,0
+ mtspr SPRN_MAS6,r6
+ mtspr SPRN_PID0,r6
+
+ mfspr r7,SPRN_MMUCFG
+ rlwinm r7,r7,21,28,31 /* extract MMUCFG[NPIDS] */
+ cmpwi r7,3
+ bne 2f /* skip if NPIDS != 3 */
+
+ mtspr SPRN_PID1,r6
+ mtspr SPRN_PID2,r6
+
+/* 5. Invalidate mapping we started in */
+2:
+ lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
+ rlwimi r7,r3,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r3) */
+ mtspr SPRN_MAS0,r7
+ tlbre
+ mfspr r6,SPRN_MAS1
+ rlwinm r6,r6,0,2,0 /* clear IPROT */
+ mtspr SPRN_MAS1,r6
+ tlbwe
+ /* Invalidate TLB1 */
+ li r9,0x0c
+ tlbivax 0,r9
+ TLBSYNC
+
+/* The mapping only needs to be cache-coherent on SMP */
+#ifdef CONFIG_SMP
+#define M_IF_SMP MAS2_M
+#else
+#define M_IF_SMP 0
+#endif
+
+/* 6. Setup KERNELBASE mapping in TLB1[0] */
+ lis r6,0x1000 /* Set MAS0(TLBSEL) = TLB1(1), ESEL = 0 */
+ mtspr SPRN_MAS0,r6
+ lis r6,(MAS1_VALID|MAS1_IPROT)@h
+ ori r6,r6,(MAS1_TSIZE(BOOK3E_PAGESZ_64M))@l
+ mtspr SPRN_MAS1,r6
+ lis r6,MAS2_VAL(PAGE_OFFSET, BOOK3E_PAGESZ_64M, M_IF_SMP)@h
+ ori r6,r6,MAS2_VAL(PAGE_OFFSET, BOOK3E_PAGESZ_64M, M_IF_SMP)@l
+ mtspr SPRN_MAS2,r6
+ mtspr SPRN_MAS3,r8
+ tlbwe
+
+/* 7. Jump to KERNELBASE mapping */
+ lis r6,(KERNELBASE & ~0xfff)@h
+ ori r6,r6,(KERNELBASE & ~0xfff)@l
+ lis r7,MSR_KERNEL@h
+ ori r7,r7,MSR_KERNEL@l
+ bl 1f /* Find our address */
+1: mflr r9
+ rlwimi r6,r9,0,20,31
+ addi r6,r6,(2f - 1b)
+ add r6, r6, r25
+ mtspr SPRN_SRR0,r6
+ mtspr SPRN_SRR1,r7
+ rfi /* start execution out of TLB1[0] entry */
+
+/* 8. Clear out the temp mapping */
+2: lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
+ rlwimi r7,r5,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r5) */
+ mtspr SPRN_MAS0,r7
+ tlbre
+ mfspr r8,SPRN_MAS1
+ rlwinm r8,r8,0,2,0 /* clear IPROT */
+ mtspr SPRN_MAS1,r8
+ tlbwe
+ /* Invalidate TLB1 */
+ li r9,0x0c
+ tlbivax 0,r9
+ TLBSYNC
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
index 9d00418..3dc7ef7 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -94,205 +94,8 @@ _ENTRY(_start);
*/
_ENTRY(__early_start)
-/* 1. Find the index of the entry we're executing in */
- bl invstr /* Find our address */
-invstr: mflr r6 /* Make it accessible */
- mfmsr r7
- rlwinm r4,r7,27,31,31 /* extract MSR[IS] */
- mfspr r7, SPRN_PID0
- slwi r7,r7,16
- or r7,r7,r4
- mtspr SPRN_MAS6,r7
- tlbsx 0,r6 /* search MSR[IS], SPID=PID0 */
- mfspr r7,SPRN_MAS1
- andis. r7,r7,MAS1_VALID@h
- bne match_TLB
-
- mfspr r7,SPRN_MMUCFG
- rlwinm r7,r7,21,28,31 /* extract MMUCFG[NPIDS] */
- cmpwi r7,3
- bne match_TLB /* skip if NPIDS != 3 */
-
- mfspr r7,SPRN_PID1
- slwi r7,r7,16
- or r7,r7,r4
- mtspr SPRN_MAS6,r7
- tlbsx 0,r6 /* search MSR[IS], SPID=PID1 */
- mfspr r7,SPRN_MAS1
- andis. r7,r7,MAS1_VALID@h
- bne match_TLB
- mfspr r7, SPRN_PID2
- slwi r7,r7,16
- or r7,r7,r4
- mtspr SPRN_MAS6,r7
- tlbsx 0,r6 /* Fall through, we had to match */
-
-match_TLB:
- mfspr r7,SPRN_MAS0
- rlwinm r3,r7,16,20,31 /* Extract MAS0(Entry) */
-
- mfspr r7,SPRN_MAS1 /* Insure IPROT set */
- oris r7,r7,MAS1_IPROT@h
- mtspr SPRN_MAS1,r7
- tlbwe
-
-/* 2. Invalidate all entries except the entry we're executing in */
- mfspr r9,SPRN_TLB1CFG
- andi. r9,r9,0xfff
- li r6,0 /* Set Entry counter to 0 */
-1: lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
- rlwimi r7,r6,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r6) */
- mtspr SPRN_MAS0,r7
- tlbre
- mfspr r7,SPRN_MAS1
- rlwinm r7,r7,0,2,31 /* Clear MAS1 Valid and IPROT */
- cmpw r3,r6
- beq skpinv /* Dont update the current execution TLB */
- mtspr SPRN_MAS1,r7
- tlbwe
- isync
-skpinv: addi r6,r6,1 /* Increment */
- cmpw r6,r9 /* Are we done? */
- bne 1b /* If not, repeat */
-
- /* Invalidate TLB0 */
- li r6,0x04
- tlbivax 0,r6
- TLBSYNC
- /* Invalidate TLB1 */
- li r6,0x0c
- tlbivax 0,r6
- TLBSYNC
-
-/* 3. Setup a temp mapping and jump to it */
- andi. r5, r3, 0x1 /* Find an entry not used and is non-zero */
- addi r5, r5, 0x1
- lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
- rlwimi r7,r3,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r3) */
- mtspr SPRN_MAS0,r7
- tlbre
-
- /* grab and fixup the RPN */
- mfspr r6,SPRN_MAS1 /* extract MAS1[SIZE] */
- rlwinm r6,r6,25,27,31
- li r8,-1
- addi r6,r6,10
- slw r6,r8,r6 /* convert to mask */
-
- bl 1f /* Find our address */
-1: mflr r7
-
- mfspr r8,SPRN_MAS3
-#ifdef CONFIG_PHYS_64BIT
- mfspr r23,SPRN_MAS7
-#endif
- and r8,r6,r8
- subfic r9,r6,-4096
- and r9,r9,r7
-
- or r25,r8,r9
- ori r8,r25,(MAS3_SX|MAS3_SW|MAS3_SR)
-
- /* Just modify the entry ID and EPN for the temp mapping */
- lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
- rlwimi r7,r5,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r5) */
- mtspr SPRN_MAS0,r7
- xori r6,r4,1 /* Setup TMP mapping in the other Address space */
- slwi r6,r6,12
- oris r6,r6,(MAS1_VALID|MAS1_IPROT)@h
- ori r6,r6,(MAS1_TSIZE(BOOK3E_PAGESZ_4K))@l
- mtspr SPRN_MAS1,r6
- mfspr r6,SPRN_MAS2
- li r7,0 /* temp EPN = 0 */
- rlwimi r7,r6,0,20,31
- mtspr SPRN_MAS2,r7
- mtspr SPRN_MAS3,r8
- tlbwe
-
- xori r6,r4,1
- slwi r6,r6,5 /* setup new context with other address space */
- bl 1f /* Find our address */
-1: mflr r9
- rlwimi r7,r9,0,20,31
- addi r7,r7,(2f - 1b)
- mtspr SPRN_SRR0,r7
- mtspr SPRN_SRR1,r6
- rfi
-2:
-/* 4. Clear out PIDs & Search info */
- li r6,0
- mtspr SPRN_MAS6,r6
- mtspr SPRN_PID0,r6
-
- mfspr r7,SPRN_MMUCFG
- rlwinm r7,r7,21,28,31 /* extract MMUCFG[NPIDS] */
- cmpwi r7,3
- bne 2f /* skip if NPIDS != 3 */
- mtspr SPRN_PID1,r6
- mtspr SPRN_PID2,r6
-
-/* 5. Invalidate mapping we started in */
-2:
- lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
- rlwimi r7,r3,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r3) */
- mtspr SPRN_MAS0,r7
- tlbre
- mfspr r6,SPRN_MAS1
- rlwinm r6,r6,0,2,0 /* clear IPROT */
- mtspr SPRN_MAS1,r6
- tlbwe
- /* Invalidate TLB1 */
- li r9,0x0c
- tlbivax 0,r9
- TLBSYNC
-
-/* The mapping only needs to be cache-coherent on SMP */
-#ifdef CONFIG_SMP
-#define M_IF_SMP MAS2_M
-#else
-#define M_IF_SMP 0
-#endif
-
-/* 6. Setup KERNELBASE mapping in TLB1[0] */
- lis r6,0x1000 /* Set MAS0(TLBSEL) = TLB1(1), ESEL = 0 */
- mtspr SPRN_MAS0,r6
- lis r6,(MAS1_VALID|MAS1_IPROT)@h
- ori r6,r6,(MAS1_TSIZE(BOOK3E_PAGESZ_64M))@l
- mtspr SPRN_MAS1,r6
- lis r6,MAS2_VAL(PAGE_OFFSET, BOOK3E_PAGESZ_64M, M_IF_SMP)@h
- ori r6,r6,MAS2_VAL(PAGE_OFFSET, BOOK3E_PAGESZ_64M, M_IF_SMP)@l
- mtspr SPRN_MAS2,r6
- mtspr SPRN_MAS3,r8
- tlbwe
-
-/* 7. Jump to KERNELBASE mapping */
- lis r6,(KERNELBASE & ~0xfff)@h
- ori r6,r6,(KERNELBASE & ~0xfff)@l
- lis r7,MSR_KERNEL@h
- ori r7,r7,MSR_KERNEL@l
- bl 1f /* Find our address */
-1: mflr r9
- rlwimi r6,r9,0,20,31
- addi r6,r6,(2f - 1b)
- add r6, r6, r25
- mtspr SPRN_SRR0,r6
- mtspr SPRN_SRR1,r7
- rfi /* start execution out of TLB1[0] entry */
-
-/* 8. Clear out the temp mapping */
-2: lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
- rlwimi r7,r5,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r5) */
- mtspr SPRN_MAS0,r7
- tlbre
- mfspr r8,SPRN_MAS1
- rlwinm r8,r8,0,2,0 /* clear IPROT */
- mtspr SPRN_MAS1,r8
- tlbwe
- /* Invalidate TLB1 */
- li r9,0x0c
- tlbivax 0,r9
- TLBSYNC
+#include "fsl_booke_entry_mapping.S"
/* Establish the interrupt vector offsets */
SET_IVOR(0, CriticalInput);
--
1.6.6.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/3] powerpc/kexec: Add support for FSL-BookE
2010-04-04 20:19 Kexec on FSL-Book-E, v4 Sebastian Andrzej Siewior
2010-04-04 20:19 ` [PATCH 1/3] powerpc/head fsl: fix the case where we are not in the first page Sebastian Andrzej Siewior
2010-04-04 20:19 ` [PATCH 2/3] powerpc/fsl head: move the entry setup code into a seperate file Sebastian Andrzej Siewior
@ 2010-04-04 20:19 ` Sebastian Andrzej Siewior
2010-05-07 6:50 ` Kumar Gala
2010-05-24 19:01 ` Kumar Gala
2 siblings, 2 replies; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-04-04 20:19 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev, Sebastian Andrzej Siewior
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
This adds support kexec on FSL-BookE where the MMU can not be simply
switched off. The code borrows the initial MMU-setup code to create the
identical mapping mapping. The only difference to the original boot code
is the size of the mapping(s) and the executeable address.
The kexec code maps the first 2 GiB of memory in 256 MiB steps. This
should work also on e500v1 boxes.
SMP support is still not available.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
arch/powerpc/Kconfig | 2 +-
arch/powerpc/include/asm/kexec.h | 13 +++++++++
arch/powerpc/kernel/fsl_booke_entry_mapping.S | 37 +++++++++++++++++++++++++
arch/powerpc/kernel/head_fsl_booke.S | 2 +
arch/powerpc/kernel/misc_32.S | 17 +++++++++++
5 files changed, 70 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 2e19500..f8ce19d 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -350,7 +350,7 @@ config ARCH_ENABLE_MEMORY_HOTREMOVE
config KEXEC
bool "kexec system call (EXPERIMENTAL)"
- depends on PPC_BOOK3S && EXPERIMENTAL
+ depends on (PPC_BOOK3S || (FSL_BOOKE && !SMP)) && 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
diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index 7e06b43..83f6481 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -2,6 +2,18 @@
#define _ASM_POWERPC_KEXEC_H
#ifdef __KERNEL__
+#ifdef CONFIG_FSL_BOOKE
+
+/*
+ * On FSL-BookE we setup a 1:1 mapping which covers the first 2GiB of memory
+ * and therefore we can only deal with memory within this range
+ */
+#define KEXEC_SOURCE_MEMORY_LIMIT (2 * 1024 * 1024 * 1024UL)
+#define KEXEC_DESTINATION_MEMORY_LIMIT (2 * 1024 * 1024 * 1024UL)
+#define KEXEC_CONTROL_MEMORY_LIMIT (2 * 1024 * 1024 * 1024UL)
+
+#else
+
/*
* Maximum page that is mapped directly into kernel memory.
* XXX: Since we copy virt we can use any page we allocate
@@ -21,6 +33,7 @@
/* TASK_SIZE, probably left over from use_mm ?? */
#define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
#endif
+#endif
#define KEXEC_CONTROL_PAGE_SIZE 4096
diff --git a/arch/powerpc/kernel/fsl_booke_entry_mapping.S b/arch/powerpc/kernel/fsl_booke_entry_mapping.S
index cdb1296..beb4d78 100644
--- a/arch/powerpc/kernel/fsl_booke_entry_mapping.S
+++ b/arch/powerpc/kernel/fsl_booke_entry_mapping.S
@@ -159,6 +159,8 @@ skpinv: addi r6,r6,1 /* Increment */
#define M_IF_SMP 0
#endif
+#if defined(ENTRY_MAPPING_BOOT_SETUP)
+
/* 6. Setup KERNELBASE mapping in TLB1[0] */
lis r6,0x1000 /* Set MAS0(TLBSEL) = TLB1(1), ESEL = 0 */
mtspr SPRN_MAS0,r6
@@ -174,6 +176,41 @@ skpinv: addi r6,r6,1 /* Increment */
/* 7. Jump to KERNELBASE mapping */
lis r6,(KERNELBASE & ~0xfff)@h
ori r6,r6,(KERNELBASE & ~0xfff)@l
+
+#elif defined(ENTRY_MAPPING_KEXEC_SETUP)
+/*
+ * 6. Setup a 1:1 mapping in TLB1. Esel 0 is unsued, 1 or 2 contains the tmp
+ * mapping so we start at 3. We setup 8 mappings, each 256MiB in size. This
+ * will cover the first 2GiB of memory.
+ */
+
+ lis r10, (MAS1_VALID|MAS1_IPROT)@h
+ ori r10,r10, (MAS1_TSIZE(BOOK3E_PAGESZ_256M))@l
+ li r11, 0
+ li r0, 8
+ mtctr r0
+
+next_tlb_setup:
+ addi r0, r11, 3
+ rlwinm r0, r0, 16, 4, 15 // Compute esel
+ rlwinm r9, r11, 28, 0, 3 // Compute [ER]PN
+ oris r0, r0, (MAS0_TLBSEL(1))@h
+ mtspr SPRN_MAS0,r0
+ mtspr SPRN_MAS1,r10
+ mtspr SPRN_MAS2,r9
+ ori r9, r9, (MAS3_SX|MAS3_SW|MAS3_SR)
+ mtspr SPRN_MAS3,r9
+ tlbwe
+ addi r11, r11, 1
+ bdnz+ next_tlb_setup
+
+/* 7. Jump to our 1:1 mapping */
+ li r6, 0
+
+#else
+ #error You need to specify the mapping or not use this at all.
+#endif
+
lis r7,MSR_KERNEL@h
ori r7,r7,MSR_KERNEL@l
bl 1f /* Find our address */
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
index 3dc7ef7..3620cf5 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -95,7 +95,9 @@ _ENTRY(_start);
_ENTRY(__early_start)
+#define ENTRY_MAPPING_BOOT_SETUP
#include "fsl_booke_entry_mapping.S"
+#undef ENTRY_MAPPING_BOOT_SETUP
/* Establish the interrupt vector offsets */
SET_IVOR(0, CriticalInput);
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 8649f53..99bc652 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -706,6 +706,22 @@ relocate_new_kernel:
/* r4 = reboot_code_buffer */
/* r5 = start_address */
+#ifdef CONFIG_FSL_BOOKE
+
+ mr r29, r3
+ mr r30, r4
+ mr r31, r5
+
+#define ENTRY_MAPPING_KEXEC_SETUP
+#include "fsl_booke_entry_mapping.S"
+#undef ENTRY_MAPPING_KEXEC_SETUP
+
+ mr r3, r29
+ mr r4, r30
+ mr r5, r31
+
+ li r0, 0
+#else
li r0, 0
/*
@@ -722,6 +738,7 @@ relocate_new_kernel:
rfi
1:
+#endif
/* from this point address translation is turned off */
/* and interrupts are disabled */
--
1.6.6.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] powerpc/kexec: Add support for FSL-BookE
2010-04-04 20:19 ` [PATCH 3/3] powerpc/kexec: Add support for FSL-BookE Sebastian Andrzej Siewior
@ 2010-05-07 6:50 ` Kumar Gala
2010-05-07 7:24 ` Sebastian Andrzej Siewior
2010-05-24 19:01 ` Kumar Gala
1 sibling, 1 reply; 12+ messages in thread
From: Kumar Gala @ 2010-05-07 6:50 UTC (permalink / raw)
To: Sebastian Andrzej Siewior; +Cc: linuxppc-dev, Sebastian Andrzej Siewior
On Apr 4, 2010, at 3:19 PM, Sebastian Andrzej Siewior wrote:
> From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>=20
> This adds support kexec on FSL-BookE where the MMU can not be simply
> switched off. The code borrows the initial MMU-setup code to create =
the
> identical mapping mapping. The only difference to the original boot =
code
> is the size of the mapping(s) and the executeable address.
> The kexec code maps the first 2 GiB of memory in 256 MiB steps. This
> should work also on e500v1 boxes.
> SMP support is still not available.
>=20
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> arch/powerpc/Kconfig | 2 +-
> arch/powerpc/include/asm/kexec.h | 13 +++++++++
> arch/powerpc/kernel/fsl_booke_entry_mapping.S | 37 =
+++++++++++++++++++++++++
> arch/powerpc/kernel/head_fsl_booke.S | 2 +
> arch/powerpc/kernel/misc_32.S | 17 +++++++++++
> 5 files changed, 70 insertions(+), 1 deletions(-)
Can you explain this a bit more. Mostly would like to have a brief =
description of the sequence of events as part of the commit message.
Something like:
* Running kernel calls machine_kexec()
* machine_kexec_32()
* jump to relocate code
* relocate clears out TLBs and sets up 2g mapping
...
what I have above might not be quite right.
- k=
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] powerpc/kexec: Add support for FSL-BookE
2010-05-07 6:50 ` Kumar Gala
@ 2010-05-07 7:24 ` Sebastian Andrzej Siewior
2010-05-07 11:35 ` wilbur.chan
0 siblings, 1 reply; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-05-07 7:24 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev
* Kumar Gala | 2010-05-07 01:50:29 [-0500]:
>Can you explain this a bit more. Mostly would like to have a brief description of the sequence of events as part of the commit message.
>
>Something like:
>
>* Running kernel calls machine_kexec()
>* machine_kexec_32()
>* jump to relocate code
>* relocate clears out TLBs and sets up 2g mapping
>...
>
>what I have above might not be quite right.
That is correct:
- kexec -l loads the kernel, dtb, ... in userland. It sets up the kimage
struct including buffers with the new kernel and a copy list which
looks like src, dst, bytes.
KEXEC_*_MEMORY_LIMIT is limiting the memory which it might allocate.
- kexec -e start the kexec, that is
* syscall reboot - kernel/sys.c
* kernel_kexec() kernel/kexec.c
* machine_kexec() arch/powerpc/kernel/machine_kexec.c
* default_machine_kexec() arch/powerpc/kernel/machine_kexec_32.c
- copy relocate_new_kernel() into a buffer which was allocated during
kexec -l. That buffer is somewhere between 0..2GiB and will not be
overwritten.
- jump there.
Here we clear the tlbs and setup a 1:1 mapping. Then we copy the
data from somewhere in 0..2GiB to its final position according to the
list. Data means new kernel, device tree and purgatory code.
- After that, the code ends in
mtlr r5
blrl
r5 has the address of purgatory_start(), purgatory/arch/ppc/v2wrap.S
in kexec userland [0].
- here we setup stack, jump to purgatory(). We have no console and still
the 2GiB 1:1 mapping
- the code performs a sha256 check to make sure the kernel is correct.
- then we get back from purgatory(), load r3 - r9 and the blr at the
bottom shoots us finally to new kernel.
- now we boot the kernel.
>- k
[0] git://git.kernel.org/pub/scm/linux/kernel/git/horms/kexec-tools.git
Sebastian
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] powerpc/kexec: Add support for FSL-BookE
2010-05-07 7:24 ` Sebastian Andrzej Siewior
@ 2010-05-07 11:35 ` wilbur.chan
2010-05-07 12:16 ` Josh Boyer
0 siblings, 1 reply; 12+ messages in thread
From: wilbur.chan @ 2010-05-07 11:35 UTC (permalink / raw)
To: Sebastian Andrzej Siewior; +Cc: linuxppc-dev
Most booke powerpc are based on SMP, I am looking forward someone to
implement this. hiahia
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] powerpc/kexec: Add support for FSL-BookE
2010-05-07 11:35 ` wilbur.chan
@ 2010-05-07 12:16 ` Josh Boyer
2010-05-07 12:50 ` Kumar Gala
0 siblings, 1 reply; 12+ messages in thread
From: Josh Boyer @ 2010-05-07 12:16 UTC (permalink / raw)
To: wilbur.chan; +Cc: linuxppc-dev, Sebastian Andrzej Siewior
On Fri, May 07, 2010 at 07:35:34PM +0800, wilbur.chan wrote:
>Most booke powerpc are based on SMP, I am looking forward someone to
>implement this. hiahia
Erm, actually most Book-E powerpc CPUs are not SMP. SMP Book-E cores are only
a fairly recent development, and if I recall correctly you need an e500mc core
to really have it work properly.
josh
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] powerpc/kexec: Add support for FSL-BookE
2010-05-07 12:16 ` Josh Boyer
@ 2010-05-07 12:50 ` Kumar Gala
0 siblings, 0 replies; 12+ messages in thread
From: Kumar Gala @ 2010-05-07 12:50 UTC (permalink / raw)
To: Josh Boyer; +Cc: linuxppc-dev, Sebastian Andrzej Siewior, wilbur.chan
On May 7, 2010, at 7:16 AM, Josh Boyer wrote:
> On Fri, May 07, 2010 at 07:35:34PM +0800, wilbur.chan wrote:
>> Most booke powerpc are based on SMP, I am looking forward someone to
>> implement this. hiahia
>=20
> Erm, actually most Book-E powerpc CPUs are not SMP. SMP Book-E cores =
are only
> a fairly recent development, and if I recall correctly you need an =
e500mc core
> to really have it work properly.
e500v2 also does SMP. MPC8572, P2020, P102x are all e500v2 SMP :)
- k=
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] powerpc/head fsl: fix the case where we are not in the first page
2010-04-04 20:19 ` [PATCH 1/3] powerpc/head fsl: fix the case where we are not in the first page Sebastian Andrzej Siewior
@ 2010-05-24 19:01 ` Kumar Gala
0 siblings, 0 replies; 12+ messages in thread
From: Kumar Gala @ 2010-05-24 19:01 UTC (permalink / raw)
To: Sebastian Andrzej Siewior; +Cc: linuxppc-dev, Sebastian Andrzej Siewior
On Apr 4, 2010, at 3:19 PM, Sebastian Andrzej Siewior wrote:
> From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>
> During boot we change the mapping a few times until we have a "defined"
> mapping. During this procedure a small 4KiB mapping is created and after
> that one a 64MiB. Currently the offset of the 4KiB page in that we run
> is zero because the complete startup up code is in first page which
> starts at RPN zero.
> If the code is recycled and moved to another location then its execution
> will fail because the start address in 64 MiB mapping is computed
> wrongly. It does not consider the offset to the page from the begin of
> the memory.
> This patch fixes this. Usually (system boot) r25 is zero so this does
> not change anything unless the code is recycled.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> arch/powerpc/kernel/head_fsl_booke.S | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
applied to next
- k
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] powerpc/fsl head: move the entry setup code into a seperate file
2010-04-04 20:19 ` [PATCH 2/3] powerpc/fsl head: move the entry setup code into a seperate file Sebastian Andrzej Siewior
@ 2010-05-24 19:01 ` Kumar Gala
0 siblings, 0 replies; 12+ messages in thread
From: Kumar Gala @ 2010-05-24 19:01 UTC (permalink / raw)
To: Sebastian Andrzej Siewior; +Cc: linuxppc-dev, Sebastian Andrzej Siewior
On Apr 4, 2010, at 3:19 PM, Sebastian Andrzej Siewior wrote:
> From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>=20
> This patch only moves the initial entry code which setups the mapping
> from what ever to KERNELBASE into a seperate file. No code change has
> been made here.
>=20
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> arch/powerpc/kernel/fsl_booke_entry_mapping.S | 200 =
+++++++++++++++++++++++++
> arch/powerpc/kernel/head_fsl_booke.S | 199 =
+------------------------
> 2 files changed, 201 insertions(+), 198 deletions(-)
> create mode 100644 arch/powerpc/kernel/fsl_booke_entry_mapping.S
applied to next
- k=
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] powerpc/kexec: Add support for FSL-BookE
2010-04-04 20:19 ` [PATCH 3/3] powerpc/kexec: Add support for FSL-BookE Sebastian Andrzej Siewior
2010-05-07 6:50 ` Kumar Gala
@ 2010-05-24 19:01 ` Kumar Gala
1 sibling, 0 replies; 12+ messages in thread
From: Kumar Gala @ 2010-05-24 19:01 UTC (permalink / raw)
To: Sebastian Andrzej Siewior; +Cc: linuxppc-dev, Sebastian Andrzej Siewior
On Apr 4, 2010, at 3:19 PM, Sebastian Andrzej Siewior wrote:
> From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>=20
> This adds support kexec on FSL-BookE where the MMU can not be simply
> switched off. The code borrows the initial MMU-setup code to create =
the
> identical mapping mapping. The only difference to the original boot =
code
> is the size of the mapping(s) and the executeable address.
> The kexec code maps the first 2 GiB of memory in 256 MiB steps. This
> should work also on e500v1 boxes.
> SMP support is still not available.
>=20
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> arch/powerpc/Kconfig | 2 +-
> arch/powerpc/include/asm/kexec.h | 13 +++++++++
> arch/powerpc/kernel/fsl_booke_entry_mapping.S | 37 =
+++++++++++++++++++++++++
> arch/powerpc/kernel/head_fsl_booke.S | 2 +
> arch/powerpc/kernel/misc_32.S | 17 +++++++++++
> 5 files changed, 70 insertions(+), 1 deletions(-)
applied to next
- k=
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2010-05-24 19:02 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-04 20:19 Kexec on FSL-Book-E, v4 Sebastian Andrzej Siewior
2010-04-04 20:19 ` [PATCH 1/3] powerpc/head fsl: fix the case where we are not in the first page Sebastian Andrzej Siewior
2010-05-24 19:01 ` Kumar Gala
2010-04-04 20:19 ` [PATCH 2/3] powerpc/fsl head: move the entry setup code into a seperate file Sebastian Andrzej Siewior
2010-05-24 19:01 ` Kumar Gala
2010-04-04 20:19 ` [PATCH 3/3] powerpc/kexec: Add support for FSL-BookE Sebastian Andrzej Siewior
2010-05-07 6:50 ` Kumar Gala
2010-05-07 7:24 ` Sebastian Andrzej Siewior
2010-05-07 11:35 ` wilbur.chan
2010-05-07 12:16 ` Josh Boyer
2010-05-07 12:50 ` Kumar Gala
2010-05-24 19:01 ` Kumar Gala
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).