Re: [PATCH v1] linux-user: Add option to run `execve`d programs through QEMU

2024-10-02 Thread Ilya Leoshkevich
On Wed, 2024-10-02 at 09:05 -0500, Noah Goldstein wrote: > On Wed, Oct 2, 2024 at 3:08 AM Ilya Leoshkevich > wrote: > > > > On Fri, 2024-08-30 at 15:36 -0700, Noah Goldstein wrote: > > > The new option '-qemu-children' makes it so that on `execve` the > &

Re: [PATCH v1] linux-user: Add option to run `execve`d programs through QEMU

2024-10-02 Thread Ilya Leoshkevich
On Wed, 2024-10-02 at 11:24 -0500, Noah Goldstein wrote: > On Wed, Oct 2, 2024 at 11:14 AM Ilya Leoshkevich > wrote: > > > > On Wed, 2024-10-02 at 10:10 -0500, Noah Goldstein wrote: > > > On Wed, Oct 2, 2024 at 9:53 AM Ilya Leoshkevich > > > > > >

Re: [PATCH v1] linux-user: Add option to run `execve`d programs through QEMU

2024-10-02 Thread Ilya Leoshkevich
On Wed, 2024-10-02 at 10:10 -0500, Noah Goldstein wrote: > On Wed, Oct 2, 2024 at 9:53 AM Ilya Leoshkevich > wrote: > > > > On Wed, 2024-10-02 at 09:44 -0500, Noah Goldstein wrote: > > > On Wed, Oct 2, 2024 at 9:38 AM Ilya Leoshkevich > > > > > > wro

Re: [PATCH v1] linux-user: Add option to run `execve`d programs through QEMU

2024-10-02 Thread Ilya Leoshkevich
On Wed, 2024-10-02 at 09:44 -0500, Noah Goldstein wrote: > On Wed, Oct 2, 2024 at 9:38 AM Ilya Leoshkevich > wrote: > > > > On Wed, 2024-10-02 at 16:08 +0200, Laurent Vivier wrote: > > > Le 02/10/2024 à 10:08, Ilya Leoshkevich a écrit : > > > > On Fri, 20

Re: [PATCH v1] linux-user: Add option to run `execve`d programs through QEMU

2024-10-02 Thread Ilya Leoshkevich
On Wed, 2024-10-02 at 16:08 +0200, Laurent Vivier wrote: > Le 02/10/2024 à 10:08, Ilya Leoshkevich a écrit : > > On Fri, 2024-08-30 at 15:36 -0700, Noah Goldstein wrote: > > > The new option '-qemu-children' makes it so that on `execve` the > > > child >

Re: [PATCH v3 1/5] linux-user: Correct print_sockaddr() format

2024-10-02 Thread Ilya Leoshkevich
x, addr, 1); > } > -    qemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last)); > +    qemu_log(","TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last)); >  } >   >  static void I see why this works, but it feels a bit wrong semantically: addr is not the last argument. Wouldn't it be better to add commas to the preceding switch's cases? Anyhow: Acked-by: Ilya Leoshkevich

Re: [PATCH v1] linux-user: Add option to run `execve`d programs through QEMU

2024-10-02 Thread Ilya Leoshkevich
On Fri, 2024-08-30 at 15:36 -0700, Noah Goldstein wrote: > The new option '-qemu-children' makes it so that on `execve` the > child > process will be launch by the same `qemu` executable that is > currently > running along with its current commandline arguments. > > The motivation for the change i

Re: [PATCH v3 2/5] linux-user: Display sockaddr buffer as pointer

2024-10-02 Thread Ilya Leoshkevich
On Wed, 2024-08-07 at 14:43 +0200, Philippe Mathieu-Daudé wrote: > Rather than 'raw param', display as pointer to get > "NULL" instead of "0x". > > Signed-off-by: Philippe Mathieu-Daudé > Reviewed-by: Richard Henderson Reviewed-by: Ilya Leoshkevich

Re: [PATCH v3 3/5] linux-user: Factor print_buf_len() out

2024-10-02 Thread Ilya Leoshkevich
On Wed, 2024-08-07 at 14:43 +0200, Philippe Mathieu-Daudé wrote: > Signed-off-by: Philippe Mathieu-Daudé > --- >  linux-user/strace.c | 13 + >  1 file changed, 9 insertions(+), 4 deletions(-) Reviewed-by: Ilya Leoshkevich

Re: [PATCH v3 4/5] linux-user: Add strace for sendto()

2024-10-02 Thread Ilya Leoshkevich
, NULL, NULL, NULL }, The output looks reasonable: 607813 sendto(9,"\24\0\0\0\26\0\1\3\242\370\374f\0\0\0\0\0\0\0\0",20,0,{nl_fam ily=AF_NETLINK,nl_pid=0,nl_groups=0},12) = 20 Reviewed-by: Ilya Leoshkevich

Re: [PATCH v3 5/5] linux-user: Add strace for recvfrom()

2024-10-01 Thread Ilya Leoshkevich
On Wed, 2024-08-07 at 14:43 +0200, Philippe Mathieu-Daudé wrote: > Signed-off-by: Philippe Mathieu-Daudé > --- >  linux-user/strace.c    | 19 +++ >  linux-user/strace.list |  2 +- >  2 files changed, 20 insertions(+), 1 deletion(-) > > diff --git a/linux-user/strace.c b/linux-user

