This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add ifunc memcpy and memmove for aarch64



On 23/01/2017 21:33, Steve Ellcey wrote:
> On Thu, 2017-01-19 at 17:41 -0200, Adhemerval Zanella wrote:
>>  
>> I think to avoid potentially multiple kernel traps at loading or plt resolve time,
>> a better solution would be issue the mrs instruction once at loader/program startup,
>> fill in an internal structure with the required information and use it later on
>> ifunc resolution.  This is similar the cpu-features/cacheinfo strategy for x86.
>>
>> From last patch iteration [1] documentation, kernel provides the HWCAP_CPUID
>> bit on hwcap to indication it supports the mrs emulation.  So using my previous
>> suggestion I would recommend:
>>
>>   1. Remove any configure check or restriction.
>>   2. Add a cpu_features module similar to x86 that set a global state with
>>      the cpu information obtained from kernel.  It will first check HWCAP_CPUID
>>      bit on hwcap and if it is set then issue the mrs instruction.  It will
>>      then populate the global state with the required cpu information.
>>   3. Use the cpu information to select the correct ifunc.
>>
>> It has another advantage of avoid more complexity with different glibc
>> with different minimum required kernels.
> 
> 
> Adhemerval,
> 
> I am looking at the cpu-features setup from x86 and trying to implement
> that for aarch64 but there are some things I don't understand about the
> code and I was hoping you (or someone else on the list) could help me.
> I have attached the patch I have so far, this code doesn't contain any
> use of the cpu features code but is just the code that tries to initialize
> it on start up.  Right now it doesn't build and I am not sure what I am
> missing.
> 
> Specifically I have these questions.
> 
> How is cpu-features-offsets.sym used and what do I need in this file?
> I think this may be how _dl_aarch64_cpu_features is supposed to be
> defined but I am not sure.
> 

The .sym files are a trick glibc uses to basically define struct or tls
offsets so use on assembly implementations. x86 uses it because it
originally implemented most of ifunc resolvers directly in assembly
(back when compiler support was lacking).

Since you are implementing directly on C, these files are unnecessary.

> I obviously need something in init_cpu_features to check if mrs is
> emulated in the kernel but I am not sure how to do that.  I know it
> involves the HWCAPs but I am not sure how to access them, do I need a
> sym file to get access to that too?  Something like
> sysdeps/arm/rtld-global-offsets.sym?
> 
> Right now my build dies with:
> 
> <stdin>:2:102: error: implicit declaration of function ‘rtld_global_ro_offsetof’ [-Werror=implicit-function-declaration]
> <stdin>:2:127: error: ‘_dl_aarch64_cpu_features’ undeclared (first use in this function)
> <stdin>:2:127: note: each undeclared identifier is reported only once for each function it appears in
> <stdin>:3:82: error: invalid application of ‘sizeof’ to incomplete type ‘struct cpu_features’
> cc1: all warnings being treated as errors
> ../Makerules:266: recipe for target '/home/ubuntu/sellcey/glibc-ifunc-new/obj-glibc64/cpu-features-offsets.h' failed
> make[2]: *** [/home/ubuntu/sellcey/glibc-ifunc-new/obj-glibc64/cpu-features-offsets.h] Error 1
> 
> Steve Ellcey
> sellcey@caviumnetworks.com
> 

This branch in my personal repo [1] have a workable draft version for
aarch64.  It contains 2 patches, one that implements the cpu-features.c
for aarch64 and another one that actually uses it to implement the
thundex ifunc.

On the first patch I would like to remove the sysdeps/aarch64/ldsodefs.h and
make only Linux specific, because of hwcap. I will try to cleanup this up
later.

[1] https://github.com/zatrazz/glibc/tree/master-aarch64-ifunc


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]