qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL v2 0/8] tcg pach queue
@ 2024-01-23 10:24 Richard Henderson
  2024-01-23 10:24 ` [PULL v2 1/8] tcg: Remove unreachable code Richard Henderson
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Richard Henderson @ 2024-01-23 10:24 UTC (permalink / raw)
  To: qemu-devel

v2: Dropped s390x test case, which gets mis-compiled with
some cross-compiler.  Add tcg/arm fix.


r~


The following changes since commit 09be34717190c1620f0c6e5c8765b8da354aeb4b:

  Merge tag 'pull-request-2024-01-19' of https://gitlab.com/thuth/qemu into staging (2024-01-20 17:22:16 +0000)

are available in the Git repository at:

  https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20240123

for you to fetch changes up to 9f6523e8e4689cafdbed7c10b7cf7c775b5a607b:

  tcg/arm: Fix SIGILL in tcg_out_qemu_st_direct (2024-01-23 13:32:10 +1000)

----------------------------------------------------------------
tcg/arm: Fix SIGILL in tcg_out_qemu_st_direct
tcg/s390x: Fix encoding of VRIc, VRSa, VRSc insns
tcg: Clean up error paths in alloc_code_gen_buffer_splitwx_memfd
linux-user/riscv: Adjust vdso signal frame cfa offsets
linux-user: Fixed cpu restore with pc 0 on SIGBUS

----------------------------------------------------------------
Joseph Burt (1):
      tcg/arm: Fix SIGILL in tcg_out_qemu_st_direct

Richard Henderson (2):
      tcg/s390x: Fix encoding of VRIc, VRSa, VRSc insns
      linux-user/riscv: Adjust vdso signal frame cfa offsets

Robbin Ehn (1):
      linux-user: Fixed cpu restore with pc 0 on SIGBUS

Samuel Tardieu (2):
      tcg: Remove unreachable code
      tcg: Make the cleanup-on-error path unique

Thomas Weißschuh (2):
      linux-user/elfload: test return value of getrlimit
      linux-user/elfload: check PR_GET_DUMPABLE before creating coredump

 linux-user/elfload.c        |  10 ++++++++--
 linux-user/signal.c         |   5 +++--
 tcg/region.c                |  10 ++++------
 tcg/arm/tcg-target.c.inc    |   3 +++
 tcg/s390x/tcg-target.c.inc  |   6 +++---
 linux-user/riscv/vdso-32.so | Bin 2900 -> 2980 bytes
 linux-user/riscv/vdso-64.so | Bin 3856 -> 3944 bytes
 linux-user/riscv/vdso.S     |   8 ++++----
 8 files changed, 25 insertions(+), 17 deletions(-)


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PULL v2 1/8] tcg: Remove unreachable code
  2024-01-23 10:24 [PULL v2 0/8] tcg pach queue Richard Henderson
@ 2024-01-23 10:24 ` Richard Henderson
  2024-01-23 10:24 ` [PULL v2 2/8] tcg: Make the cleanup-on-error path unique Richard Henderson
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-01-23 10:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Samuel Tardieu, Peter Maydell

From: Samuel Tardieu <sam@rfc1149.net>

The `fail_rx`/`fail` block is only entered while `buf_rx` is equal to
its initial value `MAP_FAILED`. The `munmap(buf_rx, size);` was never
executed.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2030
Signed-off-by: Samuel Tardieu <sam@rfc1149.net>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20231219182212.455952-2-sam@rfc1149.net>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/region.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tcg/region.c b/tcg/region.c
index 86692455c0..467e51cf6f 100644
--- a/tcg/region.c
+++ b/tcg/region.c
@@ -597,9 +597,7 @@ static int alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp)
  fail_rx:
     error_setg_errno(errp, errno, "failed to map shared memory for execute");
  fail:
-    if (buf_rx != MAP_FAILED) {
-        munmap(buf_rx, size);
-    }
+    /* buf_rx is always equal to MAP_FAILED here and does not require cleanup */
     if (buf_rw) {
         munmap(buf_rw, size);
     }
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL v2 2/8] tcg: Make the cleanup-on-error path unique
  2024-01-23 10:24 [PULL v2 0/8] tcg pach queue Richard Henderson
  2024-01-23 10:24 ` [PULL v2 1/8] tcg: Remove unreachable code Richard Henderson
