From: "Randy.Dunlap" <rddunlap@osdl.org>

kexec is a fairly major and popular feature.  People are shipping it in
products, although it is not known if Linux distributors plan to ship it.

The patch reserves the kexec syscall slots to pin the ABI down for
everyone.


- add kexec_load prototype to syscalls.h

- add LINUX_REBOOT_CMD_KEXEC to reboot.h

- add kexec_load syscall for ia32, ia64, x86_64, ppc32, ppc64


---

 25-akpm/arch/i386/kernel/entry.S    |    1 +
 25-akpm/arch/ia64/kernel/entry.S    |    2 +-
 25-akpm/arch/ia64/kernel/fsys.S     |    2 +-
 25-akpm/arch/ppc/kernel/misc.S      |    1 +
 25-akpm/arch/ppc64/kernel/misc.S    |    2 ++
 25-akpm/include/asm-i386/unistd.h   |    3 ++-
 25-akpm/include/asm-ia64/unistd.h   |    1 +
 25-akpm/include/asm-ppc/unistd.h    |    3 ++-
 25-akpm/include/asm-ppc64/unistd.h  |    3 ++-
 25-akpm/include/asm-x86_64/unistd.h |    4 +++-
 25-akpm/include/linux/reboot.h      |    2 ++
 25-akpm/include/linux/syscalls.h    |    3 +++
 12 files changed, 21 insertions(+), 6 deletions(-)

diff -puN arch/ia64/kernel/fsys.S~kexec-reserve-syscall-slot arch/ia64/kernel/fsys.S
--- 25/arch/ia64/kernel/fsys.S~kexec-reserve-syscall-slot	Mon May 17 14:04:46 2004
+++ 25-akpm/arch/ia64/kernel/fsys.S	Mon May 17 14:04:46 2004
@@ -857,7 +857,7 @@ fsyscall_table:
 	data8 0				// mq_timedreceive	// 1265
 	data8 0				// mq_notify
 	data8 0				// mq_getsetattr
-	data8 0
+	data8 0				// kexec_load
 	data8 0
 	data8 0							// 1270
 	data8 0
diff -puN arch/ppc64/kernel/misc.S~kexec-reserve-syscall-slot arch/ppc64/kernel/misc.S
--- 25/arch/ppc64/kernel/misc.S~kexec-reserve-syscall-slot	Mon May 17 14:04:46 2004
+++ 25-akpm/arch/ppc64/kernel/misc.S	Mon May 17 14:04:46 2004
@@ -850,6 +850,7 @@ _GLOBAL(sys_call_table32)
 	.llong .compat_sys_mq_timedreceive /* 265 */
 	.llong .compat_sys_mq_notify
 	.llong .compat_sys_mq_getsetattr
+	.llong .sys_ni_syscall		/* 268 reserved for sys_kexec_load */
 
 	.balign 8
 _GLOBAL(sys_call_table)
@@ -1121,3 +1122,4 @@ _GLOBAL(sys_call_table)
 	.llong .sys_mq_timedreceive	/* 265 */
 	.llong .sys_mq_notify
 	.llong .sys_mq_getsetattr
+	.llong .sys_ni_syscall		/* 268 reserved for sys_kexec_load */
diff -puN arch/ppc/kernel/misc.S~kexec-reserve-syscall-slot arch/ppc/kernel/misc.S
--- 25/arch/ppc/kernel/misc.S~kexec-reserve-syscall-slot	Mon May 17 14:04:46 2004
+++ 25-akpm/arch/ppc/kernel/misc.S	Mon May 17 14:04:46 2004
@@ -1397,3 +1397,4 @@ _GLOBAL(sys_call_table)
 	.long sys_mq_timedreceive	/* 265 */
 	.long sys_mq_notify
 	.long sys_mq_getsetattr
+	.long sys_ni_syscall		/* 268 reserved for sys_kexec_load */
diff -puN include/asm-ia64/unistd.h~kexec-reserve-syscall-slot include/asm-ia64/unistd.h
--- 25/include/asm-ia64/unistd.h~kexec-reserve-syscall-slot	Mon May 17 14:04:46 2004
+++ 25-akpm/include/asm-ia64/unistd.h	Mon May 17 14:04:46 2004
@@ -257,6 +257,7 @@
 #define __NR_mq_timedreceive		1265
 #define __NR_mq_notify			1266
 #define __NR_mq_getsetattr		1267
+#define __NR_kexec_load			1268
 
 #ifdef __KERNEL__
 
diff -puN include/asm-ppc64/unistd.h~kexec-reserve-syscall-slot include/asm-ppc64/unistd.h
--- 25/include/asm-ppc64/unistd.h~kexec-reserve-syscall-slot	Mon May 17 14:04:46 2004
+++ 25-akpm/include/asm-ppc64/unistd.h	Mon May 17 14:04:46 2004
@@ -278,8 +278,9 @@
 #define __NR_mq_timedreceive	265
 #define __NR_mq_notify		266
 #define __NR_mq_getsetattr	267
+#define __NR_kexec_load		268
 
-#define __NR_syscalls		268
+#define __NR_syscalls		269
 #ifdef __KERNEL__
 #define NR_syscalls	__NR_syscalls
 #endif
