public inbox for libc-stable@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Libc-stable Mailing List <libc-stable@sourceware.org>
Subject: Re: [PATCH] x86-64: Properly align La_x86_64_retval to VEC_SIZE [BZ #22715]
Date: Mon, 01 Jan 2018 00:00:00 -0000	[thread overview]
Message-ID: <CAMe9rOprT=pOLSKmhWUiT1TdSN5GgRRdgJ-DWPuX5Hn7-e3_Zw@mail.gmail.com> (raw)
In-Reply-To: <CAMe9rOpL4Ru0FTAOmyhDN=2LY4CBGEKBpr8NkLMg3t=gueE7dg@mail.gmail.com>

On Wed, Jan 17, 2018 at 4:00 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Jan 15, 2018 at 8:18 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>> _dl_runtime_profile calls _dl_call_pltexit, passing a pointer to
>> La_x86_64_retval which is allocated on stack.  The lrv_vector0
>> field in La_x86_64_retval must be aligned to size of vector register.
>> When allocating stack space for La_x86_64_retval, we need to make sure
>> that the address of La_x86_64_retval + RV_VECTOR0_OFFSET is aligned to
>> VEC_SIZE.  This patch checks the alignment of the lrv_vector0 field
>> and pads the stack space if needed.
>>
>> Tested with x32 and x86-64 on SSE4, AVX and AVX512 machines.
>>
>> OK for master?
>>
>> H.J.
>> ---
>>         [BZ #22715]
>>         * sysdeps/x86_64/dl-trampoline.h (_dl_runtime_profile): Properly
>>         align La_x86_64_retval to VEC_SIZE.
>> ---
>>  sysdeps/x86_64/dl-trampoline.h | 12 ++++++++++--
>>  1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/sysdeps/x86_64/dl-trampoline.h b/sysdeps/x86_64/dl-trampoline.h
>> index 15edf49674..298cfb3d99 100644
>> --- a/sysdeps/x86_64/dl-trampoline.h
>> +++ b/sysdeps/x86_64/dl-trampoline.h
>> @@ -440,8 +440,16 @@ _dl_runtime_profile:
>>  # ifdef RESTORE_AVX
>>         /* sizeof(La_x86_64_retval).  Need extra space for 2 SSE
>>            registers to detect if xmm0/xmm1 registers are changed
>> -          by audit module.  */
>> -       sub $(LRV_SIZE + XMM_SIZE*2), %RSP_LP
>> +          by audit module.  Since rsp is aligned to VEC_SIZE, we
>> +          need to make sure that the address of La_x86_64_retval +
>> +          LRV_VECTOR0_OFFSET is aligned to VEC_SIZE.  */
>> +#  define LRV_SPACE (LRV_SIZE + XMM_SIZE*2)
>> +#  define LRV_MISALIGNED ((LRV_SIZE + LRV_VECTOR0_OFFSET) & (VEC_SIZE - 1))
>> +#  if LRV_MISALIGNED == 0
>> +       sub $LRV_SPACE, %RSP_LP
>> +#  else
>> +       sub $(LRV_SPACE + VEC_SIZE - LRV_MISALIGNED), %RSP_LP
>> +#  endif
>>  # else
>>         sub $LRV_SIZE, %RSP_LP  # sizeof(La_x86_64_retval)
>>  # endif
>> --
>> 2.14.3
>>
>
> I am checking it in.
>

I will backport it to 2.23/2.24/2.25/2.26 branches tomorrow.


-- 
H.J.

           reply	other threads:[~2018-01-18 23:52 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <CAMe9rOpL4Ru0FTAOmyhDN=2LY4CBGEKBpr8NkLMg3t=gueE7dg@mail.gmail.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMe9rOprT=pOLSKmhWUiT1TdSN5GgRRdgJ-DWPuX5Hn7-e3_Zw@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=libc-stable@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).