public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: "Carlos O'Donell" <carlos@redhat.com>
To: Venkataramanan Kumar <venkataramanan.kumar@linaro.org>
Cc: libc-ports@sourceware.org,
	Marcus Shawcroft <marcus.shawcroft@arm.com>,
	       Marcus Shawcroft <marcus.shawcroft@gmail.com>,
	       Patch Tracking <patch@linaro.org>
Subject: Re: [RFC] [PATCH] [Aarch64] : Stack guard support in glibc
Date: Wed, 28 Aug 2013 02:13:00 -0000	[thread overview]
Message-ID: <521D5CCA.1070300@redhat.com> (raw)
In-Reply-To: <CAJK_mQ2V=Q4K-wRyOYaPcvD-QhkkAdtMEUrE+pN3NzBJh1d8dw@mail.gmail.com>

On 08/26/2013 12:15 AM, Venkataramanan Kumar wrote:
> I also checked the canary value and keeps changing from run to run.

Is it faster than accessing a global?

> glibc.tls.stack.guard.aarch64.diff

Please review:
http://sourceware.org/glibc/wiki/Contribution%20checklist

Please run the entire testsuite and report if there are no regressions.

You need a ChangeLog and you should also write up some text for a NEWS
entry that will go out with 2.19 talking about the new feature for ARM.
 
> Index: tls.h
> ===================================================================
> --- tls.h	(revision 23742)
> +++ tls.h	(working copy)
> @@ -68,10 +68,15 @@
>  # define TLS_TCB_SIZE		sizeof (tcbhead_t)
>  
>  /* This is the size we need before TCB.  */
> -# define TLS_PRE_TCB_SIZE	sizeof (struct pthread)
> +# define TLS_PRE_TCB_SIZE \
> +  (sizeof (struct pthread)                                              \
> +   + (PTHREAD_STRUCT_END_PADDING < 2 * sizeof (uintptr_t)               \
> +      ? ((2 * sizeof (uintptr_t) + __alignof__ (struct pthread) - 1)    \
> +         & ~(__alignof__ (struct pthread) - 1))                         \
> +      : 0))

Please use ALIGN_UP or ALIGN_DOWN from libc-internal.h.

I know you're copying this from IA64, but it should still use
the newer macros.
  
>  /* Alignment requirements for the TCB.  */
> -# define TLS_TCB_ALIGN		__alignof__ (tcbhead_t)
> +# define TLS_TCB_ALIGN __alignof__ (struct pthread)
>  /* Install the dtv pointer.  The pointer passed is to the element with
>     index -1 which contain the length.  */
> @@ -98,12 +103,28 @@
>  
>  /* Return the thread descriptor for the current thread.  */
>  # define THREAD_SELF \
> - ((struct pthread *)__builtin_thread_pointer () - 1)
> + ((struct pthread *)((char *) __builtin_thread_pointer () - TLS_PRE_TCB_SIZE))
>  
>  /* Magic for libthread_db to know how to do THREAD_SELF.  */
>  # define DB_THREAD_SELF \
> -  CONST_THREAD_AREA (64, sizeof (struct pthread))
> +  CONST_THREAD_AREA (64, TLS_PRE_TCB_SIZE)

Did you check to see if this impacts gdb in any way?

e.g. Install new glibc into a system, then build and run the gdb testsuite
and see if anything fails?

> +/* Set the stack guard field in TCB head.  */
> +#define THREAD_SET_STACK_GUARD(value) \
> +  (((uintptr_t *) __builtin_thread_pointer ())[-1] = (value))
> +#define THREAD_COPY_STACK_GUARD(descr) \
> +  (((uintptr_t *) ((char *) (descr) + TLS_PRE_TCB_SIZE))[-1] \
> +   = ((uintptr_t *) __builtin_thread_pointer ())[-1])
> +
> +/* Set the pointer guard field in TCB head.  */
> +#define THREAD_GET_POINTER_GUARD() \
> +  (((uintptr_t *) __builtin_thread_pointer ())[-2])
> +#define THREAD_SET_POINTER_GUARD(value) \
> +  (((uintptr_t *) __builtin_thread_pointer ())[-2] = (value))
> +#define THREAD_COPY_POINTER_GUARD(descr) \
> +  (((uintptr_t *) ((char *) (descr) + TLS_PRE_TCB_SIZE))[-2] \
> +   = THREAD_GET_POINTER_GUARD ())
> +

Please see the Style and Conventions:
http://sourceware.org/glibc/wiki/Style_and_Conventions#Nested_C_Preprocessor_Directives

>  /* Access to data in the thread descriptor is easy.  */
>  # define THREAD_GETMEM(descr, member) \
>    descr->member

I've only done a very light review here, please repost v2
and we can do a more thorough review.

Cheers,
Carlos.

      reply	other threads:[~2013-08-28  2:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-26  4:15 Venkataramanan Kumar
2013-08-28  2:13 ` Carlos O'Donell [this message]

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=521D5CCA.1070300@redhat.com \
    --to=carlos@redhat.com \
    --cc=libc-ports@sourceware.org \
    --cc=marcus.shawcroft@arm.com \
    --cc=marcus.shawcroft@gmail.com \
    --cc=patch@linaro.org \
    --cc=venkataramanan.kumar@linaro.org \
    /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 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).