Skip to contentSkip to conversation

NPTL support on ia32

PATCH Arun Sharma 2 participants 2 messages Oct 18, 2003 exec and binfmt

lore
Share & tools
lore
#0 lore raw

The attached patch helps you run NPTL based IA-32 threaded programs on Itanium. Specifically it:

- adds support for new NPTL related system calls
- adds support for a per-CPU GDT, just like i386 does
- adds support for new clone related flags
- Fix clobbering of %ebp (r13) (see process.c)

Please review and let me know if you have any comments.

-Arun

include/asm-ia64/ia32.h +2 -0
Index: linux-2.6/include/asm-ia64/ia32.h
===================================================================
@@ -9,9 +9,11 @@
 #ifdef CONFIG_IA32_SUPPORT
 
 extern void ia32_cpu_init (void);
+extern void ia32_boot_gdt_init (void);
 extern void ia32_gdt_init (void);
 extern int ia32_exception (struct pt_regs *regs, unsigned long isr);
 extern int ia32_intercept (struct pt_regs *regs, unsigned long isr);
+extern int ia32_clone_tls(struct task_struct *child, struct pt_regs *childregs);
 
 #endif /* !CONFIG_IA32_SUPPORT */
 
include/asm-ia64/processor.h +22 -0
Index: linux-2.6/include/asm-ia64/processor.h
===================================================================
@@ -230,6 +230,25 @@
 		 (int *) (addr));								\
 })
 
