[PATCH] Add ifunc memcpy and memmove for aarch64

Steve Ellcey sellcey@caviumnetworks.com
Mon Jan 23 23:33:00 GMT 2017


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.

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ifunc2.diff
Type: text/x-patch
Size: 10446 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20170123/2be5b0b4/attachment.bin>


More information about the Libc-alpha mailing list