From patchwork Tue Jun 12 15:31:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 928380 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-479550-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="aPbY3uKy"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 414v516Kblz9s0w for ; Wed, 13 Jun 2018 01:32:05 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=CTprOL2hss/D3OWSOIIHBLkbx9Ivn mmWN6aVWOvg+uphzxVjGmo1tKYFPXhk7Tp/RnRWf9aG6qZoXa7I2WvPTHxEyrsFN E9BJTmP0ybE/kibfHoLxrrQk1KS91q7qiiRaiokzTNtxy44/aXtR7g8OYUJHs0KU vAlNFOXPStbIPI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=1YW5k/LO6TzJxZp24fb0+0q9dFI=; b=aPb Y3uKyQYog95jnSmROXBn98UJkVt5pGYb3ARso9vdf+9ecj0WTgmDA5yC9iScWcE4 73jN/Z8TMYGmEI19douApDv9ltzbZL1bqct0bDpf33KyxGmbFL8p4nN0pnwhAhMm iUrJoFkFNZ1XpXY1alAXbrDZdmqcUD00J0Lgf494= Received: (qmail 65519 invoked by alias); 12 Jun 2018 15:31:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 65505 invoked by uid 89); 12 Jun 2018 15:31:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, NO_DNS_FOR_FROM autolearn=ham version=3.3.2 spammy=Hx-languages-length:3622, Reserve X-HELO: mga03.intel.com Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Jun 2018 15:31:57 +0000 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jun 2018 08:31:55 -0700 X-ExtLoop1: 1 Received: from gnu-cfl-1.sc.intel.com ([172.25.70.237]) by orsmga001.jf.intel.com with ESMTP; 12 Jun 2018 08:31:55 -0700 Received: by gnu-cfl-1.sc.intel.com (Postfix, from userid 1000) id 5FCB4440C20; Tue, 12 Jun 2018 08:31:55 -0700 (PDT) Date: Tue, 12 Jun 2018 08:31:55 -0700 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: Uros Bizjak Subject: [PATCH] Linux/x86: Update TARGET_THREAD_SPLIT_STACK_OFFSET comments Message-ID: <20180612153155.GA18069@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.0 (2018-05-17) Glibc 2.18 was changed by commit ecbf434213c0333d81706074e4d107ac45011635 Author: Andreas Jaeger Date: Wed May 15 20:20:54 2013 +0200 Reserve new TLS field for x86 and x86_64 [BZ #10686] * sysdeps/x86_64/tls.h (struct tcbhead_t): Add __private_ss field. * sysdeps/i386/tls.h (struct tcbhead_t): Likewise. to reduce the size of __private_tm to make room for __private_ss, which was supposed to be used for TARGET_THREAD_SPLIT_STACK_OFFSET: typedef struct { void *tcb; /* Pointer to the TCB. Not necessarily the thread descriptor used by libpthread. */ dtv_t *dtv; void *self; /* Pointer to the thread descriptor. */ int multiple_threads; uintptr_t sysinfo; uintptr_t stack_guard; uintptr_t pointer_guard; int gscope_flag; int __glibc_reserved1; /* Reservation of some values for the TM ABI. */ void *__private_tm[4]; /* GCC split stack support. */ void *__private_ss; } tcbhead_t; But the offset of __private_ss for i386 was mistakenly set to 0x30, instead of 0x34 and libgcc/config/i386/morestack.S has: cmpl %gs:0x30,%eax # See if we have enough space. movl %eax,%gs:0x30 # Save the new stack boundary. movl %eax,%gs:0x30 # Save the new stack boundary. movl %ecx,%gs:0x30 # Save new stack boundary. movl %eax,%gs:0x30 movl %gs:0x30,%eax movl %eax,%gs:0x30 Since update TARGET_THREAD_SPLIT_STACK_OFFSET changes split stack ABI, glibc 2.28 has been changed by commit 0221ce2a90be2d40fc90f0b5dcec77a1ec013f53 Author: H.J. Lu Date: Tue Jun 12 06:23:28 2018 -0700 i386: Change offset of __private_ss to 0x30 [BZ #23250] to match GCC: typedef struct { void *tcb; /* Pointer to the TCB. Not necessarily the thread descriptor used by libpthread. */ dtv_t *dtv; void *self; /* Pointer to the thread descriptor. */ int multiple_threads; uintptr_t sysinfo; uintptr_t stack_guard; uintptr_t pointer_guard; int gscope_flag; int __glibc_reserved1; /* Reservation of some values for the TM ABI. */ void *__private_tm[3]; /* GCC split stack support. */ void *__private_ss; void *__glibc_reserved2; } tcbhead_t; I am going to check it in as an obvious patch. Thanks. H.J. ---- PR target/85990 * config/i386/gnu-user.h (TARGET_THREAD_SPLIT_STACK_OFFSET): Update comments. * config/i386/gnu-user64.h (TARGET_THREAD_SPLIT_STACK_OFFSET): Likewise. --- gcc/config/i386/gnu-user.h | 2 +- gcc/config/i386/gnu-user64.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h index d1dad685e72..56449a5439e 100644 --- a/gcc/config/i386/gnu-user.h +++ b/gcc/config/i386/gnu-user.h @@ -134,6 +134,6 @@ along with GCC; see the file COPYING3. If not see /* i386 glibc provides __stack_chk_guard in %gs:0x14. */ #define TARGET_THREAD_SSP_OFFSET 0x14 -/* We steal the last transactional memory word. */ +/* i386 glibc provides __private_ss in %gs:0x30. */ #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30 #endif diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h index 491416fec0c..f7a68fdecf0 100644 --- a/gcc/config/i386/gnu-user64.h +++ b/gcc/config/i386/gnu-user64.h @@ -86,7 +86,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define TARGET_THREAD_SSP_OFFSET \ (TARGET_64BIT ? (TARGET_X32 ? 0x18 : 0x28) : 0x14) -/* We steal the last transactional memory word. */ +/* i386 glibc provides __private_ss in %gs:0x30. + x32 glibc provides it in %fs:0x40. + x86_64 glibc provides it in %fs:0x70. */ #define TARGET_THREAD_SPLIT_STACK_OFFSET \ (TARGET_64BIT ? (TARGET_X32 ? 0x40 : 0x70) : 0x30) #endif