@ 2024-01-23 10:24 ` Richard Henderson
  2024-01-23 10:24 ` [PULL v2 3/8] linux-user: Fixed cpu restore with pc 0 on SIGBUS Richard Henderson
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-01-23 10:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Samuel Tardieu, Peter Maydell

From: Samuel Tardieu <sam@rfc1149.net>

By calling `error_setg_errno()` before jumping to the cleanup-on-error
path at the `fail` label, the cleanup path is clearer.

Signed-off-by: Samuel Tardieu <sam@rfc1149.net>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20231219182212.455952-3-sam@rfc1149.net>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/region.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tcg/region.c b/tcg/region.c
index 467e51cf6f..478ec051c4 100644
--- a/tcg/region.c
+++ b/tcg/region.c
@@ -584,7 +584,9 @@ static int alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp)
 
     buf_rx = mmap(NULL, size, host_prot_read_exec(), MAP_SHARED, fd, 0);
     if (buf_rx == MAP_FAILED) {
-        goto fail_rx;
+        error_setg_errno(errp, errno,
+                         "failed to map shared memory for execute");
+        goto fail;
     }
 
     close(fd);
@@ -594,8 +596,6 @@ static int alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp)
 
     return PROT_READ | PROT_WRITE;
 
- fail_rx:
-    error_setg_errno(errp, errno, "failed to map shared memory for execute");
  fail:
     /* buf_rx is always equal to MAP_FAILED here and does not require cleanup */
     if (buf_rw) {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL v2 3/8] linux-user: Fixed cpu restore with pc 0 on SIGBUS
  2024-01-23 10:24 [PULL v2 0/8] tcg pach queue Richard Henderson
  2024-01-23 10:24 ` [PULL v2 1/8] tcg: Remove unreachable code Richard Henderson
  2024-01-23 10:24 ` [PULL v2 2/8] tcg: Make the cleanup-on-error path unique Richard Henderson
@ 2024-01-23 10:24 ` Richard Henderson
  2024-01-23 10:24 ` [PULL v2 4/8] tcg/s390x: Fix encoding of VRIc, VRSa, VRSc insns Richard Henderson
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-01-23 10:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Robbin Ehn, Palmer Dabbelt

From: Robbin Ehn <rehn@rivosinc.com>

Commit f4e1168198 (linux-user: Split out host_sig{segv,bus}_handler)
introduced a bug, when returning from host_sigbus_handler the PC is
never set. Thus cpu_loop_exit_restore is called with a zero PC and
we immediate get a SIGSEGV.

Signed-off-by: Robbin Ehn <rehn@rivosinc.com>
Fixes: f4e1168198 ("linux-user: Split out host_sig{segv,bus}_handler")
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Message-Id: <33f27425878fb529b9e39ef22c303f6e0d90525f.camel@rivosinc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/signal.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index b35d1e512f..c9527adfa3 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -925,7 +925,7 @@ static void host_sigsegv_handler(CPUState *cpu, siginfo_t *info,
     cpu_loop_exit_sigsegv(cpu, guest_addr, access_type, maperr, pc);
 }
 
-static void host_sigbus_handler(CPUState *cpu, siginfo_t *info,
+static uintptr_t host_sigbus_handler(CPUState *cpu, siginfo_t *info,
                                 host_sigcontext *uc)
 {
     uintptr_t pc = host_signal_pc(uc);
@@ -947,6 +947,7 @@ static void host_sigbus_handler(CPUState *cpu, siginfo_t *info,
         sigprocmask(SIG_SETMASK, host_signal_mask(uc), NULL);
         cpu_loop_exit_sigbus(cpu, guest_addr, access_type, pc);
     }
+    return pc;
 }
 
 static void host_signal_handler(int host_sig, siginfo_t *info, void *puc)
@@ -974,7 +975,7 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc)
             host_sigsegv_handler(cpu, info, uc);
             return;
         case SIGBUS:
