tcg pach queue
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(-)
[PULL v2 3/8] linux-user: Fixed cpu restore with pc 0 on SIGBUS
From: Robbin Ehn <[email protected]>
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.
Message-Id: <[email protected]>
--- linux-user/signal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
linux-user/signal.c +3 -2
@@ -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 :
Signature · 1 line
2.34.1
[PULL v2 2/8] tcg: Make the cleanup-on-error path unique
In reply to Richard HendersonFrom: Samuel Tardieu <[email protected]>
By calling error_setg_errno() before jumping to the cleanup-on-error path at the fail label, the cleanup path is clearer.
Message-Id: <[email protected]>
--- tcg/region.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tcg/region.c +3 -3
@@ -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) {
Signature · 1 line
2.34.1
[PULL v2 1/8] tcg: Remove unreachable code
In reply to Richard HendersonFrom: Samuel Tardieu <[email protected]>
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
Message-Id: <[email protected]>
--- tcg/region.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tcg/region.c +1 -3
@@ -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); }
Signature · 1 line
2.34.1
[PULL v2 7/8] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump
In reply to Richard HendersonFrom: Thomas Weißschuh <[email protected]>
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.
Message-Id: <[email protected]>
--- linux-user/elfload.c | 6 ++++++ 1 file changed, 6 insertions(+)
linux-user/elfload.c +6 -0
@@ -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 ; }
Signature · 1 line
2.34.1
[PULL v2 5/8] linux-user/riscv: Adjust vdso signal frame cfa offsets
In reply to Richard HendersonA 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.
--- 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(-)
linux-user/riscv/vdso-32.so binary +0 -0
linux-user/riscv/vdso-64.so binary +0 -0
linux-user/riscv/vdso.S +4 -4
@@ -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
Signature · 1 line
2.34.1
[PULL v2 6/8] linux-user/elfload: test return value of getrlimit
In reply to Richard HendersonFrom: Thomas Weißschuh <[email protected]>
Should getrlimit() fail the value of dumpsize.rlimit_cur may not be initialized. Avoid reading garbage data by checking the return value of getrlimit.
Message-Id: <[email protected]>
--- linux-user/elfload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/elfload.c +2 -2
@@ -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);
Signature · 1 line
2.34.1
[PULL v2 4/8] tcg/s390x: Fix encoding of VRIc, VRSa, VRSc insns
In reply to Richard HendersonWhile 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
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2054
Message-Id: <[email protected]>
--- tcg/s390x/tcg-target.c.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tcg/s390x/tcg-target.c.inc +3 -3
@@ -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,
Signature · 1 line
2.34.1
[PULL v2 8/8] tcg/arm: Fix SIGILL in tcg_out_qemu_st_direct
In reply to Richard HendersonFrom: Joseph Burt <[email protected]>
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.
Message-Id: <[email protected]>
--- tcg/arm/tcg-target.c.inc | 3 +++ 1 file changed, 3 insertions(+)
tcg/arm/tcg-target.c.inc +3 -0
@@ -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);
Signature · 1 line
2.34.1
Peter Maydell
AppliedQuoted 18 lines · Richard Henderson
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:
Quoted 9 lines
tcg/arm: Fix SIGILL in
tcg_out_qemu_st_direct(2024-01-23 13:32:10 +1000)----------------------------------------------------------------
tcg/arm: Fix SIGILL intcg_out_qemu_st_directtcg/s390x: Fix encoding of VRIc, VRSa, VRSc insns
tcg: Clean up error paths inalloc_code_gen_buffer_splitwx_memfdlinux-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