x86_64 patch for OpenSSI - 1 of 6 - Modified base files for CI

John Hughes <[email protected]> Fri, 12 Feb 2010 15:56:07 +0100
Newsgroups gmane.linux.cluster.ssic.devel
Message-ID <[email protected]>
This first patch modifies the base kernel x86_64 architecture files for 
CI.  (kernel/include/asm-x86_64 and kernel/arch/x86_64).

To apply:

   1. get the current (12/2/2010) CI cvs to ./ci

   2. extract the base 2.6.11 kernel to ./linux

   3. save the patch as ./ci-base-x86_64.patch

   4. cd ./ci/kernel

   5. copy the files from the base kernel:

      perl -MFile::Basename -MFile::Copy -ane 'next unless $F[0] eq "Index:"; \
      	system "mkdir -p " .dirname $F[1]; \
      	copy ("../../linux/" .$F[1], $F[1])' ../../base-ci-x86_64.patch

   6. Apply the patch:

      patch -p0 <../../base-ci/x86_64.patch

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev

_______________________________________________
ssic-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ssic-linux-devel
base-ci-x86_64.patch (text/x-patch, 6.7 KB)
Index: arch/x86_64/Kconfig
===================================================================
RCS file: /usr/local/lib/cvs-repo/openssi-future/arch/x86_64/Kconfig,v
retrieving revision 1.1.1.2
retrieving revision 1.1.1.2.4.1
diff -u -p -r1.1.1.2 -r1.1.1.2.4.1
--- arch/x86_64/Kconfig	17 Jun 2005 19:48:29 -0000	1.1.1.2
+++ arch/x86_64/Kconfig	22 Jan 2010 12:12:25 -0000	1.1.1.2.4.1
@@ -495,3 +495,5 @@ source "security/Kconfig"
 source "crypto/Kconfig"
 
 source "lib/Kconfig"
+
+source "cluster/Kconfig"
Index: arch/x86_64/kernel/entry.S
===================================================================
RCS file: /usr/local/lib/cvs-repo/openssi-future/arch/x86_64/kernel/entry.S,v
retrieving revision 1.1.1.2
retrieving revision 1.1.1.2.4.3
diff -u -p -r1.1.1.2 -r1.1.1.2.4.3
--- arch/x86_64/kernel/entry.S	17 Jun 2005 19:48:29 -0000	1.1.1.2
+++ arch/x86_64/kernel/entry.S	27 Jan 2010 14:38:25 -0000	1.1.1.2.4.3
@@ -127,6 +127,7 @@ ENTRY(ret_from_fork)
 	CFI_DEFAULT_STACK
 	call schedule_tail
 	GET_THREAD_INFO(%rcx)
+ret_from_fork_common:
 	testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),threadinfo_flags(%rcx)
 	jnz rff_trace
 rff_action:	
@@ -143,6 +144,47 @@ rff_trace:
 	GET_THREAD_INFO(%rcx)	
 	jmp rff_action
 	CFI_ENDPROC
+#ifdef CONFIG_SSI
+ENTRY(ret_from_rproc)
+	CFI_STARTPROC
+	CFI_DEFAULT_STACK
+	GET_THREAD_INFO(%r8)
+	movq %r8,%rax
+	addq $THREAD_SIZE-SS-8,%rax
+	subq $SS+8,%rax                 # destination for new regs
+	movl %esi,%ebx                  # save signal flag
+	movq %rdi,%rsi                  # pointer to regs (assumed on stack)
+	cmpq %rsp,%rax                  # stack above register destination?
+	jae 10f
+	movq %rax,%rsp                  # no, make room on stack
+10:
+	# Copy registers onto stack; taken from memmove()
+
+	movq $(SS+8)/8,%rcx
+	movq %rax,%rdi
+
+	cmpq %rdi,%rsi                  # dst before src?
+	jae 20f
+
+	movq $SS,%rdx                   # no, copy backwards
+	addq %rdx,%rsi
+	addq %rdx,%rdi
+	std
+20:
+	rep movsq
+	cld
+
+	movq %rax,%rsp                  # set correct stack address
+
+	movq %r8,%rcx
+	test %ebx,%ebx                  # %ebx != 0 => signal return
+	jne ret_from_fork_common
+
+	movq $0,RAX(%rsp)       # set the syscall return value (success)
+	jmp ret_from_fork_common
+	CFI_ENDPROC
+#endif
+
 
 /*
  * System call entry. Upto 6 arguments in registers are supported.
@@ -336,6 +378,12 @@ int_restore_rest:
 	PTREGSCALL stub_sigaltstack, sys_sigaltstack, %rdx
 	PTREGSCALL stub_iopl, sys_iopl, %rsi
 
+#ifdef CONFIG_SSI
+	PTREGSCALL stub_migrate, sys_migrate, %rsi
+	PTREGSCALL stub_rfork, sys_rfork, %rsi
+	PTREGSCALL stub_rexecve, sys_rexecve, %r8
+#endif
+
 ENTRY(ptregscall_common)
 	CFI_STARTPROC
 	popq %r11
@@ -710,8 +758,16 @@ bad_gs: 
  *
  * asm input arguments:
  *	rdi: fn, rsi: arg, rdx: flags
+#ifdef CONFIG_SSI
+ *     rcx: pid
+#endif
  */