[PATCH] linux-user: Trace wait4()'s and waitpid()'s wstatus

2024-10-01 Thread Ilya Leoshkevich
1ff0a0,0,(nil)) = 475837 (wstatus={WIFSIGNALED(s) && WTERMSIG(s) == SIGKILL}) 1168 waitpid(1171,0x7f44eea00340,0) = 1171 (wstatus={WIFSIGNALED(s) && WTERMSIG(s) == SIGKILL}) Signed-off-by: Ilya Leoshkevich --- linux-user/strace.c| 61 ++

[PATCH v4] tests/tcg/x86_64: Add cross-modifying code test

2024-10-01 Thread Ilya Leoshkevich
sure there are no regressions. [1] https://lists.gnu.org/archive/html/qemu-devel/2022-09/msg00034.html Signed-off-by: Ilya Leoshkevich --- v3: https://lore.kernel.org/qemu-devel/20230316214711.318339-1-...@linux.ibm.com/ v3 -> v4: Rebase. I've been looking into the .NET f

[PATCH] tests/tcg/s390x: Test modifying an EXECUTE target

2024-10-01 Thread Ilya Leoshkevich
ed-off-by: Ilya Leoshkevich --- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/ex-smc.c| 57 + 2 files changed, 58 insertions(+) create mode 100644 tests/tcg/s390x/ex-smc.c diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.

Re: [PULL v2 00/47] riscv-to-apply queue

2024-09-30 Thread Ilya Leoshkevich
On Sat, 2024-09-28 at 17:40 -0300, Daniel Henrique Barboza wrote: > > > On 9/28/24 8:34 AM, Peter Maydell wrote: > > On Tue, 24 Sept 2024 at 23:18, Alistair Francis > > wrote: > > > > > > The following changes since commit > > > 01dc65a3bc262ab1bec8fe89775e9bbfa627becb: > > > > > >    Merge ta

Re: [PATCH 00/18] Stop all qemu-cpu threads on a breakpoint

2024-09-25 Thread Ilya Leoshkevich
On Tue, 2024-09-24 at 13:46 +0200, Richard Henderson wrote: > On 9/23/24 18:12, Ilya Leoshkevich wrote: > > Hi, > > > > On reporting a breakpoint in a non-non-stop mode, GDB remotes must > > stop > > all threads. Currently qemu-user doesn't do that, breaking

Re: [PATCH] tests/docker: Fix microblaze atomics

2024-09-24 Thread Ilya Leoshkevich
On Tue, 2024-09-24 at 12:54 +0100, Alex Bennée wrote: > Ilya Leoshkevich writes: > > (add Mahesh to CC) > > > GCC produces invalid code for microblaze atomics. > > > > The fix is unfortunately not upstream, so fetch it from an external > > location and appl

Re: Using ubuntu24.4 system qemu-system-aarch64 +gdb-multiarch to debug the kernel, setting breakpoints cannot be stopped

2024-09-23 Thread Ilya Leoshkevich
On Mon, 2024-09-23 at 22:36 +0800, jie ren wrote: > Hi, I have a question for help >     I recently  Using ubuntu24.4 system qemu-system-aarch64 +gdb- > multiarch to debug the kernel, setting breakpoints cannot be stopped. >    system information: >         ubuntu version: 22.04 >     Debug ker

Re: [PATCH 00/18] Stop all qemu-cpu threads on a breakpoint

2024-09-23 Thread Ilya Leoshkevich
On Mon, 2024-09-23 at 18:12 +0200, Ilya Leoshkevich wrote: > Hi, > > On reporting a breakpoint in a non-non-stop mode, GDB remotes must > stop > all threads. Currently qemu-user doesn't do that, breaking the > debugging session for at least two reasons: concurrent access t

[PATCH 13/18] cpu: Implement cpu_thread_is_idle() for qemu-user

2024-09-23 Thread Ilya Leoshkevich
Stopped CPUs are parked until cpu_thread_is_idle() is true, so implement it for qemu-user. Share a part of the qemu-system's implementation. Signed-off-by: Ilya Leoshkevich --- accel/tcg/user-exec.c | 12 cpu-common.c | 19 +++ include/exe

[PATCH 11/18] accel/tcg: Unify user implementations of qemu_cpu_kick()

2024-09-23 Thread Ilya Leoshkevich
linux-user and bsd-user have the same implementation. Move it to user-exec.c. Signed-off-by: Ilya Leoshkevich --- accel/tcg/user-exec.c | 5 + bsd-user/main.c | 5 - linux-user/main.c | 5 - 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/accel/tcg/user

[PATCH 04/18] gdbstub: Factor out gdb_try_stop()

2024-09-23 Thread Ilya Leoshkevich
Move checking and setting allow_stop_reply into a function. Signed-off-by: Ilya Leoshkevich --- gdbstub/gdbstub.c | 15 +++ gdbstub/internals.h | 2 ++ gdbstub/system.c| 6 ++ gdbstub/user.c | 11 --- 4 files changed, 19 insertions(+), 15 deletions(-) diff

[PATCH 16/18] cpu: Allow pausing and resuming CPUs in qemu-user

2024-09-23 Thread Ilya Leoshkevich
Move the respective functions from sysemu to cpu-common. Signed-off-by: Ilya Leoshkevich --- accel/tcg/user-exec-stub.c | 4 -- accel/tcg/user-exec.c | 11 +++- cpu-common.c | 115 + include/exec/cpu-common.h | 7 +++ include/sysemu

