linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ulrich Drepper <drepper@redhat.com>
To: Andi Kleen <ak@suse.de>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Better CLONE_SETTLS support for Hammer
Date: Wed, 05 Mar 2003 10:55:50 -0800	[thread overview]
Message-ID: <3E664836.7040405@redhat.com> (raw)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andi,

Please consider using this patch which changes the way CLONE_SETTLS is
handled on Hammer completely.  The old approach was to slavishly follow
what x86 does with the desastrous result that TCBs (and therefore
stacks) could only be allocated in the low 4GB.  This would have been a
really bad limitation going forward.

But as it turns out the kernel already has support for handling %fs in a
different way, to support prctl(ARCH_SET_FS).  So let's just use the
same mechanism.  clone() will simply take an 64-bit address and use it
as if prctl() was called.

The changes are pretty minimal.  The appened patch is relative to the
current BK sources and they also incorporate the bug fix to use the
correct register for the SETTLS clone() parameter.


- --- arch/x86_64/kernel/process.c	2003-02-23 22:02:23.000000000 -0800
+++ arch/x86_64/kernel/process.c-new	2003-03-05 10:14:46.000000000 -0800
@@ -269,11 +269,18 @@

 	p->thread.rip = (unsigned long) ret_from_fork;

- -	p->thread.fs = me->thread.fs;
+	if ((clone_flags & CLONE_SETTLS) && !test_thread_flag(TIF_IA32)) {
+		if (regs->r8 >= TASK_SIZE)
+			return -EPERM;
+		p->thread.fs = regs->r8;
+		p->thread.fsindex = 0;
+	} else {
+		p->thread.fs = me->thread.fs;
+		asm("movl %%fs,%0" : "=m" (p->thread.fsindex));
+	}
 	p->thread.gs = me->thread.gs;

 	asm("movl %%gs,%0" : "=m" (p->thread.gsindex));
- -	asm("movl %%fs,%0" : "=m" (p->thread.fsindex));
 	asm("movl %%es,%0" : "=m" (p->thread.es));
 	asm("movl %%ds,%0" : "=m" (p->thread.ds));

@@ -291,14 +298,12 @@
 	/*
 	 * Set a new TLS for the child thread?
 	 */
- -	if (clone_flags & CLONE_SETTLS) {
+	if ((clone_flags & CLONE_SETTLS) && test_thread_flag(TIF_IA32)) {
 		struct n_desc_struct *desc;
 		struct user_desc info;
 		int idx;

- -		if (copy_from_user(&info, test_thread_flag(TIF_IA32) ?
- -								  (void *)childregs->rsi :
- -								  (void *)childregs->rdx, sizeof(info)))
+		if (copy_from_user(&info, (void *)childregs->rsi))
 			return -EFAULT;
 		if (LDT_empty(&info))
 			return -EINVAL;


- -- 
- --------------.                        ,-.            444 Castro Street
Ulrich Drepper \    ,-----------------'   \ Mountain View, CA 94041 USA
Red Hat         `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+Zkg32ijCOnn/RHQRAr9cAKDL+9bmX26v4P6GRpAq11kzUrgDOwCdFcrk
RO3CMzlLQrEpO28itl0JdxM=
=YxTu
-----END PGP SIGNATURE-----


             reply	other threads:[~2003-03-05 18:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-05 18:55 Ulrich Drepper [this message]
2003-03-05 19:06 ` Better CLONE_SETTLS support for Hammer Andi Kleen
2003-03-05 19:25   ` Ulrich Drepper
2003-03-05 21:19     ` Andi Kleen
2003-03-05 19:32   ` Ulrich Drepper
2003-03-05 21:21     ` Andi Kleen
2003-03-05 23:04       ` Ulrich Drepper
2003-03-06  1:05         ` Andi Kleen
2003-03-06  3:53           ` Ulrich Drepper
2003-03-06  4:14           ` Ulrich Drepper
2003-03-06 10:27             ` Andi Kleen
2003-03-06 18:58               ` Ulrich Drepper
2003-03-06 19:09                 ` Andi Kleen
2003-03-06  2:08         ` Benjamin LaHaise
2003-03-06  3:52           ` Ulrich Drepper
2003-03-06  5:29             ` Benjamin LaHaise
2003-03-06  5:47               ` Ulrich Drepper
2003-03-06  5:33   ` H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E664836.7040405@redhat.com \
    --to=drepper@redhat.com \
    --cc=ak@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).