From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16996 invoked by alias); 2 Nov 2018 22:40:32 -0000 Mailing-List: contact libc-help-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: libc-help-owner@sourceware.org Received: (qmail 16974 invoked by uid 89); 2 Nov 2018 22:40:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=HX-Received:sk:t5-v6mr, HX-Received:5f05, H*c:alternative, HX-HELO:sk:mail-pg X-HELO: mail-pg1-f171.google.com Received: from mail-pg1-f171.google.com (HELO mail-pg1-f171.google.com) (209.85.215.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Nov 2018 22:40:28 +0000 Received: by mail-pg1-f171.google.com with SMTP id k1-v6so1578345pgq.1 for ; Fri, 02 Nov 2018 15:40:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=I/8L0VWh3B1PyTcrfj2kOsNrWUVTbO9wjB0mZjo41JI=; b=se6K9dBYicfec4mSUaRbni9O6axKGChKi+in25JufppqoRHr4uroUpDE/w76iVoCJs XiIKMJmU9ea/i3CkNrBUlVYwWTo/pbdXSCIvWbnJkbTyXSbU1SU1DX89utdFjvndi27S kpqhv1U82t++TSKG9fR+6GyhwJILSdKk/J/qY9AHELOG2K5XOLUtpYjVxAHfgDzTxG6D aex9Z1I8vd5LIqQ1CPMeVFrF2tdfp8mSk+4xYXlnCgHjJxx3JoJszK7WMM94SUFxqt2f RJrM3Z+tZ4ZDFSY1ZAhWTZJQUBWyXSUQkIWCyZR3ircY5vmKvtwtgovwN/cGjfH35a7E 5q9Q== MIME-Version: 1.0 From: Gc Frix Date: Fri, 02 Nov 2018 22:40:00 -0000 Message-ID: Subject: Question about s390 THREAD_SET_STACK_GUARD To: libc-help@sourceware.org Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2018-11/txt/msg00001.txt.bz2 Hello, I was looking through the s390 sources and I noticed something I don't quite understand. From sysdeps/s390/nptl/tls.h: ``` /* Set the stack guard field in TCB head. */ #define THREAD_SET_STACK_GUARD(value) \ do \ { \ __asm__ __volatile__ ("" : : : "a0", "a1"); \ THREAD_SETMEM (THREAD_SELF, header.stack_guard, value); \ } \ while (0) /* For reference, here's THREAD_SETMEM and THREAD_SELF. */ #define THREAD_SETMEM(descr, member, value) \ descr->member = (value) # define THREAD_SELF ((struct pthread *) __builtin_thread_pointer ()) ``` I can't figure out what the point of the asm in THREAD_SET_STACK_GUARD is. I know that for s390x, the thread pointer is split between a0 and a1, and that __builtin_thread_pointer() is a GCC builtin that represents them (__builtin_thread_pointer is completely undocumented for s390, by the way). What I don't understand is why the asm is necessary at all. The most I can figure is that it's meant to force a reload from a0 and a1, but why? Shouldn't they only ever get modified by context switches after they get set? I'm new to glibc, so I apologize if this is a dumb question. Regards, Giancarlo Frix