Add private syscalls to support NPTL
Subsystems (3)
Hello Geert,
The attached patches add kernel support for userspace NPTL bits for m68k.
Since the draft m68k/ColdFire NPTL ABI was posted at http://marc.info/?l=linux-m68k&m=119644992713696&w=2 several issues surfaced that called for syscall equivalents of the vDSO helpers; the main reason for the syscalls is that GLIBC does not support linking in vDSO for static binaries.
Another reason is that I'm having problems implementing user-space atomic_cmpxchg (for ColdFire) and context switching for user-space TP (both m68k and ColdFire). I've spent quite some time trying to figure these two out, but couldn't make everything work reliably. I'll follow up on this in a different thread.
These patches were tested on a ColdFire board running a 2.6.29 kernel, and the system passed GLIBC's nptl tests.
The one issue I know of with this patch is that strace needs update to pretty print the new [negative] syscalls.
Does the patches look fine?
Thanks,
--
Maxim K.
CodeSourcery
Quoted 1 line
From
fda8fc4e5706e93f527c2cbc554813f090a1a3feMon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <[email protected]>
Date: Mon, 17 Aug 2009 12:16:36 -0700
Subject: [PATCH 1/2] Add syscalls to support m68k NPTL.
This patch adds several syscalls, private to M68K, that provide necessary functionality to support NPTL.
The syscalls are read_tp, write_tp, atomic_cmpxchg_32 and atomic_barrier. The cmpxchg syscall is required for ColdFire as it doesn't support 'cas' instruction.
--- arch/m68k/include/asm/thread_info_mm.h | 1 + arch/m68k/include/asm/unistd.h | 7 +++ arch/m68k/kernel/entry.S | 10 ++++- arch/m68k/kernel/sys_m68k.c | 78 ++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 1 deletions(-)
arch/m68k/include/asm/thread_info_mm.h +1 -0
@@ -10,6 +10,7 @@ struct thread_info {struct exec_domain *exec_domain;/* execution domain */ int preempt_count;/* 0 => preemptable, <0 => BUG */ __u32 cpu;/* should always be 0 on m68k */ +unsigned long tp_value;struct restart_block restart_block; };
arch/m68k/include/asm/unistd.h +7 -0
@@ -335,9 +335,16 @@#define __NR_preadv 329#define __NR_pwritev 330 +/* Private syscalls. */ +#define __M68K_NR_read_tp 0xffffffff +#define __M68K_NR_write_tp 0xfffffffe +#define __M68K_NR_atomic_cmpxchg_32 0xfffffffd +#define __M68K_NR_atomic_barrier 0xfffffffc +#ifdef __KERNEL__#define NR_syscalls 331 +#define M68K_NR_syscalls 0xfffffffb#define __ARCH_WANT_IPC_PARSE_VERSION#define __ARCH_WANT_OLD_READDIR
arch/m68k/kernel/entry.S +9 -1
@@ -86,6 +86,8 @@ do_trace_entry: movel %sp@(PT_ORIG_D0),%d0 cmpl #NR_syscalls,%d0 jcs syscall + cmpl #M68K_NR_syscalls,%d0 + jcc syscall badsys: movel #-ENOSYS,%sp@(PT_D0) jra ret_from_syscall
@@ -124,7 +126,9 @@ ENTRY(system_call) tstb %curptr@(TASK_INFO+TINFO_FLAGS+2) jmi do_trace_entry cmpl #NR_syscalls,%d0 - jcc badsys + jcs syscall + cmpl #M68K_NR_syscalls,%d0 + jcs badsys syscall: jbsr @(sys_call_table,%d0:l:4)@(0) movel %d0,%sp@(PT_D0) | save the return value
@@ -423,6 +427,10 @@ resume: .data ALIGN + .long m68k_sys_atomic_barrier /* 0xfffffffc */ + .long m68k_sys_atomic_cmpxchg_32 /* 0xfffffffd */ + .long m68k_sys_write_tp /* 0xfffffffe */ + .long m68k_sys_read_tp /* 0xffffffff */ sys_call_table: .long sys_restart_syscall /* 0 - old "setup()" system call, used for restarting */ .long sys_exit
arch/m68k/kernel/sys_m68k.c +78 -0
87 lines not on this page · raw message
Signature · 1 line
1.6.2.4
Quoted 1 line
From
14291fcace3b39c5302716f0b1972e586d2b991aMon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <[email protected]>
Date: Mon, 17 Aug 2009 12:40:56 -0700
Subject: [PATCH 2/2] Update m68k's clone_thread.
This patch adds handling of CLONE_SETTLS flag to m68k's clone_thread.
--- arch/m68k/kernel/process.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
arch/m68k/kernel/process.c +4 -0
@@ -251,6 +251,10 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, p->thread.usp = usp; p->thread.ksp = (unsigned long )childstack; + +if (clone_flags &CLONE_SETTLS ) +task_thread_info (p)->tp_value = regs->d5; +/* * Must save the current SFC/DFC value, NOT the value when * the parent was last descheduled - RGH 10-08-96
Signature · 1 line
1.6.2.4
arch/m68k/include/asm/unistd.h line 342
Quoted 13 lines · Maxim Kuvyrkov
arch/m68k/include/asm/unistd.h +5
-0@@ -335,9 +335,16 @@#define __NR_preadv 329#define __NR_pwritev 330 +/* Private syscalls. */ +#define __M68K_NR_read_tp 0xffffffff +#define __M68K_NR_write_tp 0xfffffffe +#define __M68K_NR_atomic_cmpxchg_32 0xfffffffd +#define __M68K_NR_atomic_barrier 0xfffffffc
I don't see the need for these weird syscall numbers.
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 10 lines · Andreas Schwab
Quoted 8 lines · Maxim Kuvyrkov
arch/m68k/include/asm/unistd.h +0
-0@@ -335,9 +335,16 @@#define __NR_preadv 329#define __NR_pwritev 330
Quoted 7 lines
arch/m68k/include/asm/unistd.h line 342
Quoted 5 lines
arch/m68k/include/asm/unistd.h +5
-0+/* Private syscalls. */ +#define __M68K_NR_read_tp 0xffffffff +#define __M68K_NR_write_tp 0xfffffffe +#define __M68K_NR_atomic_cmpxchg_32 0xfffffffd +#define __M68K_NR_atomic_barrier 0xfffffffcI don't see the need for these weird syscall numbers.
The need would be (a) use numbers that are very unlikely to used for normal syscalls, and (b) using -1..-4 for the syscall numbers works out quite nicely for the code in entry.S. It adds just a couple of instructions to the execution path.
Do you think it's better to assign different numbers to the m68k-specific syscall?
--
Maxim
Quoted 2 lines · Maxim Kuvyrkov
The need would be (a) use numbers that are very unlikely to used for normal syscalls,
I don't understand. These are normal syscalls.
Quoted 3 lines
and (b) using -1..-4 for the syscall numbers works out quite nicely for the code in
entry.S. It adds just a couple of instructions to the execution path.
Those additional instructions are totally unnecessary.
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 5 lines · Andreas Schwab
Quoted 2 lines · Maxim Kuvyrkov
The need would be (a) use numbers that are very unlikely to used for normal syscalls,
Quoted 7 lines
I don't understand. These are normal syscalls.
Quoted 3 lines
and (b) using -1..-4 for the syscall numbers works out quite nicely for the code in
entry.S. It adds just a couple of instructions to the execution path.Those additional instructions are totally unnecessary.
Hm, I though it would be preferable to keep syscalls that are specific to m68k (in the sense that no other target requires them) separate from the ones implementing standard unix/linux functionality.
If the consensus is that the new syscalls should received 331..334 numbers, that would only simplify the implementation.
--
Maxim
Geert Uytterhoeven
maintainerQuoted 11 lines · Maxim Kuvyrkov
Quoted 10 lines · Andreas Schwab
Quoted 2 lines · Maxim Kuvyrkov
The need would be (a) use numbers that are very unlikely to used for normal syscalls,
I don't understand. These are normal syscalls.
Quoted 3 lines
and (b) using -1..-4 for the syscall numbers works out quite nicely for the code in
entry.S. It adds just a couple of instructions to the execution path.
Quoted 8 lines
Quoted 1 line
Those additional instructions are totally unnecessary.
Hm, I though it would be preferable to keep syscalls that are specific to m68k (in the sense that no other target requires them) separate from the ones implementing standard unix/linux functionality.
If the consensus is that the new syscalls should received 331..334 numbers, that would only simplify the implementation.
I prefer to just add them at the bottom of the list.
(slowly recovering from my backlog) I noticed some new syscalls got added recently:
| <stdin>:1515:2: warning: #warning syscall rt_tgsigqueueinfo not implemented | <stdin>:1519:2: warning: #warning syscall perf_counter_open not implemented
Probably I should wire those up first (for 2.6.31, if still possible).
Next I should reserve 333..336 for you?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 23 lines · Geert Uytterhoeven
Quoted 9 lines · Maxim Kuvyrkov
Quoted 8 lines · Andreas Schwab
Quoted 2 lines · Maxim Kuvyrkov
The need would be (a) use numbers that are very unlikely to used for normal syscalls,
I don't understand. These are normal syscalls.
Quoted 3 lines
and (b) using -1..-4 for the syscall numbers works out quite nicely for the code in
entry.S. It adds just a couple of instructions to the execution path.Quoted 7 lines
Quoted 1 line
Those additional instructions are totally unnecessary.
Hm, I though it would be preferable to keep syscalls that are specific to m68k (in the sense that no other target requires them) separate from the ones implementing standard unix/linux functionality.
If the consensus is that the new syscalls should received 331..334 numbers, that would only simplify the implementation.
I prefer to just add them at the bottom of the list.
(slowly recovering from my backlog) I noticed some new syscalls got added recently:
Quoted 6 lines
| <stdin>:1515:2: warning: #warning syscall
rt_tgsigqueueinfonot implemented | <stdin>:1519:2: warning: #warning syscallperf_counter_opennot implementedProbably I should wire those up first (for 2.6.31, if still possible).
Next I should reserve 333..336 for you?
That's fine, thank you. I'll follow up with an updated patch in couple of days.
--
Maxim
Quoted 3 lines · Geert Uytterhoeven
Probably I should wire those up first (for 2.6.31, if still possible).
Next I should reserve 333..336 for you?
We could even (re-)use some of the smaller numbers that were never implemented, allowing the use of moveq.
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 11 lines · Geert Uytterhoeven
I prefer to just add them at the bottom of the list.
(slowly recovering from my backlog) I noticed some new syscalls got added recently:
| <stdin>:1515:2: warning: #warning syscall
rt_tgsigqueueinfonot implemented | <stdin>:1519:2: warning: #warning syscallperf_counter_opennot implementedProbably I should wire those up first (for 2.6.31, if still possible).
Next I should reserve 333..336 for you?
Here is the updated patch.
I moved the declaration of do_page_fault() to the beginning of the file, same as another user of this function -- traps.c -- does.
Regards,
--
Maxim K.
CodeSourcery
From 2e11b258c406cd5cd71b82c39066d9dc35010891 Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <[email protected]>
Date: Mon, 24 Aug 2009 00:10:33 +0400
Subject: [PATCH] Add syscalls to support m68k NPTL.
This patch adds several syscalls, private to M68K, that provide necessary functionality to support NPTL.
The syscalls are read_tp, write_tp, atomic_cmpxchg_32 and atomic_barrier. The cmpxchg syscall is required for ColdFire as it doesn't support 'cas' instruction.
--- arch/m68k/include/asm/thread_info_mm.h | 1 + arch/m68k/kernel/entry.S | 4 ++ arch/m68k/kernel/sys_m68k.c | 82 ++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 0 deletions(-)
arch/m68k/include/asm/thread_info_mm.h +1 -0
@@ -10,6 +10,7 @@ struct thread_info {struct exec_domain *exec_domain;/* execution domain */ int preempt_count;/* 0 => preemptable, <0 => BUG */ __u32 cpu;/* should always be 0 on m68k */ +unsigned long tp_value;struct restart_block restart_block; };
arch/m68k/kernel/entry.S +4 -0
@@ -757,4 +757,8 @@ sys_call_table: .long sys_pwritev /* 330 */ .long sys_rt_tgsigqueueinfo .long sys_perf_counter_open + .long sys_read_tp + .long sys_write_tp + .long sys_atomic_cmpxchg_32 /* 335 */ + .long sys_atomic_barrier
arch/m68k/kernel/sys_m68k.c +82 -0
91 lines not on this page · raw message
Signature · 1 line
1.6.4
Quoted 1 line · Maxim Kuvyrkov
Here is the updated patch.
Hm, I've attached the patch without the unistd.h hunk. Here is the proper one.
--
Maxim K.
CodeSourcery
From 828160ab5d329e15543a50d0b50ce50f2975966b Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <[email protected]>
Date: Tue, 25 Aug 2009 23:37:26 +0400
Subject: [PATCH] Add syscalls to support m68k NPTL.
This patch adds several syscalls, private to M68K, that provide necessary functionality to support NPTL.
The syscalls are read_tp, write_tp, atomic_cmpxchg_32 and atomic_barrier. The cmpxchg syscall is required for ColdFire as it doesn't support 'cas' instruction.
--- arch/m68k/include/asm/thread_info_mm.h | 1 + arch/m68k/include/asm/unistd.h | 6 ++- arch/m68k/kernel/entry.S | 4 ++ arch/m68k/kernel/sys_m68k.c | 82 ++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 1 deletions(-)
arch/m68k/include/asm/thread_info_mm.h +1 -0
@@ -10,6 +10,7 @@ struct thread_info {struct exec_domain *exec_domain;/* execution domain */ int preempt_count;/* 0 => preemptable, <0 => BUG */ __u32 cpu;/* should always be 0 on m68k */ +unsigned long tp_value;struct restart_block restart_block; };
arch/m68k/include/asm/unistd.h +5 -1
@@ -336,10 +336,14 @@#define __NR_pwritev 330#define __NR_rt_tgsigqueueinfo 331#define __NR_perf_counter_open 332 +#define __NR_read_tp 333 +#define __NR_write_tp 334 +#define __NR_atomic_cmpxchg_32 335 +#define __NR_atomic_barrier 336#ifdef __KERNEL__ -#define NR_syscalls 333 +#define NR_syscalls 337#define __ARCH_WANT_IPC_PARSE_VERSION#define __ARCH_WANT_OLD_READDIR
arch/m68k/kernel/entry.S +4 -0
@@ -757,4 +757,8 @@ sys_call_table: .long sys_pwritev /* 330 */ .long sys_rt_tgsigqueueinfo .long sys_perf_counter_open + .long sys_read_tp + .long sys_write_tp + .long sys_atomic_cmpxchg_32 /* 335 */ + .long sys_atomic_barrier
arch/m68k/kernel/sys_m68k.c +82 -0
91 lines not on this page · raw message
Signature · 1 line
1.6.4
Quoted 5 lines · Maxim Kuvyrkov
Quoted 1 line · Maxim Kuvyrkov
Here is the updated patch.
Hm, I've attached the patch without the
unistd.hhunk. Here is the proper one.
Yet, another update patch. This version fixes several indentation errors.
BTW, Geert, what is the preferred branch in m68k git repository for patches to be sent against? I looked around and 'for-linus' seems to be the most appropriate choice.
--
Maxim K.
CodeSourcery
From 2d7f5332009cf6bbc4029fb62979d0cd19b2e0d9 Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <[email protected]>
Date: Fri, 28 Aug 2009 14:46:21 +0400
Subject: [PATCH] Add syscalls to support m68k NPTL.
This patch adds several syscalls, that provide necessary functionality to support NPTL on m68k/ColdFire.
The syscalls are read_tp, write_tp, atomic_cmpxchg_32 and atomic_barrier. The cmpxchg syscall is required for ColdFire as it doesn't support 'cas' instruction.
--- arch/m68k/include/asm/thread_info_mm.h | 1 + arch/m68k/include/asm/unistd.h | 6 ++- arch/m68k/kernel/entry.S | 4 ++ arch/m68k/kernel/process.c | 4 ++ arch/m68k/kernel/sys_m68k.c | 82 ++++++++++++++++++++++++++++++++ 5 files changed, 96 insertions(+), 1 deletions(-)
arch/m68k/include/asm/thread_info_mm.h +1 -0
@@ -10,6 +10,7 @@ struct thread_info {struct exec_domain *exec_domain;/* execution domain */ int preempt_count;/* 0 => preemptable, <0 => BUG */ __u32 cpu;/* should always be 0 on m68k */ +unsigned long tp_value;struct restart_block restart_block; };
arch/m68k/include/asm/unistd.h +5 -1
@@ -336,10 +336,14 @@#define __NR_pwritev 330#define __NR_rt_tgsigqueueinfo 331#define __NR_perf_counter_open 332 +#define __NR_read_tp 333 +#define __NR_write_tp 334 +#define __NR_atomic_cmpxchg_32 335 +#define __NR_atomic_barrier 336#ifdef __KERNEL__ -#define NR_syscalls 333 +#define NR_syscalls 337#define __ARCH_WANT_IPC_PARSE_VERSION#define __ARCH_WANT_OLD_READDIR
arch/m68k/kernel/entry.S +4 -0
@@ -757,4 +757,8 @@ sys_call_table: .long sys_pwritev /* 330 */ .long sys_rt_tgsigqueueinfo .long sys_perf_counter_open + .long sys_read_tp + .long sys_write_tp + .long sys_atomic_cmpxchg_32 /* 335 */ + .long sys_atomic_barrier
arch/m68k/kernel/process.c +4 -0
@@ -251,6 +251,10 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, p->thread.usp = usp; p->thread.ksp = (unsigned long )childstack; + +if (clone_flags &CLONE_SETTLS ) +task_thread_info (p)->tp_value = regs->d5; +/* * Must save the current SFC/DFC value, NOT the value when * the parent was last descheduled - RGH 10-08-96
arch/m68k/kernel/sys_m68k.c +82 -0
91 lines not on this page · raw message
Signature · 1 line
1.6.4
Quoted 10 lines · Maxim Kuvyrkov
Quoted 5 lines · Maxim Kuvyrkov
Quoted 1 line · Maxim Kuvyrkov
Here is the updated patch.
Hm, I've attached the patch without the
unistd.hhunk. Here is the proper one.Yet, another update patch. This version fixes several indentation errors.
BTW, Geert, what is the preferred branch in m68k git repository for patches to be sent against? I looked around and 'for-linus' seems to be the most appropriate choice.
Yet another update. The difference compared to the previous patch is attached in the first file.
The new version fixes a potential bug in the cmpxchg implementation and adds ptrace hook to allow debugging of TLS variables (corresponding gdbserver patch is yet to be submitted).
Geert, in case there'll be further changes in the NPTL patch, would you like me submit full patch against original tree or only the incremental difference?
Thanks,
--
Maxim K.
CodeSourcery
arch/m68k/include/asm/ptrace.h +2 -0
@@ -71,6 +71,8 @@ struct switch_stack {#define PTRACE_GETFPREGS 14#define PTRACE_SETFPREGS 15 +#define PTRACE_GET_THREAD_AREA 25 +#ifdef __KERNEL__#ifndef PS_S
arch/m68k/kernel/ptrace.c +5 -0
@@ -265,6 +265,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ret = -EFAULT ;break ; +case PTRACE_GET_THREAD_AREA : + ret =put_user (task_thread_info (child)->tp_value, + (unsigned long __user *) data); +break ; +default : ret =ptrace_request (child, request, addr, data);break ;
arch/m68k/kernel/sys_m68k.c +1 -2
@@ -688,10 +688,9 @@ asmlinkage int sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5, unsigned long __user *mem) { -struct mm_struct *mm = current->mm; -/* This was borrowed from ARM's implementation. */ for (;;) { +struct mm_struct *mm = current->mm;pgd_t *pgd;pmd_t *pmd;pte_t *pte;spinlock_t *ptl;unsigned long mem_value;
From 5e74222fec124ea8d3c6d8b2514c638dc5622a25 Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <[email protected]>
Date: Fri, 28 Aug 2009 14:46:21 +0400
Subject: [PATCH] Add NPTL support for m68k.
This patch adds several syscalls, that provide necessary functionality to support NPTL on m68k/ColdFire.
The syscalls are read_tp, write_tp, atomic_cmpxchg_32 and atomic_barrier. The cmpxchg syscall is required for ColdFire as it doesn't support 'cas' instruction.
Also a ptrace call PTRACE_GET_THREAD_AREA is added to allow debugger to inspect the TLS storage.
--- arch/m68k/include/asm/ptrace.h | 2 + arch/m68k/include/asm/thread_info_mm.h | 1 + arch/m68k/include/asm/unistd.h | 6 ++- arch/m68k/kernel/entry.S | 4 ++ arch/m68k/kernel/process.c | 4 ++ arch/m68k/kernel/ptrace.c | 5 ++ arch/m68k/kernel/sys_m68k.c | 81 ++++++++++++++++++++++++++++++++ 7 files changed, 102 insertions(+), 1 deletions(-)
arch/m68k/include/asm/ptrace.h +2 -0
@@ -71,6 +71,8 @@ struct switch_stack {#define PTRACE_GETFPREGS 14#define PTRACE_SETFPREGS 15 +#define PTRACE_GET_THREAD_AREA 25 +#ifdef __KERNEL__#ifndef PS_S
arch/m68k/include/asm/thread_info_mm.h +1 -0
@@ -10,6 +10,7 @@ struct thread_info {struct exec_domain *exec_domain;/* execution domain */ int preempt_count;/* 0 => preemptable, <0 => BUG */ __u32 cpu;/* should always be 0 on m68k */ +unsigned long tp_value;struct restart_block restart_block; };
arch/m68k/include/asm/unistd.h +5 -1
@@ -336,10 +336,14 @@#define __NR_pwritev 330#define __NR_rt_tgsigqueueinfo 331#define __NR_perf_counter_open 332 +#define __NR_read_tp 333 +#define __NR_write_tp 334 +#define __NR_atomic_cmpxchg_32 335 +#define __NR_atomic_barrier 336#ifdef __KERNEL__ -#define NR_syscalls 333 +#define NR_syscalls 337#define __ARCH_WANT_IPC_PARSE_VERSION#define __ARCH_WANT_OLD_READDIR
arch/m68k/kernel/entry.S +4 -0
@@ -757,4 +757,8 @@ sys_call_table: .long sys_pwritev /* 330 */ .long sys_rt_tgsigqueueinfo .long sys_perf_counter_open + .long sys_read_tp + .long sys_write_tp + .long sys_atomic_cmpxchg_32 /* 335 */ + .long sys_atomic_barrier
arch/m68k/kernel/process.c +4 -0
@@ -251,6 +251,10 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, p->thread.usp = usp; p->thread.ksp = (unsigned long )childstack; + +if (clone_flags &CLONE_SETTLS ) +task_thread_info (p)->tp_value = regs->d5; +/* * Must save the current SFC/DFC value, NOT the value when * the parent was last descheduled - RGH 10-08-96
arch/m68k/kernel/ptrace.c +5 -0
@@ -265,6 +265,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ret = -EFAULT ;break ; +case PTRACE_GET_THREAD_AREA : + ret =put_user (task_thread_info (child)->tp_value, + (unsigned long __user *) data); +break ; +default : ret =ptrace_request (child, request, addr, data);break ;
arch/m68k/kernel/sys_m68k.c +81 -0
90 lines not on this page · raw message
Signature · 1 line
1.6.4
Maxim Kuvyrkov wrote:
...
Quoted 1 line
Geert, in case there'll be further changes in the NPTL patch, would you like me submit full patch against original tree or only the incremental difference?
Ping.
Geert, did you have a chance to look over the patch from Oct. 2 2009?
I've done a lot of testing since then and TLS/NPTL support on m68k/ColdFire is now stable enough to have no unexpected failures on binutils, gcc, g++, libstdc++ and glibc testsuites.
Thanks,
Signature · 4 lines
Maxim Kuvyrkov CodeSourcery [email protected] (650) 331-3385 x724
Quoted 6 lines · Maxim Kuvyrkov
Maxim Kuvyrkov wrote:
...Quoted 3 lines
Geert, in case there'll be further changes in the NPTL patch, would you like me submit full patch against original tree or only the incremental difference?
Quoted 7 lines
Ping.
Geert, did you have a chance to look over the patch from Oct. 2 2009?
I've done a lot of testing since then and TLS/NPTL support on m68k/ColdFire is now stable enough to have no unexpected failures on binutils, gcc, g++, libstdc++ and glibc testsuites.
Nice work. I'm looking forward to eglibc patches so I can build a current toolchain.
I suppose you can't really backport to eglibc 2.10 until the siginfo question is resolved. It appears from the list traffic that the consensus is to adopt the generic struct layout here. Is that the solution that you've used in testing? If so, can you send the patches you been testing?
Thanks,
Finn
Quoted 4 lines
Thanks,
Quoted 5 lines · Finn Thain
Quoted 2 lines · Maxim Kuvyrkov
Maxim Kuvyrkov wrote:
...
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Geert, in case there'll be further changes in the NPTL patch, would you like me submit full patch against original tree or only the incremental difference?
Ping.
Geert, did you have a chance to look over the patch from Oct. 2 2009?
I've done a lot of testing since then and TLS/NPTL support on m68k/ColdFire is now stable enough to have no unexpected failures on binutils, gcc, g++, libstdc++ and glibc testsuites.
Nice work. I'm looking forward to eglibc patches so I can build a current toolchain.
We [CodeSourcery] have just updated all of our toolchains, and the GNU/Linux toolchain is based on EGLIBC 2.10 and has well tested TLS/NPTL support. If you are targeting ColdFire you can simply download the toolchain at <http://www.codesourcery.com/sgpp/lite/coldfire>.
Quoted 1 line
I suppose you can't really backport to eglibc 2.10 until the siginfo question is resolved. It appears from the list traffic that the consensus is to adopt the generic struct layout here. Is that the solution that you've used in testing?
I'm not sure if any parts of the m68k kernel port depend on the custom layout of siginfo, so I've only fixed the pieces which I'm sure are wrong. I.e, I've been testing with this <http://marc.info/?l=linux-m68k&m=125447365311948&w=2> patch.
Quoted 1 line
If so, can you send the patches you been testing?
All the patches are in the mailing lists.
The kernel patches are at
http://marc.info/?l=linux-m68k&m=125447760017098&w=2
http://marc.info/?l=linux-m68k&m=125447365311948&w=2
The [E]GLIBC patches are at
[M68K/ColdFire patch 1/n] Update sysdep.h
http://sourceware.org/ml/libc-ports/2009-08/msg00006.html
[M68K/ColdFire patch 2/n] Add CFI information to dl-trampoline.S
http://sourceware.org/ml/libc-ports/2009-08/msg00007.html
[M68K/ColdFire patch 3/n] Update jmpbuf-unwind.h
http://sourceware.org/ml/libc-ports/2009-08/msg00008.html
[M68K/ColdFire patch 4/n] Remove kernel headers
Update by hand to match your kernel
[M68K/ColdFire patch 5/n] Main NPTL patch
http://sourceware.org/ml/libc-ports/2009-10/msg00006.html
http://sourceware.org/ml/libc-ports/2009-10/msg00030.html
[M68K/ColdFire patch 6/n] Add TLS relocations to elf/elf.h
http://sourceware.org/ml/libc-ports/2009-08/msg00012.html
Should I post this one to glibc-alpha@ for the review?
[M68K/ColdFire patch 7/n] Handle libgcc_s.so.2
http://sourceware.org/bugzilla/show_bug.cgi?id=4457
Let me know if you find any particular problems with these patches.
Signature · 4 lines
Maxim Kuvyrkov CodeSourcery [email protected] (650) 331-3385 x724
Quoted 18 lines · Maxim Kuvyrkov
Quoted 17 lines · Finn Thain
Quoted 13 lines · Maxim Kuvyrkov
Maxim Kuvyrkov wrote:
...Quoted 3 lines
Geert, in case there'll be further changes in the NPTL patch, would you like me submit full patch against original tree or only the incremental difference?
Ping.
Geert, did you have a chance to look over the patch from Oct. 2 2009?
I've done a lot of testing since then and TLS/NPTL support on m68k/ColdFire is now stable enough to have no unexpected failures on binutils, gcc, g++, libstdc++ and glibc testsuites.
Quoted 7 lines
Quoted 2 lines
Nice work. I'm looking forward to eglibc patches so I can build a current toolchain.
We [CodeSourcery] have just updated all of our toolchains, and the GNU/Linux toolchain is based on EGLIBC 2.10 and has well tested TLS/NPTL support. If you are targeting ColdFire you can simply download the toolchain at <http://www.codesourcery.com/sgpp/lite/coldfire>.
At the moment I'm more interested in the m68k toolchain, particularly for debian. But thanks for the link, I was unaware of the free download.
Quoted 37 lines
Quoted 4 lines
I suppose you can't really backport to eglibc 2.10 until the siginfo question is resolved. It appears from the list traffic that the consensus is to adopt the generic struct layout here. Is that the solution that you've used in testing?
I'm not sure if any parts of the m68k kernel port depend on the custom layout of siginfo, so I've only fixed the pieces which I'm sure are wrong. I.e, I've been testing with this
<http://marc.info/?l=linux-m68k&m=125447365311948&w=2> patch.Quoted 1 line
If so, can you send the patches you been testing?
All the patches are in the mailing lists.
The kernel patches are at
http://marc.info/?l=linux-m68k&m=125447760017098&w=2
http://marc.info/?l=linux-m68k&m=125447365311948&w=2The [E]GLIBC patches are at
[M68K/ColdFire patch 1/n] Update
sysdep.h
http://sourceware.org/ml/libc-ports/2009-08/msg00006.html[M68K/ColdFire patch 2/n] Add CFI information to
dl-trampoline.S
http://sourceware.org/ml/libc-ports/2009-08/msg00007.html[M68K/ColdFire patch 3/n] Update
jmpbuf-unwind.h
http://sourceware.org/ml/libc-ports/2009-08/msg00008.html[M68K/ColdFire patch 4/n] Remove kernel headers
Update by hand to match your kernel[M68K/ColdFire patch 5/n] Main NPTL patch
http://sourceware.org/ml/libc-ports/2009-10/msg00006.html
http://sourceware.org/ml/libc-ports/2009-10/msg00030.html
Quoted 9 lines
[M68K/ColdFire patch 6/n] Add TLS relocations to
elf/elf.h
http://sourceware.org/ml/libc-ports/2009-08/msg00012.html
Should I post this one to glibc-alpha@ for the review?[M68K/ColdFire patch 7/n] Handle libgcc_s.so.2
http://sourceware.org/bugzilla/show_bug.cgi?id=4457Let me know if you find any particular problems with these patches.
That's a great help, thanks.
Finn
Quoted 17 lines · Maxim Kuvyrkov
...
We [CodeSourcery] have just updated all of our toolchains, and the GNU/Linux toolchain is based on EGLIBC 2.10 and has well tested TLS/NPTL support. If you are targeting ColdFire you can simply download the toolchain at <http://www.codesourcery.com/sgpp/lite/coldfire>.
Quoted 4 lines
I suppose you can't really backport to eglibc 2.10 until the siginfo question is resolved. It appears from the list traffic that the consensus is to adopt the generic struct layout here. Is that the solution that you've used in testing?
I'm not sure if any parts of the m68k kernel port depend on the custom layout of siginfo, so I've only fixed the pieces which I'm sure are wrong. I.e, I've been testing with this
<http://marc.info/?l=linux-m68k&m=125447365311948&w=2> patch.
Quoted 7 lines
Quoted 1 line
If so, can you send the patches you been testing?
All the patches are in the mailing lists.
The kernel patches are at
For the benefit of anyone playing along at home, I found that the first attachment ("patch.diff") is already merged in the second attachment
of the same message ("0001-Add-NPTL-support-for-m68k.patch").
Quoted 7 lines
http://marc.info/?l=linux-m68k&m=125447365311948&w=2
The [E]GLIBC patches are at
[M68K/ColdFire patch 1/n] Update
sysdep.h
http://sourceware.org/ml/libc-ports/2009-08/msg00006.html
Quoted 8 lines
[M68K/ColdFire patch 2/n] Add CFI information to
dl-trampoline.S
http://sourceware.org/ml/libc-ports/2009-08/msg00007.html[M68K/ColdFire patch 3/n] Update
jmpbuf-unwind.h
http://sourceware.org/ml/libc-ports/2009-08/msg00008.html[M68K/ColdFire patch 4/n] Remove kernel headers
Update by hand to match your kernel
I suppose I don't need to remove or update anything, since I build eglibc against fresh new kernel headers, from linux-2.6.31 patched with your TLS patches.
Quoted 2 lines
[M68K/ColdFire patch 5/n] Main NPTL patch
http://sourceware.org/ml/libc-ports/2009-10/msg00006.html
For the benefit of anyone else attempting this, the first patch in that email ("Don't bind rtld's vdso pointers to libc symbols") is merged into the second patch in the same email ("Nptl support for m68k/ColdFire").
I did run into a problem with this second patch. It doesn't apply to the eglibc_2.10 branch in svn as of yesterday. The following hunk is the problem:
sysdeps/unix/sysv/linux/m68k/Versions +12 -0
@@ -31,5 +31,17 @@ libc { } GLIBC_2.11 { fallocate64; + __m68k_read_tp; + } + GLIBC_PRIVATE { + __vdso_atomic_cmpxchg_32; __vdso_atomic_barrier; + } +} + +ld { + GLIBC_PRIVATE { + __rtld___vdso_read_tp; + __rtld___vdso_atomic_cmpxchg_32; + __rtld___vdso_atomic_barrier; } }
It appears that another patch is needed, to allow your patch to apply:
http://sourceware.org/ml/libc-ports/2009-05/msg00028.html
And probably this patch too (I used both):
http://sourceware.org/ml/libc-hacker/2009-05/msg00003.html
Should I be using any other patches?
Quoted 4 lines
http://sourceware.org/ml/libc-ports/2009-10/msg00030.html
[M68K/ColdFire patch 6/n] Add TLS relocations to
elf/elf.h
http://sourceware.org/ml/libc-ports/2009-08/msg00012.html
(Trap for the uwary: this patch is for eglibc/libc, the others are for eglibc/ports.)
Quoted 4 lines
Should I post this one to glibc-alpha@ for the review?
[M68K/ColdFire patch 7/n] Handle libgcc_s.so.2
http://sourceware.org/bugzilla/show_bug.cgi?id=4457
The two patches attached to that bug are already in the eglibc_2.10 branch, BTW.
Quoted 3 lines
Let me know if you find any particular problems with these patches.
Using the above patches, I am almost able to compile eglibc_2.10. But there is an old build failure (since glibc-2.4 I think) when linking libc.so:
/tmp/build/glibc-m68k-linux-gnu-3/libc_pic.os: In function fchownat': (.text+0x911c2): undefined reference to __atfct_seterrno' /tmp/gcc-4.4.1/lib/gcc/m68k-linux-gnu/4.4.1/../../../../m68k-linux-gnu/bin/ld: /tmp/build/glibc-m68k-linux-gnu-3/libc.so: hidden symbol `__atfct_seterrno' isn't defined /tmp/gcc-4.4.1/lib/gcc/m68k-linux-gnu/4.4.1/../../../../m68k-linux-gnu/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
make[1]: *** [/tmp/build/glibc-m68k-linux-gnu-3/libc.so] Error 1
make[1]: Leaving directory `/tmp/build/glibc-2.10.1'
make: *** [all] Error 2
To try to fix this issue, I've basically copied this patch:
http://sources.redhat.com/ml/libc-hacker/2006-08/msg00004.html
An m68k version is attached. Can someone have a look at it and tell whether this is the correct fix or not?
The end result is that I now have a NPTL/TLS m68k toolchain (binutils-2.19.51 and patched gcc-4.4.1). Thank you for making that possible. I've not run the test suites yet, but so far it seems to work.
Only, I did find that a statically linked binary (pccardctl) built with this toolchain segfaults ("unknown errorSegmentation fault") when run under a linux-2.6.31 kernel that lacks your patches. Is this expected?
Etch-m68k seems to run fine with or without the kernel patches. I've CC'd the debian-m68k list but I suppose they can't use any of this until both the siginfo ABI is resolved and eglibc passes its tests on m68k hardware.
Finn
ports/sysdeps/unix/sysv/linux/m68k/fchownat.c renamed from ports/sysdeps/unix/sysv/linux/m68k/fchownat.c.orig +24 -6
@@ -40,6 +40,24 @@int fchownat (int fd,const char *file,uid_t owner,gid_t group,int flag) { +int result; + +#ifdef __NR_fchownat +# ifndef __ASSUME_ATFCTS + if (__have_atfcts >= 0) +# endif + { + result = INLINE_SYSCALL (fchownat, 5, fd, file, owner, group, flag); +# ifndef __ASSUME_ATFCTS + if (result == -1 && errno == ENOSYS) + __have_atfcts = -1; + else +# endif + return result; + } +#endif + +#ifndef __ASSUME_ATFCTS if (flag & ~AT_SYMLINK_NOFOLLOW) { __set_errno (EINVAL);
@@ -66,18 +84,17 @@ file = buf; } -int result;INTERNAL_SYSCALL_DECL (err); -#if __ASSUME_32BITUIDS > 0 +# if __ASSUME_32BITUIDS > 0 if (flag & AT_SYMLINK_NOFOLLOW) result = INTERNAL_SYSCALL (lchown32, err, 3, CHECK_STRING (file), owner, group); else result = INTERNAL_SYSCALL (chown32, err, 3, CHECK_STRING (file), owner, group); -#else -# ifdef __NR_chown32 +# else +# ifdef __NR_chown32 if (__libc_missing_32bit_uids <= 0) { if (flag & AT_SYMLINK_NOFOLLOW)
@@ -94,7 +111,7 @@ __libc_missing_32bit_uids = 1; } -# endif /* __NR_chown32 */ +# endif /* __NR_chown32 */ if (((owner +1 ) > (gid_t) ((__kernel_uid_t) -1U )) || ((group +1 ) > (gid_t) ((__kernel_gid_t) -1U )))
@@ -109,7 +126,7 @@ else result =INTERNAL_SYSCALL (chown, err,3 ,CHECK_STRING (file), owner, group); -#endif +# endif if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err),0 )) {
@@ -117,6 +134,7 @@__atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); result = -1; } +#endif return result; }
Quoted 5 lines · Finn Thain
Quoted 3 lines · Maxim Kuvyrkov
...
We [CodeSourcery] have just updated all of our toolchains, and the GNU/Linux toolchain is based on EGLIBC 2.10 and has well tested TLS/NPTL support. If you are targeting ColdFire you can simply download the toolchain at <http://www.codesourcery.com/sgpp/lite/coldfire>.
...
Quoted 1 line
I did run into a problem with this second patch. It doesn't apply to the eglibc_2.10 branch in svn as of yesterday. The following hunk is the problem:
The patches posted are all against FSF GLIBC, not EGLIBC, so some conflicts are expected.
...
Quoted 10 lines
Using the above patches, I am almost able to compile eglibc_2.10. But there is an old build failure (since glibc-2.4 I think) when linking libc.so:
/tmp/build/glibc-m68k-linux-gnu-3/libc_pic.os: In functionfchownat': (.text+0x911c2): undefined reference to__atfct_seterrno'/tmp/gcc-4.4.1/lib/gcc/m68k-linux-gnu/4.4.1/../../../../m68k-linux-gnu/bin/ld:/tmp/build/glibc-m68k-linux-gnu-3/libc.so: hidden symbol `__atfct_seterrno' isn't defined/tmp/gcc-4.4.1/lib/gcc/m68k-linux-gnu/4.4.1/../../../../m68k-linux-gnu/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
make[1]: *** [/tmp/build/glibc-m68k-linux-gnu-3/libc.so] Error 1
make[1]: Leaving directory `/tmp/build/glibc-2.10.1'
make: *** [all] Error 2
Quoted 3 lines
To try to fix this issue, I've basically copied this patch:
http://sources.redhat.com/ml/libc-hacker/2006-08/msg00004.html
An m68k version is attached. Can someone have a look at it and tell whether this is the correct fix or not?
I don't really know, this is the first time I see this failure.
Quoted 3 lines
The end result is that I now have a NPTL/TLS m68k toolchain (binutils-2.19.51 and patched gcc-4.4.1). Thank you for making that possible. I've not run the test suites yet, but so far it seems to work.
Only, I did find that a statically linked binary (pccardctl) built with this toolchain segfaults ("unknown errorSegmentation fault") when run under a linux-2.6.31 kernel that lacks your patches. Is this expected?
The binary will certainly not work, but I remember run-time linker gracefully exiting with a proper error message when invoked on a system with unpatched kernel. I don't think I tested statically linked binaries on such system.
Signature · 4 lines
Maxim Kuvyrkov CodeSourcery [email protected] (650) 331-3385 x724
Quoted 10 lines · Maxim Kuvyrkov
Quoted 9 lines · Finn Thain
Quoted 7 lines · Maxim Kuvyrkov
...
We [CodeSourcery] have just updated all of our toolchains, and the GNU/Linux toolchain is based on EGLIBC 2.10 and has well tested TLS/NPTL support. If you are targeting ColdFire you can simply download the toolchain at
<http://www.codesourcery.com/sgpp/lite/coldfire>.
Quoted 7 lines
...
Quoted 3 lines
I did run into a problem with this second patch. It doesn't apply to the eglibc_2.10 branch in svn as of yesterday. The following hunk is the problem:
The patches posted are all against FSF GLIBC, not EGLIBC, so some conflicts are expected. ...
OK. I suppose that means no back-porting of other patches is required.
Quoted 16 lines
Quoted 16 lines
Using the above patches, I am almost able to compile eglibc_2.10. But there is an old build failure (since glibc-2.4 I think) when linking libc.so:
/tmp/build/glibc-m68k-linux-gnu-3/libc_pic.os: In function `fchownat':
(.text+0x911c2): undefined reference to `__atfct_seterrno'/tmp/gcc-4.4.1/lib/gcc/m68k-linux-gnu/4.4.1/../../../../m68k-linux-gnu/bin/ld:/tmp/build/glibc-m68k-linux-gnu-3/libc.so: hidden symbol `__atfct_seterrno' isn't defined/tmp/gcc-4.4.1/lib/gcc/m68k-linux-gnu/4.4.1/../../../../m68k-linux-gnu/bin/ld:
final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
make[1]: *** [/tmp/build/glibc-m68k-linux-gnu-3/libc.so] Error 1 make[1]: Leaving directory `/tmp/build/glibc-2.10.1'
make: *** [all] Error 2
Quoted 6 lines
Quoted 4 lines
To try to fix this issue, I've basically copied this patch:
http://sources.redhat.com/ml/libc-hacker/2006-08/msg00004.html
An m68k version is attached. Can someone have a look at it and tell whether this is the correct fix or not?I don't really know, this is the first time I see this failure.
I found out why it happens.
If you build eglibc with "--enable-kernel=2.6.31" it fails as above. If you omit that option, it works.
Do you think my patch is a reasonable solution? I don't understand it, I just copied it from x86 -- "monkey see, monkey do."
I used the eglibc-2.10/EGLIBC.cross-building script to test this. I configured eglibc with "--enable-add-ons=ports,nptl" to prevent localedef from breaking the configure step. Package versions were binutils-2.19.51, gcc-4.4.1 (patched), linux-2.6.31 (patched), eglibc 2_10 branch (patched).
I also tried eglibc trunk but the build failed elsewhere:
../sysdeps/unix/sysv/linux/i386/fcntl.c: In function '__fcntl_nocancel':../sysdeps/unix/sysv/linux/i386/fcntl.c:133: error: storage size of 'fex' isn't known ../sysdeps/unix/sysv/linux/i386/fcntl.c:134: error: 'F_GETOWN_EX' undeclared (first use in this function) ../sysdeps/unix/sysv/linux/i386/fcntl.c:134: error: (Each undeclared identifier is reported only once ../sysdeps/unix/sysv/linux/i386/fcntl.c:134: error: for each function it appears in.) ../sysdeps/unix/sysv/linux/i386/fcntl.c:136: error: 'F_OWNER_GID' undeclared (first use in this function) ../sysdeps/unix/sysv/linux/i386/fcntl.c:133: warning: unused variable 'fex'
make[2]: *** [/home/fthain/cross-build/m68k/obj/eglibc/io/fcntl.o] Error 1
make[2]: Leaving directory `/home/fthain/cross-build/src/eglibc-trunk-r9191/io'
make[1]: *** [io/subdir_lib] Error 2
make[1]: Leaving directory `/home/fthain/cross-build/src/eglibc-trunk-r9191'
make: *** [all] Error 2
For now I'm content with eglibc-2.10, since that is the version in the debian archive.
Quoted 6 lines
Quoted 6 lines
The end result is that I now have a NPTL/TLS m68k toolchain (binutils-2.19.51 and patched gcc-4.4.1). Thank you for making that possible. I've not run the test suites yet, but so far it seems to work.
Quoted 6 lines
Quoted 4 lines
Only, I did find that a statically linked binary (pccardctl) built with this toolchain segfaults ("unknown errorSegmentation fault") when run under a linux-2.6.31 kernel that lacks your patches. Is this expected?
The binary will certainly not work,
Right. I see that this is documented in the CodeSourcery G++ Lite m68k docs.
Finn
Quoted 5 lines
but I remember run-time linker gracefully exiting with a proper error message when invoked on a system with unpatched kernel. I don't think I tested statically linked binaries on such system.
Quoted 15 lines · Finn Thain
I also tried eglibc trunk but the build failed elsewhere:
../sysdeps/unix/sysv/linux/i386/fcntl.c: In function '__fcntl_nocancel':../sysdeps/unix/sysv/linux/i386/fcntl.c:133: error: storage size of 'fex' isn't known../sysdeps/unix/sysv/linux/i386/fcntl.c:134: error: 'F_GETOWN_EX' undeclared (first use in this function)../sysdeps/unix/sysv/linux/i386/fcntl.c:134: error: (Each undeclared identifier is reported only once../sysdeps/unix/sysv/linux/i386/fcntl.c:134: error: for each function it appears in.)../sysdeps/unix/sysv/linux/i386/fcntl.c:136: error: 'F_OWNER_GID' undeclared (first use in this function)../sysdeps/unix/sysv/linux/i386/fcntl.c:133: warning: unused variable 'fex'
make[2]: *** [/home/fthain/cross-build/m68k/obj/eglibc/io/fcntl.o] Error 1
make[2]: Leaving directory `/home/fthain/cross-build/src/eglibc-trunk-r9191/io'
make[1]: *** [io/subdir_lib] Error 2
make[1]: Leaving directory `/home/fthain/cross-build/src/eglibc-trunk-r9191'
make: *** [all] Error 2
Quoted 2 lines
For now I'm content with eglibc-2.10, since that is the version in the debian archive.
It looks like this needs a newer version of the kernel headers. That stuff was added relatively recently:
If I'm reading the dates correctly, this commit wasn't in 2.6.31.
As a side note, there is already a patch floating around to fix that commit, which apparently broke stuff.
http://patchwork.kernel.org/patch/56568/
Brad Boyer
[email protected]
Quoted 32 lines · Finn Thain
Quoted 9 lines · Maxim Kuvyrkov
Quoted 5 lines · Finn Thain
Quoted 3 lines · Maxim Kuvyrkov
...
We [CodeSourcery] have just updated all of our toolchains, and the GNU/Linux toolchain is based on EGLIBC 2.10 and has well tested TLS/NPTL support. If you are targeting ColdFire you can simply download the toolchain at <http://www.codesourcery.com/sgpp/lite/coldfire>.
...
Quoted 1 line
I did run into a problem with this second patch. It doesn't apply to the eglibc_2.10 branch in svn as of yesterday. The following hunk is the problem:
The patches posted are all against FSF GLIBC, not EGLIBC, so some conflicts are expected. ...
OK. I suppose that means no back-porting of other patches is required.
Quoted 17 lines
Quoted 17 lines
Using the above patches, I am almost able to compile eglibc_2.10. But there is an old build failure (since glibc-2.4 I think) when linking libc.so:
/tmp/build/glibc-m68k-linux-gnu-3/libc_pic.os: In function `fchownat':
(.text+0x911c2): undefined reference to `__atfct_seterrno'/tmp/gcc-4.4.1/lib/gcc/m68k-linux-gnu/4.4.1/../../../../m68k-linux-gnu/bin/ld:/tmp/build/glibc-m68k-linux-gnu-3/libc.so: hidden symbol `__atfct_seterrno' isn't defined/tmp/gcc-4.4.1/lib/gcc/m68k-linux-gnu/4.4.1/../../../../m68k-linux-gnu/bin/ld:
final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
make[1]: *** [/tmp/build/glibc-m68k-linux-gnu-3/libc.so] Error 1 make[1]: Leaving directory `/tmp/build/glibc-2.10.1'
make: *** [all] Error 2To try to fix this issue, I've basically copied this patch:
http://sources.redhat.com/ml/libc-hacker/2006-08/msg00004.html
An m68k version is attached. Can someone have a look at it and tell whether this is the correct fix or not?
Quoted 8 lines
Quoted 1 line
I don't really know, this is the first time I see this failure.
I found out why it happens.
If you build eglibc with "--enable-kernel=2.6.31" it fails as above. If you omit that option, it works.
Do you think my patch is a reasonable solution? I don't understand it, I just copied it from x86 -- "monkey see, monkey do."
I can't spot anything wrong in it.
Quoted 2 lines
I used the eglibc-2.10/EGLIBC.cross-building script to test this. I configured eglibc with "--enable-add-ons=ports,nptl" to prevent localedef from breaking the configure step. Package versions were binutils-2.19.51, gcc-4.4.1 (patched), linux-2.6.31 (patched), eglibc 2_10 branch (patched).
What hardware / emulator do you use to test the result? I tested all the work on ColdFire systems, but I also would like to run some tests on a usual m68k.
Regards,
Signature · 4 lines
Maxim Kuvyrkov CodeSourcery [email protected] (650) 331-3385 x724
Quoted 7 lines · Maxim Kuvyrkov
Quoted 3 lines · Finn Thain
Do you think my patch is a reasonable solution? I don't understand it, I just copied it from x86 -- "monkey see, monkey do."
I can't spot anything wrong in it.
Thanks for looking it over. I'll send it upstream.
Quoted 10 lines
Quoted 6 lines
I used the eglibc-2.10/EGLIBC.cross-building script to test this. I configured eglibc with "--enable-add-ons=ports,nptl" to prevent localedef from breaking the configure step. Package versions were binutils-2.19.51, gcc-4.4.1 (patched), linux-2.6.31 (patched), eglibc 2_10 branch (patched).
What hardware / emulator do you use to test the result? I tested all the work on ColdFire systems, but I also would like to run some tests on a usual m68k.
I've been testing on 68040 machines. I've not yet tried the test suites.
The latest random test I did was to build the cross toolchain using patched debian sid source packages. Then I copied sshd and its supporting libraries etc from an etch-m68k system into the toolchain sysroot, along with a few old busybox bits and pieces that I had lying around. I then exported the sysroot with NFS and booted that. After some messing around I was able to log in with ssh and gather the info below.
So far, so good!
Finn
# cat /proc/cpuinfo
CPU: 68040
MMU: 68040
FPU: 68040
Clocking: 24.6MHz
BogoMips: 16.43
Calibration: 82176 loops
# cat /proc/version
Linux version 2.6.31.5-mac (fthain@nippy) (gcc version 4.4.1 (GCC) ) #2 Wed Nov 11 00:52:38 EST 2009
# /lib/libc.so.6
GNU C Library (EGLIBC) stable release version 2.10.1, by Roland McGrath et al.
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.4.1.
Compiled on a Linux >>2.6.31.5<< system on 2009-11-10.
Available extensions:
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
Native POSIX Threads Library by Ulrich Drepper et al
Support for some architectures added on, not maintained in glibc core.
BIND-8.2.3-T5B
For bug reporting instructions, please see:
<http://www.eglibc.org/issues/>.
# cat /proc/649/maps
80000000-80047000 r-xp 00000000 00:0c 84898 /etch-m68k-root/usr/sbin/sshd
80048000-80049000 rw-p 00046000 00:0c 84898 /etch-m68k-root/usr/sbin/sshd
80049000-8006f000 rwxp 00000000 00:00 0 [heap]
c0000000-c0018000 r-xp 00000000 00:0c 115132 /lib/ld-2.10.1.so
c0018000-c0019000 rw-p 00000000 00:00 0
c0019000-c001a000 r--p 00019000 00:0c 115132 /lib/ld-2.10.1.so
c001a000-c001b000 rw-p 0001a000 00:0c 115132 /lib/ld-2.10.1.so
c001b000-c0022000 r-xp 00000000 00:0c 442806 /usr/local/lib/libwrap.so.0.7.6
c0022000-c0023000 ---p 00007000 00:0c 442806 /usr/local/lib/libwrap.so.0.7.6
c0023000-c0024000 rw-p 00006000 00:0c 442806 /usr/local/lib/libwrap.so.0.7.6
c0024000-c0025000 rw-p 00000000 00:00 0
c0025000-c002c000 r-xp 00000000 00:0c 442808 /usr/local/lib/libpam.so.0.79
c002c000-c002d000 ---p 00007000 00:0c 442808 /usr/local/lib/libpam.so.0.79
c002d000-c002f000 rw-p 00006000 00:0c 442808 /usr/local/lib/libpam.so.0.79
c002f000-c0030000 rw-p 00000000 00:00 0
c0030000-c0032000 r-xp 00000000 00:0c 115080 /lib/libdl-2.10.1.so
c0032000-c0033000 ---p 00002000 00:0c 115080 /lib/libdl-2.10.1.so
c0033000-c0034000 r--p 00001000 00:0c 115080 /lib/libdl-2.10.1.so
c0034000-c0035000 rw-p 00002000 00:0c 115080 /lib/libdl-2.10.1.so
c0035000-c0046000 r-xp 00000000 00:0c 442809 /usr/local/lib/libselinux.so.1
c0046000-c0047000 ---p 00011000 00:0c 442809 /usr/local/lib/libselinux.so.1
c0047000-c0048000 rw-p 00010000 00:0c 442809 /usr/local/lib/libselinux.so.1
c0048000-c0049000 rw-p 00000000 00:00 0
c0049000-c0058000 r-xp 00000000 00:0c 115096 /lib/libresolv-2.10.1.so
c0058000-c005a000 ---p 0000f000 00:0c 115096 /lib/libresolv-2.10.1.so
c005a000-c005b000 r--p 0000f000 00:0c 115096 /lib/libresolv-2.10.1.so
c005b000-c005c000 rw-p 00010000 00:0c 115096 /lib/libresolv-2.10.1.so
c005c000-c005e000 rw-p 00000000 00:00 0
c005e000-c016b000 r-xp 00000000 00:0c 442810 /usr/local/lib/libcrypto.so.0.9.8
c016b000-c016c000 ---p 0010d000 00:0c 442810 /usr/local/lib/libcrypto.so.0.9.8
c016c000-c0180000 rw-p 0010c000 00:0c 442810 /usr/local/lib/libcrypto.so.0.9.8
c0180000-c0184000 rw-p 00000000 00:00 0
c0184000-c0186000 r-xp 00000000 00:0c 115130 /lib/libutil-2.10.1.so
c0186000-c0187000 ---p 00002000 00:0c 115130 /lib/libutil-2.10.1.so
c0187000-c0188000 r--p 00001000 00:0c 115130 /lib/libutil-2.10.1.so
c0188000-c0189000 rw-p 00002000 00:0c 115130 /lib/libutil-2.10.1.so
c0189000-c019a000 r-xp 00000000 00:0c 442812 /usr/local/lib/libz.so.1.2.3
c019a000-c019b000 ---p 00011000 00:0c 442812 /usr/local/lib/libz.so.1.2.3
c019b000-c019c000 rw-p 00010000 00:0c 442812 /usr/local/lib/libz.so.1.2.3
c019c000-c019d000 rw-p 00000000 00:00 0
c019d000-c01af000 r-xp 00000000 00:0c 115120 /lib/libnsl-2.10.1.so
c01af000-c01b0000 ---p 00012000 00:0c 115120 /lib/libnsl-2.10.1.so
c01b0000-c01b1000 r--p 00011000 00:0c 115120 /lib/libnsl-2.10.1.so
c01b1000-c01b2000 rw-p 00012000 00:0c 115120 /lib/libnsl-2.10.1.so
c01b2000-c01b4000 rw-p 00000000 00:00 0
c01b4000-c01bd000 r-xp 00000000 00:0c 115088 /lib/libcrypt-2.10.1.so
c01bd000-c01bf000 ---p 00009000 00:0c 115088 /lib/libcrypt-2.10.1.so
c01bf000-c01c0000 r--p 00009000 00:0c 115088 /lib/libcrypt-2.10.1.so
c01c0000-c01c1000 rw-p 0000a000 00:0c 115088 /lib/libcrypt-2.10.1.so
c01c1000-c01e8000 rw-p 00000000 00:00 0
c01e8000-c01ff000 r-xp 00000000 00:0c 442814 /usr/local/lib/libgssapi_krb5.so.2.2
c01ff000-c0200000 ---p 00017000 00:0c 442814 /usr/local/lib/libgssapi_krb5.so.2.2
c0200000-c0201000 rw-p 00016000 00:0c 442814 /usr/local/lib/libgssapi_krb5.so.2.2
c0201000-c0269000 r-xp 00000000 00:0c 442816 /usr/local/lib/libkrb5.so.3.2
c0269000-c026a000 ---p 00068000 00:0c 442816 /usr/local/lib/libkrb5.so.3.2
c026a000-c026d000 rw-p 00067000 00:0c 442816 /usr/local/lib/libkrb5.so.3.2
c026d000-c028d000 r-xp 00000000 00:0c 442822 /usr/local/lib/libk5crypto.so.3.0
c028d000-c028e000 ---p 00020000 00:0c 442822 /usr/local/lib/libk5crypto.so.3.0
c028e000-c0290000 rw-p 0001f000 00:0c 442822 /usr/local/lib/libk5crypto.so.3.0
c0290000-c0292000 r-xp 00000000 00:0c 442818 /usr/local/lib/libcom_err.so.2.1
c0292000-c0293000 ---p 00002000 00:0c 442818 /usr/local/lib/libcom_err.so.2.1
c0293000-c0294000 rw-p 00001000 00:0c 442818 /usr/local/lib/libcom_err.so.2.1
c0294000-c0295000 rw-p 00000000 00:00 0
c0295000-c0298000 r-xp 00000000 00:0c 442820 /usr/local/lib/libkrb5support.so.0.0
c0298000-c0299000 ---p 00003000 00:0c 442820 /usr/local/lib/libkrb5support.so.0.0
c0299000-c029b000 rw-p 00002000 00:0c 442820 /usr/local/lib/libkrb5support.so.0.0
c029b000-c03b7000 r-xp 00000000 00:0c 114361 /lib/libc-2.10.1.so
c03b7000-c03b9000 r--p 0011c000 00:0c 114361 /lib/libc-2.10.1.so
c03b9000-c03bc000 rw-p 0011e000 00:0c 114361 /lib/libc-2.10.1.so
c03bc000-c03bf000 rw-p 00000000 00:00 0
c03bf000-c03f1000 r-xp 00000000 00:0c 442823 /usr/local/lib/libsepol.so.1
c03f1000-c03f2000 ---p 00032000 00:0c 442823 /usr/local/lib/libsepol.so.1
c03f2000-c03f4000 rw-p 00031000 00:0c 442823 /usr/local/lib/libsepol.so.1
c03f4000-c0401000 rw-p 00000000 00:00 0
c0401000-c0407000 r-xp 00000000 00:0c 115126 /lib/libnss_compat-2.10.1.so
c0407000-c0408000 ---p 00006000 00:0c 115126 /lib/libnss_compat-2.10.1.so
c0408000-c0409000 r--p 00005000 00:0c 115126 /lib/libnss_compat-2.10.1.so
c0409000-c040a000 rw-p 00006000 00:0c 115126 /lib/libnss_compat-2.10.1.so
c040a000-c0412000 r-xp 00000000 00:0c 115122 /lib/libnss_nis-2.10.1.so
c0412000-c0413000 ---p 00008000 00:0c 115122 /lib/libnss_nis-2.10.1.so
c0413000-c0414000 r--p 00007000 00:0c 115122 /lib/libnss_nis-2.10.1.so
c0414000-c0415000 rw-p 00008000 00:0c 115122 /lib/libnss_nis-2.10.1.so
c0415000-c041e000 r-xp 00000000 00:0c 115108 /lib/libnss_files-2.10.1.so
c041e000-c0420000 ---p 00009000 00:0c 115108 /lib/libnss_files-2.10.1.so
c0420000-c0421000 r--p 00009000 00:0c 115108 /lib/libnss_files-2.10.1.so
c0421000-c0422000 rw-p 0000a000 00:0c 115108 /lib/libnss_files-2.10.1.so
efcb7000-efccc000 rw-p 00000000 00:00 0 [stack]arch/m68k/kernel/sys_m68k.c int kernel_execve(const char *filename, char *const argv[], char *const envp[]) · line 723
Quoted 3 lines · Maxim Kuvyrkov
arch/m68k/kernel/sys_m68k.c +3
-0+ { +int do_page_fault (struct pt_regs *,unsigned long , +unsigned long );
Functions should always be declared in headers, and definitely never in block scope.
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 8 lines · Andreas Schwab
arch/m68k/kernel/sys_m68k.c int kernel_execve(const char *filename, char *const argv[], char *const envp[]) · line 723
Quoted 3 lines · Maxim Kuvyrkov
arch/m68k/kernel/sys_m68k.c +3
-0+ { +int do_page_fault (struct pt_regs *,unsigned long , +unsigned long );Functions should always be declared in headers, and definitely never in block scope.
I missed that when cleaning up the patch, will follow up with the fix once other issues are resolved.
--
Maxim
arch/m68k/kernel/sys_m68k.c int kernel_execve(const char *filename, char *const argv[], char *const envp[]) · line 686
Quoted 6 lines · Maxim Kuvyrkov
arch/m68k/kernel/sys_m68k.c +6
-0+/* This syscall gets its arguments in A0 (mem), A1 (oldval) and +D1 (newval). */ +asmlinkage int +m68k_sys_atomic_cmpxchg_32 (unsigned long newval,int d2,int d3,int d4,int d5, +unsigned long __user *mem,unsigned long oldval) +{
Any particular reason for this calling convention? The real CAS instruction specifically takes two data registers for the two values. It seems more logical to me to have oldval and newval in data registers and just have the mem argument in an address register.
For reference, here's the syntax summary from the m68k PRM:
CAS Dc, Du, <ea>
Brad Boyer
[email protected]
Quoted 12 lines · Brad Boyer
arch/m68k/kernel/sys_m68k.c int kernel_execve(const char *filename, char *const argv[], char *const envp[]) · line 686
Quoted 6 lines · Maxim Kuvyrkov
arch/m68k/kernel/sys_m68k.c +6
-0+/* This syscall gets its arguments in A0 (mem), A1 (oldval) and +D1 (newval). */ +asmlinkage int +m68k_sys_atomic_cmpxchg_32 (unsigned long newval,int d2,int d3,int d4,int d5, +unsigned long __user *mem,unsigned long oldval) +{Any particular reason for this calling convention? The real CAS instruction specifically takes two data registers for the two values. It seems more logical to me to have oldval and newval in data registers and just have the mem argument in an address register.
The reason for this calling convention is to minimize difference in invokation of the vDSO helper and the syscall. The helper gets its arguments in a0 (mem), d0 (oldval) and d1 (newval); in a stub, which is used when vDSO is not available, one then can do:
movel %d0,%a1
movel #NR,%d0
trap #0
--
Maxim
Quoted 15 lines · Maxim Kuvyrkov
Quoted 13 lines · Brad Boyer
Review
Quoted 7 lines · Maxim Kuvyrkov
arch/m68k/kernel/sys_m68k.c +4
-0+/* This syscall gets its arguments in A0 (mem), A1 (oldval) and +D1 (newval). */ +asmlinkage int +m68k_sys_atomic_cmpxchg_32(unsigned long newval, int d2, int d3, int d4,int d5,
(quoted diff) +2
-0+ unsigned long __user *mem, unsigned long oldval) +{Any particular reason for this calling convention? The real CAS instruction specifically takes two data registers for the two values. It seems more logical to me to have oldval and newval in data registers and just have the mem argument in an address register.
Quoted 8 lines
The reason for this calling convention is to minimize difference in invokation of the vDSO helper and the syscall. The helper gets its arguments in a0 (mem), d0 (oldval) and d1 (newval); in a stub, which is used when vDSO is not available, one then can do:
movel %d0,%a1
movel #NR,%d0
trap #0
Then wouldn't it make sense to use %d2 instead of %a1?
Brad Boyer
[email protected]
Quoted 14 lines · Brad Boyer
Quoted 13 lines · Maxim Kuvyrkov
Quoted 12 lines · Brad Boyer
Review
Quoted 7 lines · Maxim Kuvyrkov
arch/m68k/kernel/sys_m68k.c +4
-0+/* This syscall gets its arguments in A0 (mem), A1 (oldval) and +D1 (newval). */ +asmlinkage int +m68k_sys_atomic_cmpxchg_32(unsigned long newval, int d2, int d3, int d4,int d5,
(quoted diff) +2
-0+ unsigned long __user *mem, unsigned long oldval) +{Any particular reason for this calling convention? The real CAS instruction specifically takes two data registers for the two values. It seems more logical to me to have oldval and newval in data registers and just have the mem argument in an address register.
Quoted 7 lines
Quoted 5 lines
The reason for this calling convention is to minimize difference in invokation of the vDSO helper and the syscall. The helper gets its arguments in a0 (mem), d0 (oldval) and d1 (newval); in a stub, which is used when vDSO is not available, one then can do:
movel %d0,%a1
movel #NR,%d0
trap #0Then wouldn't it make sense to use %d2 instead of %a1?
Thanks for pointing this out, there's no reason for using %a1 /anymore/.
As for the past, %d2 is call-clobbered, so it would've needed saving
on the stack.
Initially, I planned to argue changing ABI of the vDSO kernel helper to allow clobber of %a1, but then decided that it doesn't worth it and that it's better to save/restore whatever register a value from %d0 is being moved to.
As there's no reasoning for using %a1 anymore, I'll make the syscall expect its arguments in %a0(mem), %d1(newval) and %d2(oldval).
--
Maxim K.
CodeSourcery
Quoted 11 lines · Brad Boyer
Quoted 8 lines · Maxim Kuvyrkov
The reason for this calling convention is to minimize difference in invokation of the vDSO helper and the syscall. The helper gets its arguments in a0 (mem), d0 (oldval) and d1 (newval); in a stub, which is used when vDSO is not available, one then can do:
movel %d0,%a1
movel #NR,%d0
trap #0Then wouldn't it make sense to use %d2 instead of %a1?
d2 is a callee-saved register, a1 isn't.
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 3 lines · Maxim Kuvyrkov
Hello Geert,
The attached patches add kernel support for userspace NPTL bits for m68k.
Here is yet another final version of the patch. As Andreas pointed out in another thread, the indentation is off in couple of places, so I fixed that by formatting the code with scripts/Lindent. I also forwarded the reformatted version of the uClinux patch to uclinux-dev@.
Signature · 4 lines
Maxim Kuvyrkov CodeSourcery [email protected] (650) 331-3385 x724
Quoted 1 line
From
571248e741ab66392ec0296f4662f3e893a9d105Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <[email protected]>
Date: Mon, 7 Dec 2009 00:24:27 -0800
Subject: [PATCH 1/2] Add NPTL support for m68k
This patch adds several syscalls, that provide necessary functionality to support NPTL on m68k/ColdFire.
The syscalls are read_tp, write_tp, atomic_cmpxchg_32 and atomic_barrier. The cmpxchg syscall is required for ColdFire as it doesn't support 'cas' instruction.
Also a ptrace call PTRACE_GET_THREAD_AREA is added to allow debugger to inspect the TLS storage.
--- arch/m68k/include/asm/ptrace.h | 2 + arch/m68k/include/asm/thread_info_mm.h | 1 + arch/m68k/include/asm/unistd.h | 6 ++- arch/m68k/kernel/entry.S | 4 ++ arch/m68k/kernel/process.c | 4 ++ arch/m68k/kernel/ptrace.c | 5 ++ arch/m68k/kernel/sys_m68k.c | 80 ++++++++++++++++++++++++++++++++ 7 files changed, 101 insertions(+), 1 deletions(-)
arch/m68k/include/asm/ptrace.h +2 -0
@@ -71,6 +71,8 @@ struct switch_stack {#define PTRACE_GETFPREGS 14#define PTRACE_SETFPREGS 15 +#define PTRACE_GET_THREAD_AREA 25 +#define PTRACE_SINGLEBLOCK 33/* resume execution until next branch */ #ifdef __KERNEL__
arch/m68k/include/asm/thread_info_mm.h +1 -0
@@ -16,6 +16,7 @@ struct thread_info {struct exec_domain *exec_domain;/* execution domain */ int preempt_count;/* 0 => preemptable, <0 => BUG */ __u32 cpu;/* should always be 0 on m68k */ +unsigned long tp_value; struct restart_block restart_block; };#endif /* __ASSEMBLY__ */
arch/m68k/include/asm/unistd.h +5 -1
@@ -336,10 +336,14 @@#define __NR_pwritev 330#define __NR_rt_tgsigqueueinfo 331#define __NR_perf_event_open 332 +#define __NR_read_tp 333 +#define __NR_write_tp 334 +#define __NR_atomic_cmpxchg_32 335 +#define __NR_atomic_barrier 336#ifdef __KERNEL__ -#define NR_syscalls 333 +#define NR_syscalls 337#define __ARCH_WANT_IPC_PARSE_VERSION#define __ARCH_WANT_OLD_READDIR
arch/m68k/kernel/entry.S +4 -0
@@ -761,4 +761,8 @@ sys_call_table: .long sys_pwritev /* 330 */ .long sys_rt_tgsigqueueinfo .long sys_perf_event_open + .long sys_read_tp + .long sys_write_tp + .long sys_atomic_cmpxchg_32 /* 335 */ + .long sys_atomic_barrier
arch/m68k/kernel/process.c +4 -0
@@ -251,6 +251,10 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, p->thread.usp = usp; p->thread.ksp = (unsigned long )childstack; + +if (clone_flags &CLONE_SETTLS ) +task_thread_info (p)->tp_value = regs->d5; +/* * Must save the current SFC/DFC value, NOT the value when * the parent was last descheduled - RGH 10-08-96
arch/m68k/kernel/ptrace.c +5 -0
@@ -245,6 +245,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ret = -EFAULT ;break ; +case PTRACE_GET_THREAD_AREA : + ret =put_user (task_thread_info (child)->tp_value, + (unsigned long __user *)data); +break ; +default : ret =ptrace_request (child, request, addr, data);break ;
arch/m68k/kernel/sys_m68k.c +80 -0
89 lines not on this page · raw message
Signature · 1 line
1.6.2.4
Hi!
I've been testing this patch (together w/the latest codesourcery toolchain release) on an m548x the last couple of days.
It looks like there is still an issue in sys_atomic_cmpxchg_32. When cloning a large process, it accesses memory it shouldn't:
cmpxchg32: new 1, old 0, mem 801cb604
cmpxchg32: new 2, old 1, mem 807f2404
cmpxchg32: new 1, old 0, mem 807f15b8
cmpxchg32: new 0, old 1, mem 801cb604
cmpxchg32: new 0, old 1, mem 801cb604
cmpxchg32: new 1, old 0, mem 801cb604
cmpxchg32: new 0, old 1, mem 801cb604
cmpxchg32: new 1, old 0, mem 801cb604
cmpxchg32: new 1, old 0, mem 801cbc7c
cmpxchg32: new 0, old 1, mem 801cb604
cmpxchg32: new 0, old 1, mem 801cbc7c
cmpxchg32: new 0, old 1, mem 807f15b8
cmpxchg32: new 1, old 0, mem 801cb5e0
cmpxchg32: new 0, old 1, mem 801cb5e0
cmpxchg32: new 1, old 0, mem 801cb604
cmpxchg32: new 1, old 2, mem 807f2404
cmpxchg32: new 1, old 0, mem 801cb5ec
cmpxchg32: new 0, old 1, mem 801cb604
Unable to handle kernel access at virtual address 807f2404 Oops: 00000000
PC: [<00021e50>]<0>
SR: 2004 SP: 031ebf54 a2: 0321c920
d0: 03ac7411 d1: 0315877c d2: 807f2404 d3: 00000002
d4: 000007e4 d5: 00000002 a0: 807f2404 a1: 0004f020
Process dapper (pid: 334, stackpage=0321e920) Stack from 031ebf54:
<0> 0315877c<0> 807f2404<0> 00000002<0> 000007e4<0> 00000002<0> 807f2404<0> 0004f020<0> 0321c920
<0> 03ac7411<0> ffffffff<0> 00000000<0> 807f2404<0> 0000000a<0> 48092004<0> 00021e50<0> 00000002
<0> 00000000<0> 80822278<0> 00000155<0> 00000002<0> 0000014e<0> 807f23f0<0> 806db658<0> 807ef2dc
<0> 01832000<0> 03158778<0> bf94fbec<0> 00023d2e<0> 00000001<0> 00000002<0> 00000000<0> 80822278
<0> 00000155<0> 807f2404<0> 807f2404<0> bf94fbac<0> 0000014f<0> 0000014f<0> 00000000<0> 807ef2f8
<0> 00000000<0> 40800000<0> 806db664System.map:00021d70 T sys_read_tp00021d7c T sys_write_tp 00021d8c T sys_atomic_barrier 00021d96 T sys_atomic_cmpxchg_32 00021e92 T sys_cacheflush 00021fdc T sys_ipc
I'm not sure why the page table calls that precede the *mem don't catch the forbidden access. Could the relevant TLB get replaced?
This happens every time one of our applications calls popen(). In smaller apps, popen works fine.. I'm currently trying to create a test app that reproduces this, will send that as soon as it's done. It looks like the difference is the amount of libraries the calling application is linked against, and/or stack usage.
I'll happily provide any additional debug info to help track this down. best regards,
Klaus
Quoted 223 lines · Maxim Kuvyrkov
Quoted 2 lines · Maxim Kuvyrkov
Hello Geert,
The attached patches add kernel support for userspace NPTL bits for m68k.Here is yet another final version of the patch. As Andreas pointed out in another thread, the indentation is off in couple of places, so I fixed that by formatting the code with
scripts/Lindent. I also forwarded the reformatted version of the uClinux patch to uclinux-dev@.Signature · 4 lines
Maxim Kuvyrkov CodeSourcery [email protected] (650) 331-3385 x724Quoted 1 line
From
571248e741ab66392ec0296f4662f3e893a9d105Mon Sep 17 00:00:00 2001From: Maxim Kuvyrkov <[email protected]>
Date: Mon, 7 Dec 2009 00:24:27 -0800
Subject: [PATCH 1/2] Add NPTL support for m68kThis patch adds several syscalls, that provide necessary functionality to support NPTL on m68k/ColdFire.
The syscalls areread_tp,write_tp,atomic_cmpxchg_32andatomic_barrier. The cmpxchg syscall is required for ColdFire as it doesn't support 'cas' instruction.Also a ptrace call
PTRACE_GET_THREAD_AREAis added to allow debugger to inspect the TLS storage.Signed-off-by Maxim Kuvyrkov <[email protected]>---
arch/m68k/include/asm/ptrace.h | 2 + arch/m68k/include/asm/thread_info_mm.h | 1 + arch/m68k/include/asm/unistd.h | 6 ++- arch/m68k/kernel/entry.S | 4 ++ arch/m68k/kernel/process.c | 4 ++ arch/m68k/kernel/ptrace.c | 5 ++ arch/m68k/kernel/sys_m68k.c | 80 ++++++++++++++++++++++++++++++++ 7 files changed, 101 insertions(+), 1 deletions(-)arch/m68k/include/asm/ptrace.h +2
-0@@ -71,6 +71,8 @@ struct switch_stack {#define PTRACE_GETFPREGS 14#define PTRACE_SETFPREGS 15 +#define PTRACE_GET_THREAD_AREA 25 +#define PTRACE_SINGLEBLOCK 33/* resume execution until next branch */ #ifdef __KERNEL__arch/m68k/include/asm/thread_info_mm.h +1
-0@@ -16,6 +16,7 @@ struct thread_info {struct exec_domain *exec_domain;/* execution domain */ int preempt_count;/* 0 => preemptable, <0 => BUG */ __u32 cpu;/* should always be 0 on m68k */ +unsigned long tp_value; struct restart_block restart_block; };#endif /* __ASSEMBLY__ */ arch/m68k/include/asm/unistd.h +5
-1@@ -336,10 +336,14 @@#define __NR_pwritev 330#define __NR_rt_tgsigqueueinfo 331#define __NR_perf_event_open 332 +#define __NR_read_tp 333 +#define __NR_write_tp 334 +#define __NR_atomic_cmpxchg_32 335 +#define __NR_atomic_barrier 336#ifdef __KERNEL__ -#define NR_syscalls 333 +#define NR_syscalls 337#define __ARCH_WANT_IPC_PARSE_VERSION#define __ARCH_WANT_OLD_READDIRarch/m68k/kernel/entry.S +4
-0@@ -761,4 +761,8 @@ sys_call_table: .long sys_pwritev /* 330 */ .long sys_rt_tgsigqueueinfo .long sys_perf_event_open + .long sys_read_tp + .long sys_write_tp + .long sys_atomic_cmpxchg_32 /* 335 */ + .long sys_atomic_barrierarch/m68k/kernel/process.c +4
-0@@ -251,6 +251,10 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, p->thread.usp = usp; p->thread.ksp = (unsigned long )childstack; + +if (clone_flags &CLONE_SETTLS ) +task_thread_info (p)->tp_value = regs->d5; +/* * Must save the current SFC/DFC value, NOT the value when * the parent was last descheduled - RGH 10-08-96 arch/m68k/kernel/ptrace.c +5
-0@@ -245,6 +245,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ret = -EFAULT ;break ; +case PTRACE_GET_THREAD_AREA : + ret =put_user (task_thread_info (child)->tp_value, + (unsigned long __user *)data); +break ; +default : ret =ptrace_request (child, request, addr, data);break ;arch/m68k/kernel/sys_m68k.c +5
-0@@ -28,6 +28,11 @@#include <asm/traps.h> #include <asm/page.h> #include <asm/unistd.h> +#include <linux/elf.h> +#include <asm/tlb.h> + +asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address, +unsigned long error_code);/* common code for old and new mmaps */ static inline long do_mmap2(
arch/m68k/kernel/sys_m68k.c +75
-0@@ -662,3 +667,78 @@ int kernel_execve(const char *filename, char *const argv[], char *const envp[]) : "d" (__a), "d" (__b), "d" (__c));return __res; } + +asmlinkage unsigned long sys_read_tp (void ) +{ +return current_thread_info ()->tp_value; +} + +asmlinkage int sys_write_tp(unsigned long tp) +{ +current_thread_info ()->tp_value = tp; +return 0 ; +} + +/* This syscall gets its arguments in A0 (mem), D2 (oldval) and +D1 (newval). */ +asmlinkage int +sys_atomic_cmpxchg_32 (unsigned long newval,int oldval,int d3,int d4,int d5, +unsigned long __user * mem) +{ +/* This was borrowed from ARM's implementation. */ +for (;;) { +struct mm_struct *mm = current->mm; +pgd_t *pgd; +pmd_t *pmd; +pte_t *pte; +spinlock_t *ptl; +unsigned long mem_value; + +down_read (&mm->mmap_sem); + pgd =pgd_offset (mm, (unsigned long )mem); +if (!pgd_present (*pgd)) + goto bad_access; + pmd =pmd_offset (pgd, (unsigned long )mem); +if (!pmd_present (*pmd)) + goto bad_access; + pte =pte_offset_map_lock (mm, pmd, (unsigned long )mem, &ptl); +if (!pte_present (*pte) || !pte_dirty (*pte)) { +pte_unmap_unlock (pte, ptl); + goto bad_access; + } + + mem_value = *mem; +if (mem_value == oldval) + *mem = newval; + +pte_unmap_unlock (pte, ptl); +up_read (&mm->mmap_sem); +return mem_value; + + bad_access: +up_read (&mm->mmap_sem); +/* This is not necessarily a bad access, we can get here if +a memory we're trying to write to should be copied-on-write. +Make the kernel do the necessary page stuff, then re-iterate. +Simulate a write access fault to do that. */ + { +/* The first argument of the function corresponds to +D1, which is the first field of struct pt_regs. */ +struct pt_regs *fp = (struct pt_regs *)&newval; + +/* '3' is an RMW flag. */ +if (do_page_fault (fp, (unsigned long )mem,3 )) +/* If the do_page_fault() failed, we don't +have anything meaningful to return. +There should be a SIGSEGV pending for +the process. */ +return 0xdeadbeef ; + } + } +} + +asmlinkage int sys_atomic_barrier(void) +{ +/* no code needed for uniprocs */ +return 0 ; +}Signature · 1 line
1.6.2.4
--
Klaus Kuehnhammer
Bitstem Software
Wasnergasse 11/5
1200 Wien, Austria
+43 664 2133466
[email protected]
Quoted 5 lines · Klaus Kuehnhammer
Hi!
I've been testing this patch (together w/the latest codesourcery toolchain release) on an m548x the last couple of days.
It looks like there is still an issue in
sys_atomic_cmpxchg_32. When cloning a large process, it accesses memory it shouldn't:
Hi Klaus,
Which kernel version are you using? Where does the kernel oops? Is it at `mem_value = *mem;' ?
Regards,
Signature · 4 lines
Maxim Kuvyrkov CodeSourcery [email protected] (650) 331-3385 x724
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hello again,
It looks like the issue is caused by the page being write-protected. Adding !pte_write(*pte) to the checks seems to fix this, it goes into page fault and reloads the page entry writable. A patch is attached.
I'm not entirely comfortable w/this solution... I understand why calling do_page_fault w/a fixed RMW flag makes the write access work on the next iteration, but why would this page lack the write flag in the first place? Or, conversely, why does glibc call cmpxchg on a mem location in a non-writeable page?
Regarding the freescale kernel issues: Is there another kernel version we could try?
best regards,
Klaus
PS I'm putting the list back on CC
arch/m68k/kernel/sys_m68k.c +1 -1
@@ -736,7 +736,7 @@if (!pmd_present (*pmd)) goto bad_access; pte =pte_offset_map_lock (mm, pmd, (unsigned long )mem, &ptl); -if (!pte_present (*pte) || !pte_dirty (*pte)) { +if (!pte_write (*pte) || !pte_present (*pte) || !pte_dirty (*pte)) {pte_unmap_unlock (pte, ptl); goto bad_access; }
Quoted 6 lines · Maxim Kuvyrkov
Quoted 4 lines · Klaus Kuehnhammer
Hi!
Thanks for the quick reply!
It's a 2.6.25 kernel from the mid-2008 freescale BSP, w/the NPTL patches for the latest toolchain. Linux version 2.6.25 (klaus@uvirt) (gcc version 4.4.1 (Sourcery G++ Lite 4.4-54) )
Quoted 13 lines
This kernel has several known issues, some of them can be triggered by NPTL support.
Quoted 1 line
I haven't run this in the debugger yet so i don't know for certain. From the address the oops gives, it's definitely in
sys_atomic_cmpxchg_32. I added a printk, and the offending address comes in via the mem param, so yes, I guess the first *mem is the place.Would you please provide a dump of the code near the place where the oops occurs, you should be able to do that with `m68k-linux-gnu-objdump -d vmlinux | grep -C 80
00021e50'. And, of cause, a testcase will be of great help for tracking this down.Thanks,
Signature · 4 lines
Maxim Kuvyrkov CodeSourcery [email protected] (650) 331-3385 x724
--
Klaus Kuehnhammer
Bitstem Software
Wasnergasse 11/5
1200 Wien, Austria
+43 664 2133466
[email protected]
Quoted 10 lines · Klaus Kuehnhammer
Hello again,
It looks like the issue is caused by the page being write-protected. Adding !pte_write(*pte) to the checks seems to fix this, it goes into page fault and reloads the page entry writable. A patch is attached.
I'm not entirely comfortable w/this solution... I understand why calling
do_page_faultw/a fixed RMW flag makes the write access work on the next iteration, but why would this page lack the write flag in the first place?
It may have the write bit cleared (or have a readonly bit set) when the page should be copied-on-write. What strange is why !pte_dirty() doesn't imply !pte_write(). The cmpxchg code was ported from arm.c:traps.c; here is the comment to the patch that changed !pte_write() to !pte_dirty in ARM's implementation:
|pte_write() just says that the page _may_ be writable. It doesn't say |that the MMU is programmed to allow writes. If pte_dirty() doesn't |return true, that means that the page is _not_ writable from userspace. |If you write to it from kernel mode (without using put_user) you'll |bypass the MMU read-only protection and may end up writing to a page |owned by two separate processes.
From the above it seems that your patch is safe. However, it may be papering over the consequences of a different bug. Is there a linux memory management expert around to comment on this?
...
Quoted 2 lines
Regarding the freescale kernel issues: Is there another kernel version we could try?
I sent a link to this thread to Jason (Jin) who's working at Freescale and he suggested you try the following patch and see if it fixes the problem. This patch fixes a cache handling problem on some of the ColdFire CPUs.
-------------------
arch/m68k/coldfire/signal.c +0 -0
@@ -608,9 +608,8 @@ static inline int rt_setup_ucontext(struct ucontext
__user *uc,
static inline void push_cache(unsigned long vaddr) {
-#if 0
-// JKM -- need to add into the old cpushl cache stuff
- cf_cache_push(__pa(vaddr), 8);
+#ifdef CONFIG_M547X_8X
+ flush_icache_range(vaddr, vaddr + 8);
#endif
}
-------------------
Regards,
Signature · 4 lines
Maxim Kuvyrkov CodeSourcery [email protected] (650) 331-3385 x724
Geert Uytterhoeven
maintainerQuoted 13 lines · Maxim Kuvyrkov
Quoted 1 line · Maxim Kuvyrkov
The attached patches add kernel support for userspace NPTL bits for m68k.
Here is yet another final version of the patch. As Andreas pointed out in another thread, the indentation is off in couple of places, so I fixed that by formatting the code with
scripts/Lindent. I also forwarded the reformatted version of the uClinux patch to uclinux-dev@.arch/m68k/include/asm/unistd.h +0
-0
arch/m68k/include/asm/unistd.h line 342
Quoted 7 lines
arch/m68k/include/asm/unistd.h +4
-0@@ -336,10 +336,14 @@ #define __NR_pwritev 330 #define __NR_rt_tgsigqueueinfo 331 #define __NR_perf_event_open 332 +#define __NR_read_tp 333 +#define __NR_write_tp 334 +#define __NR_atomic_cmpxchg_32 335 +#define __NR_atomic_barrier 336
BTW, other architectures seem to call these __NR_[gs]et_thread_area instead of __NR_{read,write}_tp?
Shouldn't we follow for consistency?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev
Quoted 1 line · Geert Uytterhoeven
On Mon, Dec 7, 2009 at 09:38, Maxim Kuvyrkov<[email protected]> wrote:
...
Quoted 8 lines
Quoted 8 lines
arch/m68k/include/asm/unistd.h +0
-0@@ -336,10 +336,14 @@#define __NR_pwritev 330#define __NR_rt_tgsigqueueinfo 331#define __NR_perf_event_open 332
Quoted 8 lines
arch/m68k/include/asm/unistd.h line 342
Quoted 4 lines
arch/m68k/include/asm/unistd.h +4
-0+#define __NR_read_tp 333 +#define __NR_write_tp 334 +#define __NR_atomic_cmpxchg_32 335 +#define __NR_atomic_barrier 336BTW, other architectures seem to call these __NR_[gs]et_thread_area instead of __NR_{read,write}_tp?
Shouldn't we follow for consistency?
Yes, we may. As long as the syscall numbers stay the same. I'll send the updated patch once the memory handling issue is resolved.
BTW, does the analysis of the memory handling bug (http://marc.info/?l=linux-m68k&m=126043678613032&w=2) look right to you?
Regards,
Signature · 4 lines
Maxim Kuvyrkov CodeSourcery [email protected] (650) 331-3385 x724
Quoted 3 lines · Maxim Kuvyrkov
Quoted 2 lines · Geert Uytterhoeven
On Mon, Dec 7, 2009 at 09:38, Maxim Kuvyrkov<[email protected]> wrote:
...
Quoted 6 lines
Quoted 3 lines
BTW, other architectures seem to call these __NR_[gs]et_thread_area instead of __NR_{read,write}_tp?
Shouldn't we follow for consistency?Yes, we may. As long as the syscall numbers stay the same. I'll send the updated patch once the memory handling issue is resolved.
Here is the updated patch. I renamed {read,write}_tp syscalls to [gs]et_thread_area. Regarding the memory access issue in cmpxchg syscall, I looked through the mm/ files and it seems that checking for !pte_write() is the right way to fix the problem; so the patch fixes that too.
As I understand, this patch fixes all outstanding issues and is ready for merge.
Regards,
Signature · 4 lines
Maxim Kuvyrkov CodeSourcery [email protected] (650) 331-3385 x724
From f1e2bdaa191f08d33938bd42cf090f3d9466866e Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <[email protected]>
Date: Mon, 7 Dec 2009 00:24:27 -0800
Subject: [PATCH 1/2] Add NPTL support for m68k
This patch adds several syscalls, that provide necessary functionality to support NPTL on m68k/ColdFire.
The syscalls are get_thread_area, set_thread_area, atomic_cmpxchg_32 and atomic_barrier.
The cmpxchg syscall is required for ColdFire as it doesn't support 'cas' instruction.
Also a ptrace call PTRACE_GET_THREAD_AREA is added to allow debugger to inspect the TLS storage.
--- arch/m68k/include/asm/ptrace.h | 2 + arch/m68k/include/asm/swab.h | 2 +- arch/m68k/include/asm/thread_info_mm.h | 1 + arch/m68k/include/asm/unistd.h | 6 ++- arch/m68k/kernel/entry.S | 4 ++ arch/m68k/kernel/process.c | 4 ++ arch/m68k/kernel/ptrace.c | 5 ++ arch/m68k/kernel/sys_m68k.c | 81 ++++++++++++++++++++++++++++++++ 8 files changed, 103 insertions(+), 2 deletions(-)
arch/m68k/include/asm/ptrace.h +2 -0
@@ -71,6 +71,8 @@ struct switch_stack {#define PTRACE_GETFPREGS 14#define PTRACE_SETFPREGS 15 +#define PTRACE_GET_THREAD_AREA 25 +#define PTRACE_SINGLEBLOCK 33/* resume execution until next branch */ #ifdef __KERNEL__
arch/m68k/include/asm/thread_info_mm.h +1 -0
@@ -16,6 +16,7 @@ struct thread_info {struct exec_domain *exec_domain;/* execution domain */ int preempt_count;/* 0 => preemptable, <0 => BUG */ __u32 cpu;/* should always be 0 on m68k */ +unsigned long tp_value;/* thread pointer */ struct restart_block restart_block; };#endif /* __ASSEMBLY__ */
arch/m68k/include/asm/unistd.h +5 -1
@@ -336,10 +336,14 @@#define __NR_pwritev 330#define __NR_rt_tgsigqueueinfo 331#define __NR_perf_event_open 332 +#define __NR_get_thread_area 333 +#define __NR_set_thread_area 334 +#define __NR_atomic_cmpxchg_32 335 +#define __NR_atomic_barrier 336#ifdef __KERNEL__ -#define NR_syscalls 333 +#define NR_syscalls 337#define __ARCH_WANT_IPC_PARSE_VERSION#define __ARCH_WANT_OLD_READDIR
arch/m68k/kernel/entry.S +4 -0
@@ -761,4 +761,8 @@ sys_call_table: .long sys_pwritev /* 330 */ .long sys_rt_tgsigqueueinfo .long sys_perf_event_open + .long sys_get_thread_area + .long sys_set_thread_area + .long sys_atomic_cmpxchg_32 /* 335 */ + .long sys_atomic_barrier
arch/m68k/kernel/process.c +4 -0
@@ -251,6 +251,10 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, p->thread.usp = usp; p->thread.ksp = (unsigned long )childstack; + +if (clone_flags &CLONE_SETTLS ) +task_thread_info (p)->tp_value = regs->d5; +/* * Must save the current SFC/DFC value, NOT the value when * the parent was last descheduled - RGH 10-08-96
arch/m68k/kernel/ptrace.c +5 -0
@@ -245,6 +245,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ret = -EFAULT ;break ; +case PTRACE_GET_THREAD_AREA : + ret =put_user (task_thread_info (child)->tp_value, + (unsigned long __user *)data); +break ; +default : ret =ptrace_request (child, request, addr, data);break ;
arch/m68k/kernel/sys_m68k.c +81 -0
90 lines not on this page · raw message
Signature · 1 line
1.6.2.4