[PATCH 10/18] cpu: Use BQL in qemu-user

2024-09-23 Thread Ilya Leoshkevich
Currently BQL is stubbed out in qemu-user. However, enabling the ability to pause and resume CPUs requires BQL, so introduce it. Signed-off-by: Ilya Leoshkevich --- accel/tcg/user-exec.c | 2 ++ bsd-user/freebsd/os-syscall.c | 6 bsd-user/main.c | 2 ++ cpu

[PATCH 17/18] gdbstub: Pause all CPUs before sending stop replies

2024-09-23 Thread Ilya Leoshkevich
This is required by the GDB remote protocol. Signed-off-by: Ilya Leoshkevich --- gdbstub/gdbstub.c | 2 ++ gdbstub/user.c| 10 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index a096104b07a..be632f8b214 100644 --- a/gdbstub

[PATCH 18/18] tests/tcg: Stress test thread breakpoints

2024-09-23 Thread Ilya Leoshkevich
Add a test to prevent regressions. Signed-off-by: Ilya Leoshkevich --- tests/tcg/multiarch/Makefile.target | 13 ++- .../gdbstub/test-thread-breakpoint-stress.py | 28 ++ .../tcg/multiarch/thread-breakpoint-stress.c | 92 +++ 3 files changed, 132 insertions(+), 1

[PATCH 03/18] gdbstub: Move gdb_syscall_mode to GDBSyscallState

2024-09-23 Thread Ilya Leoshkevich
Follow the convention that all the pieces of the global stub state must be inside a single struct. Signed-off-by: Ilya Leoshkevich --- gdbstub/syscalls.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gdbstub/syscalls.c b/gdbstub/syscalls.c index

[PATCH 00/18] Stop all qemu-cpu threads on a breakpoint

2024-09-23 Thread Ilya Leoshkevich
rting pause_all_vcpus() from qemu-system. This in turn requires introducing BQL and a few stubs to qemu-user. Best regards, Ilya [1] https://gitlab.com/qemu-project/qemu/-/issues/2465 Ilya Leoshkevich (18): gdbstub: Make gdb_get_char() static gdbstub: Move phy_memory_mode to GDBSystemState gdbstub:

[PATCH 07/18] qemu-thread: Introduce QEMU_COND_INITIALIZER

2024-09-23 Thread Ilya Leoshkevich
Allow static initialization of condition variables. Signed-off-by: Ilya Leoshkevich --- include/qemu/thread-posix.h | 2 ++ include/qemu/thread-win32.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/qemu/thread-posix.h b/include/qemu/thread-posix.h index fc0846bfa7c..ed08181a9c6

[PATCH 05/18] accel/tcg: Factor out cpu_exec_user()

2024-09-23 Thread Ilya Leoshkevich
All linux-user cpu_loop() implementations contain the same sequence of function calls. Factor them out so that they can be changed in one place. Signed-off-by: Ilya Leoshkevich --- accel/tcg/user-exec.c | 12 bsd-user/aarch64/target_arch_cpu.h | 6 +- bsd-user/arm

[PATCH 15/18] cpu: Set current_cpu early in qemu-user

2024-09-23 Thread Ilya Leoshkevich
qemu_plugin_get_registers() may be called before cpu_exec(), and it requires current_cpu. Signed-off-by: Ilya Leoshkevich --- bsd-user/main.c | 1 + linux-user/main.c| 1 + linux-user/syscall.c | 1 + 3 files changed, 3 insertions(+) diff --git a/bsd-user/main.c b/bsd-user/main.c

[PATCH 06/18] qemu-thread: Introduce QEMU_MUTEX_INITIALIZER

2024-09-23 Thread Ilya Leoshkevich
Allow static initialization of mutexes. Signed-off-by: Ilya Leoshkevich --- include/qemu/thread-posix.h | 6 ++ include/qemu/thread-win32.h | 6 ++ 2 files changed, 12 insertions(+) diff --git a/include/qemu/thread-posix.h b/include/qemu/thread-posix.h index 5f2f3d1386b..fc0846bfa7c

[PATCH 08/18] replay: Add replay_mutex_{lock, unlock}() stubs for qemu-user

2024-09-23 Thread Ilya Leoshkevich
Sharing pause_all_vcpus() with qemu-user requires providing no-op definitions of replay mutex functions. Make these functions available via replay-core.h and move the existing stubs to a separate file. Signed-off-by: Ilya Leoshkevich --- include/exec/replay-core.h | 13 + include

[PATCH 09/18] qemu-timer: Provide qemu_clock_enable() stub for qemu-user

2024-09-23 Thread Ilya Leoshkevich
Sharing pause_all_vcpus() with qemu-user requires a no-op implementation of qemu_clock_enable(). Signed-off-by: Ilya Leoshkevich --- stubs/meson.build | 4 stubs/qemu-timer.c | 6 ++ 2 files changed, 10 insertions(+) create mode 100644 stubs/qemu-timer.c diff --git a/stubs

[PATCH 14/18] cpu: Introduce cpu_is_paused()

2024-09-23 Thread Ilya Leoshkevich
A qemu-system CPU is considered paused as a result of an external request. A qemu-user CPU, in addition to that, should be considered paused when it's executing a syscall. Signed-off-by: Ilya Leoshkevich --- accel/tcg/user-exec.c | 5 + include/exec/cpu-common.h | 1 + system/c

