From: Jeff Law <law@redhat.com>
To: Tamar Christina <Tamar.Christina@arm.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: nd <nd@arm.com>, James Greenhalgh <James.Greenhalgh@arm.com>,
Richard Earnshaw <Richard.Earnshaw@arm.com>,
Marcus Shawcroft <Marcus.Shawcroft@arm.com>
Subject: Re: [PATCH][GCC][AArch64] Ensure that outgoing argument size is at least 8 bytes when alloca and stack-clash. [Patch (3/6)]
Date: Fri, 03 Aug 2018 18:05:00 -0000 [thread overview]
Message-ID: <b1b9069d-41fc-99c4-56f3-e1a740f73fdc@redhat.com> (raw)
In-Reply-To: <HE1SPR8PMB31307FA8A8174988657D704FF540@HE1SPR8PMB313.eurprd08.prod.outlook.com>
On 07/25/2018 05:09 AM, Tamar Christina wrote:
> Hi All,
>
> Attached an updated patch which documents what the test cases are expecting as requested.
>
> Ok for trunk?
>
> Thanks,
> Tamar
>
> gcc/
> 2018-07-25 Tamar Christina <tamar.christina@arm.com>
>
> PR target/86486
> * config/aarch64/aarch64.h (STACK_CLASH_OUTGOING_ARGS,
> STACK_DYNAMIC_OFFSET): New.
> * config/aarch64/aarch64.c (aarch64_layout_frame):
> Update outgoing args size.
> (aarch64_stack_clash_protection_alloca_probe_range,
> TARGET_STACK_CLASH_PROTECTION_ALLOCA_PROBE_RANGE): New.
>
> gcc/testsuite/
> 2018-07-25 Tamar Christina <tamar.christina@arm.com>
>
> PR target/86486
> * gcc.target/aarch64/stack-check-alloca-1.c: New.
> * gcc.target/aarch64/stack-check-alloca-10.c: New.
> * gcc.target/aarch64/stack-check-alloca-2.c: New.
> * gcc.target/aarch64/stack-check-alloca-3.c: New.
> * gcc.target/aarch64/stack-check-alloca-4.c: New.
> * gcc.target/aarch64/stack-check-alloca-5.c: New.
> * gcc.target/aarch64/stack-check-alloca-6.c: New.
> * gcc.target/aarch64/stack-check-alloca-7.c: New.
> * gcc.target/aarch64/stack-check-alloca-8.c: New.
> * gcc.target/aarch64/stack-check-alloca-9.c: New.
> * gcc.target/aarch64/stack-check-alloca.h: New.
> * gcc.target/aarch64/stack-check-14.c: New.
> * gcc.target/aarch64/stack-check-15.c: New.
>
>> -----Original Message-----
>> From: Tamar Christina
>> Sent: Friday, July 13, 2018 17:36
>> To: Tamar Christina <Tamar.Christina@arm.com>; gcc-patches@gcc.gnu.org
>> Cc: nd <nd@arm.com>; James Greenhalgh <James.Greenhalgh@arm.com>;
>> Richard Earnshaw <Richard.Earnshaw@arm.com>; Marcus Shawcroft
>> <Marcus.Shawcroft@arm.com>
>> Subject: RE: [PATCH][GCC][AArch64] Ensure that outgoing argument size is at
>> least 8 bytes when alloca and stack-clash. [Patch (3/6)]
>>
>> Hi All,
>>
>> I'm sending an updated patch which updates a testcase that hits one of our
>> corner cases.
>> This is an assembler scan only update in a testcase.
>>
>> Regards,
>> Tamar
>>
>>> -----Original Message-----
>>> From: Tamar Christina <tamar.christina@arm.com>
>>> Sent: Wednesday, July 11, 2018 12:21
>>> To: gcc-patches@gcc.gnu.org
>>> Cc: nd <nd@arm.com>; James Greenhalgh <James.Greenhalgh@arm.com>;
>>> Richard Earnshaw <Richard.Earnshaw@arm.com>; Marcus Shawcroft
>>> <Marcus.Shawcroft@arm.com>
>>> Subject: [PATCH][GCC][AArch64] Ensure that outgoing argument size is
>>> at least 8 bytes when alloca and stack-clash. [Patch (3/6)]
>>>
>>> Hi All,
>>>
>>> This patch adds a requirement that the number of outgoing arguments
>>> for a function is at least 8 bytes when using stack-clash protection.
>>>
>>> By using this condition we can avoid a check in the alloca code and so
>>> have smaller and simpler code there.
>>>
>>> A simplified version of the AArch64 stack frames is:
>>>
>>> +-----------------------+
>>> | |
>>> | |
>>> | |
>>> +-----------------------+
>>> |LR |
>>> +-----------------------+
>>> |FP |
>>> +-----------------------+
>>> |dynamic allocations | ---- expanding area which will push the outgoing
>>> +-----------------------+ args down during each allocation.
>>> |padding |
>>> +-----------------------+
>>> |outgoing stack args | ---- safety buffer of 8 bytes (aligned)
>>> +-----------------------+
>>>
>>> By always defining an outgoing argument, alloca(0) effectively is safe
>>> to probe at $sp due to the reserved buffer being there. It will never
>>> corrupt the stack.
>>>
>>> This is also safe for alloca(x) where x is 0 or x % page_size == 0.
>>> In the former it is the same case as alloca(0) while the latter is
>>> safe because any allocation pushes the outgoing stack args down:
>>>
>>> |FP |
>>> +-----------------------+
>>> | |
>>> |dynamic allocations | ---- alloca (x)
>>> | |
>>> +-----------------------+
>>> |padding |
>>> +-----------------------+
>>> |outgoing stack args | ---- safety buffer of 8 bytes (aligned)
>>> +-----------------------+
>>>
>>> Which means when you probe for the residual, if it's 0 you'll again
>>> just probe in the outgoing stack args range, which we know is non-zero (at
>> least 8 bytes).
>>>
>>> Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
>>> Target was tested with stack clash on and off by default.
>>>
>>> Ok for trunk?
>>>
>>> Thanks,
>>> Tamar
>>>
>>> gcc/
>>> 2018-07-11 Tamar Christina <tamar.christina@arm.com>
>>>
>>> PR target/86486
>>> * config/aarch64/aarch64.h (STACK_CLASH_OUTGOING_ARGS,
>>> STACK_DYNAMIC_OFFSET): New.
>>> * config/aarch64/aarch64.c (aarch64_layout_frame):
>>> Update outgoing args size.
>>> (aarch64_stack_clash_protection_alloca_probe_range,
>>> TARGET_STACK_CLASH_PROTECTION_ALLOCA_PROBE_RANGE):
>>> New.
>>>
>>> gcc/testsuite/
>>> 2018-07-11 Tamar Christina <tamar.christina@arm.com>
>>>
>>> PR target/86486
>>> * gcc.target/aarch64/stack-check-alloca-1.c: New.
>>> * gcc.target/aarch64/stack-check-alloca-10.c: New.
>>> * gcc.target/aarch64/stack-check-alloca-2.c: New.
>>> * gcc.target/aarch64/stack-check-alloca-3.c: New.
>>> * gcc.target/aarch64/stack-check-alloca-4.c: New.
>>> * gcc.target/aarch64/stack-check-alloca-5.c: New.
>>> * gcc.target/aarch64/stack-check-alloca-6.c: New.
>>> * gcc.target/aarch64/stack-check-alloca-7.c: New.
>>> * gcc.target/aarch64/stack-check-alloca-8.c: New.
>>> * gcc.target/aarch64/stack-check-alloca-9.c: New.
>>> * gcc.target/aarch64/stack-check-alloca.h: New.
>>> * gcc.target/aarch64/stack-check-14.c: New.
>>> * gcc.target/aarch64/stack-check-15.c: New.
>>>
>>> --
Likewise -- no concerns on my end. AArch64 maintainers have the final say.
jeff
next prev parent reply other threads:[~2018-08-03 18:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-11 11:21 Tamar Christina
2018-07-13 16:35 ` Tamar Christina
2018-07-25 11:09 ` Tamar Christina
2018-08-03 18:05 ` Jeff Law [this message]
2018-08-07 10:09 ` Tamar Christina
2018-08-07 16:18 ` James Greenhalgh
2018-10-09 6:38 ` Tamar Christina
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=b1b9069d-41fc-99c4-56f3-e1a740f73fdc@redhat.com \
--to=law@redhat.com \
--cc=James.Greenhalgh@arm.com \
--cc=Marcus.Shawcroft@arm.com \
--cc=Richard.Earnshaw@arm.com \
--cc=Tamar.Christina@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=nd@arm.com \
/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).