Re: [PATCH] tcg: Use uintptr_t in tcg_malloc implementation

2025-07-11 Thread Ilya Leoshkevich
On Thu, 2025-07-10 at 16:50 -0600, Richard Henderson wrote: > Avoid ubsan failure with clang-20, >   tcg.h:715:19: runtime error: applying non-zero offset 64 to null > pointer > by not using pointers. > > Cc: Ilya Leoshkevich > Signed-off-by: Richard Henderson

[PATCH v2] tcg: Remove NULL arithmetic in tcg_malloc()

2025-06-18 Thread Ilya Leoshkevich
l as subtracting NULL from NULL. Signed-off-by: Ilya Leoshkevich --- v1: https://lore.kernel.org/qemu-devel/20250618103555.2020-1-...@linux.ibm.com/ v1 -> v2: Also change the allocation check. include/tcg/tcg.h | 9 - tcg/tcg.c | 3 ++- 2 files changed, 6 insertions(+), 6 deletio

Re: [PATCH] tcg: Remove null pointer arithmetic in tcg_malloc()

2025-06-18 Thread Ilya Leoshkevich
On Wed, 2025-06-18 at 12:35 +0200, Ilya Leoshkevich wrote: > Clang 20.1.6 (Fedora 20.1.6-1.fc42)'s UBSAN complains: > >     qemu/include/tcg/tcg.h:715:19: runtime error: applying non-zero > offset 64 to null pointer > > The code uses NULL as pool's initial start a

[PATCH] tcg: Remove null pointer arithmetic in tcg_malloc()

2025-06-18 Thread Ilya Leoshkevich
he allocation. Unfortunately C prohibits adding non-zero to NULL, even if the result is not dereferenced. Fix by using a dummy pool. Signed-off-by: Ilya Leoshkevich --- tcg/tcg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index d714ae2889c..afcc7ec8849 100

Re: [RFC PATCH] util: split unix socket functions out of qemu-sockets

