Skip to contentSkip to conversation

kexec for 2.5.52

PATCH In review Eric W. Biederman 2 participants 4 messages Dec 16, 2002 – Dec 17, 2002 kexec

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kexec for 2.5.52

Linus will you please apply this?

 MAINTAINERS                        |    8 
 arch/i386/Kconfig                  |   17 
 arch/i386/kernel/Makefile          |    1 
 arch/i386/kernel/entry.S           |    2 
 arch/i386/kernel/machine_kexec.c   |  142 ++++++++
 arch/i386/kernel/relocate_kernel.S |  107 ++++++
 include/asm-i386/kexec.h           |   25 +
 include/asm-i386/unistd.h          |    2 
 include/linux/kexec.h              |   45 ++
 include/linux/reboot.h             |    2 
 kernel/Makefile                    |    1 
 kernel/kexec.c                     |  640 +++++++++++++++++++++++++++++++++++++
 kernel/sys.c                       |   23 +
 13 files changed, 1013 insertions, 2 deletions
MAINTAINERS +8 -0
diff -uNr linux-2.5.52/MAINTAINERS linux-2.5.52.x86kexec/MAINTAINERS
@@ -997,6 +997,14 @@
 W:	http://www.cse.unsw.edu.au/~neilb/patches/linux-devel/
 S:	Maintained
 
+KEXEC
+P:	Eric Biederman
+M:	[email protected]
+M:	[email protected]
+W:	http://www.xmission.com/~ebiederm/files/kexec/
+L:	[email protected]
+S:	Maintained
+
 LANMEDIA WAN CARD DRIVER
 P:	Andrew Stanley-Jones
 M:	[email protected]
arch/i386/Kconfig +17 -0
diff -uNr linux-2.5.52/arch/i386/Kconfig linux-2.5.52.x86kexec/arch/i386/Kconfig
@@ -686,6 +686,23 @@
 	depends on (SMP || PREEMPT) && X86_CMPXCHG
 	default y
 
+config KEXEC
+	bool "kexec system call (EXPERIMENTAL)"
+	depends on 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
+	  but it is indepedent of the system firmware.   And like a reboot
+	  you can start any kernel with it not just Linux.  
+	
+	  The name comes from the similiarity to the exec system call. 
+	
+	  It is on an going process to be certain the hardware in a machine
+	  is properly shutdown, so do not be surprised if this code does not
+	  initially work for you.  It may help to enable device hotplugging
+	  support.  As of this writing the exact hardware interface is
+	  strongly in flux, so no good recommendation can be made.
+
 endmenu
 
 
arch/i386/kernel/Makefile +1 -0
diff -uNr linux-2.5.52/arch/i386/kernel/Makefile linux-2.5.52.x86kexec/arch/i386/kernel/Makefile
@@ -24,6 +24,7 @@
 obj-$(CONFIG_X86_MPPARSE)	+= mpparse.o
 obj-$(CONFIG_X86_LOCAL_APIC)	+= apic.o nmi.o
 obj-$(CONFIG_X86_IO_APIC)	+= io_apic.o
+obj-$(CONFIG_KEXEC)		+= machine_kexec.o relocate_kernel.o
 obj-$(CONFIG_SOFTWARE_SUSPEND)	+= suspend.o suspend_asm.o
 obj-$(CONFIG_X86_NUMAQ)		+= numaq.o
 obj-$(CONFIG_PROFILING)		+= profile.o
arch/i386/kernel/entry.S +1 -1
diff -uNr linux-2.5.52/arch/i386/kernel/entry.S linux-2.5.52.x86kexec/arch/i386/kernel/entry.S
@@ -743,7 +743,7 @@
 	.long sys_epoll_wait
  	.long sys_remap_file_pages
  	.long sys_set_tid_address
-
+	.long sys_kexec_load
 
 	.rept NR_syscalls-(.-sys_call_table)/4
 		.long sys_ni_syscall
arch/i386/kernel/machine_kexec.c +142 -0

142 lines not on this page · raw message

arch/i386/kernel/relocate_kernel.S +107 -0

107 lines not on this page · raw message

include/asm-i386/kexec.h +25 -0
diff -uNr linux-2.5.52/include/asm-i386/kexec.h linux-2.5.52.x86kexec/include/asm-i386/kexec.h
@@ -0,0 +1,25 @@
+#ifndef _I386_KEXEC_H
+#define _I386_KEXEC_H
+
+#include <asm/fixmap.h>
+
+/*
+ * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
+ * I.e. Maximum page that is mapped directly into kernel memory,
+ * and kmap is not required.
+ *
+ * Someone correct me if FIXADDR_START - PAGEOFFSET is not the correct
+ * calculation for the amount of memory directly mappable into the
+ * kernel memory space.
+ */
+
+/* Maximum physical address we can use pages from */
+#define KEXEC_SOURCE_MEMORY_LIMIT (FIXADDR_START - PAGE_OFFSET) 
+/* Maximum address we can reach in physical address mode */
+#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
+
+#define KEXEC_REBOOT_CODE_SIZE	4096
+#define KEXEC_REBOOT_CODE_ALIGN 0
+
+
+#endif /* _I386_KEXEC_H */
include/asm-i386/unistd.h +1 -1
diff -uNr linux-2.5.52/include/asm-i386/unistd.h linux-2.5.52.x86kexec/include/asm-i386/unistd.h
@@ -264,7 +264,7 @@
 #define __NR_epoll_wait		256
 #define __NR_remap_file_pages	257
 #define __NR_set_tid_address	258
