2005-06-26 05:58:11 +08:00
|
|
|
/*
|
|
|
|
* arch/s390/kernel/machine_kexec.c
|
|
|
|
*
|
|
|
|
* (C) Copyright IBM Corp. 2005
|
|
|
|
*
|
|
|
|
* Author(s): Rolf Adelsberger <adelsberger@de.ibm.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* s390_machine_kexec.c - handle the transition of Linux booting another kernel
|
|
|
|
* on the S390 architecture.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/kexec.h>
|
|
|
|
#include <linux/delay.h>
|
2006-02-12 09:56:01 +08:00
|
|
|
#include <asm/cio.h>
|
|
|
|
#include <asm/setup.h>
|
2005-06-26 05:58:11 +08:00
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/pgalloc.h>
|
|
|
|
#include <asm/system.h>
|
2006-02-12 09:56:01 +08:00
|
|
|
#include <asm/smp.h>
|
2006-12-04 22:40:26 +08:00
|
|
|
#include <asm/reset.h>
|
2005-06-26 05:58:11 +08:00
|
|
|
|
|
|
|
static void kexec_halt_all_cpus(void *);
|
|
|
|
|
|
|
|
typedef void (*relocate_kernel_t) (kimage_entry_t *, unsigned long);
|
|
|
|
|
2006-06-27 00:57:34 +08:00
|
|
|
extern const unsigned char relocate_kernel[];
|
|
|
|
extern const unsigned long long relocate_kernel_len;
|
2005-06-26 05:58:11 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
machine_kexec_prepare(struct kimage *image)
|
|
|
|
{
|
|
|
|
unsigned long reboot_code_buffer;
|
|
|
|
|
|
|
|
/* We don't support anything but the default image type for now. */
|
|
|
|
if (image->type != KEXEC_TYPE_DEFAULT)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Get the destination where the assembler code should be copied to.*/
|
|
|
|
reboot_code_buffer = page_to_pfn(image->control_code_page)<<PAGE_SHIFT;
|
|
|
|
|
|
|
|
/* Then copy it */
|
|
|
|
memcpy((void *) reboot_code_buffer, relocate_kernel,
|
|
|
|
relocate_kernel_len);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
machine_kexec_cleanup(struct kimage *image)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
machine_shutdown(void)
|
|
|
|
{
|
|
|
|
printk(KERN_INFO "kexec: machine_shutdown called\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
NORET_TYPE void
|
|
|
|
machine_kexec(struct kimage *image)
|
|
|
|
{
|
|
|
|
on_each_cpu(kexec_halt_all_cpus, image, 0, 0);
|
2005-06-26 05:58:28 +08:00
|
|
|
for (;;);
|
2005-06-26 05:58:11 +08:00
|
|
|
}
|
|
|
|
|
2005-08-02 12:11:33 +08:00
|
|
|
extern void pfault_fini(void);
|
|
|
|
|
2005-06-26 05:58:11 +08:00
|
|
|
static void
|
|
|
|
kexec_halt_all_cpus(void *kernel_image)
|
|
|
|
{
|
|
|
|
static atomic_t cpuid = ATOMIC_INIT(-1);
|
|
|
|
int cpu;
|
|
|
|
struct kimage *image;
|
|
|
|
relocate_kernel_t data_mover;
|
|
|
|
|
2005-08-02 12:11:33 +08:00
|
|
|
#ifdef CONFIG_PFAULT
|
|
|
|
if (MACHINE_IS_VM)
|
|
|
|
pfault_fini();
|
|
|
|
#endif
|
|
|
|
|
2006-01-06 16:19:07 +08:00
|
|
|
if (atomic_cmpxchg(&cpuid, -1, smp_processor_id()) != -1)
|
2005-06-26 05:58:11 +08:00
|
|
|
signal_processor(smp_processor_id(), sigp_stop);
|
|
|
|
|
|
|
|
/* Wait for all other cpus to enter stopped state */
|
|
|
|
for_each_online_cpu(cpu) {
|
|
|
|
if (cpu == smp_processor_id())
|
|
|
|
continue;
|
2005-06-26 05:58:28 +08:00
|
|
|
while (!smp_cpu_not_running(cpu))
|
2005-06-26 05:58:11 +08:00
|
|
|
cpu_relax();
|
|
|
|
}
|
|
|
|
|
2006-12-04 22:40:26 +08:00
|
|
|
s390_reset_system();
|
|
|
|
|
2005-06-26 05:58:11 +08:00
|
|
|
image = (struct kimage *) kernel_image;
|
|
|
|
data_mover = (relocate_kernel_t)
|
|
|
|
(page_to_pfn(image->control_code_page) << PAGE_SHIFT);
|
|
|
|
|
|
|
|
/* Call the moving routine */
|
|
|
|
(*data_mover) (&image->head, image->start);
|
|
|
|
}
|