2025-05-22 Thread Ilya Leoshkevich
-sockets.c @@ -1,5 +1,5 @@ /* - * inet and unix socket functions for qemu + * inet socket functions for qemu * * (c) 2008 Gerd Hoffmann * Should we mention that static linking of this file is not supported? With or without this: Acked-by: Ilya Leoshkevich

Re: [PATCH v2 11/17] gdbstub: Try unlinking the unix socket before binding

2025-05-20 Thread Ilya Leoshkevich
On 2025-05-20 15:50, Michael Tokarev wrote: 07.02.2025 18:31, Alex Bennée wrote: From: Ilya Leoshkevich In case an emulated process execve()s another emulated process, bind() will fail, because the socket already exists. So try deleting it. Use the existing unix_listen() function which does

[PATCH v2] tcg/perf: Placate clang-21's -Wdefault-const-init-field-unsafe

2025-05-20 Thread Ilya Leoshkevich
o make the build work: * -Wno-parentheses-equality * -Wno-unused-value * -Wno-tautological-unsigned-enum-zero-compare * -Wno-tautological-compare Reported-by: Peter Maydell Closes: https://gitlab.com/qemu-project/qemu/-/issues/2970 Reviewed-by: Peter Maydell Signed-off-by: Ilya Leoshkevich ---

[PATCH] tcg/perf: Placate clang-21's -Wdefault-const-init-field-unsafe

2025-05-19 Thread Ilya Leoshkevich
k: * -Wno-parentheses-equality * -Wno-unused-value * -Wno-tautological-unsigned-enum-zero-compare * -Wno-tautological-compare Reported-by: Peter Maydell Closes: https://gitlab.com/qemu-project/qemu/-/issues/2970 Signed-off-by: Ilya Leoshkevich --- tcg/perf.c | 2 +- 1 file changed, 1 insertion(+),

Re: [PATCH 01/17] accel/tcg: Store section pointer in CPUTLBEntryFull

2025-04-15 Thread Ilya Leoshkevich
On 2025-04-15 10:12, Jim Shu wrote: 'CPUTLBEntryFull.xlat_section' stores section_index in last 12 bits to find the correct section when CPU access the IO region over the IOTLB (iotlb_to_section()). However, section_index is only unique inside single AddressSpace. If address space translation is

[PATCH] stub: Remove monitor-fd.c

2025-02-17 Thread Ilya Leoshkevich
: fccb744f41c6 ("gdbstub: Try unlinking the unix socket before binding") Signed-off-by: Ilya Leoshkevich --- stubs/meson.build | 2 +- stubs/monitor-fd.c | 9 - 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 stubs/monitor-fd.c diff --git a/stubs/meson.build b/stubs/m

Re: [PULL v2 42/61] physmem: Add helper function to destroy CPU AddressSpace

2025-02-05 Thread Ilya Leoshkevich
On Mon, 2024-08-19 at 16:22 +0100, Peter Maydell wrote: > On Tue, 23 Jul 2024 at 11:59, Michael S. Tsirkin > wrote: > > > > From: Salil Mehta > > > > Virtual CPU Hot-unplug leads to unrealization of a CPU object. This > > also > > involves destruction of the CPU AddressSpace. Add common functio

Re: [PATCH 1/2] target/s390x: Fix MVC not always invalidating translation blocks

2025-01-28 Thread Ilya Leoshkevich
On Tue, 2025-01-28 at 10:56 +0100, David Hildenbrand wrote: > On 28.01.25 01:12, Ilya Leoshkevich wrote: > > Node.js crashes in qemu-system-s390x with random SIGSEGVs / > > SIGILLs. > > > > The v8 JIT used by Node.js can garbage collect and overwrite unused > >

[PATCH 1/2] target/s390x: Fix MVC not always invalidating translation blocks

2025-01-27 Thread Ilya Leoshkevich
new code. This quickly leads to either a SIGSEGV or a SIGILL in case the old code ends in the middle of a new instruction. Fix by passing the true size. Reported-by: Berthold Gunreben Cc: Sarah Kriesch Cc: qemu-sta...@nongnu.org Closes: https://bugzilla.opensuse.org/show_bug.cgi?id=1235709 Sign

[PATCH 2/2] tests/tcg/s390x: Test modifying code using the MVC instruction

2025-01-27 Thread Ilya Leoshkevich
Add a small test to prevent regressions. Signed-off-by: Ilya Leoshkevich --- tests/tcg/s390x/Makefile.softmmu-target | 1 + tests/tcg/s390x/mvc-smc.c | 82 + 2 files changed, 83 insertions(+) create mode 100644 tests/tcg/s390x/mvc-smc.c diff --git a

[PATCH] hw/s390x/s390-virtio-ccw: Fix a record/replay deadlock

2025-01-24 Thread Ilya Leoshkevich
/replay mutex, like it's done in pause_all_vcpus(). Signed-off-by: Ilya Leoshkevich --- hw/s390x/s390-virtio-ccw.c | 24 +++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 38aeba14eeb..e2386910f78 1

[PATCH] target/s390x: Fix PPNO execution with icount

2025-01-23 Thread Ilya Leoshkevich
lved by calling translator_io_start(). On s390x one uses IF_IO in order to make this call happen automatically. Signed-off-by: Ilya Leoshkevich --- target/s390x/tcg/insn-data.h.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/s390x/tcg/insn-data.h.inc b/target/s390x/tcg/insn-d

[PATCH v6 3/8] user: Introduce user/signal.h

2025-01-16 Thread Ilya Leoshkevich
gdbstub needs target_to_host_signal(), so move its declaration to a public header. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich --- bsd-user/signal-common.h | 1 - bsd-user/signal.c | 1 + include/user/signal.h | 23

[PATCH v6 0/8] gdbstub: Allow late attachment

2025-01-16 Thread Ilya Leoshkevich
ly compile-tested on the BSDs. If this series is accepted, I will rebase the all-stop series on top of it. Best regards, Ilya Ilya Leoshkevich (8): gdbstub: Allow the %d placeholder in the socket path gdbstub: Try unlinking the unix socket before binding user: Introduce user/signal.h

[PATCH v6 7/8] docs/user: Document the %d placeholder and suspend=n QEMU_GDB features

2025-01-16 Thread Ilya Leoshkevich
Reviewed-by: Alex Bennée Signed-off-by: Ilya Leoshkevich --- docs/user/main.rst | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/user/main.rst b/docs/user/main.rst index 80a77f0a0c9..9a1c60448c5 100644 --- a/docs/user/main.rst +++ b/docs/user/main.rst

[PATCH v6 4/8] user: Introduce host_interrupt_signal

2025-01-16 Thread Ilya Leoshkevich
ding disturbing poorly written guests. Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich --- bsd-user/signal.c | 12 include/user/signal.h | 2 ++ linux-user/signal.c | 25 - 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/bsd-user

[PATCH v6 5/8] osdep: Introduce qemu_kill_thread()

2025-01-16 Thread Ilya Leoshkevich
Add a function for sending signals to individual threads. It does not make sense on Windows, so do not provide an implementation, so that if someone uses it by accident, they will get a linker error. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich

[PATCH v6 1/8] gdbstub: Allow the %d placeholder in the socket path

2025-01-16 Thread Ilya Leoshkevich
() the GDB socket. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich --- gdbstub/user.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/gdbstub/user.c b/gdbstub/user.c index c2bdfc3d491..fd29d595f40 100644 --- a/gdbstub/user.c +++ b/gdbstub

[PATCH v6 2/8] gdbstub: Try unlinking the unix socket before binding

2025-01-16 Thread Ilya Leoshkevich
handle this in do_execv(): deleting gdbserver_user_state.socket_path before safe_execve() is not correct, because the latter may fail, and afterwards we may lose control. Signed-off-by: Ilya Leoshkevich --- gdbstub/user.c | 29 +++-- stubs/meson.build | 2 ++ stubs

[PATCH v6 6/8] gdbstub: Allow late attachment

2025-01-16 Thread Ilya Leoshkevich
result of this gdb_handlesig() invocation is handled, as opposed to many other existing call sites. These other call sites probably need to be fixed separately. Signed-off-by: Ilya Leoshkevich --- bsd-user/main.c | 1 - gdbstub/user.c| 115

[PATCH v6 8/8] tests/tcg: Add late gdbstub attach test

2025-01-16 Thread Ilya Leoshkevich
Add a small test to prevent regressions. Make sure that host_interrupt_signal is not visible to the guest. Reviewed-by: Alex Bennée Signed-off-by: Ilya Leoshkevich --- tests/guest-debug/run-test.py | 15 ++-- tests/tcg/multiarch/Makefile.target| 9 - tests/tcg

[PATCH v2 1/2] tcg: Document tb_lookup() and tcg_tb_lookup()

2025-01-16 Thread Ilya Leoshkevich
These similarly named functions serve different purposes; add docstrings to highlight them. Suggested-by: Alex Bennée Signed-off-by: Ilya Leoshkevich --- accel/tcg/cpu-exec.c | 15 ++- include/tcg/tcg.h| 41 + 2 files changed, 55

[PATCH v2 2/2] accel/tcg: Call tcg_tb_insert() for one-insn TBs

2025-01-16 Thread Ilya Leoshkevich
y: Richard Henderson Signed-off-by: Ilya Leoshkevich --- accel/tcg/translate-all.c | 27 ++- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 453eb20ec95..7ec1c53f240 100644 --- a/accel/tcg/transla

Re: [PATCH] accel/tcg: Call tcg_tb_insert() for one-insn TBs

2025-01-16 Thread Ilya Leoshkevich
On Thu, 2025-01-16 at 15:41 +, Peter Maydell wrote: > On Thu, 16 Jan 2025 at 15:40, Alex Bennée > wrote: > > > > Richard Henderson writes: > > > > > On 1/16/25 07:06, Ilya Leoshkevich wrote: > > > > On Thu, 2025-01-16 at 06:54 -0800, Richar

Re: [PATCH] accel/tcg: Call tcg_tb_insert() for one-insn TBs

2025-01-16 Thread Ilya Leoshkevich
On Thu, 2025-01-16 at 06:54 -0800, Richard Henderson wrote: > On 1/15/25 15:20, Ilya Leoshkevich wrote: > > Currently single-insn TBs created from I/O memory are not added to > > region_trees. Therefore, when they generate exceptions, they are > > not > > handled b

Re: [PATCH] accel/tcg: Call tcg_tb_insert() for one-insn TBs

2025-01-16 Thread Ilya Leoshkevich
On Thu, 2025-01-16 at 11:06 +, Peter Maydell wrote: > On Thu, 16 Jan 2025 at 10:52, Alex Bennée > wrote: > > > > Ilya Leoshkevich writes: > > > > > On Wed, 2025-01-15 at 16:08 -0800, Richard Henderson wrote: > > > > On 1/15/25 15:20, Ilya Leosh

Re: [PATCH] accel/tcg: Call tcg_tb_insert() for one-insn TBs

2025-01-16 Thread Ilya Leoshkevich
On Wed, 2025-01-15 at 16:08 -0800, Richard Henderson wrote: > On 1/15/25 15:20, Ilya Leoshkevich wrote: > > Currently single-insn TBs created from I/O memory are not added to > > region_trees. Therefore, when they generate exceptions, they are > > not > > handled b

Re: [PATCH] linux-user: Add syscall dispatch support

2025-01-15 Thread Ilya Leoshkevich
On Wed, 2025-01-15 at 15:36 +0100, Arusekk via wrote: > This commit adds support for the `prctl(PR_SET_SYSCALL_DISPATCH)` > function in the Linux userspace emulator. Typo: this should be PR_SET_SYSCALL_USER_DISPATCH. > It is implemented as a fully host-independent function, by forcing a > SIGSYS

[PATCH] accel/tcg: Call tcg_tb_insert() for one-insn TBs

2025-01-15 Thread Ilya Leoshkevich
uncontrollably. Co-developed-by: Nina Schoetterl-Glausch Signed-off-by: Ilya Leoshkevich --- accel/tcg/translate-all.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 453eb20ec95..602813e 100644

Re: [PATCH v2 10/37] system: propagate Error to gdbserver_start (and other device setups)

2025-01-14 Thread Ilya Leoshkevich
aro.org> > Reviewed-by: Pierrick Bouvier > Signed-off-by: Alex Bennée > Acked-by: Ilya Leoshkevich Apparently the BSD code needs to be adjusted: ../qemu/bsd-user/main.c:631:32: error: too few arguments to function call, expected 2, have 1 631 | gdbserver_start(gdbstub);

Re: [PATCH 3/3] accel/tcg: Implement cpu_exec_reset_hold() on user emulation

2025-01-14 Thread Ilya Leoshkevich
On Fri, 2025-01-10 at 00:43 +0100, Ilya Leoshkevich wrote: > On Thu, 2025-01-02 at 19:25 +0100, Philippe Mathieu-Daudé wrote: > > Commit bb6cf6f0168 ("accel/tcg: Factor tcg_cpu_reset_hold() > > out") wanted to restrict tlb_flush() to system emulation, > > bu

[PATCH 0/3] gdbstub: Protect gdb_handlesig() with EXCLUSIVE_GUARD()

2025-01-13 Thread Ilya Leoshkevich
/6d1171d8debb462f468bb47ff875e0e9db253b4e.ca...@linux.ibm.com/ Ilya Leoshkevich (3): cpu: Set current_cpu early in qemu-user cpu: Introduce EXCLUSIVE_GUARD() gdbstub: Protect gdb_handlesig() with EXCLUSIVE_GUARD() bsd-user/main.c | 2 ++ gdbstub/user.c| 2 ++ include/hw/core/cpu.h | 11 +++ linux

[PATCH 3/3] gdbstub: Protect gdb_handlesig() with EXCLUSIVE_GUARD()

2025-01-13 Thread Ilya Leoshkevich
If multiple threads hit a breakpoint at the same time, GDB gets confused [1]. Prevent this situation by stopping the other threads once a thread hits a breakpoint. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=32023 Signed-off-by: Ilya Leoshkevich --- gdbstub/user.c | 2 ++ 1 file

[PATCH 1/3] cpu: Set current_cpu early in qemu-user

2025-01-13 Thread Ilya Leoshkevich
gdb_handlesig() uses current_cpu. Signed-off-by: Ilya Leoshkevich --- bsd-user/main.c | 2 ++ linux-user/main.c| 2 ++ linux-user/syscall.c | 1 + 3 files changed, 5 insertions(+) diff --git a/bsd-user/main.c b/bsd-user/main.c index 0a5bc578365..aa052e515c9 100644 --- a/bsd-user

[PATCH 2/3] cpu: Introduce EXCLUSIVE_GUARD()

2025-01-13 Thread Ilya Leoshkevich
Add a macro that produces a start_exclusive() / end_exclusive() pair. Useful to guarantee an exit from an exclusive section in large functions. Signed-off-by: Ilya Leoshkevich --- include/hw/core/cpu.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/include/hw/core/cpu.h b

[PATCH v5 2/8] gdbstub: Try unlinking the unix socket before binding

2025-01-10 Thread Ilya Leoshkevich
handle this in do_execv(): deleting gdbserver_user_state.socket_path before safe_execve() is not correct, because the latter may fail, and afterwards we may lose control. Signed-off-by: Ilya Leoshkevich --- gdbstub/user.c | 24 +--- stubs/meson.build | 2 ++ stubs/monitor

[PATCH v5 6/8] gdbstub: Allow late attachment

2025-01-10 Thread Ilya Leoshkevich
result of this gdb_handlesig() invocation is handled, as opposed to many other existing call sites. These other call sites probably need to be fixed separately. Signed-off-by: Ilya Leoshkevich --- bsd-user/main.c | 1 - gdbstub/user.c| 122

[PATCH v5 0/8] gdbstub: Allow late attachment

2025-01-10 Thread Ilya Leoshkevich
pted, I will rebase the all-stop series on top of it. Patch 6 is the implementation, patch 7 is a documentation update, patch 8 is a test. I tested this series on Linux and only compile-tested on the BSDs. Best regards, Ilya Ilya Leoshkevich (8): gdbstub: Allow the %d placeholder in the socket p

[PATCH v5 7/8] docs/user: Document the %d placeholder and suspend=n QEMU_GDB features

2025-01-10 Thread Ilya Leoshkevich
Reviewed-by: Alex Bennée Signed-off-by: Ilya Leoshkevich --- docs/user/main.rst | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/user/main.rst b/docs/user/main.rst index 7a126ee8093..8dcb1d90a8b 100644 --- a/docs/user/main.rst +++ b/docs/user/main.rst

[PATCH v5 8/8] tests/tcg: Add late gdbstub attach test

2025-01-10 Thread Ilya Leoshkevich
Add a small test to prevent regressions. Make sure that host_interrupt_signal is not visible to the guest. Reviewed-by: Alex Bennée Signed-off-by: Ilya Leoshkevich --- tests/guest-debug/run-test.py | 15 ++-- tests/tcg/multiarch/Makefile.target| 9 - tests/tcg

[PATCH v5 5/8] osdep: Introduce qemu_kill_thread()

2025-01-10 Thread Ilya Leoshkevich
Add a function for sending signals to individual threads. It does not make sense on Windows, so do not provide an implementation, so that if someone uses it by accident, they will get a linker error. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich

[PATCH v5 1/8] gdbstub: Allow the %d placeholder in the socket path

2025-01-10 Thread Ilya Leoshkevich
() the GDB socket. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich --- gdbstub/user.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/gdbstub/user.c b/gdbstub/user.c index 0b4bfa9c488..ef52f249ce9 100644 --- a/gdbstub/user.c +++ b/gdbstub

[PATCH v5 4/8] user: Introduce host_interrupt_signal

2025-01-10 Thread Ilya Leoshkevich
ding disturbing poorly written guests. Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich --- bsd-user/signal.c | 12 include/user/signal.h | 2 ++ linux-user/signal.c | 25 - 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/bsd-user

[PATCH v5 3/8] user: Introduce user/signal.h

2025-01-10 Thread Ilya Leoshkevich
gdbstub needs target_to_host_signal(), so move its declaration to a public header. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich --- bsd-user/signal-common.h | 1 - bsd-user/signal.c | 1 + include/user/signal.h | 23

Re: [PATCH v4 1/9] qapi: Make qapi_bool_parse() gracefully handle NULL value

2025-01-10 Thread Ilya Leoshkevich
On Fri, 2025-01-10 at 11:33 +, Daniel P. Berrangé wrote: > On Wed, Jan 08, 2025 at 09:04:56PM +0100, Ilya Leoshkevich wrote: > > Use g_strcmp0(), so that NULL is considered an invalid parameter > > value. > > Why are we calling qapi_bool_parse with a NULL value in the

Re: [PATCH] gdbstub/user-target: fix gdbserver int format (%d -> %x)

2025-01-09 Thread Ilya Leoshkevich
On Fri, 2024-12-27 at 18:04 +0100, Dominik 'Disconnect3d' Czarnota wrote: > From: disconnect3d > > This commit fixes an incorrect format string for formatting integers > provided to GDB when debugging a target run in QEMU user mode. > > The correct format is hexadecimal for both success and errn

Re: [PATCH 3/3] accel/tcg: Implement cpu_exec_reset_hold() on user emulation

2025-01-09 Thread Ilya Leoshkevich
On Thu, 2025-01-02 at 19:25 +0100, Philippe Mathieu-Daudé wrote: > Commit bb6cf6f0168 ("accel/tcg: Factor tcg_cpu_reset_hold() > out") wanted to restrict tlb_flush() to system emulation, > but inadvertently also restricted tcg_flush_jmp_cache(), > which was before called on user emulation via: > >

Re: [PATCH 2/3] accel/tcg: Factor out common tcg_exec_reset() helper

2025-01-09 Thread Ilya Leoshkevich
e Mathieu-Daudé > --- >  accel/tcg/internal-common.h | 1 + >  accel/tcg/cpu-exec-common.c | 6 ++ >  accel/tcg/tcg-accel-ops.c   | 4 ++-- >  3 files changed, 9 insertions(+), 2 deletions(-) Reviewed-by: Ilya Leoshkevich

Re: [PATCH 1/3] linux-user: Only include 'exec/tb-flush.h' header when necessary

2025-01-09 Thread Ilya Leoshkevich
gned-off-by: Philippe Mathieu-Daudé > --- >  linux-user/user-internals.h | 1 - >  linux-user/mmap.c   | 1 + >  linux-user/syscall.c    | 1 + >  3 files changed, 2 insertions(+), 1 deletion(-) Reviewed-by: Ilya Leoshkevich

[PATCH v4 7/9] gdbstub: Allow late attachment

2025-01-08 Thread Ilya Leoshkevich
result of this gdb_handlesig() invocation is handled, as opposed to many other existing call sites. These other call sites probably need to be fixed separately. Signed-off-by: Ilya Leoshkevich --- bsd-user/main.c | 1 - gdbstub/user.c| 118

[PATCH v4 9/9] tests/tcg: Add late gdbstub attach test

2025-01-08 Thread Ilya Leoshkevich
Add a small test to prevent regressions. Make sure that host_interrupt_signal is not visible to the guest. Reviewed-by: Alex Bennée Signed-off-by: Ilya Leoshkevich --- tests/guest-debug/run-test.py | 15 ++-- tests/tcg/multiarch/Makefile.target| 9 - tests/tcg

[PATCH v4 4/9] user: Introduce user/signal.h

2025-01-08 Thread Ilya Leoshkevich
gdbstub needs target_to_host_signal(), so move its declaration to a public header. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich --- bsd-user/signal-common.h | 1 - bsd-user/signal.c | 1 + include/user/signal.h | 23

[PATCH v4 3/9] gdbstub: Try unlinking the unix socket before binding

2025-01-08 Thread Ilya Leoshkevich
before safe_execve() is not correct, because the latter may fail, and afterwards we may lose control. Signed-off-by: Ilya Leoshkevich --- gdbstub/user.c | 24 +--- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/gdbstub/user.c b/gdbstub/user.c index ef52f249ce9

[PATCH v4 6/9] osdep: Introduce qemu_kill_thread()

2025-01-08 Thread Ilya Leoshkevich
Add a function for sending signals to individual threads. It does not make sense on Windows, so do not provide an implementation, so that if someone uses it by accident, they will get a linker error. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich

[PATCH v4 2/9] gdbstub: Allow the %d placeholder in the socket path

2025-01-08 Thread Ilya Leoshkevich
() the GDB socket. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich --- gdbstub/user.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/gdbstub/user.c b/gdbstub/user.c index 0b4bfa9c488..ef52f249ce9 100644 --- a/gdbstub/user.c +++ b/gdbstub

[PATCH v4 0/9] gdbstub: Allow late attachment

2025-01-08 Thread Ilya Leoshkevich
e safe_syscall infrastructure, so the changes are fairly simple. If this series is accepted, I will rebase the all-stop series on top of it. Patch 6 is the implementation, patch 7 is a documentation update, patch 8 is a test. I tested this series on Linux and only compile-tested on the BSDs. Best re

[PATCH v4 8/9] docs/user: Document the %d placeholder and suspend=n QEMU_GDB features

2025-01-08 Thread Ilya Leoshkevich
Reviewed-by: Alex Bennée Signed-off-by: Ilya Leoshkevich --- docs/user/main.rst | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/user/main.rst b/docs/user/main.rst index 7a126ee8093..8dcb1d90a8b 100644 --- a/docs/user/main.rst +++ b/docs/user/main.rst

[PATCH v4 1/9] qapi: Make qapi_bool_parse() gracefully handle NULL value

2025-01-08 Thread Ilya Leoshkevich
Use g_strcmp0(), so that NULL is considered an invalid parameter value. Suggested-by: Alex Bennée Signed-off-by: Ilya Leoshkevich --- qapi/qapi-util.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c index 65a7d184372

[PATCH v4 5/9] user: Introduce host_interrupt_signal

2025-01-08 Thread Ilya Leoshkevich
ding disturbing poorly written guests. Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich --- bsd-user/signal.c | 12 include/user/signal.h | 2 ++ linux-user/signal.c | 25 - 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/bsd-user

Re: [RFC PATCH] gdbstub: propagate Error to gdbserver_start (and other device setups)

2025-01-08 Thread Ilya Leoshkevich
/* failure will exit via error_fatal */ everywhere is not optimal. > Signed-off-by: Alex Bennée > Cc: Ilya Leoshkevich > --- >  include/exec/gdbstub.h |  8 +++- >  gdbstub/system.c   | 22 +- >  gdbstub/user.c | 20 + >  linux-user/main.c