-            host_sigbus_handler(cpu, info, uc);
+            pc = host_sigbus_handler(cpu, info, uc);
             sync_sig = true;
             break;
         case SIGILL:
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL v2 4/8] tcg/s390x: Fix encoding of VRIc, VRSa, VRSc insns
  2024-01-23 10:24 [PULL v2 0/8] tcg pach queue Richard Henderson
                   ` (2 preceding siblings ...)
  2024-01-23 10:24 ` [PULL v2 3/8] linux-user: Fixed cpu restore with pc 0 on SIGBUS Richard Henderson
@ 2024-01-23 10:24 ` Richard Henderson
  2024-01-23 10:24 ` [PULL v2 5/8] linux-user/riscv: Adjust vdso signal frame cfa offsets Richard Henderson
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-01-23 10:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Michael Tokarev, Thomas Huth

While the format names the second vector register 'v3',
it is still in the second position (bits 12-15) and
the argument to RXB must match.

Example error:
 -   e7 00 00 10 2a 33       verllf  %v16,%v0,16
 +   e7 00 00 10 2c 33       verllf  %v16,%v16,16

Cc: qemu-stable@nongnu.org
Reported-by: Michael Tokarev <mjt@tls.msk.ru>
Fixes: 22cb37b4172 ("tcg/s390x: Implement vector shift operations")
Fixes: 79cada8693d ("tcg/s390x: Implement tcg_out_dup*_vec")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2054
Reviewed-by: Thomas Huth <thuth@redhat.com>
Tested-by: Michael Tokarev <mjt@tls.msk.ru>
Message-Id: <20240117213646.159697-2-richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/s390x/tcg-target.c.inc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc
index fbee43d3b0..7f6b84aa2c 100644
--- a/tcg/s390x/tcg-target.c.inc
+++ b/tcg/s390x/tcg-target.c.inc
@@ -683,7 +683,7 @@ static void tcg_out_insn_VRIc(TCGContext *s, S390Opcode op,
     tcg_debug_assert(is_vector_reg(v3));
     tcg_out16(s, (op & 0xff00) | ((v1 & 0xf) << 4) | (v3 & 0xf));
     tcg_out16(s, i2);
-    tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, v3, 0) | (m4 << 12));
+    tcg_out16(s, (op & 0x00ff) | RXB(v1, v3, 0, 0) | (m4 << 12));
 }
 
 static void tcg_out_insn_VRRa(TCGContext *s, S390Opcode op,
@@ -738,7 +738,7 @@ static void tcg_out_insn_VRSa(TCGContext *s, S390Opcode op, TCGReg v1,
     tcg_debug_assert(is_vector_reg(v3));
     tcg_out16(s, (op & 0xff00) | ((v1 & 0xf) << 4) | (v3 & 0xf));
     tcg_out16(s, b2 << 12 | d2);
-    tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, v3, 0) | (m4 << 12));
+    tcg_out16(s, (op & 0x00ff) | RXB(v1, v3, 0, 0) | (m4 << 12));
 }
 
 static void tcg_out_insn_VRSb(TCGContext *s, S390Opcode op, TCGReg v1,
@@ -762,7 +762,7 @@ static void tcg_out_insn_VRSc(TCGContext *s, S390Opcode op, TCGReg r1,
     tcg_debug_assert(is_vector_reg(v3));
     tcg_out16(s, (op & 0xff00) | (r1 << 4) | (v3 & 0xf));
     tcg_out16(s, b2 << 12 | d2);
-    tcg_out16(s, (op & 0x00ff) | RXB(0, 0, v3, 0) | (m4 << 12));
+    tcg_out16(s, (op & 0x00ff) | RXB(0, v3, 0, 0) | (m4 << 12));
 }
 
 static void tcg_out_insn_VRX(TCGContext *s, S390Opcode op, TCGReg v1,
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL v2 5/8] linux-user/riscv: Adjust vdso signal frame cfa offsets
  2024-01-23 10:24 [PULL v2 0/8] tcg pach queue Richard Henderson
                   ` (3 preceding siblings ...)
  2024-01-23 10:24 ` [PULL v2 4/8] tcg/s390x: Fix encoding of VRIc, VRSa, VRSc insns Richard Henderson
@ 2024-01-23 10:24 ` Richard Henderson
  2024-01-23 10:24 ` [PULL v2 6/8] linux-user/elfload: test return value of getrlimit Richard Henderson
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-01-23 10:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Vineet Gupta, Philippe Mathieu-Daudé, Alistair Francis

A typo in sizeof_reg put the registers at the wrong offset.

Simplify the expressions to use positive addresses from the
start of uc_mcontext instead of negative addresses from the
end of uc_mcontext.

Reported-by: Vineet Gupta <vineetg@rivosinc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/riscv/vdso-32.so | Bin 2900 -> 2980 bytes
 linux-user/riscv/vdso-64.so | Bin 3856 -> 3944 bytes
 linux-user/riscv/vdso.S     |   8 ++++----
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/linux-user/riscv/vdso-32.so b/linux-user/riscv/vdso-32.so
index 1ad1e5cbbbb8b1fe36b0fe4bcb6c06fab8219ecd..c2ce2a4757900a16b891bb98f7a027ac30c47a5f 100755
GIT binary patch
delta 643
zcmYjPOH5Ni6ur|gwzc+9XhF0TMNp`GR6Zh~mKGzXLQ}<nX)IXKDriMfutkSuO^l&=
z8%#8QLeLmPh&6@~q8pbkjmE?!?quJE3vZFdn`GwPbMD;S+&S~jvFMz4i@%wQ7Lm>j
z)#}rFqIBkAs)(L%{#f{&3ii(}e_yh8Pgey7+LRKpj+~BYkcbM&LN$yL<+mtroa4HJ
zZMB#&#N4vYgN#$Ed?)jG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z57PlQR)-eG#s<cwn&yg@lGcK@oc4^4l+J{%nC^(4kluhkpMH-CE)yLl*-W;WVlvfW
zn$C2M87easX35N!m?JV*U>?tWjs-3YofbJbEw)=?v(##t#d5P1CM%6r8LZY@qqA0P
zoyK~#4JsRzHYseD+aj}7YMaD%u^l2ig?0(-=G()wmunx#evpSj4qh<1k!|y419kyW
za5-|gGn!0n6rMbX!-TP6@<on##+1p1oZ^xu(C~qIwGXHh6nYVp6M?emVY>k;>oa*G
zP}TuWFGF&2M1Z-gk@Mz*obD`4Zx|+X@#%5GYydif&z`YjawDHTFrX$M;<IB+n9Rs;
L&uBT>kzXAEcnEna

