All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Albert Cahalan <acahalan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	torvalds@osdl.org, mingo@elte.hu, ak@suse.de,
	arjan@infradead.org, zach@vmware.com,
	linux-kernel@vger.kernel.org
Subject: Re: Assignment of GDT entries
Date: Wed, 13 Sep 2006 23:29:13 -0700	[thread overview]
Message-ID: <4508F6B9.1040709@goop.org> (raw)
In-Reply-To: <787b0d920609132319y660c62c5rc245843aa55fd615@mail.gmail.com>

Albert Cahalan wrote:
> So if I grabbed the first two slots before glibc got to
> mess with them, glibc wouldn't break horribly?

glibc would be happy with anything it got; if you grabbed all 3 TLS 
slots it would probably be upset.

> If I grabbed one slot and glibc grabbed another, Wine
> would be OK with the third instead of the second?

Presumably.

> So basically it's not allowed to just grab the 3rd slot?
Eh?  You mean there's no "allocate and return TLS slot #N" operation?  
No, but all the TLS slots should be interchangeable.  Once you've got 
your entry numbers and worked out your selector values, you can just use 
them.

> What if I want to find out what is already in use?
> Am I supposed to iterate over all 8191 possible
> GDT entries? How do I even tell how many slots
> are available without using them all up?
The kernel reserves 3 slots in the GDT for usermode use, which are 
per-thread.  If you want more segment descriptors, you can always 
allocate an LDT.

> Eeeeeeew. Well this was documented exactly nowhere.
> The man page is even vague about entry_number,

man set_thread_area has this as paragraph 2:

       When  set_thread_area() is passed an entry_number of -1, it uses a free
       TLS entry. If set_thread_area() finds a free TLS entry,  the  value  of
       u_info->entry_number  is  set  upon  return  to  show  which  entry was
       changed.

which seems pretty clear to me.  A quick run with strace on any binary 
shows this in action:

    set_thread_area({entry_number:-1 -> 6, base_addr:0xb7fb06c0,
    limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
    limit_in_pages:1, seg_not_present:0, useable:1}) = 0

    J

  parent reply	other threads:[~2006-09-14  6:29 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-14  4:06 Assignment of GDT entries Albert Cahalan
2006-09-14  4:44 ` Eric W. Biederman
2006-09-14  6:19   ` Albert Cahalan
2006-09-14  6:28     ` Zachary Amsden
2006-09-14  7:12       ` Albert Cahalan
2006-09-14  7:24         ` Zachary Amsden
2006-09-14  6:29     ` Jeremy Fitzhardinge [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-09-15  7:55 Mikael Pettersson
2006-09-15  8:20 ` Jeremy Fitzhardinge
2006-09-15  8:58   ` Mikael Pettersson
2006-09-15 18:27     ` Jeremy Fitzhardinge
2006-09-14  3:23 Albert Cahalan
2006-09-14  6:11 ` Jeremy Fitzhardinge
2006-09-13 18:58 Jeremy Fitzhardinge
2006-09-13 19:16 ` Arjan van de Ven
2006-09-13 20:00   ` Alan Cox
2006-09-13 20:02     ` Jeremy Fitzhardinge
2006-09-13 20:20   ` Jeremy Fitzhardinge
2006-09-13 20:59     ` Zachary Amsden
2006-09-13 21:15       ` Jeremy Fitzhardinge
2006-09-13 21:35       ` Alan Cox
2006-09-14  0:25         ` Zachary Amsden
2006-09-14  1:40           ` Stephen Rothwell
2006-09-14 13:03           ` Alan Cox
2006-09-13 19:55 ` linux-os (Dick Johnson)
2006-09-13 20:08   ` Jeremy Fitzhardinge
2006-09-13 20:32     ` linux-os (Dick Johnson)
2006-09-13 21:21 ` Linus Torvalds
2006-09-13 21:47   ` Jeremy Fitzhardinge
2006-09-13 22:05     ` Linus Torvalds
2006-09-13 22:22       ` Jeremy Fitzhardinge
2006-09-14  6:00 ` Andi Kleen

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=4508F6B9.1040709@goop.org \
    --to=jeremy@goop.org \
    --cc=acahalan@gmail.com \
    --cc=ak@suse.de \
    --cc=arjan@infradead.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@osdl.org \
    --cc=zach@vmware.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.