[PATCH 01/18] gdbstub: Make gdb_get_char() static

2024-09-23 Thread Ilya Leoshkevich
It's user-only since commit a7e0f9bd2ace ("gdbstub: abstract target specific details from gdb_put_packet_binary"). Signed-off-by: Ilya Leoshkevich --- gdbstub/internals.h | 2 -- gdbstub/user.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/gdbstu

[PATCH 02/18] gdbstub: Move phy_memory_mode to GDBSystemState

2024-09-23 Thread Ilya Leoshkevich
Follow the convention that all the pieces of the global stub state must be inside a single struct. Signed-off-by: Ilya Leoshkevich --- gdbstub/system.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gdbstub/system.c b/gdbstub/system.c index 1ad87fe7fdf

[PATCH 12/18] cpu: Track CPUs executing syscalls

2024-09-23 Thread Ilya Leoshkevich
CPUs that execute syscalls should be considered paused by all_vcpus_paused(). Lay the groundwork by introducing a bool field in CPUState to track this. The field is not used by sysemu, but it's only one byte, so it should not be a problem. Signed-off-by: Ilya Leoshkevich --- accel/tcg

Re: [PATCH] target/ppc: Fix lxvx/stxvx facility check

2024-09-20 Thread Ilya Leoshkevich
| 2 +- > > > >  1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/target/ppc/translate/vsx-impl.c.inc > > > > b/target/ppc/translate/vsx-impl.c.inc > > > > index 40a87ddc4a..a869f30e86 100644 > > > >

[PATCH] tests/docker: Fix microblaze atomics

2024-09-19 Thread Ilya Leoshkevich
GCC produces invalid code for microblaze atomics. The fix is unfortunately not upstream, so fetch it from an external location and apply it locally. Suggested-by: Peter Maydell Signed-off-by: Ilya Leoshkevich --- .../debian-microblaze-cross.d/build-toolchain.sh | 8 tests

PING: [PATCH v2 0/2] target/ppc: Make divd[u] handler method decodetree compatible

2024-09-18 Thread Ilya Leoshkevich
On Mon, 2024-08-12 at 10:53 +0200, Ilya Leoshkevich wrote: > v1: > https://lore.kernel.org/qemu-devel/20240731100953.14950-1-...@linux.ibm.com/ > v1 -> v2: Add R-bs and a targeted divd[u] patch. > > Hi, > > This series contains two fixes for the same issue: divd[u] touc

Re: [PATCH v2 12/18] tests/tcg: ensure s390x-softmmu output redirected

2024-09-16 Thread Ilya Leoshkevich
f-by: Alex Bennée Acked-by: Ilya Leoshkevich

[PATCH v2 4/5] target/i386/gdbstub: Expose orig_ax

2024-09-12 Thread Ilya Leoshkevich
Copy XML files describing orig_ax from GDB and glue them with CPUX86State.orig_ax. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich --- configs/targets/i386-linux-user.mak | 2 +- configs/targets/x86_64-linux-user.mak | 2 +- gdb-xml/i386-32bit-linux.xml | 11

[PATCH v2 0/5] linux-user/i386: Emulate orig_ax

2024-09-12 Thread Ilya Leoshkevich
b, and enables the existing test-proc-mappings.py on i386. Best regards, Ilya Ilya Leoshkevich (5): include/exec: Introduce env_cpu_const() linux-user/i386: Emulate orig_ax target/i386/gdbstub: Factor out gdb_get_reg() and gdb_write_reg() target/i386/gdbstub: Expose orig_ax tests/tcg: Ru

[PATCH v2 2/5] linux-user/i386: Emulate orig_ax

2024-09-12 Thread Ilya Leoshkevich
The kernel uses orig_rax/orig_eax to store the syscall number before a syscall. One can see this value in core dumps and ptrace. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich --- linux-user/elfload.c | 4 ++-- linux-user/i386/cpu_loop.c | 3 +++ linux-user/qemu.h

[PATCH v2 3/5] target/i386/gdbstub: Factor out gdb_get_reg() and gdb_write_reg()

2024-09-12 Thread Ilya Leoshkevich
i386 gdbstub handles both i386 and x86_64. Factor out two functions for reading and writing registers without knowing their bitness. While at it, simplify the TARGET_LONG_BITS == 32 case. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich --- target/i386/gdbstub.c | 51

[PATCH v2 5/5] tests/tcg: Run test-proc-mappings.py on i386

2024-09-12 Thread Ilya Leoshkevich
Now that orig_ax is exposed and GDB is happy, don't skip test-proc-mappings.py on i386. In fact, it's broken only on m68k now, so skip only this architecture. Acked-by: Alex Bennée Signed-off-by: Ilya Leoshkevich --- .../tcg/multiarch/gdbstub/test-proc-mappings.py | 17 ++

[PATCH v2 1/5] include/exec: Introduce env_cpu_const()

2024-09-12 Thread Ilya Leoshkevich
It's the same as env_cpu(), but for const objects. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich --- include/exec/cpu-common.h | 13 - linux-user/elfload.c | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/exec/cpu-commo

Re: [PATCH v2 3/4] target/s390x: fix build warning (gcc-12 -fsanitize=thread)

2024-08-14 Thread Ilya Leoshkevich
> > Signed-off-by: Pierrick Bouvier Acked-by: Ilya Leoshkevich