Re: [PATCH v3 6/8] gdbstub: Allow late attachment

2025-01-08 Thread Ilya Leoshkevich
On Wed, 2025-01-08 at 17:20 +, Alex Bennée wrote: > Ilya Leoshkevich writes: > > > Allow debugging individual processes in multi-process applications > > by > > starting them with export QEMU_GDB=/tmp/qemu-%d.sock,suspend=n. > > Currently one would have to att

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

2025-01-08 Thread Ilya Leoshkevich
On Wed, 2025-01-08 at 15:56 +, Alex Bennée wrote: > Ilya Leoshkevich writes: > > > 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 >

Re: [PATCH v3 2/8] gdbstub: Try unlinking the unix socket before binding

2025-01-08 Thread Ilya Leoshkevich
On Wed, 2025-01-08 at 16:10 +, Alex Bennée wrote: > Ilya Leoshkevich writes: > > > In case an emulated process execve()s another emulated process, > > bind() > > will fail, because the socket already exists. So try deleting it. > > > > Note that it is not

Re: [PATCH 0/2] include: Two cleanups around missing 'qemu/atomic.h'

2024-12-17 Thread Ilya Leoshkevich
gt; > Regards, > > Phil. > > Philippe Mathieu-Daudé (2): >   exec/translation-block: Include missing 'qemu/atomic.h' header >   qemu/coroutine: Include missing 'qemu/atomic.h' header > >  include/exec/translation-block.h | 1 + >  include/qemu/coroutine.h     | 1 + >  2 files changed, 2 insertions(+) Acked-by: Ilya Leoshkevich