diff --git a/linux-user/riscv/vdso.S b/linux-user/riscv/vdso.S
index a86d8fc488..c37275233a 100644
--- a/linux-user/riscv/vdso.S
+++ b/linux-user/riscv/vdso.S
@@ -101,12 +101,12 @@ endf __vdso_flush_icache
 	.cfi_startproc simple
 	.cfi_signal_frame
 
-#define sizeof_reg	(__riscv_xlen / 4)
+#define sizeof_reg	(__riscv_xlen / 8)
 #define sizeof_freg	8
-#define B_GR	(offsetof_uc_mcontext - sizeof_rt_sigframe)
-#define B_FR	(offsetof_uc_mcontext - sizeof_rt_sigframe + offsetof_freg0)
+#define B_GR	0
+#define B_FR	offsetof_freg0
 
-	.cfi_def_cfa	2, sizeof_rt_sigframe
+	.cfi_def_cfa	2, offsetof_uc_mcontext
 
 	/* Return address */
 	.cfi_return_column 64
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL v2 6/8] linux-user/elfload: test return value of getrlimit
  2024-01-23 10:24 [PULL v2 0/8] tcg pach queue Richard Henderson
                   ` (4 preceding siblings ...)
  2024-01-23 10:24 ` [PULL v2 5/8] linux-user/riscv: Adjust vdso signal frame cfa offsets Richard Henderson
