On Tue, 13 Aug 2002, Linus Torvalds wrote:
> > CLONE_SETTLS => if present then the third clone() syscall parameter
> > is the new TLS.
> >
> > CLONE_SETTID => if present then the child TID is written to the
> > address specified by the fourth clone() parameter.
>
> Except you actually test the CLONE_SETTLS bit..
We've tested clone_startup() with real threads on a 2.4-backported version
of yesterday's final TLS API quite extensively, and it works as expected.
(as we've tested earlier incarnations of the TLS API and code as well.)
This portion of the code is not changed by CLONE_SETTLS - so it should
work equally well, unless i've done something stupid ... I'll backport
this and will fit glibc to the new API later today. (Ulrich's on LW)
> This looks basically ok, although that "struct thread_struct *t" still
> serves no useful purpose..
this was just me shortening some code a bit. I've attached a new patch
that gets rid of those unrelated changes and does the CLONE_SETTLS /
CLONE_SETTID bits only.
Ingo
--- linux/arch/i386/kernel/process.c.orig Tue Aug 13 21:08:01 2002
+++ linux/arch/i386/kernel/process.c Tue Aug 13 21:10:36 2002
@@ -579,6 +579,35 @@
unlazy_fpu(tsk);
struct_cpy(&p->thread.i387, &tsk->thread.i387);
+ /*
+ * Set a new TLS for the child thread?
+ */
+ if (clone_flags & CLONE_SETTLS) {
+ struct desc_struct *desc;
+ struct user_desc info;
+ int idx;
+
+ if (copy_from_user(&info, (void *)childregs->esi, sizeof(info)))
+ return -EFAULT;
+ if (LDT_empty(&info))
+ return -EINVAL;
+
+ idx = info.entry_number;
+ if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
+ return -EINVAL;
+
+ desc = p->thread.tls_array + idx - GDT_ENTRY_TLS_MIN;
+ desc->a = LDT_entry_a(&info);
+ desc->b = LDT_entry_b(&info);
+ }
+
+ /*
+ * Notify the child of the TID?
+ */
+ if (clone_flags & CLONE_SETTLS)
+ if (put_user(p->pid, (pid_t *)childregs->edx))
+ return -EFAULT;
+
if (unlikely(NULL != tsk->thread.ts_io_bitmap)) {
p->thread.ts_io_bitmap = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL);
if (!p->thread.ts_io_bitmap)
--- linux/include/linux/sched.h.orig Tue Aug 13 21:01:51 2002
+++ linux/include/linux/sched.h Tue Aug 13 21:08:56 2002
@@ -45,6 +45,8 @@
#define CLONE_THREAD 0x00010000 /* Same thread group? */
#define CLONE_NEWNS 0x00020000 /* New namespace group? */
#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
+#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
+#define CLONE_SETTID 0x00100000 /* write the TID back to userspace */
#define CLONE_SIGNAL (CLONE_SIGHAND | CLONE_THREAD)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Thu Aug 15 2002 - 22:00:33 EST