From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1130) id 4D9F13857033; Tue, 12 Sep 2023 15:25:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D9F13857033 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694532346; bh=hu54SjUE9lJ0fbLYFprZQmsKH37GPcVbafbR4L01r/g=; h=From:To:Subject:Date:From; b=EhKync4Qp7uQNRAdTlOHu2pijcGVAWrObBgy10Ye+Y3R15XMhqqNJeYJThfBOZY2X WCBLUTW0TNR7HuuGyyLkyO5ziFCvTM4vMf7FfTZP2rIu6fe6CQCgvbwy1rklzuZIwv wRVzgj6hkAF8gdXxvK00G9WpxN7AZTfJJ1pv+ICw= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Richard Sandiford To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/CVE-2023-4039/gcc-10)] aarch64: Simplify probe of final frame allocation X-Act-Checkin: gcc X-Git-Author: Richard Sandiford X-Git-Refname: refs/vendors/ARM/heads/CVE-2023-4039/gcc-10 X-Git-Oldrev: 128abc59aedc06b4418ac57d08a484e1fd92dee2 X-Git-Newrev: c940aadecb4f623a39abe16b6c62b307e2b10638 Message-Id: <20230912152546.4D9F13857033@sourceware.org> Date: Tue, 12 Sep 2023 15:25:46 +0000 (GMT) List-Id: https://gcc.gnu.org/g:c940aadecb4f623a39abe16b6c62b307e2b10638 commit c940aadecb4f623a39abe16b6c62b307e2b10638 Author: Richard Sandiford Date: Tue Aug 8 01:57:26 2023 +0100 aarch64: Simplify probe of final frame allocation Previous patches ensured that the final frame allocation only needs a probe when the size is strictly greater than 1KiB. It's therefore safe to use the normal 1024 probe offset in all cases. The main motivation for doing this is to simplify the code and remove the number of special cases. gcc/ * config/aarch64/aarch64.c (aarch64_allocate_and_probe_stack_space): Always probe the residual allocation at offset 1024, asserting that that is in range. gcc/testsuite/ * gcc.target/aarch64/stack-check-prologue-17.c: Expect the probe to be at offset 1024 rather than offset 0. * gcc.target/aarch64/stack-check-prologue-18.c: Likewise. Diff: --- gcc/config/aarch64/aarch64.c | 12 ++++-------- gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c | 2 +- gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c | 4 ++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 3d73c5f352f6..37c6219b07ab 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -8153,16 +8153,12 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2, are still safe. */ if (residual) { - HOST_WIDE_INT residual_probe_offset = guard_used_by_caller; + gcc_assert (guard_used_by_caller + byte_sp_alignment <= size); + /* If we're doing final adjustments, and we've done any full page allocations then any residual needs to be probed. */ if (final_adjustment_p && rounded_size != 0) min_probe_threshold = 0; - /* If doing a small final adjustment, we always probe at offset 0. - This is done to avoid issues when the final adjustment is smaller - than the probing offset. */ - else if (final_adjustment_p && rounded_size == 0) - residual_probe_offset = 0; aarch64_sub_sp (temp1, temp2, residual, frame_related_p); if (residual >= min_probe_threshold) @@ -8173,8 +8169,8 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2, HOST_WIDE_INT_PRINT_DEC " bytes, probing will be required." "\n", residual); - emit_stack_probe (plus_constant (Pmode, stack_pointer_rtx, - residual_probe_offset)); + emit_stack_probe (plus_constant (Pmode, stack_pointer_rtx, + guard_used_by_caller)); emit_insn (gen_blockage ()); } } diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c index 0d8a25d73a24..f0ec1389771d 100644 --- a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c +++ b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c @@ -33,7 +33,7 @@ int test1(int z) { ** ... ** str x30, \[sp\] ** sub sp, sp, #1040 -** str xzr, \[sp\] +** str xzr, \[sp, #?1024\] ** cbnz w0, .* ** bl g ** ... diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c index b646f040b54e..71d33ba34e9e 100644 --- a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c +++ b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c @@ -10,7 +10,7 @@ void g(); ** str x30, \[sp\] ** ... ** sub sp, sp, #4064 -** str xzr, \[sp\] +** str xzr, \[sp, #?1024\] ** cbnz w0, .* ** bl g ** ... @@ -52,7 +52,7 @@ int test1(int z) { ** str x30, \[sp\] ** ... ** sub sp, sp, #1040 -** str xzr, \[sp\] +** str xzr, \[sp, #?1024\] ** cbnz w0, .* ** bl g ** ...