Skip to content

Commit b3df895

Browse files
Sebastian Andrzej Siewiorkumargala
authored andcommitted
powerpc/kexec: Add support for FSL-BookE
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. (Kumar: Added minor change to build to ifdef CONFIG_PPC_STD_MMU_64 some code that was PPC64 specific) Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
1 parent 7c08ce7 commit b3df895

File tree

6 files changed

+74
-1
lines changed

6 files changed

+74
-1
lines changed

arch/powerpc/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ config ARCH_ENABLE_MEMORY_HOTREMOVE
351351

352352
config KEXEC
353353
bool "kexec system call (EXPERIMENTAL)"
354-
depends on PPC_BOOK3S && EXPERIMENTAL
354+
depends on (PPC_BOOK3S || (FSL_BOOKE && !SMP)) && EXPERIMENTAL
355355
help
356356
kexec is a system call that implements the ability to shutdown your
357357
current kernel, and to start another kernel. It is like a reboot

arch/powerpc/include/asm/kexec.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22
#define _ASM_POWERPC_KEXEC_H
33
#ifdef __KERNEL__
44

5+
#ifdef CONFIG_FSL_BOOKE
6+
7+
/*
8+
* On FSL-BookE we setup a 1:1 mapping which covers the first 2GiB of memory
9+
* and therefore we can only deal with memory within this range
10+
*/
11+
#define KEXEC_SOURCE_MEMORY_LIMIT (2 * 1024 * 1024 * 1024UL)
12+
#define KEXEC_DESTINATION_MEMORY_LIMIT (2 * 1024 * 1024 * 1024UL)
13+
#define KEXEC_CONTROL_MEMORY_LIMIT (2 * 1024 * 1024 * 1024UL)
14+
15+
#else
16+
517
/*
618
* Maximum page that is mapped directly into kernel memory.
719
* XXX: Since we copy virt we can use any page we allocate
@@ -21,6 +33,7 @@
2133
/* TASK_SIZE, probably left over from use_mm ?? */
2234
#define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
2335
#endif
36+
#endif
2437

2538
#define KEXEC_CONTROL_PAGE_SIZE 4096
2639

arch/powerpc/kernel/crash.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ static void crash_kexec_prepare_cpus(int cpu)
163163
}
164164

165165
/* wait for all the CPUs to hit real mode but timeout if they don't come in */
166+
#ifdef CONFIG_PPC_STD_MMU_64
166167
static void crash_kexec_wait_realmode(int cpu)
167168
{
168169
unsigned int msecs;
@@ -187,6 +188,7 @@ static void crash_kexec_wait_realmode(int cpu)
187188
}
188189
mb();
189190
}
191+
#endif
190192

191193
/*
192194
* This function will be called by secondary cpus or by kexec cpu
@@ -445,7 +447,9 @@ void default_machine_crash_shutdown(struct pt_regs *regs)
445447
crash_kexec_prepare_cpus(crashing_cpu);
446448
cpu_set(crashing_cpu, cpus_in_crash);
447449
crash_kexec_stop_spus();
450+
#ifdef CONFIG_PPC_STD_MMU_64
448451
crash_kexec_wait_realmode(crashing_cpu);
452+
#endif
449453
if (ppc_md.kexec_cpu_down)
450454
ppc_md.kexec_cpu_down(1, 0);
451455
}

arch/powerpc/kernel/fsl_booke_entry_mapping.S

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ skpinv: addi r6,r6,1 /* Increment */
159159
#define M_IF_SMP 0
160160
#endif
161161

162+
#if defined(ENTRY_MAPPING_BOOT_SETUP)
163+
162164
/* 6. Setup KERNELBASE mapping in TLB1[0] */
163165
lis r6,0x1000 /* Set MAS0(TLBSEL) = TLB1(1), ESEL = 0 */
164166
mtspr SPRN_MAS0,r6
@@ -174,6 +176,41 @@ skpinv: addi r6,r6,1 /* Increment */
174176
/* 7. Jump to KERNELBASE mapping */
175177
lis r6,(KERNELBASE & ~0xfff)@h
176178
ori r6,r6,(KERNELBASE & ~0xfff)@l
179+
180+
#elif defined(ENTRY_MAPPING_KEXEC_SETUP)
181+
/*
182+
* 6. Setup a 1:1 mapping in TLB1. Esel 0 is unsued, 1 or 2 contains the tmp
183+
* mapping so we start at 3. We setup 8 mappings, each 256MiB in size. This
184+
* will cover the first 2GiB of memory.
185+
*/
186+
187+
lis r10, (MAS1_VALID|MAS1_IPROT)@h
188+
ori r10,r10, (MAS1_TSIZE(BOOK3E_PAGESZ_256M))@l
189+
li r11, 0
190+
li r0, 8
191+
mtctr r0
192+
193+
next_tlb_setup:
194+
addi r0, r11, 3
195+
rlwinm r0, r0, 16, 4, 15 // Compute esel
196+
rlwinm r9, r11, 28, 0, 3 // Compute [ER]PN
197+
oris r0, r0, (MAS0_TLBSEL(1))@h
198+
mtspr SPRN_MAS0,r0
199+
mtspr SPRN_MAS1,r10
200+
mtspr SPRN_MAS2,r9
201+
ori r9, r9, (MAS3_SX|MAS3_SW|MAS3_SR)
202+
mtspr SPRN_MAS3,r9
203+
tlbwe
204+
addi r11, r11, 1
205+
bdnz+ next_tlb_setup
206+
207+
/* 7. Jump to our 1:1 mapping */
208+
li r6, 0
209+
210+
#else
211+
#error You need to specify the mapping or not use this at all.
212+
#endif
213+
177214
lis r7,MSR_KERNEL@h
178215
ori r7,r7,MSR_KERNEL@l
179216
bl 1f /* Find our address */

arch/powerpc/kernel/head_fsl_booke.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ _ENTRY(_start);
9595

9696
_ENTRY(__early_start)
9797

98+
#define ENTRY_MAPPING_BOOT_SETUP
9899
#include "fsl_booke_entry_mapping.S"
100+
#undef ENTRY_MAPPING_BOOT_SETUP
99101

100102
/* Establish the interrupt vector offsets */
101103
SET_IVOR(0, CriticalInput);

arch/powerpc/kernel/misc_32.S

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,22 @@ relocate_new_kernel:
711711
/* r4 = reboot_code_buffer */
712712
/* r5 = start_address */
713713

714+
#ifdef CONFIG_FSL_BOOKE
715+
716+
mr r29, r3
717+
mr r30, r4
718+
mr r31, r5
719+
720+
#define ENTRY_MAPPING_KEXEC_SETUP
721+
#include "fsl_booke_entry_mapping.S"
722+
#undef ENTRY_MAPPING_KEXEC_SETUP
723+
724+
mr r3, r29
725+
mr r4, r30
726+
mr r5, r31
727+
728+
li r0, 0
729+
#else
714730
li r0, 0
715731

716732
/*
@@ -727,6 +743,7 @@ relocate_new_kernel:
727743
rfi
728744

729745
1:
746+
#endif
730747
/* from this point address translation is turned off */
731748
/* and interrupts are disabled */
732749

0 commit comments

Comments
 (0)