On 10/15/2013 02:27 PM, Jakub Jelinek wrote:
On Tue, Oct 15, 2013 at 02:16:28PM -0400, Carlos O'Donell wrote:
> There is no effective security difference between accessing the randomized
> stack guard value from a global variable or a value stored in the dynamic
> thread vector.
>
> It is only a performance optimization. The choice of a global variable vs.
> DTV offset has only to do with the speed of access of the stack guard.
DTV access is of course going to be expensive, after all, that is a function
call, the question was about reserving a word at fixed constant offset from
the TLS base and how expensive that is vs. global variable access.
For soft FP I guess global variable access must win, for -mtp=cp15
]it depends on how fast the mrc instruction is.
I talk about DTV, but I should really just say constant offset from TP
since that's what I mean. I don't actually mean using a TLS variable.
Will Newton tested the global variable access code on soft and hard TP
configurations and to quote some initial discussions:
https://sourceware.org/ml/libc-ports/2013-09/msg00134.html
~~~
From a back of the envelope calculation the cost of accessing TLS is
one cycle faster than accessing a global in best case (e.g.
Cortex-A15), considerably slower in common case (50-60 cycles,
Cortex-A9) and slower still in worst case (function call to libgcc and
the kernel, ARMv4/ARMv5).
~~~
Therefore for 32-bit ARM it was decided that a global variable was the
best choice.
For AArch64 it will definitely be a reserved word at a constant offset
from the TP since that's going to be fastest.
Does that clarify things?
Cheers,
Carlos.