@ 2024-01-23 10:24 ` Richard Henderson
  2024-01-23 10:24 ` [PULL v2 7/8] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Richard Henderson
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-01-23 10:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Weißschuh, Philippe Mathieu-Daudé

From: Thomas Weißschuh <thomas@t-8ch.de>

Should getrlimit() fail the value of dumpsize.rlimit_cur may not be
initialized. Avoid reading garbage data by checking the return value of
getrlimit.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Message-Id: <20240120-qemu-user-dumpable-v3-1-6aa410c933f1@t-8ch.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/elfload.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index cf9e74468b..c596871938 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -4667,9 +4667,9 @@ static int elf_core_dump(int signr, const CPUArchState *env)
     init_note_info(&info);
 
     errno = 0;
-    getrlimit(RLIMIT_CORE, &dumpsize);
-    if (dumpsize.rlim_cur == 0)
+    if (getrlimit(RLIMIT_CORE, &dumpsize) == 0 && dumpsize.rlim_cur == 0) {
         return 0;
+    }
 
     corefile = core_dump_filename(ts);
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL v2 7/8] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump
  2024-01-23 10:24 [PULL v2 0/8] tcg pach queue Richard Henderson
                   ` (5 preceding siblings ...)
  2024-01-23 10:24 ` [PULL v2 6/8] linux-user/elfload: test return value of getrlimit Richard Henderson
@ 2024-01-23 10:24 ` Richard Henderson
  2024-01-23 10:24 ` [PULL v2 8/8] tcg/arm: Fix SIGILL in tcg_out_qemu_st_direct Richard Henderson
  2024-01-25 15:11 ` [PULL v2 0/8] tcg pach queue Peter Maydell
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-01-23 10:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Weißschuh, Philippe Mathieu-Daudé

From: Thomas Weißschuh <thomas@t-8ch.de>

A process can opt-out of coredump creation by calling
prctl(PR_SET_DUMPABLE, 0).
linux-user passes this call from the guest through to the
operating system.
From there it can be read back again to avoid creating coredumps from
qemu-user itself if the guest chose so.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Message-Id: <20240120-qemu-user-dumpable-v3-2-6aa410c933f1@t-8ch.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/elfload.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index c596871938..daf7ef8435 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2,6 +2,7 @@
 #include "qemu/osdep.h"
 #include <sys/param.h>
 
+#include <sys/prctl.h>
 #include <sys/resource.h>
 #include <sys/shm.h>
 
@@ -4667,6 +4668,11 @@ static int elf_core_dump(int signr, const CPUArchState *env)
     init_note_info(&info);
 
     errno = 0;
+
+    if (prctl(PR_GET_DUMPABLE) == 0) {
+        return 0;
+    }
+
     if (getrlimit(RLIMIT_CORE, &dumpsize) == 0 && dumpsize.rlim_cur == 0) {
         return 0;
     }
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL v2 8/8] tcg/arm: Fix SIGILL in tcg_out_qemu_st_direct
  2024-01-23 10:24 [PULL v2 0/8] tcg pach queue Richard Henderson
                   ` (6 preceding siblings ...)
  2024-01-23 10:24 ` [PULL v2 7/8] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Richard Henderson
@ 2024-01-23 10:24 ` Richard Henderson
  2024-01-25 15:11 ` [PULL v2 0/8] tcg pach queue Peter Maydell
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-01-23 10:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Joseph Burt

From: Joseph Burt <caseorum@gmail.com>

When tcg_out_qemu_st_{index,direct} were merged, the direct case for
MO_64 was omitted, causing qemu_st_i64 to be encoded as 0xffffffff due
to underflow when adding h.base and h.index.

Fixes: 1df6d611bdc2 ("tcg/arm: Introduce HostAddress")
Signed-off-by: Joseph Burt <caseorum@gmail.com>
Message-Id: <20240121211439.100829-1-caseorum@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/arm/tcg-target.c.inc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc
index fc78566494..a9aa8aa91c 100644
--- a/tcg/arm/tcg-target.c.inc
+++ b/tcg/arm/tcg-target.c.inc
@@ -1662,6 +1662,9 @@ static void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc, TCGReg datalo,
             } else {
                 tcg_out_strd_r(s, h.cond, datalo, h.base, h.index);
             }
+        } else if (h.index < 0) {
+            tcg_out_st32_12(s, h.cond, datalo, h.base, 0);
+            tcg_out_st32_12(s, h.cond, datahi, h.base, 4);
         } else if (h.index_scratch) {
             tcg_out_st32_rwb(s, h.cond, datalo, h.index, h.base);
             tcg_out_st32_12(s, h.cond, datahi, h.index, 4);
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PULL v2 0/8] tcg pach queue
  2024-01-23 10:24 [PULL v2 0/8] tcg pach queue Richard Henderson
                   ` (7 preceding siblings ...)
  2024-01-23 10:24 ` [PULL v2 8/8] tcg/arm: Fix SIGILL in tcg_out_qemu_st_direct Richard Henderson
@ 2024-01-25 15:11 ` Peter Maydell
  8 siblings, 0 replies; 10+ messages in thread
