public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* Question about s390 THREAD_SET_STACK_GUARD
@ 2018-11-02 22:40 Gc Frix
  2018-11-05 15:59 ` Adhemerval Zanella
  0 siblings, 1 reply; 3+ messages in thread
From: Gc Frix @ 2018-11-02 22:40 UTC (permalink / raw)
  To: libc-help

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-08 14:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-02 22:40 Question about s390 THREAD_SET_STACK_GUARD Gc Frix
2018-11-05 15:59 ` Adhemerval Zanella
2018-11-08 14:57   ` Stefan Liebler

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 read-only IMAP folder(s) and NNTP newsgroup(s).