From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
qemu-stable@nongnu.org
Subject: Re: [PATCH v2 1/3] tcg/sparc: Fix temp_allocate_frame vs sparc stack bias
Date: Sat, 19 Jun 2021 16:41:36 +0200 [thread overview]
Message-ID: <5bd744f2-a7c8-59db-e73d-de05202a6ba7@amsat.org> (raw)
In-Reply-To: <20210619134216.590423-2-richard.henderson@linaro.org>
On 6/19/21 3:42 PM, Richard Henderson wrote:
> We should not be aligning the offset in temp_allocate_frame,
> because the odd offset produces an aligned address in the end.
> Instead, pass the logical offset into tcg_set_frame and add
> the stack bias last.
>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> tcg/tcg.c | 9 +++------
> tcg/sparc/tcg-target.c.inc | 16 ++++++++++------
> 2 files changed, 13 insertions(+), 12 deletions(-)
LGTM but I'd rather have another review...
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> diff --git a/tcg/tcg.c b/tcg/tcg.c
> index dd584f3bba..52e858523c 100644
> --- a/tcg/tcg.c
> +++ b/tcg/tcg.c
> @@ -3015,17 +3015,14 @@ static void check_regs(TCGContext *s)
>
> static void temp_allocate_frame(TCGContext *s, TCGTemp *ts)
> {
> -#if !(defined(__sparc__) && TCG_TARGET_REG_BITS == 64)
> - /* Sparc64 stack is accessed with offset of 2047 */
> - s->current_frame_offset = (s->current_frame_offset +
> - (tcg_target_long)sizeof(tcg_target_long) - 1) &
> - ~(sizeof(tcg_target_long) - 1);
> -#endif
> if (s->current_frame_offset + (tcg_target_long)sizeof(tcg_target_long) >
> s->frame_end) {
> tcg_abort();
> }
> ts->mem_offset = s->current_frame_offset;
> +#if defined(__sparc__)
> + ts->mem_offset += TCG_TARGET_STACK_BIAS;
> +#endif
> ts->mem_base = s->frame_temp;
> ts->mem_allocated = 1;
> s->current_frame_offset += sizeof(tcg_target_long);
> diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc
> index ce39ac2d86..a6ec94a094 100644
> --- a/tcg/sparc/tcg-target.c.inc
> +++ b/tcg/sparc/tcg-target.c.inc
> @@ -984,14 +984,18 @@ static void tcg_target_qemu_prologue(TCGContext *s)
> {
> int tmp_buf_size, frame_size;
>
> - /* The TCG temp buffer is at the top of the frame, immediately
> - below the frame pointer. */
> + /*
> + * The TCG temp buffer is at the top of the frame, immediately
> + * below the frame pointer. Use the logical (aligned) offset here;
> + * the stack bias is applied in temp_allocate_frame().
> + */
> tmp_buf_size = CPU_TEMP_BUF_NLONGS * (int)sizeof(long);
> - tcg_set_frame(s, TCG_REG_I6, TCG_TARGET_STACK_BIAS - tmp_buf_size,
> - tmp_buf_size);
> + tcg_set_frame(s, TCG_REG_I6, -tmp_buf_size, tmp_buf_size);
>
> - /* TCG_TARGET_CALL_STACK_OFFSET includes the stack bias, but is
> - otherwise the minimal frame usable by callees. */
> + /*
> + * TCG_TARGET_CALL_STACK_OFFSET includes the stack bias, but is
> + * otherwise the minimal frame usable by callees.
> + */
> frame_size = TCG_TARGET_CALL_STACK_OFFSET - TCG_TARGET_STACK_BIAS;
> frame_size += TCG_STATIC_CALL_ARGS_SIZE + tmp_buf_size;
> frame_size += TCG_TARGET_STACK_ALIGN - 1;
>
next prev parent reply other threads:[~2021-06-19 14:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-19 13:42 [PATCH v2 0/3] tcg: Fixes for temp_allocate_frame Richard Henderson
2021-06-19 13:42 ` [PATCH v2 1/3] tcg/sparc: Fix temp_allocate_frame vs sparc stack bias Richard Henderson
2021-06-19 14:41 ` Philippe Mathieu-Daudé [this message]
2021-06-19 13:42 ` [PATCH v2 2/3] tcg: Allocate sufficient storage in temp_allocate_frame Richard Henderson
2021-06-19 13:42 ` [PATCH v2 3/3] tcg: Restart when exhausting the stack frame Richard Henderson
2021-06-19 14:37 ` Philippe Mathieu-Daudé
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=5bd744f2-a7c8-59db-e73d-de05202a6ba7@amsat.org \
--to=f4bug@amsat.org \
--cc=alex.bennee@linaro.org \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=richard.henderson@linaro.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 NNTP newsgroup(s).