From: Peter Maydell @ 2024-01-25 15:11 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel

On Tue, 23 Jan 2024 at 10:24, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> v2: Dropped s390x test case, which gets mis-compiled with
> some cross-compiler.  Add tcg/arm fix.
>
>
> r~
>
>
> The following changes since commit 09be34717190c1620f0c6e5c8765b8da354aeb4b:
>
>   Merge tag 'pull-request-2024-01-19' of https://gitlab.com/thuth/qemu into staging (2024-01-20 17:22:16 +0000)
>
> are available in the Git repository at:
>
>   https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20240123
>
> for you to fetch changes up to 9f6523e8e4689cafdbed7c10b7cf7c775b5a607b:
>
>   tcg/arm: Fix SIGILL in tcg_out_qemu_st_direct (2024-01-23 13:32:10 +1000)
>
> ----------------------------------------------------------------
> tcg/arm: Fix SIGILL in tcg_out_qemu_st_direct
> tcg/s390x: Fix encoding of VRIc, VRSa, VRSc insns
> tcg: Clean up error paths in alloc_code_gen_buffer_splitwx_memfd
> linux-user/riscv: Adjust vdso signal frame cfa offsets
> linux-user: Fixed cpu restore with pc 0 on SIGBUS
>


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/9.0
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-01-25 15:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-23 10:24 [PULL v2 0/8] tcg pach queue Richard Henderson
2024-01-23 10:24 ` [PULL v2 1/8] tcg: Remove unreachable code Richard Henderson
2024-01-23 10:24 ` [PULL v2 2/8] tcg: Make the cleanup-on-error path unique Richard Henderson
2024-01-23 10:24 ` [PULL v2 3/8] linux-user: Fixed cpu restore with pc 0 on SIGBUS Richard Henderson
2024-01-23 10:24 ` [PULL v2 4/8] tcg/s390x: Fix encoding of VRIc, VRSa, VRSc insns Richard Henderson
2024-01-23 10:24 ` [PULL v2 5/8] linux-user/riscv: Adjust vdso signal frame cfa offsets Richard Henderson
2024-01-23 10:24 ` [PULL v2 6/8] linux-user/elfload: test return value of getrlimit Richard Henderson
2024-01-23 10:24 ` [PULL v2 7/8] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Richard Henderson
2024-01-23 10:24 ` [PULL v2 8/8] tcg/arm: Fix SIGILL in tcg_out_qemu_st_direct Richard Henderson
2024-01-25 15:11 ` [PULL v2 0/8] tcg pach queue Peter Maydell

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).