[PATCH] tests/tcg/s390x: Use the SLOF libc headers for the multiarch tests

2024-12-16 Thread Ilya Leoshkevich
is because Fedora does not have a cross-libc. Since console.c already uses the SLOF libc implementation, add the respective headers to the include path. Signed-off-by: Ilya Leoshkevich --- tests/tcg/s390x/Makefile.softmmu-target | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git

[PATCH v3 5/8] osdep: Introduce qemu_kill_thread()

2024-12-16 Thread Ilya Leoshkevich
Add a function for sending signals to individual threads. It does not make sense on Windows, so do not provide an implementation, so that if someone uses it by accident, they will get a linker error. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich

[PATCH v3 1/8] gdbstub: Allow the %d placeholder in the socket path

2024-12-16 Thread Ilya Leoshkevich
() the GDB socket. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich --- gdbstub/user.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/gdbstub/user.c b/gdbstub/user.c index 0b4bfa9c488..ef52f249ce9 100644 --- a/gdbstub/user.c +++ b/gdbstub

[PATCH v3 3/8] user: Introduce user/signal.h

2024-12-16 Thread Ilya Leoshkevich
gdbstub needs target_to_host_signal(), so move its declaration to a public header. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich --- bsd-user/signal-common.h | 1 - bsd-user/signal.c | 1 + include/user/signal.h | 23