[PATCH v2 2/2] target/ppc: Make divd[u] handler method decodetree compatible

2024-08-12 Thread Ilya Leoshkevich
This is like commit 86e6202a57b1 ("target/ppc: Make divw[u] handler method decodetree compatible."), but for gen_op_arith_divd(). Suggested-by: Richard Henderson Signed-off-by: Ilya Leoshkevich --- target/ppc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) di

[PATCH v2 1/2] target/ppc: Set ctx->opcode for decode_insn32()

2024-08-12 Thread Ilya Leoshkevich
ctx->opcode. Cc: qemu-sta...@nongnu.org Fixes: 99082815f17f ("target/ppc: Add infrastructure for prefixed insns") Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Ilya Leoshkevich --- target/ppc/translate.c | 3 +-- 1 file changed, 1 insertion(+),

[PATCH v2 0/2] target/ppc: Make divd[u] handler method decodetree compatible

2024-08-12 Thread Ilya Leoshkevich
. IMHO it's worth having something like this until the legacy decoder is fully eliminated. Patch 2 is a targeted fix for divd[u] only. Best regards, Ilya Ilya Leoshkevich (2): target/ppc: Set ctx->opcode for decode_insn32() target/ppc: Make divd[u] handler method decodetree compatibl

Re: [PATCH] linux-user/elfload: Fix pr_pid values in core files

2024-08-02 Thread Ilya Leoshkevich
On Fri, 2024-08-02 at 15:20 +0200, Philippe Mathieu-Daudé wrote: > On 1/8/24 22:23, Ilya Leoshkevich wrote: > > Analyzing qemu-produced core dumps of multi-threaded apps runs > > into: > > > > (gdb) info threads > >    [...] > >    21  

[PATCH 5/5] tests/tcg: Run test-proc-mappings.py on i386

2024-08-02 Thread Ilya Leoshkevich
Now that orig_ax is exposed and GDB is happy, don't skip test-proc-mappings.py on i386. In fact, it's broken only on m68k now, so skip only this architecture. Signed-off-by: Ilya Leoshkevich --- .../tcg/multiarch/gdbstub/test-proc-mappings.py | 17 ++--- 1 file changed, 6

[PATCH 3/5] target/i386/gdbstub: Factor out gdb_get_reg() and gdb_write_reg()

2024-08-02 Thread Ilya Leoshkevich
i386 gdbstub handles both i386 and x86_64. Factor out two functions for reading and writing registers without knowing their bitness. Signed-off-by: Ilya Leoshkevich --- target/i386/gdbstub.c | 52 ++- 1 file changed, 31 insertions(+), 21 deletions

[PATCH 4/5] target/i386/gdbstub: Expose orig_ax

2024-08-02 Thread Ilya Leoshkevich
Copy XML files describing orig_ax from GDB and glue them with CPUX86State.orig_ax. Signed-off-by: Ilya Leoshkevich --- configs/targets/i386-linux-user.mak | 2 +- configs/targets/x86_64-linux-user.mak | 2 +- gdb-xml/i386-32bit-linux.xml | 11 ++ gdb-xml/i386-64bit-linux.xml

[PATCH 2/5] linux-user/i386: Emulate orig_ax

2024-08-02 Thread Ilya Leoshkevich
The kernel uses orig_rax/orig_eax to store the syscall number before a syscall. One can see this value in core dumps and ptrace. Signed-off-by: Ilya Leoshkevich --- linux-user/elfload.c | 4 ++-- linux-user/i386/cpu_loop.c | 3 +++ linux-user/qemu.h | 5 + 3 files changed, 10

[PATCH 1/5] include/exec: Introduce env_cpu_const()

2024-08-02 Thread Ilya Leoshkevich
It's the same as env_cpu(), but for const objects. Signed-off-by: Ilya Leoshkevich --- include/exec/cpu-common.h | 13 - linux-user/elfload.c | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h

[PATCH 0/4] linux-user/i386: Emulate orig_ax

2024-08-02 Thread Ilya Leoshkevich
amd64_linux_init_abi_common() -> linux_init_abi(). This series adds orig_ax support to the emulator and gdbstub, and enables the existing test-proc-mappings.py on i386. Best regards, Ilya Ilya Leoshkevich (5): include/exec: Introduce env_cpu_const() linux-user/i386: Emulate orig_ax target/i386/gdbs

[PATCH] linux-user/elfload: Fix pr_pid values in core files

2024-08-01 Thread Ilya Leoshkevich
same TaskState is used for all CPUs when generating NT_PRSTATUS notes. Fix by using TaskStates associated with individual CPUs. Cc: qemu-sta...@nongnu.org Fixes: 243c47066253 ("linux-user/elfload: Write corefile elf header in one block") Signed-off-by: Ilya Leoshkevich --- linux-use

Re: [PATCH] bsd-user/main: Allow setting tb-size

2024-08-01 Thread Ilya Leoshkevich
On Wed, 2024-07-31 at 15:21 -0600, Warner Losh wrote: > On Wed, Jul 31, 2024 at 8: 45 AM Ilya Leoshkevich > wrote: While qemu-system can set tb-size using > -accel tcg,tb-size=n, there is no similar knob for qemu-bsd-user. Add > one in a way similar to how one-insn-per-tb is already &

[PATCH] bsd-user/main: Allow setting tb-size

