This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Add Prefer_MAP_32BIT_EXEC for Silvermont
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Zack Weinberg <zackw at panix dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 14 Dec 2015 09:31:25 -0800
- Subject: Re: [PATCH] Add Prefer_MAP_32BIT_EXEC for Silvermont
- Authentication-results: sourceware.org; auth=none
- References: <CAKCAbMhMArQ9wsXhw2y+Fvv+_3O5i4g8pdDQdWo6_1YxqfVxkQ at mail dot gmail dot com> <CAMe9rOrVjSnhp-EzmAnVBg10wbqk9U4n+hL-3xF5=DPZP5co1A at mail dot gmail dot com> <CAKCAbMhk69hUBbrQ=0j0NDYjRT6R-EK1+F43+Mmi9FwS7epexQ at mail dot gmail dot com> <CAKCAbMhA6x4r6Bhw8cnAavoWzjWsm6WM8JPzrnCsrqxbEswS_g at mail dot gmail dot com> <87egeszoq3 dot fsf at tassilo dot jf dot intel dot com> <CAKCAbMibxh54DGJ6p59ah6jQK=oFkH9LCZo0UDBefQeh1y-5eg at mail dot gmail dot com> <CAMe9rOoyc4MXVz74GmjViora-iCEKitQXbpX9EB+Ln1Q_DAD_A at mail dot gmail dot com> <CAKCAbMi_noBivP+ksLaotNtfEhGrtUuUacbnZgjMg5m0PfEniw at mail dot gmail dot com> <20151211222913 dot GT15533 at two dot firstfloor dot org> <566B55DF dot 2040200 at redhat dot com> <20151212001449 dot GU15533 at two dot firstfloor dot org> <CAKCAbMgcZKr8-i2XuhHAnk4nKpJnpWEqj1XNuygkNhYzXPb8hA at mail dot gmail dot com> <566B8008 dot 6010106 at redhat dot com> <CAMe9rOofj5_TQFcU695CbMmpqcULUgD4r0O9kY2+VmsNoPJx9A at mail dot gmail dot com> <CAKCAbMjnZTjzuVyR4ZXNQZxab3KELkFhoY+Be7w3ZP37eG+hNg at mail dot gmail dot com> <CAMe9rOqXh5frV3NYQBg0AucN0QP2qX_kgUJ8xwmnjw0zyvJ6vQ at mail dot gmail dot com> <CAKCAbMg27+cnvA8JTFK-DcZwon0qe=iWQzaCH47_xzYBsQORoA at mail dot gmail dot com>
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.