+#ifdef CONFIG_SSI
+ENTRY(__kernel_thread_with_pid)
+	# rcx: pid
+#else
 ENTRY(kernel_thread)
+#endif
 	CFI_STARTPROC
 	FAKE_STACK_FRAME $child_rip
 	SAVE_ALL
@@ -722,11 +778,21 @@ ENTRY(kernel_thread)
 	movq $-1, %rsi
 	movq %rsp, %rdx
 
+#ifdef CONFIG_SSI
+	pushq   %rcx
+	xorq    %rcx, %rcx
+#endif
+
 	xorl %r8d,%r8d
 	xorl %r9d,%r9d
 	
 	# clone now
+#ifdef CONFIG_SSI
+	call __do_fork
+	popq    %rcx
+#else
 	call do_fork
+#endif
 	movq %rax,RAX(%rsp)
 	xorl %edi,%edi
 
Index: include/asm-x86_64/processor.h
===================================================================
RCS file: /usr/local/lib/cvs-repo/openssi-future/include/asm-x86_64/processor.h,v
retrieving revision 1.1.1.2
retrieving revision 1.1.1.2.4.1
diff -u -p -r1.1.1.2 -r1.1.1.2.4.1
--- include/asm-x86_64/processor.h	17 Jun 2005 19:48:29 -0000	1.1.1.2
+++ include/asm-x86_64/processor.h	22 Jan 2010 12:12:26 -0000	1.1.1.2.4.1
@@ -288,10 +288,22 @@ extern void release_thread(struct task_s
 /* Prepare to copy thread state - unlazy all lazy status */
 extern void prepare_to_copy(struct task_struct *tsk);
 
+extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
+
 /*
  * create a kernel thread without removing it from tasklists
  */
+#ifdef CONFIG_SSI
+extern long __kernel_thread_with_pid(int (*fn)(void *), void * arg, unsigned long flags, pid_t pid);
+#define kernel_thread_with_pid(fn, arg, flags, pid) \
+	__kernel_thread_with_pid(fn, arg, flags, pid)
+
+#define kernel_thread(fn, arg, flags) \
+	__kernel_thread_with_pid(fn, arg, flags, 0)
+#else
 extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
+#endif
+
 
 /*
  * Return saved PC of a blocked thread.
Index: include/asm-x86_64/thread_info.h
===================================================================
RCS file: /usr/local/lib/cvs-repo/openssi-future/include/asm-x86_64/thread_info.h,v
retrieving revision 1.1.1.2
retrieving revision 1.1.1.2.4.1
diff -u -p -r1.1.1.2 -r1.1.1.2.4.1
--- include/asm-x86_64/thread_info.h	17 Jun 2005 19:48:29 -0000	1.1.1.2
+++ include/asm-x86_64/thread_info.h	22 Jan 2010 12:12:26 -0000	1.1.1.2.4.1
@@ -109,6 +109,11 @@ static inline struct thread_info *stack_
 #define TIF_ABI_PENDING		19
 #define TIF_MEMDIE		20
 
+#ifdef CONFIG_SSI
+#define TIF_MIGPENDING          9       /* process migration pending */
+#define TIF_MIGSTRESS           10      /* process stress migration */
+#endif
+
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
Index: include/asm-x86_64/unistd.h
===================================================================
RCS file: /usr/local/lib/cvs-repo/openssi-future/include/asm-x86_64/unistd.h,v
retrieving revision 1.1.1.2
retrieving revision 1.1.1.2.4.3
diff -u -p -r1.1.1.2 -r1.1.1.2.4.3
--- include/asm-x86_64/unistd.h	17 Jun 2005 19:48:29 -0000	1.1.1.2
+++ include/asm-x86_64/unistd.h	25 Jan 2010 19:23:11 -0000	1.1.1.2.4.3
@@ -562,7 +562,22 @@ __SYSCALL(__NR_request_key, sys_request_
 #define __NR_keyctl		250
 __SYSCALL(__NR_keyctl, sys_keyctl)
 
-#define __NR_syscall_max __NR_keyctl
+/* BEGIN CLUSTER SYSTEM CALLS */
+
+/* By the time we get to 2.6.32 the max syscall is up to 298!
+   By sheer coincidence these numbers match the 386 kernel.
+   Comment at top of file says no holes, but why? */
+
+#define __NR_ssisys             350     /* Base kernel up to 332 at 2.6.29 */
+__SYSCALL(__NR_ssisys, sys_ssisys)
+#define __NR_rfork              351
+__SYSCALL(__NR_rfork, stub_rfork)
+#define __NR_rexecve            352
+__SYSCALL(__NR_rexecve, stub_rexecve)
+#define __NR_migrate            353
+__SYSCALL(__NR_migrate, stub_migrate)
+
+#define __NR_syscall_max __NR_migrate
 #ifndef __NO_STUBS
 
 /* user-visible error numbers are in the range -1 - -4095 */
@@ -579,6 +594,7 @@ do { \
 } while (0)
 
 #ifdef __KERNEL__
+#define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_OLD_STAT
 #define __ARCH_WANT_SYS_ALARM