2024-07-31 Thread Ilya Leoshkevich
While qemu-system can set tb-size using -accel tcg,tb-size=n, there is no similar knob for qemu-bsd-user. Add one in a way similar to how one-insn-per-tb is already handled. Suggested-by: Philippe Mathieu-Daudé Signed-off-by: Ilya Leoshkevich --- bsd-user/main.c | 9 + 1 file changed

[PATCH] bsd-user/x86_64/target_arch_thread.h: Align stack

2024-07-31 Thread Ilya Leoshkevich
aligned: (gdb) p/x env->regs[5] $1 = 0x822443b58 A quick experiment shows that the userspace entry point expects misaligned rsp: (gdb) starti (gdb) p/x $rsp $1 = 0x7fffeaa8 Emulate this behavior in bsd-user. Signed-off-by: Ilya Leoshkevich --- bsd-user/x86

[PATCH] target/ppc: Set ctx->opcode for decode_insn32()

2024-07-31 Thread Ilya Leoshkevich
ctx->opcode. Cc: qemu-sta...@nongnu.org Fixes: 99082815f17f ("target/ppc: Add infrastructure for prefixed insns") Signed-off-by: Ilya Leoshkevich --- target/ppc/translate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.

[PATCH] linux-user/main: Allow setting tb-size

2024-07-30 Thread Ilya Leoshkevich
While qemu-system can set tb-size using -accel tcg,tb-size=n, there is no similar knob for qemu-user. Add one in a way similar to how one-insn-per-tb is already handled. Signed-off-by: Ilya Leoshkevich --- linux-user/main.c | 12 1 file changed, 12 insertions(+) diff --git a/linux

Re: [PATCH 0/2] target/arm: Fix unwind from dc zva and FEAT_MOPS

2024-07-05 Thread Ilya Leoshkevich
On Thu, 2024-07-04 at 14:48 -0700, Richard Henderson wrote: > On 7/4/24 08:18, Richard Henderson wrote: > > On 7/4/24 07:50, Ilya Leoshkevich wrote: > > > On Tue, 2024-07-02 at 16:41 -0700, Richard Henderson wrote: > > > > While looking into Zoltan's attempt t

Re: [PATCH 0/2] target/arm: Fix unwind from dc zva and FEAT_MOPS

2024-07-04 Thread Ilya Leoshkevich
On Tue, 2024-07-02 at 16:41 -0700, Richard Henderson wrote: > While looking into Zoltan's attempt to speed up ppc64 DCBZ > (data cache block set to zero), I wondered what AArch64 was > doing differently.  It turned out that Arm is the only user > of tlb_vaddr_to_host. > > None of the code sequence

[PATCH v2] linux-user: Make TARGET_NR_setgroups affect only the current thread

2024-06-14 Thread Ilya Leoshkevich
Like TARGET_NR_setuid, TARGET_NR_setgroups should affect only the calling thread, and not the entire process. Therefore, implement it using a syscall, and not a libc call. Cc: qemu-sta...@nongnu.org Fixes: 19b84f3c35d7 ("added setgroups and getgroups syscalls") Signed-off-by: Ilya L

Re: [PATCH] target/s390x: Fix tracing header path in TCG mem_helper.c

2024-06-06 Thread Ilya Leoshkevich
y: Philippe Mathieu-Daudé > --- > Ideally we should only use trace events from current directory. > --- >  target/s390x/tcg/mem_helper.c | 2 +- >  1 file changed, 1 insertion(+), 1 deletion(-) Acked-by: Ilya Leoshkevich

Re: [PATCH 09/14] target/s390x: Raise exception from helper_per_branch

2024-05-22 Thread Ilya Leoshkevich
On Wed, 2024-05-01 at 22:44 -0700, Richard Henderson wrote: > Drop from argument, since gbea has always been updated with > this address.  Add ilen argument for setting int_pgm_ilen. > Use update_cc_op before calling per_branch. > > By raising the exception here, we need not call > per_check_excep

Re: [PATCH 04/14] target/s390x: Record separate PER bits in TB flags

2024-05-22 Thread Ilya Leoshkevich
| 10 >  4 files changed, 61 insertions(+), 34 deletions(-) Reviewed-by: Ilya Leoshkevich

Re: [PATCH 03/14] target/s390x: Update CR9 bits

2024-05-22 Thread Ilya Leoshkevich
tions(+), 8 deletions(-) Reviewed-by: Ilya Leoshkevich

Re: [PATCH 02/14] target/s390x: Move cpu_get_tb_cpu_state out of line

2024-05-22 Thread Ilya Leoshkevich
On Wed, 2024-05-01 at 22:44 -0700, Richard Henderson wrote: > Signed-off-by: Richard Henderson > --- >  target/s390x/cpu.h | 23 ++- >  target/s390x/cpu.c | 22 ++ >  2 files changed, 24 insertions(+), 21 deletions(-) Reviewed-by: Ilya Leoshkevich

Re: [PATCH 01/14] target/s390x: Do not use unwind for per_check_exception

2024-05-22 Thread Ilya Leoshkevich
When a PER interruption is caused by branch- ing, the PER address identifies the branch instruction (or execute-type instruction, as appro- priate), whereas the old PSW points to the next instruction to be executed. whereas currently old PSW = unwind(GETPC()) = branch instruction. Reviewed-by: Ilya Leoshkevich

Re: [PATCH 14/14] tests/tcg/s390x: Add per.S

