This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCHv2] powerpc: ABI change - add HWCAP/HWCAP2/platform info to TCB
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: Carlos Eduardo Seo <cseo at linux dot vnet dot ibm dot com>
- Cc: munroesj at linux dot vnet dot ibm dot com, GNU C Library <libc-alpha at sourceware dot org>, "Steven J. Munroe" <sjmunroe at us dot ibm dot com>, Tulio Machado <tuliom at linux dot vnet dot ibm dot com>
- Date: Thu, 3 Sep 2015 14:02:40 -0400
- Subject: Re: [PATCHv2] powerpc: ABI change - add HWCAP/HWCAP2/platform info to TCB
- Authentication-results: sourceware.org; auth=none
- References: <C6F0963E-DA8E-48B3-B6F6-8D6A4C399AED at linux dot vnet dot ibm dot com> <55DE2452 dot 1000907 at redhat dot com> <1440643271 dot 31963 dot 17 dot camel at oc7878010663> <1440643752 dot 3213 dot 4 dot camel at oc7878010663> <55DF11D0 dot 2090100 at redhat dot com> <D0EBE325-B80E-4961-BE62-A31F1865AAF9 at linux dot vnet dot ibm dot com>
On 08/31/2015 05:57 PM, Carlos Eduardo Seo wrote:
> I was running some tests with dl_platform_init() (calling the
> init_hwcapinfo() code in there to populate my global variables) and
> it works fine in the dynamic linking case, but it does not seem to
> work for the static case, even though I see a placeholder for
> DL_PLATFORM_INIT in elf/dl-support.c. Am I missing something?
No. You'll have to review the code. I agree that _dl_non_dynamic_init()
should call your copy of DL_PLATFORM_INIT, but you'll have to debug this.
>> The code comments should make these assumptions clear e.g. early
>> init.
>>
>>>> The TCB fields hwcap and at_platform must be initialized from
>>>> the corresponding static variables before: Library init/ctors
>>>> get control for the main thread, and before any new thread gets
>>>> control from clone.
>>>>
>>> before: Library init/ctors and main() get control for the main
>>> thread, and before any new thread gets control from clone.
>>
>> That also sounds good. You'll likely need to do this in the nptl
>> code that starts the thread e.g. createthread.c via
>> TLS_DEFINE_INIT_TP.
>
> Iâm not sure if I understand what you mean by this. What exactly
> needs to be done in TLS_DEFINE_INIT_TP?
The macro TLS_DEFINE_INIT_TP is designed to take the pthread_t and
convert it into a tp that can be used in the clone call. You could
use this macro to additionally setup the TP if you needed such
additional setup like setting the hwcap bits in the TCB.
sysdeps/unix/sysv/linux/createthread.c
100 TLS_DEFINE_INIT_TP (tp, pd);
101
102 if (__glibc_unlikely (ARCH_CLONE (&start_thread, STACK_VARIABLES_ARGS,
103 clone_flags, pd, &pd->tid, tp, &pd->tid)
104 == -1))
105 return errno;
sysdeps/powerpc/nptl/tls.h
131 /* Code to initially initialize the thread pointer. This might need
132 special attention since 'errno' is not yet available and if the
133 operation can cause a failure 'errno' must not be touched. */
134 # define TLS_INIT_TP(tcbp) \
135 ({ \
136 __thread_register = (void *) (tcbp) + TLS_TCB_OFFSET; \
137 THREAD_SET_TM_CAPABLE (GLRO (dl_hwcap2) & PPC_FEATURE2_HAS_HTM ? 1 : 0); \
138 NULL; \
139 })
Cheers,
Carlos.