diff -puN include/asm-ppc/unistd.h~kexec-reserve-syscall-slot include/asm-ppc/unistd.h
--- 25/include/asm-ppc/unistd.h~kexec-reserve-syscall-slot	Mon May 17 14:04:46 2004
+++ 25-akpm/include/asm-ppc/unistd.h	Mon May 17 14:04:46 2004
@@ -272,8 +272,9 @@
 #define __NR_mq_timedreceive	265
 #define __NR_mq_notify		266
 #define __NR_mq_getsetattr	267
+#define __NR_kexec_load		268
 
-#define __NR_syscalls		268
+#define __NR_syscalls		269
 
 #define __NR(n)	#n
 
diff -puN include/asm-x86_64/unistd.h~kexec-reserve-syscall-slot include/asm-x86_64/unistd.h
--- 25/include/asm-x86_64/unistd.h~kexec-reserve-syscall-slot	Mon May 17 14:04:46 2004
+++ 25-akpm/include/asm-x86_64/unistd.h	Mon May 17 14:04:46 2004
@@ -552,8 +552,10 @@ __SYSCALL(__NR_mq_timedreceive, sys_mq_t
 __SYSCALL(__NR_mq_notify, sys_mq_notify)
 #define __NR_mq_getsetattr 	245
 __SYSCALL(__NR_mq_getsetattr, sys_mq_getsetattr)
+#define __NR_kexec_load 	246
+__SYSCALL(__NR_kexec_load, sys_ni_syscall)
 
-#define __NR_syscall_max __NR_mq_getsetattr
+#define __NR_syscall_max __NR_kexec_load
 #ifndef __NO_STUBS
 
 /* user-visible error numbers are in the range -1 - -4095 */
diff -puN include/linux/reboot.h~kexec-reserve-syscall-slot include/linux/reboot.h
--- 25/include/linux/reboot.h~kexec-reserve-syscall-slot	Mon May 17 14:04:46 2004
+++ 25-akpm/include/linux/reboot.h	Mon May 17 14:04:46 2004
@@ -22,6 +22,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 system using a previously loaded Linux kernel
  */
 
 #define	LINUX_REBOOT_CMD_RESTART	0x01234567
@@ -31,6 +32,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__
diff -puN include/linux/syscalls.h~kexec-reserve-syscall-slot include/linux/syscalls.h
--- 25/include/linux/syscalls.h~kexec-reserve-syscall-slot	Mon May 17 14:04:46 2004
+++ 25-akpm/include/linux/syscalls.h	Mon May 17 14:04:46 2004
@@ -19,6 +19,7 @@ struct io_event;
 struct iovec;
 struct itimerspec;
 struct itimerval;
+struct kexec_segment;
 struct linux_dirent;
 struct linux_dirent64;
 struct list_head;
@@ -154,6 +155,8 @@ asmlinkage long sys_shutdown(int, int);
 asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd,
 				void __user *arg);
 asmlinkage long sys_restart_syscall(void);
+asmlinkage long sys_kexec_load(void *entry, unsigned long nr_segments,
+			struct kexec_segment *segments, unsigned long flags);
 
 asmlinkage long sys_exit(int error_code);
 asmlinkage void sys_exit_group(int error_code);
diff -puN arch/i386/kernel/entry.S~kexec-reserve-syscall-slot arch/i386/kernel/entry.S
--- 25/arch/i386/kernel/entry.S~kexec-reserve-syscall-slot	Mon May 17 14:04:46 2004
+++ 25-akpm/arch/i386/kernel/entry.S	Mon May 17 14:04:46 2004
@@ -911,5 +911,6 @@ ENTRY(sys_call_table)
 	.long sys_mq_timedreceive	/* 280 */
 	.long sys_mq_notify
 	.long sys_mq_getsetattr
+	.long sys_ni_syscall		/* reserved for kexec */
 
 syscall_table_size=(.-sys_call_table)
diff -puN include/asm-i386/unistd.h~kexec-reserve-syscall-slot include/asm-i386/unistd.h
--- 25/include/asm-i386/unistd.h~kexec-reserve-syscall-slot	Mon May 17 14:04:46 2004
+++ 25-akpm/include/asm-i386/unistd.h	Mon May 17 14:04:46 2004
@@ -288,8 +288,9 @@
 #define __NR_mq_timedreceive	(__NR_mq_open+3)
 #define __NR_mq_notify		(__NR_mq_open+4)
 #define __NR_mq_getsetattr	(__NR_mq_open+5)
+#define __NR_sys_kexec_load	283
 
-#define NR_syscalls 283
+#define NR_syscalls 284
 
 /* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
 
diff -puN arch/ia64/kernel/entry.S~kexec-reserve-syscall-slot arch/ia64/kernel/entry.S
--- 25/arch/ia64/kernel/entry.S~kexec-reserve-syscall-slot	Mon May 17 14:43:07 2004
+++ 25-akpm/arch/ia64/kernel/entry.S	Mon May 17 14:44:00 2004
@@ -1510,7 +1510,7 @@ sys_call_table:
 	data8 sys_mq_timedreceive		// 1265
 	data8 sys_mq_notify
 	data8 sys_mq_getsetattr
-	data8 sys_ni_syscall
+	data8 sys_ni_syscall			// reserved for kexec_load
 	data8 sys_ni_syscall
 	data8 sys_ni_syscall			// 1270
 	data8 sys_ni_syscall

_