2024-05-22 Thread Ilya Leoshkevich
gt;  2 files changed, 83 insertions(+) >  create mode 100644 tests/tcg/s390x/per.S Acked-by: Ilya Leoshkevich Tested-by: Ilya Leoshkevich

[PATCH] tests/tcg/s390x: Allow specifying extra QEMU options on the command line

2024-05-22 Thread Ilya Leoshkevich
hitectures. Signed-off-by: Ilya Leoshkevich --- tests/tcg/s390x/Makefile.softmmu-target | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tcg/s390x/Makefile.softmmu-target b/tests/tcg/s390x/Makefile.softmmu-target index 1078655dd31..4ca0dac7257 100644 --- a/tests

Re: [PATCH v3 00/13] exec: Rework around CPUState user fields (part 2)

2024-04-30 Thread Ilya Leoshkevich
On Tue, Apr 30, 2024 at 09:00:17PM +0200, Philippe Mathieu-Daudé wrote: > On 30/4/24 20:45, Philippe Mathieu-Daudé wrote: > > Hi Ilya, > > > > On 30/4/24 19:55, Ilya Leoshkevich wrote: > > > On Tue, Apr 30, 2024 at 02:27:54PM +0200, Philippe Mathieu-Daudé wrote: &

Re: [PATCH v3 00/13] exec: Rework around CPUState user fields (part 2)

2024-04-30 Thread Ilya Leoshkevich
On Tue, Apr 30, 2024 at 02:27:54PM +0200, Philippe Mathieu-Daudé wrote: > Missing WASM testing by Ilya (branch available at > https://gitlab.com/philmd/qemu/-/commits/tcg_flush_jmp_cache) Hmm, it dies very early now: # gdb --args ./qemu-s390x -L /usr/s390x-linux-gnu /build/wasmtime/target/s390

Re: [PATCH v2 10/13] accel/tcg: Remove NULL check in tcg_flush_jmp_cache()

2024-04-29 Thread Ilya Leoshkevich
s://lore.kernel.org/qemu-devel/20221027141856.w5umjgklawgu7pqv@heavy/ > to confirm. Ilya, do you mind testing? If so, we could > squash this with the previous patch. > > Cc: Ilya Leoshkevich > Signed-off-by: Philippe Mathieu-Daudé > --- > accel/tcg/translate-all.c | 8 +---

[PATCH v2 2/4] linux-user: Fix shmat() strace

2024-03-25 Thread Ilya Leoshkevich
Henderson Signed-off-by: Ilya Leoshkevich --- linux-user/strace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 660f942f599..54169096aa4 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -701,7 +701,7 @@

[PATCH v2 4/4] tests/tcg: Test shmat(NULL)

2024-03-25 Thread Ilya Leoshkevich
Add a small test to prevent regressions. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich --- tests/tcg/multiarch/linux/linux-shmat-null.c | 38 1 file changed, 38 insertions(+) create mode 100644 tests/tcg/multiarch/linux/linux-shmat-null.c diff --git a

[PATCH v2 0/4] linux-user: Fix shmat(NULL) for h != g

2024-03-25 Thread Ilya Leoshkevich
and adds a test. Best regards, Ilya Ilya Leoshkevich (4): linux-user: Fix semctl() strace linux-user: Fix shmat() strace linux-user: Fix shmat(NULL) for h != g tests/tcg: Test shmat(NULL) linux-user/mmap.c| 2 +- linux-user/strace.c |

[PATCH v2 1/4] linux-user: Fix semctl() strace

2024-03-25 Thread Ilya Leoshkevich
t;Fix warnings that would be caused by gcc flag -Wwrite-strings") Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich --- linux-user/strace.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 9934e2208e2..6

[PATCH v2 3/4] linux-user: Fix shmat(NULL) for h != g

2024-03-25 Thread Ilya Leoshkevich
", which is set after mmap_find_vma(), is true. Fixes: 78bc8ed9a8f0 ("linux-user: Rewrite target_shmat") Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich --- linux-user/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/mmap.c b

[PATCH 0/4] linux-user: Fix shmat(NULL) for h != g

2024-03-25 Thread Ilya Leoshkevich
Hi, I noticed that while shmat() now works with /proc/self/maps, shmat(NULL) got broken. This series fixes that along with two related strace issues, and adds a test. Best regards, Ilya Ilya Leoshkevich (4): linux-user: Fix semctl() strace linux-user: Fix shmat() strace linux-user: Fix

[PATCH 2/4] linux-user: Fix shmat() strace

2024-03-25 Thread Ilya Leoshkevich
The indices of arguments passed to print_shmat() are all off-by-1, because arg1 is the ipc() command. Fix them. New output for linux-shmat-maps test: 3501769 shmat(4784214,0x0080,SHM_RND) = 0 Fixes: 9f7c97324c27 ("linux-user: Add strace for shmat") Signed-of

[PATCH 1/4] linux-user: Fix semctl() strace

2024-03-25 Thread Ilya Leoshkevich
t;Fix warnings that would be caused by gcc flag -Wwrite-strings") Signed-off-by: Ilya Leoshkevich --- linux-user/strace.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 9934e2208e2..9be71af4016 100644 --- a/linux-use

[PATCH 4/4] tests/tcg: Test shmat(NULL)

2024-03-25 Thread Ilya Leoshkevich
Add a small test to prevent regressions. Signed-off-by: Ilya Leoshkevich --- tests/tcg/multiarch/linux/linux-shmat-null.c | 38 1 file changed, 38 insertions(+) create mode 100644 tests/tcg/multiarch/linux/linux-shmat-null.c diff --git a/tests/tcg/multiarch/linux/linux

[PATCH 3/4] linux-user: Fix shmat(NULL) for h != g

2024-03-25 Thread Ilya Leoshkevich
", which is set after mmap_find_vma(), is true. Fixes: 78bc8ed9a8f0 ("linux-user: Rewrite target_shmat") Signed-off-by: Ilya Leoshkevich --- linux-user/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index e88faf1ab3d.

[PATCH v2 1/2] target/s390x: Use mutable temporary value for op_ts

2024-03-18 Thread Ilya Leoshkevich
From: Ido Plat Otherwise TCG would assume the register that holds t1 would be constant and reuse whenever it needs the value within it. Cc: qemu-sta...@nongnu.org Fixes: f1ea739bd598 ("target/s390x: Use tcg_constant_* in local contexts") Reviewed-by: Ilya Leoshkevich Reviewed-b

[PATCH v2 2/2] tests/tcg/s390x: Test TEST AND SET

2024-03-18 Thread Ilya Leoshkevich
Add a small test to prevent regressions. Signed-off-by: Ilya Leoshkevich --- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/ts.c| 35 + 2 files changed, 36 insertions(+) create mode 100644 tests/tcg/s390x/ts.c diff --git a/tests/tcg/s390x

[PATCH 2/2] tests/tcg/s390x: Test TEST AND SET

2024-03-18 Thread Ilya Leoshkevich
Add a small test to prevent regressions. Signed-off-by: Ilya Leoshkevich --- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/ts.c| 35 + 2 files changed, 36 insertions(+) create mode 100644 tests/tcg/s390x/ts.c diff --git a/tests/tcg/s390x

[PATCH 1/2] target/s390x: Use mutable temporary value for op_ts

2024-03-18 Thread Ilya Leoshkevich
From: Ido Plat Otherwise TCG would assume the register that holds t1 would be constant and reuse whenever it needs the value within it. Reviewed-by: Ilya Leoshkevich [iii: Adjust a newline and capitalization] Signed-off-by: Ido Plat --- target/s390x/tcg/translate.c | 3 ++- 1 file changed, 2

[PATCH] meson: Make DEBUG_REMAP a meson option

2024-03-11 Thread Ilya Leoshkevich
Currently DEBUG_REMAP is a macro that needs to be manually #defined to be activated, which makes it hard to have separate build directories dedicated to testing the code with it. Promote it to a meson option. Signed-off-by: Ilya Leoshkevich --- bsd-user/qemu.h | 6 ++ linux

[PATCH] gdbstub: Fix double close() of the follow-fork-mode socket

2024-03-11 Thread Ilya Leoshkevich
returning - instead. Fixes: Coverity CID 1539966 Fixes: d547e711a8a5 ("gdbstub: Implement follow-fork-mode child") Signed-off-by: Ilya Leoshkevich --- gdbstub/user.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gdbstub/user.c b/gdbstub/user.c index 7f9f19a1249..0

Re: [PATCH] linux-user: Make TARGET_NR_setgroups affect only the current thread

2024-02-26 Thread Ilya Leoshkevich
On Wed, Jan 31, 2024 at 02:10:55PM +0100, Philippe Mathieu-Daudé wrote: > On 31/1/24 01:18, Ilya Leoshkevich wrote: > > Like TARGET_NR_setuid, TARGET_NR_setgroups should affect only the > > calling thread, and not the entire process. Therefore, implement it > > using a syscall

Re: [PATCH 3/3] linux-user: Rewrite target_shmat

2024-02-23 Thread Ilya Leoshkevich
hmat() unless the address is sufficiently > + * aligned for the host, we'll need to check both. > + * TODO: Could be fixed with softmmu. > + */ Are there any plans to introduce softmmu to qemu-user? [...] Reviewed-by: Ilya Leoshkevich Please consider adding the reproducer to the

[PATCH v4 03/12] {linux,bsd}-user: Update ts_tid after fork()

2024-02-19 Thread Ilya Leoshkevich
Currently ts_tid contains the parent tid after fork(), which is not correct. So far it has not affected anything, but the upcoming follow-fork-mode child support relies on the correct value, so fix it. Reviewed-by: Alex Bennée Signed-off-by: Ilya Leoshkevich --- bsd-user/main.c | 1 + linux

[PATCH v4 02/12] {linux,bsd}-user: Introduce get_task_state()

2024-02-19 Thread Ilya Leoshkevich
A CPU's TaskState is stored in the CPUState's void *opaque field, accessing which is somewhat awkward due to having to use a cast. Introduce a wrapper and use it everywhere. Suggested-by: Alex Bennée Signed-off-by: Ilya Leoshkevich --- bsd-user/bsd-file.h | 2 +- bsd-u

[PATCH v4 00/12] gdbstub: Implement follow-fork-mode child

2024-02-19 Thread Ilya Leoshkevich
past exec() though). Patches 1-10 are preliminary refactorings, patch 11 is the implementation, and patch 12 is the test. [1] https://lists.gnu.org/archive/html/qemu-devel/2024-01/msg06424.html Best regards, Ilya Ilya Leoshkevich (12): gdbstub: Support disablement in a multi-threaded process {

  1   2   3   4   5   6   7   8   9   10   >