[PATCH v3 0/8] gdbstub: Allow late attachment

2024-12-16 Thread Ilya Leoshkevich
accepted, I will rebase the all-stop series on top of it. Patch 6 is the implementation, patch 7 is a documentation update, patch 8 is a test. I tested this series on Linux and only compile-tested on the BSDs. Best regards, Ilya Ilya Leoshkevich (8): gdbstub: Allow the %d placeholder in the socke

[PATCH v3 7/8] docs/user: Document the %d placeholder and suspend=n QEMU_GDB features

2024-12-16 Thread Ilya Leoshkevich
Signed-off-by: Ilya Leoshkevich --- docs/user/main.rst | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/user/main.rst b/docs/user/main.rst index 7a126ee8093..8dcb1d90a8b 100644 --- a/docs/user/main.rst +++ b/docs/user/main.rst @@ -50,7 +50,7 @@ Command

[PATCH v3 4/8] user: Introduce host_interrupt_signal

2024-12-16 Thread Ilya Leoshkevich
ding disturbing poorly written guests. Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich --- bsd-user/signal.c | 12 include/user/signal.h | 2 ++ linux-user/signal.c | 25 - 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/bsd-user

[PATCH v3 6/8] gdbstub: Allow late attachment

2024-12-16 Thread Ilya Leoshkevich
result of this gdb_handlesig() invocation is handled, as opposed to many other existing call sites. These other call sites probably need to be fixed separately. Signed-off-by: Ilya Leoshkevich --- bsd-user/main.c | 1 - gdbstub/user.c| 120

