* [PATCH 0/2] tcg: Fixes for temp_allocate_frame
@ 2021-06-19 4:56 Richard Henderson
2021-06-19 4:56 ` [PATCH 1/2] tcg/sparc: Fix temp_allocate_frame vs sparc stack bias Richard Henderson
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Richard Henderson @ 2021-06-19 4:56 UTC (permalink / raw)
To: qemu-devel; +Cc: sw
Stefan, I think this will resolve #367 for you -- please test.
r~
Richard Henderson (2):
tcg/sparc: Fix temp_allocate_frame vs sparc stack bias
tcg: Allocate sufficient storage in temp_allocate_frame
tcg/tcg.c | 41 ++++++++++++++++++++++++++++----------
tcg/sparc/tcg-target.c.inc | 16 +++++++++------
2 files changed, 40 insertions(+), 17 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] tcg/sparc: Fix temp_allocate_frame vs sparc stack bias
2021-06-19 4:56 [PATCH 0/2] tcg: Fixes for temp_allocate_frame Richard Henderson
@ 2021-06-19 4:56 ` Richard Henderson
2021-06-19 4:57 ` [PATCH 2/2] tcg: Allocate sufficient storage in temp_allocate_frame Richard Henderson
2021-06-19 8:16 ` [PATCH 0/2] tcg: Fixes for temp_allocate_frame Stefan Weil
2 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2021-06-19 4:56 UTC (permalink / raw)
To: qemu-devel; +Cc: sw, mark.cave-ayland, qemu-stable
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
Cc: mark.cave-ayland@ilande.co.uk
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(-)
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;
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] tcg: Allocate sufficient storage in temp_allocate_frame
2021-06-19 4:56 [PATCH 0/2] tcg: Fixes for temp_allocate_frame Richard Henderson
2021-06-19 4:56 ` [PATCH 1/2] tcg/sparc: Fix temp_allocate_frame vs sparc stack bias Richard Henderson
@ 2021-06-19 4:57 ` Richard Henderson
2021-06-19 9:41 ` Philippe Mathieu-Daudé
2021-06-19 8:16 ` [PATCH 0/2] tcg: Fixes for temp_allocate_frame Stefan Weil
2 siblings, 1 reply; 6+ messages in thread
From: Richard Henderson @ 2021-06-19 4:57 UTC (permalink / raw)
To: qemu-devel; +Cc: sw, qemu-stable
This function should have been updated for vector types
when they were introduced.
Cc: qemu-stable@nongnu.org
Fixes: d2fd745fe8b
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/367
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/tcg.c | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 52e858523c..1bad423bde 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -3015,17 +3015,39 @@ static void check_regs(TCGContext *s)
static void temp_allocate_frame(TCGContext *s, TCGTemp *ts)
{
- if (s->current_frame_offset + (tcg_target_long)sizeof(tcg_target_long) >
- s->frame_end) {
- tcg_abort();
+ size_t size, align;
+ intptr_t off;
+
+ switch (ts->type) {
+ case TCG_TYPE_I32:
+ size = align = 4;
+ break;
+ case TCG_TYPE_I64:
+ case TCG_TYPE_V64:
+ size = align = 8;
+ break;
+ case TCG_TYPE_V128:
+ size = align = 16;
+ break;
+ case TCG_TYPE_V256:
+ /* Note that we do not require aligned storage for V256. */
+ size = 32, align = TCG_TARGET_STACK_ALIGN;
+ break;
+ default:
+ g_assert_not_reached();
}
- ts->mem_offset = s->current_frame_offset;
+
+ assert(align <= TCG_TARGET_STACK_ALIGN);
+ off = ROUND_UP(s->current_frame_offset, align);
+ assert(off + size <= s->frame_end);
+ s->current_frame_offset = off + size;
+
+ ts->mem_offset = off;
#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);
}
static void temp_load(TCGContext *, TCGTemp *, TCGRegSet, TCGRegSet, TCGRegSet);
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] tcg: Fixes for temp_allocate_frame
2021-06-19 4:56 [PATCH 0/2] tcg: Fixes for temp_allocate_frame Richard Henderson
2021-06-19 4:56 ` [PATCH 1/2] tcg/sparc: Fix temp_allocate_frame vs sparc stack bias Richard Henderson
2021-06-19 4:57 ` [PATCH 2/2] tcg: Allocate sufficient storage in temp_allocate_frame Richard Henderson
@ 2021-06-19 8:16 ` Stefan Weil
2021-06-21 8:42 ` Daniel P. Berrangé
2 siblings, 1 reply; 6+ messages in thread
From: Stefan Weil @ 2021-06-19 8:16 UTC (permalink / raw)
To: Richard Henderson, qemu-devel, Daniel P. Berrange
Am 19.06.21 um 06:56 schrieb Richard Henderson:
> Stefan, I think this will resolve #367 for you -- please test.
Tested-by: Stefan Weil <sw@weilnetz.de>
Thank you, yes, it seems to resolve that issue.
I had to make two additional changes for building on Windows:
- Downgrade to support glib 2.54 (that's the version provided by Cygwin
for mingw-w64). Daniel, could we go back from 2.56 to 2.54?
- Fix assertion in oslib-win32.c (I already have sent a patch for that,
see
http://patchwork.ozlabs.org/project/qemu-devel/patch/20210611105846.347954-1-sw@weilnetz.de/)
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] tcg: Allocate sufficient storage in temp_allocate_frame
2021-06-19 4:57 ` [PATCH 2/2] tcg: Allocate sufficient storage in temp_allocate_frame Richard Henderson
@ 2021-06-19 9:41 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-19 9:41 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: sw, qemu-stable
On 6/19/21 6:57 AM, Richard Henderson wrote:
> This function should have been updated for vector types
> when they were introduced.
>
> Cc: qemu-stable@nongnu.org
> Fixes: d2fd745fe8b
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/367
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> tcg/tcg.c | 32 +++++++++++++++++++++++++++-----
> 1 file changed, 27 insertions(+), 5 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] tcg: Fixes for temp_allocate_frame
2021-06-19 8:16 ` [PATCH 0/2] tcg: Fixes for temp_allocate_frame Stefan Weil
@ 2021-06-21 8:42 ` Daniel P. Berrangé
0 siblings, 0 replies; 6+ messages in thread
From: Daniel P. Berrangé @ 2021-06-21 8:42 UTC (permalink / raw)
To: Stefan Weil; +Cc: Richard Henderson, qemu-devel
On Sat, Jun 19, 2021 at 10:16:55AM +0200, Stefan Weil wrote:
> Am 19.06.21 um 06:56 schrieb Richard Henderson:
>
> > Stefan, I think this will resolve #367 for you -- please test.
>
>
> Tested-by: Stefan Weil <sw@weilnetz.de>
>
>
> Thank you, yes, it seems to resolve that issue.
>
> I had to make two additional changes for building on Windows:
>
> - Downgrade to support glib 2.54 (that's the version provided by Cygwin for
> mingw-w64). Daniel, could we go back from 2.56 to 2.54?
2.55.1 introduced support for autoptr with GSList/GList and we have already
started using this functionality, so it isn't a clean downgrade.
I'm pretty surprised cygwin would be on 2.54, as that is almost a 3 year
old release at this point in time. What's their timeframe for actually
pulling in a new release ?
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-06-21 8:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-19 4:56 [PATCH 0/2] tcg: Fixes for temp_allocate_frame Richard Henderson
2021-06-19 4:56 ` [PATCH 1/2] tcg/sparc: Fix temp_allocate_frame vs sparc stack bias Richard Henderson
2021-06-19 4:57 ` [PATCH 2/2] tcg: Allocate sufficient storage in temp_allocate_frame Richard Henderson
2021-06-19 9:41 ` Philippe Mathieu-Daudé
2021-06-19 8:16 ` [PATCH 0/2] tcg: Fixes for temp_allocate_frame Stefan Weil
2021-06-21 8:42 ` Daniel P. Berrangé
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.