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>
- Cc: Jeff Law <law at redhat dot com>, Andi Kleen <andi at firstfloor dot org>, Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 14 Dec 2015 08:43:03 -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>
On Mon, Dec 14, 2015 at 6:56 AM, Zack Weinberg <zackw@panix.com> wrote:
> On Sat, Dec 12, 2015 at 12:36 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> Here is the updated patch to make it opt-in. OK for master?
>
> Thank you for being willing to make that change.
>
> I have no more principled objections; however, the code could be much
> simpler. Now that it's opt-in, there's no reason to entangle it with
> the x86 tuning code; it should be wholly controlled by the environment
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 ();
+
> 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.
--
H.J.