[PATCH v3 8/8] tests/tcg: Add late gdbstub attach test

2024-12-16 Thread Ilya Leoshkevich
Add a small test to prevent regressions. Make sure that host_interrupt_signal is not visible to the guest. Signed-off-by: Ilya Leoshkevich --- tests/guest-debug/run-test.py | 15 ++-- tests/tcg/multiarch/Makefile.target| 9 - tests/tcg/multiarch/gdbstub/late

[PATCH v3 2/8] gdbstub: Try unlinking the unix socket before binding

2024-12-16 Thread Ilya Leoshkevich
fail, and afterwards we may lose control. Signed-off-by: Ilya Leoshkevich --- gdbstub/user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gdbstub/user.c b/gdbstub/user.c index ef52f249ce9..c900d0a52fe 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -337,6 +337,7 @@ static int

Re: [PATCH] tests/tcg: Do not use inttypes.h in multiarch/system/memory.c

2024-12-16 Thread Ilya Leoshkevich
On Mon, 2024-11-04 at 11:34 +, Richard Henderson wrote: > On 10/29/24 23:29, Ilya Leoshkevich wrote: > > On Thu, 2024-10-10 at 11:20 +0200, Paolo Bonzini wrote: > > > On 10/10/24 10:58, Ilya Leoshkevich wrote: > > > > make check-tcg fails on Fedora with the f

