-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add kexec support to ARM. Improvements like commandline handling could be made but this patch gives basic functional support. It uses the next available syscall number, 347. Once the syscall number is known, userspace support will be finalised/submitted to kexec-tools, various patches already exist. Originally based on a patch by Maxim Syrchin but updated and forward ported by various people. Signed-off-by: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
- Loading branch information
Richard Purdie
authored and
Russell King
committed
Feb 16, 2007
1 parent
3b581f5
commit c587e4a
Showing
8 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* machine_kexec.c - handle transition of Linux booting another kernel | ||
*/ | ||
|
||
#include <linux/mm.h> | ||
#include <linux/kexec.h> | ||
#include <linux/delay.h> | ||
#include <linux/reboot.h> | ||
#include <asm/pgtable.h> | ||
#include <asm/pgalloc.h> | ||
#include <asm/mmu_context.h> | ||
#include <asm/io.h> | ||
#include <asm/cacheflush.h> | ||
#include <asm/mach-types.h> | ||
|
||
const extern unsigned char relocate_new_kernel[]; | ||
const extern unsigned int relocate_new_kernel_size; | ||
|
||
extern void setup_mm_for_reboot(char mode); | ||
|
||
extern unsigned long kexec_start_address; | ||
extern unsigned long kexec_indirection_page; | ||
extern unsigned long kexec_mach_type; | ||
|
||
/* | ||
* Provide a dummy crash_notes definition while crash dump arrives to arm. | ||
* This prevents breakage of crash_notes attribute in kernel/ksysfs.c. | ||
*/ | ||
|
||
int machine_kexec_prepare(struct kimage *image) | ||
{ | ||
return 0; | ||
} | ||
|
||
void machine_kexec_cleanup(struct kimage *image) | ||
{ | ||
} | ||
|
||
void machine_shutdown(void) | ||
{ | ||
} | ||
|
||
void machine_crash_shutdown(struct pt_regs *regs) | ||
{ | ||
} | ||
|
||
void machine_kexec(struct kimage *image) | ||
{ | ||
unsigned long page_list; | ||
unsigned long reboot_code_buffer_phys; | ||
void *reboot_code_buffer; | ||
|
||
|
||
page_list = image->head & PAGE_MASK; | ||
|
||
/* we need both effective and real address here */ | ||
reboot_code_buffer_phys = | ||
page_to_pfn(image->control_code_page) << PAGE_SHIFT; | ||
reboot_code_buffer = page_address(image->control_code_page); | ||
|
||
/* Prepare parameters for reboot_code_buffer*/ | ||
kexec_start_address = image->start; | ||
kexec_indirection_page = page_list; | ||
kexec_mach_type = machine_arch_type; | ||
|
||
/* copy our kernel relocation code to the control code page */ | ||
memcpy(reboot_code_buffer, | ||
relocate_new_kernel, relocate_new_kernel_size); | ||
|
||
|
||
flush_icache_range((unsigned long) reboot_code_buffer, | ||
(unsigned long) reboot_code_buffer + KEXEC_CONTROL_CODE_SIZE); | ||
printk(KERN_INFO "Bye!\n"); | ||
|
||
cpu_proc_fin(); | ||
setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/ | ||
cpu_reset(reboot_code_buffer_phys); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* relocate_kernel.S - put the kernel image in place to boot | ||
*/ | ||
|
||
#include <asm/kexec.h> | ||
|
||
.globl relocate_new_kernel | ||
relocate_new_kernel: | ||
|
||
ldr r0,kexec_indirection_page | ||
ldr r1,kexec_start_address | ||
|
||
|
||
0: /* top, read another word for the indirection page */ | ||
ldr r3, [r0],#4 | ||
|
||
/* Is it a destination page. Put destination address to r4 */ | ||
tst r3,#1,0 | ||
beq 1f | ||
bic r4,r3,#1 | ||
b 0b | ||
1: | ||
/* Is it an indirection page */ | ||
tst r3,#2,0 | ||
beq 1f | ||
bic r0,r3,#2 | ||
b 0b | ||
1: | ||
|
||
/* are we done ? */ | ||
tst r3,#4,0 | ||
beq 1f | ||
b 2f | ||
|
||
1: | ||
/* is it source ? */ | ||
tst r3,#8,0 | ||
beq 0b | ||
bic r3,r3,#8 | ||
mov r6,#1024 | ||
9: | ||
ldr r5,[r3],#4 | ||
str r5,[r4],#4 | ||
subs r6,r6,#1 | ||
bne 9b | ||
b 0b | ||
|
||
2: | ||
/* Jump to relocated kernel */ | ||
mov lr,r1 | ||
mov r0,#0 | ||
ldr r1,kexec_mach_type | ||
mov r2,#0 | ||
mov pc,lr | ||
|
||
.globl kexec_start_address | ||
kexec_start_address: | ||
.long 0x0 | ||
|
||
.globl kexec_indirection_page | ||
kexec_indirection_page: | ||
.long 0x0 | ||
|
||
.globl kexec_mach_type | ||
kexec_mach_type: | ||
.long 0x0 | ||
|
||
relocate_new_kernel_end: | ||
|
||
.globl relocate_new_kernel_size | ||
relocate_new_kernel_size: | ||
.long relocate_new_kernel_end - relocate_new_kernel | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef _ARM_KEXEC_H | ||
#define _ARM_KEXEC_H | ||
|
||
#ifdef CONFIG_KEXEC | ||
|
||
/* Maximum physical address we can use pages from */ | ||
#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL) | ||
/* Maximum address we can reach in physical address mode */ | ||
#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL) | ||
/* Maximum address we can use for the control code buffer */ | ||
#define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE | ||
|
||
#define KEXEC_CONTROL_CODE_SIZE 4096 | ||
|
||
#define KEXEC_ARCH KEXEC_ARCH_ARM | ||
|
||
#ifndef __ASSEMBLY__ | ||
|
||
#define MAX_NOTE_BYTES 1024 | ||
|
||
struct kimage; | ||
/* Provide a dummy definition to avoid build failures. */ | ||
static inline void crash_setup_regs(struct pt_regs *newregs, | ||
struct pt_regs *oldregs) { } | ||
|
||
#endif /* __ASSEMBLY__ */ | ||
|
||
#endif /* CONFIG_KEXEC */ | ||
|
||
#endif /* _ARM_KEXEC_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters