From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12294 Path: news.gmane.org!.POSTED!not-for-mail From: Markus Wichmann Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] Add comments to i386 assembly source Date: Mon, 1 Jan 2018 20:52:24 +0100 Message-ID: <20180101195224.tpkl5g5w66rzwzz3@voyager> References: <20171223094545.rmx6xtmucyz5xzap@voyager> <72c68934-4445-c83d-7bbc-004953b2f9e9@bitwagon.com> <20171231154926.GG1627@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1514836267 16161 195.159.176.226 (1 Jan 2018 19:51:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 1 Jan 2018 19:51:07 +0000 (UTC) User-Agent: NeoMutt/20170609 (1.8.3) To: musl@lists.openwall.com Original-X-From: musl-return-12310-gllmg-musl=m.gmane.org@lists.openwall.com Mon Jan 01 20:51:03 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1eW66q-0003XR-BD for gllmg-musl@m.gmane.org; Mon, 01 Jan 2018 20:50:56 +0100 Original-Received: (qmail 26163 invoked by uid 550); 1 Jan 2018 19:52:57 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 26136 invoked from network); 1 Jan 2018 19:52:57 -0000 Content-Disposition: inline In-Reply-To: <20171231154926.GG1627@brightrain.aerifal.cx> X-Provags-ID: V03:K0:z/BYvy4Oj4PfYb4g1Hivm9kx9QAbbyWKw6MlTIY0k+YP9q2Esag eXdP+LvACd/AKQxMN26JYk4aTKdEw/o+qYKBCEv1Y7Gj1HAVNMV05s7+PiggVjkQjGtQ1qk BaEtpW/Per1lOok/LkI4uMsaG0F8Lwe2sS8cpGFXCGFPjZTv11Ml74yJdnBGbnBpBE1YB6c 9IIMi6xTxeuNzMi37vnNQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:htIwpsMGRMQ=:7gmdoZ45yBn8JOfyDIoT9i vv2ReX9YCOjuDYzPo0VB3e7IzIGStHpZH2UHbld+CgihIpX1WEiUC51nIxhb7nolFFm60VTps iAFODxJsZelKT+lVB/F3EYPeZPp40ScMsi+M6KQ8Ar7/HVsbkucrnXvOsnEz3ik89/ZHyTCDS fLhwlzF6cFX8gyg9VUVB1Isi9AxCb9JxUBx0SbSN5K4MI3XxzjNyR9nmerwO1Gfv58O5oNNfc 2YwyOB+wrK+U2jV1zsU6YQO1ns78JeCEWCO2/At6u1EkAezV57FYuQNGLwCyBQqcawnv3XlAN /rYPpLQOvtg97ajRZLFohk/15HSQX923agKc2RIzjHDrHTiXrf/GPGR4dj4IPW9MW/+Z2hDF/ KFWH0Blu8cNEAquNptrqr9y+U7KnuIGy8CrVyHucKAqBOF9XfBgCldLlV1pLFlbM7Oh0ozSGC c5QPfJQ/LFKZ2YEfwiqRb7uJhOXgYvZdloklXG/VfKkOd9v9IE7ah4eHQl8/M789Y0hH0+IIw by7YAL6YJhLSRLedml1mJov8odqZ1ZGheK9SsTPMzIjk777tnlupD+OnFvkbfKt5SFRaDHWWk jSWvUBzJTbMJZjAe2VAXKMltmZy8wKK9AYSi3hBmZ9NzFq/pSBj34G2WLFdXYNKSfQVgKQrT+ yIUGddrl6+5xvLhQDlYWr92uYG/lO+4WHHq/y5EuxNDuznO/EWgsa/Qe4EqKIRfLnx9CsCzl6 fiRTnRtl79MxCDXBI0euK5Y29vzfyhEz5NE4BPkIowxllnJY3sSfHNSzCB5lwwjINSZ5CePc Xref: news.gmane.org gmane.linux.lib.musl.general:12294 Archived-At: On Sun, Dec 31, 2017 at 10:49:26AM -0500, Rich Felker wrote: > I don't follow your reasoning here. Where are you getting the possible > range of %gs from? If __clone is called with flags relevant to thread > creation, %gs is necessarily a GDT entry. The LDT stuff in i386's > __set_thread_area is only used to provide a working %gs for > single-threaded processes on ancient kernels that lack thread support; > in this case pthread_create always fails without calling __clone. > First of all, happy new year everybody. The range of GS is rather simple: GS is a word in Intel-lingo, i.e. 16 bits, so that sets its range. Nothing else limits it down any way further. Not the interpretation of it (there are 13 bits for selector index, so enough for 8192 selector entries), not GDT size (the GDTR can hold a size of at most 65535 bytes, which is enough for 8192 selector entries if each entry is 8 bytes), not the ABI (kernel returns GDT index as int), nor the API (set_thread_area(2) is underdocumented, anyway). Now, __set_thread_area() for i386 only makes sense if Linux has a different GDT for each thread: In the entire code, you make sure to only allocate a single TLS array index for the whole process runtime, which would be nonsense if the GDT were distributed any further. In that case, exceeding twenty segments would be quite a feat, never mind two hundred. Also, the thing about the LDT not being used except on kernels that don't have threading, that should be documented as well. Solves the question I had in the OP of this thread nicely. > Thank you and Markus for reminding me why some comments would help > here. :-) > You're welcome. :-) Ciao, Markus