Re: [PATCH 3/6] linux-user: Adjust brk for load_bias [regression]

2024-11-26 Thread Ilya Leoshkevich
cutables are usually linked at offset 0 and are >     relocated somewhere during load.  The hiaddr needs to >     be adjusted to keep the brk next to the executable. >     >     Cc: qemu-sta...@nongnu.org >     Fixes: 1f356e8c013 ("linux-user: Adjust initial brk when > interpr

[PATCH v2] linux-user: Fix strace output for s390x mmap()

2024-11-20 Thread Ilya Leoshkevich
...@nongnu.org Fixes: d971040c2d16 ("linux-user: Fix strace output for old_mmap") Suggested-by: Richard Henderson Signed-off-by: Ilya Leoshkevich --- v1: https://lore.kernel.org/qemu-devel/20241119211138.148806-1-...@linux.ibm.com/ v1 -> v2: Share the detection logic between syscall.c

[PATCH] linux-user: Fix strace output for s390x mmap()

2024-11-19 Thread Ilya Leoshkevich
("linux-user: Fix strace output for old_mmap") 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 b70eadc19ef..50f41e746ec 100644 --- a/linux-user/strace.c +++ b/linux-use

Ping: [PATCH v2] tests/tcg: Stop using exit() in the gdbstub testcases

2024-11-12 Thread Ilya Leoshkevich
On Tue, 2024-10-22 at 13:37 +0200, Ilya Leoshkevich wrote: > GDB 15 does not like exit() anymore: > >     (gdb) python exit(0) >     Python Exception : 0 >     Error occurred in Python: 0 > > Use the GDB's own exit command, like it's already done in a couple &g

[PATCH v2 1/1] tests/tcg: Test that sigreturn() does not corrupt the signal mask

2024-11-08 Thread Ilya Leoshkevich
Add a small test to prevent regressions. Signed-off-by: Ilya Leoshkevich --- tests/tcg/multiarch/Makefile.target | 3 ++ tests/tcg/multiarch/sigreturn-sigmask.c | 51 + 2 files changed, 54 insertions(+) create mode 100644 tests/tcg/multiarch/sigreturn-sigmask.c

[PATCH v2 0/1] tests/tcg: Test that sigreturn() does not corrupt the signal mask

2024-11-08 Thread Ilya Leoshkevich
ssing, so I'm resending the test with this issue fixed. Best regards, Ilya Ilya Leoshkevich (1): tests/tcg: Test that sigreturn() does not corrupt the signal mask tests/tcg/multiarch/Makefile.target | 3 ++ tests/tcg/multiarch/sigreturn-sigmask.c | 51 + 2

[PATCH v2 8/8] tests/tcg: Add late gdbstub attach test

2024-11-06 Thread Ilya Leoshkevich
Add a small test to prevent regressions. Make sure that host_interrupt_signal is not visible to the guest. Signed-off-by: Ilya Leoshkevich --- tests/guest-debug/run-test.py | 15 ++-- tests/tcg/multiarch/Makefile.target| 9 - tests/tcg/multiarch/gdbstub/late

[PATCH v2 3/8] user: Introduce user/signal.h

2024-11-06 Thread Ilya Leoshkevich
gdbstub needs target_to_host_signal(), so move its declaration to a public header. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich --- bsd-user/signal-common.h | 1 - bsd-user/signal.c | 1 + include/user/signal.h | 23

[PATCH v2 5/8] osdep: Introduce qemu_kill_thread()

2024-11-06 Thread Ilya Leoshkevich
Add a function for sending signals to individual threads. It does not make sense on Windows, so do not provide an implementation, so that if someone uses it by accident, they will get a linker error. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich

[PATCH v2 6/8] gdbstub: Allow late attachment

2024-11-06 Thread Ilya Leoshkevich
result of this gdb_handlesig() invocation is handled, as opposed to many other existing call sites. These other call sites probably need to be fixed separately. Signed-off-by: Ilya Leoshkevich --- bsd-user/main.c | 1 - gdbstub/user.c| 120

[PATCH v2 7/8] docs/user: Document the %d placeholder and suspend=n QEMU_GDB features

2024-11-06 Thread Ilya Leoshkevich
Signed-off-by: Ilya Leoshkevich --- docs/user/main.rst | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/user/main.rst b/docs/user/main.rst index 7a126ee8093..8dcb1d90a8b 100644 --- a/docs/user/main.rst +++ b/docs/user/main.rst @@ -50,7 +50,7 @@ Command

[PATCH v2 1/8] gdbstub: Allow the %d placeholder in the socket path

2024-11-06 Thread Ilya Leoshkevich
() the GDB socket. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich --- gdbstub/user.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/gdbstub/user.c b/gdbstub/user.c index 0b4bfa9c488..ef52f249ce9 100644 --- a/gdbstub/user.c +++ b/gdbstub

[PATCH v2 2/8] gdbstub: Try unlinking the unix socket before binding

2024-11-06 Thread Ilya Leoshkevich
fail, and afterwards we may lose control. Signed-off-by: Ilya Leoshkevich --- gdbstub/user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gdbstub/user.c b/gdbstub/user.c index ef52f249ce9..c900d0a52fe 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -337,6 +337,7 @@ static int

[PATCH v2 0/8] gdbstub: Allow late attachment

2024-11-06 Thread Ilya Leoshkevich
documentation update, patch 8 is a test. I tested this series on Linux and only compile-tested on the BSDs. Best regards, Ilya [1] https://lore.kernel.org/qemu-devel/94ebebf2-e775-4fd2-8fcf-921610261...@linaro.org/ Ilya Leoshkevich (8): gdbstub: Allow the %d placeholder in the socket path

[PATCH v2 4/8] user: Introduce host_interrupt_signal

2024-11-06 Thread Ilya Leoshkevich
ding disturbing poorly written guests. Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich --- bsd-user/signal.c | 12 include/user/signal.h | 2 ++ linux-user/signal.c | 25 - 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/bsd-user

Re: [PATCH 4/8] user: Introduce host_interrupt_signal

2024-11-05 Thread Ilya Leoshkevich
On Tue, 2024-11-05 at 22:30 +, Richard Henderson wrote: > On 11/5/24 15:50, Ilya Leoshkevich wrote: > > On Tue, 2024-11-05 at 08:39 -0700, Warner Losh wrote: > > > On Thu, Oct 24, 2024 at 2:00 PM Ilya Leoshkevich > > > > > > wrote: > > > &g

Re: [PULL 02/67] target/ppc: Make divd[u] handler method decodetree compatible

2024-11-05 Thread Ilya Leoshkevich
On Tue, 2024-11-05 at 18:33 +0300, Michael Tokarev wrote: > 04.11.2024 03:17, Nicholas Piggin wrote: > > From: Ilya Leoshkevich > > > > This is like commit 86e6202a57b1 ("target/ppc: Make divw[u] handler > > method decodetree compatible."), but for gen_

Re: [PATCH] linux-user: Fix setreuid and setregid to use direct syscalls

2024-11-05 Thread Ilya Leoshkevich
ons. > > Add and use the corresponding wrappers for setreuid and setregid > which > were missed in that commit. > > This fixes the build of the debian package of the uid_wrapper library > (https://cwrap.org/uid_wrapper.html) when running linux-user. > > Signed-off-

Re: [PATCH 4/8] user: Introduce host_interrupt_signal

2024-11-05 Thread Ilya Leoshkevich
On Tue, 2024-11-05 at 08:39 -0700, Warner Losh wrote: > On Thu, Oct 24, 2024 at 2:00 PM Ilya Leoshkevich > wrote: > > Attaching to the gdbstub of a running process requires stopping its > > threads. For threads that run on a CPU, cpu_exit() is enough, but > > the > >

Re: [PATCH] tests/tcg: Do not use inttypes.h in multiarch/system/memory.c

2024-10-29 Thread Ilya Leoshkevich
On Thu, 2024-10-10 at 11:20 +0200, Paolo Bonzini wrote: > On 10/10/24 10:58, Ilya Leoshkevich wrote: > > make check-tcg fails on Fedora with the following error message: > > > > alpha-linux-gnu-gcc [...] > > qemu/tests/tcg/multiarch/system/memory.c -o memory [.

[PATCH v3 1/2] linux-user: Allow custom rt signal mappings

2024-10-29 Thread Ilya Leoshkevich
tsig hsig count[,...]" syntax. Target realtime signals [tsig,tsig+count) are mapped to host realtime signals [hsig,hsig+count). Care is taken to avoid double and out-of-range mappings. Signed-off-by: Ilya Leoshkevich --- linux-user/main.c | 12 +++- linux-user/signal-common.h

  1   2   3   4   5   6   7   8   9   10   >