+#ifdef CONFIG_IA32_SUPPORT
+struct desc_struct {
+	unsigned int a,b;
+};
+
+#define desc_empty(desc) \
+		(!((desc)->a + (desc)->b))
+
+#define desc_equal(desc1, desc2) \
+		(((desc1)->a == (desc2)->a) && ((desc1)->b == (desc2)->b))
+
+#define GDT_ENTRY_TLS_ENTRIES	3
+#define GDT_ENTRY_TLS_MIN	6
+#define GDT_ENTRY_TLS_MAX 	(GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
+
+#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8)
+
+#endif
+
 struct thread_struct {
 	__u32 flags;			/* various thread flags (see IA64_THREAD_*) */
 	/* writing on_ustack is performance-critical, so it's worth spending 8 bits on it... */
@@ -249,6 +268,9 @@
 	__u64 fdr;			/* IA32 fp except. data reg */
 	__u64 old_k1;			/* old value of ar.k1 */
 	__u64 old_iob;			/* old IOBase value */
+        /* cached TLS descriptors. */
+	struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
+
 # define INIT_THREAD_IA32	.eflag =	0,			\
 				.fsr =		0,			\
 				.fcr =		0x17800000037fULL,	\
arch/ia64/kernel/process.c +10 -2
Index: linux-2.6/arch/ia64/kernel/process.c
===================================================================
@@ -36,6 +36,10 @@
 # include <asm/perfmon.h>
 #endif
 
+#ifdef CONFIG_IA32_SUPPORT
+#include <asm/ia32.h>
+#endif
+
 #include "sigframe.h"
 
 void (*ia64_mark_idle)(int);
@@ -324,7 +328,8 @@
 	memcpy((void *) child_rbs, (void *) rbs, rbs_size);
 
 	if (user_mode(child_ptregs)) {
-		if (clone_flags & CLONE_SETTLS)
+		if ((clone_flags & CLONE_SETTLS) && (!IS_IA32_PROCESS(regs)))
+
 			child_ptregs->r13 = regs->r16;	/* see sys_clone2() in entry.S */
 		if (user_stack_base) {
 			child_ptregs->r12 = user_stack_base + user_stack_size - 16;
@@ -383,8 +388,11 @@
 	 * If we're cloning an IA32 task then save the IA32 extra
 	 * state from the current task to the new task
 	 */
-	if (IS_IA32_PROCESS(ia64_task_regs(current)))
+	if (IS_IA32_PROCESS(ia64_task_regs(current))) {
 		ia32_save_state(p);
+		if (clone_flags & CLONE_SETTLS)
+			retval = ia32_clone_tls(p, child_ptregs);
+	}
 #endif
 
 #ifdef CONFIG_PERFMON
arch/ia64/kernel/smpboot.c +6 -0
Index: linux-2.6/arch/ia64/kernel/smpboot.c
===================================================================
@@ -47,6 +47,9 @@
 #include <asm/sal.h>
 #include <asm/system.h>
 #include <asm/unistd.h>
+#ifdef CONFIG_IA32_SUPPORT
+#include <asm/ia32.h>
+#endif
 
 #define SMP_DEBUG 0
 
@@ -312,6 +315,9 @@
 	local_irq_enable();
 	calibrate_delay();
 	local_cpu_data->loops_per_jiffy = loops_per_jiffy;
+#ifdef CONFIG_IA32_SUPPORT
+	ia32_gdt_init();
+#endif
 
 	if (!(sal_platform_features & IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT)) {
 		/*
arch/ia64/mm/init.c +1 -1
Index: linux-2.6/arch/ia64/mm/init.c
===================================================================
@@ -555,6 +555,6 @@
 	setup_gate();	/* setup gate pages before we free up boot memory... */
 
 #ifdef CONFIG_IA32_SUPPORT
-	ia32_gdt_init();
+	ia32_boot_gdt_init();
 #endif
 }
arch/ia64/ia32/ia32_entry.S +9 -7
Index: linux-2.6/arch/ia64/ia32/ia32_entry.S
===================================================================
@@ -32,7 +32,7 @@
 
 ENTRY(ia32_clone)
 	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
-	alloc r16=ar.pfs,2,2,4,0
+	alloc r16=ar.pfs,5,2,6,0
 	DO_SAVE_SWITCH_STACK
 	mov loc0=rp
 	mov loc1=r16				// save ar.pfs across do_fork
@@ -41,6 +41,8 @@
 	mov out3=16				// stacksize (compensates for 16-byte scratch area)
 	adds out2=IA64_SWITCH_STACK_SIZE+16,sp	// out2 = &regs
 	dep out0=0,in0,CLONE_IDLETASK_BIT,1	// out0 = clone_flags & ~CLONE_IDLETASK
+	zxt4 out4=in2				// out4 = parent_tidptr
+	zxt4 out5=in4				// out5 = child_tidptr
 	br.call.sptk.many rp=do_fork
 .ret0:	.restore sp
 	adds sp=IA64_SWITCH_STACK_SIZE,sp	// pop the switch stack
@@ -424,13 +426,13 @@
 	data8 sys_ni_syscall	/* 235 */
 	data8 sys_ni_syscall
 	data8 sys_ni_syscall
+	data8 sys_tkill
 	data8 sys_ni_syscall
-	data8 sys_ni_syscall
 	data8 compat_sys_futex	/* 240 */
 	data8 compat_sys_sched_setaffinity
 	data8 compat_sys_sched_getaffinity
-	data8 sys_ni_syscall
-	data8 sys_ni_syscall
+	data8 sys32_set_thread_area
+	data8 sys32_get_thread_area
 	data8 sys_ni_syscall	/* 245 */
 	data8 sys_ni_syscall
 	data8 sys_ni_syscall
@@ -438,14 +440,14 @@
 	data8 sys_ni_syscall
 	data8 sys_ni_syscall	/* 250 */
 	data8 sys_ni_syscall
+	data8 sys_exit_group
 	data8 sys_ni_syscall
-	data8 sys_ni_syscall
 	data8 sys_epoll_create
 	data8 sys32_epoll_ctl	/* 255 */
 	data8 sys32_epoll_wait
+	data8 sys_remap_file_pages
+	data8 sys_set_tid_address
 	data8 sys_ni_syscall
-	data8 sys_ni_syscall
-	data8 sys_ni_syscall
 	data8 sys_ni_syscall	/* 260 */
 	data8 sys_ni_syscall
 	data8 sys_ni_syscall
arch/ia64/ia32/ia32_ldt.c +1 -1
Index: linux-2.6/arch/ia64/ia32/ia32_ldt.c
===================================================================
@@ -82,7 +82,7 @@
 static int
 write_ldt (void * ptr, unsigned long bytecount, int oldmode)
 {
-	struct ia32_modify_ldt_ldt_s ldt_info;
+	struct ia32_user_desc ldt_info;
 	__u64 entry;
 	int ret;
 
arch/ia64/ia32/ia32priv.h +54 -5

76 lines not on this page · raw message

arch/ia64/ia32/binfmt_elf32.c +1 -1
Index: linux-2.6/arch/ia64/ia32/binfmt_elf32.c
===================================================================
@@ -62,7 +62,7 @@
 struct page *
 ia32_install_shared_page (struct vm_area_struct *vma, unsigned long address, int no_share)
 {
-	struct page *pg = ia32_shared_page[(address - vma->vm_start)/PAGE_SIZE];
+	struct page *pg = ia32_shared_page[ smp_processor_id() + (address - vma->vm_start)/PAGE_SIZE];
 
 	get_page(pg);
 	return pg;
arch/ia64/ia32/ia32_support.c +67 -28

160 lines not on this page · raw message

arch/ia64/ia32/sys_ia32.c +110 -0

116 lines not on this page · raw message

#1 lore raw

Argh, this is bad timing. I don't think there is much chance Linus will let this slip through as a "bug fix" (especially not now that test8 is out).

	--david