[PATCHv2] powerpc: ABI change - add HWCAP/HWCAP2/platform info to TCB
Carlos O'Donell
carlos@redhat.com
Thu Sep 3 18:02:00 GMT 2015
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.
More information about the Libc-alpha
mailing list