-
+#define __NR_sys_kexec_load	259
 
 /* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
 
include/linux/kexec.h +45 -0

45 lines not on this page · raw message

include/linux/reboot.h +2 -0
diff -uNr linux-2.5.52/include/linux/reboot.h linux-2.5.52.x86kexec/include/linux/reboot.h
@@ -21,6 +21,7 @@
  * POWER_OFF   Stop OS and remove all power from system, if possible.
  * RESTART2    Restart system using given command string.
  * SW_SUSPEND  Suspend system using Software Suspend if compiled in
+ * KEXEC       Restart the system using a different kernel.
  */
 
 #define	LINUX_REBOOT_CMD_RESTART	0x01234567
@@ -30,6 +31,7 @@
 #define	LINUX_REBOOT_CMD_POWER_OFF	0x4321FEDC
 #define	LINUX_REBOOT_CMD_RESTART2	0xA1B2C3D4
 #define	LINUX_REBOOT_CMD_SW_SUSPEND	0xD000FCE2
+#define LINUX_REBOOT_CMD_KEXEC		0x45584543
 
 
 #ifdef __KERNEL__
kernel/Makefile +1 -0
diff -uNr linux-2.5.52/kernel/Makefile linux-2.5.52.x86kexec/kernel/Makefile
@@ -21,6 +21,7 @@
 obj-$(CONFIG_CPU_FREQ) += cpufreq.o
 obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
 obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend.o
+obj-$(CONFIG_KEXEC) += kexec.o
 obj-$(CONFIG_COMPAT) += compat.o
 
 ifneq ($(CONFIG_IA64),y)
kernel/kexec.c +640 -0

640 lines not on this page · raw message

kernel/sys.c +23 -0
diff -uNr linux-2.5.52/kernel/sys.c linux-2.5.52.x86kexec/kernel/sys.c
@@ -16,6 +16,7 @@
 #include <linux/init.h>
 #include <linux/highuid.h>
 #include <linux/fs.h>
+#include <linux/kexec.h>
 #include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/times.h>
@@ -207,6 +208,7 @@
 cond_syscall(sys_lookup_dcookie)
 cond_syscall(sys_swapon)
 cond_syscall(sys_swapoff)
+cond_syscall(sys_kexec_load)
 cond_syscall(sys_init_module)
 cond_syscall(sys_delete_module)
 
@@ -419,6 +421,27 @@
 		machine_restart(buffer);
 		break;
 
+#ifdef CONFIG_KEXEC
+	case LINUX_REBOOT_CMD_KEXEC:
+	{
+		struct kimage *image;
+		if (arg) {
+			unlock_kernel();
+			return -EINVAL;
+		}
+		image = xchg(&kexec_image, 0);
+		if (!image) {
+			unlock_kernel();
+			return -EINVAL;
+		}
+		notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL);
+		system_running = 0;
+		device_shutdown();
+		printk(KERN_EMERG "Starting new kernel\n");
+		machine_kexec(image);
+		break;
+	}
+#endif
 #ifdef CONFIG_SOFTWARE_SUSPEND
 	case LINUX_REBOOT_CMD_SW_SUSPEND:
 		if (!software_suspend_enabled) {
#1 lore raw
Quoted 1 line · Eric W. Biederman

Linus will you please apply this?

Eric,

The patch applied cleanly for me.

Is there a new kexec-tools package for this, or should the 1.8 rev located here:
http://www.xmission.com/~ebiederm/files/kexec/
work okay?

Also, is there a separate hwfixes patch as before?

Thanks,
Andy

#2 lore raw
Quoted 11 lines · Andy Pfiffer
Quoted 1 line · Eric W. Biederman

Linus will you please apply this?

Eric,

The patch applied cleanly for me.

Is there a new kexec-tools package for this, or should the 1.8 rev located here:
http://www.xmission.com/~ebiederm/files/kexec/
work okay?

1.8 should work.

Quoted 1 line

Also, is there a separate hwfixes patch as before?

The old hwfixes should work as well. If the .48 version does not patch cleanly holler.

Eric

#3 lore raw

Re: [PATCH] kexec for 2.5.52 [OSDL PLM]

Quoted 6 lines · Eric W. Biederman
Quoted 4 lines

Is there a new kexec-tools package for this, or should the 1.8 rev located here:
http://www.xmission.com/~ebiederm/files/kexec/
work okay?

1.8 should work.

Okay. Thanks.

Quoted 2 lines

The old hwfixes should work as well. If the .48 version does not patch cleanly holler.

The hwfixes for .48 applied cleanly for me, so I tossed the patches into OSDL's PLM hopper:
http://www.osdl.org/cgi-bin/plm?module=patch_info&patch_id=1043
http://www.osdl.org/cgi-bin/plm?module=patch_info&patch_id=1042
http://www.osdl.org/cgi-bin/plm?module=patch_info&patch_id=1041
http://www.osdl.org/cgi-bin/plm?module=patch_info&patch_id=1038

Legend for those that don't want to click on the URLs:
a) PLM ID #1043: changes CONFIG_KEXEC to y by default (a quirk of the PLM infrastructure).
b) PLM ID #1042: .48 hwfixes for kexec
c) PLM ID #1041: base kexec for 2.5.52
d) PLM ID #1038: base 2.5.52 kernel
e) OSDL PLM: http://www.osdl.org/cgi-bin/plm/

Andy