[PATCH] Add Prefer_MAP_32BIT_EXEC for Silvermont
H.J. Lu
hjl.tools@gmail.com
Mon Dec 14 17:31:00 GMT 2015
On Mon, Dec 14, 2015 at 9:16 AM, Zack Weinberg <zackw@panix.com> wrote:
> On Mon, Dec 14, 2015 at 11:43 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> How about
>>
>> @@ -161,6 +195,14 @@ init_cpu_features (struct cpu_features *cpu_features)
>> if (HAS_CPU_FEATURE (CMOV))
>> cpu_features->feature[index_I686] |= bit_I686;
>>
>> + /* For 64-bit applications, branch prediction performance may be
>> + negatively impacted when the target of a branch is more than 4GB
>> + away from the branch. Set the Prefer_MAP_32BIT_EXEC bit so that
>> + mmap will try to map executable pages with MAP_32BIT first.
>> + NB: MAP_32BIT will map to lower 2GB, not lower 4GB, address. */
>> + cpu_features->feature[index_Prefer_MAP_32BIT_EXEC]
>> + |= get_prefer_map_32bit_exec ();
>
> Uh, what I'm saying is I don't think this belongs in cpu_features[] *at all*.
If other 64-bit architectures want to support LD_ENABLE_PREFER_MAP_32BIT_EXEC,
I will make it generic. Otherwise, I will leave it in x86 cpu_features.
>>> variable. Also, why are you open-coding a loop over the contents of
>>> __environ? Isn't this what __secure_getenv is for?
>>
>> It is bcause get_prefer_map_32bit_exec is called very early in ld.so when
>> __secure_getenv/getenv aren't available yet.
>
> Then we should fix that instead of duplicating security-sensitive logic.
ld.so has its own functions to process environment variables. Since
only sysdeps/x86/cpu-features.c needs it, I left __secure_getenv out of
elf/dl-environ.c.
--
H.J.
More information about the Libc-alpha
mailing list