Re: [PATCH] tests/tcg/x86_64: add cross-modifying code test

2022-09-05 Thread Ilya Leoshkevich
On Sat, 2022-09-03 at 10:13 +0100, Alex Bennée wrote: > > Ilya Leoshkevich writes: > > > commit f025692c992c ("accel/tcg: Clear PAGE_WRITE before > > translation") > > fixed cross-modifying code handling, but did not add a test. The > > changed co

[PATCH v2] tests/tcg/x86_64: add cross-modifying code test

2022-09-05 Thread Ilya Leoshkevich
make sure there are no regressions. [1] https://lists.gnu.org/archive/html/qemu-devel/2022-09/msg00034.html Signed-off-by: Ilya Leoshkevich --- v1: https://lists.gnu.org/archive/html/qemu-devel/2022-09/msg00455.html v1 -> v2: Fix tweaking the flags (Alex). Keep the custom build rule for

[PATCH v2] linux-user: Implement stracing madvise()

2022-09-05 Thread Ilya Leoshkevich
The default implementation has several problems: the first argument is not displayed as a pointer, making it harder to grep; the third argument is not symbolized; and there are several extra unused arguments. Signed-off-by: Ilya Leoshkevich --- v1: https://lists.gnu.org/archive/html/qemu-devel

[PATCH v3 2/5] linux-user: Fix madvise(MADV_DONTNEED) on alpha

2022-09-05 Thread Ilya Leoshkevich
MADV_DONTNEED has a different value on alpha, compared to all the other architectures. Fix by using TARGET_MADV_DONTNEED instead of MADV_DONTNEED. Fixes: 892a4f6a750a ("linux-user: Add partial support for MADV_DONTNEED") Signed-off-by: Ilya Leoshkevich --- linux-user/mmap.c | 3 +

[PATCH v3 3/5] linux-user: Implement stracing madvise()

2022-09-05 Thread Ilya Leoshkevich
The default implementation has several problems: the first argument is not displayed as a pointer, making it harder to grep; the third argument is not symbolized; and there are several extra unused arguments. Signed-off-by: Ilya Leoshkevich --- linux-user/strace.c| 41

[PATCH v3 1/5] linux-user: Provide MADV_* definitions

2022-09-05 Thread Ilya Leoshkevich
Provide MADV_* definitions using target_mman.h header, similar to what kernel does. Most architectures use the same values, with the exception of alpha and hppa. Signed-off-by: Ilya Leoshkevich --- linux-user/aarch64/target_mman.h | 1 + linux-user/alpha/target_mman.h | 8 +++ linux

[PATCH v3 0/5] linux-user: Passthrough MADV_DONTNEED for certain file mappings

2022-09-05 Thread Ilya Leoshkevich
* constants for all architectures. Patch 2 fixes the alpha bug. Patch 3 adds madvise() support to strace. Patch 4 adds MADV_DONTNEED support for file mappings. Patch 5 adds a test. Best regards, Ilya [1] https://lists.gnu.org/archive/html/qemu-devel/2022-09/msg00710.html Ilya Leoshkevich (5

[PATCH v3 4/5] linux-user: Passthrough MADV_DONTNEED for certain file mappings

2022-09-05 Thread Ilya Leoshkevich
ASSTHROUGH, and then allow madvise() passthrough for these pages. Drop the explicit PAGE_ANON check, since anonymous mappings are expected to have PAGE_PASSTHROUGH anyway. Add PAGE_PASSTHROUGH to PAGE_STICKY in order to keep it on mprotect(). Signed-off-by: Ilya Leoshkevich Message-Id: <202207251

Re: [PATCH v2] linux-user: Implement stracing madvise()

2022-09-05 Thread Ilya Leoshkevich
On Mon, 2022-09-05 at 23:40 +0200, Ilya Leoshkevich wrote: > The default implementation has several problems: the first argument > is > not displayed as a pointer, making it harder to grep; the third > argument is not symbolized; and there are several extra unused > arguments.

[PATCH v3 5/5] tests/tcg/linux-test: Add linux-madvise test

2022-09-05 Thread Ilya Leoshkevich
Add a test that checks madvise(MADV_DONTNEED) behavior with anonymous and file mappings in order to prevent regressions. Signed-off-by: Ilya Leoshkevich --- tests/tcg/multiarch/linux/linux-madvise.c | 70 +++ 1 file changed, 70 insertions(+) create mode 100644 tests/tcg

Re: [PATCH v6 17/21] accel/tcg: Add fast path for translator_ld*

2022-08-22 Thread Ilya Leoshkevich
l(CPUArchState *env, DisasContextBase *db, > abi_ptr pc) > +{ > +uint32_t ret, plug; > +void *p = translator_access(env, db, pc, sizeof(ret)); > + > +if (p) { > + plugin_insn_append(pc, p, sizeof(ret)); > +return ldl_p(p); > +} > +ret = cpu_ldl_code(env, pc); > +plug = tswap32(ret); > +plugin_insn_append(pc, , sizeof(ret)); > +return ret; > +} > + > +uint64_t translator_ldq(CPUArchState *env, DisasContextBase *db, > abi_ptr pc) > +{ > +uint64_t ret, plug; > +void *p = translator_access(env, db, pc, sizeof(ret)); > + > +if (p) { > +plugin_insn_append(pc, p, sizeof(ret)); > +return ldq_p(p); > +} > +ret = cpu_ldq_code(env, pc); > +plug = tswap64(ret); > +plugin_insn_append(pc, , sizeof(ret)); > +return ret; > +} Hi, I think you need the following fixup here: --- a/tests/tcg/multiarch/noexec.c.inc +++ b/tests/tcg/multiarch/noexec.c.inc @@ -1,8 +1,5 @@ /* * Common code for arch-specific MMU_INST_FETCH fault testing. - * - * Declare struct arch_noexec_test before including this file and define - * arch_check_mcontext() after that. */ #define _GNU_SOURCE @@ -13,6 +10,7 @@ #include #include #include +#include #include #include After the simplifications the comment is no longer true or useful; unistd.h is needed for getpagesize(). With that: Acked-by: Ilya Leoshkevich Tested-by: Ilya Leoshkevich for the series. Best regards, Ilya

Re: [PATCH 1/1] tcg: add perfmap and jitdump

2022-10-17 Thread Ilya Leoshkevich
On Fri, 2022-10-14 at 07:35 +1100, Richard Henderson wrote: > On 10/12/22 22:18, Ilya Leoshkevich wrote: > > Add ability to dump /tmp/perf-.map and jit-.dump. > > The first one allows the perf tool to map samples to each > > individual > > translation block. The

Re: [PATCH] MAINTAINERS: target/s390x/: add Ilya as reviewer

2022-10-19 Thread Ilya Leoshkevich
ERS > index e3d5b7e09c46..ae5e8c8ecbb6 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -305,6 +305,7 @@ F: target/rx/ >  S390 TCG CPUs >  M: Richard Henderson >  M: David Hildenbrand > +R: Ilya Leoshkevich >  S: Maintained >  F: target/s390x/ >  F: target/s390x/tcg Acked-by: Ilya Leoshkevich Thanks!

Re: [PATCH v3 23/26] target/s390x: don't use ld_code2 to probe next pc

2022-10-21 Thread Ilya Leoshkevich
gt;   > return pc + get_ilen((insn >> 8) & 0xff); >  } Acked-by: Ilya Leoshkevich

Re: [PATCH v3 24/26] target/s390x: don't probe next pc for EXecuted insns

2022-10-21 Thread Ilya Leoshkevich
t;base.pc_next)) || > -    dc->ex_value) { > +    if (dc->ex_value || > +    !is_same_page(dcbase, dc->base.pc_next) || > +    !is_same_page(dcbase, get_next_pc(env, dc, dc- > >base.pc_next))) { > dc->base.is_jmp = DISAS_TOO_MANY; > } > } Acked-by: Ilya Leoshkevich

Re: [PATCH v3 25/26] target/s390x: fake instruction loading when handling 'ex'

2022-10-21 Thread Ilya Leoshkevich
with translator so plugins work */ > +    for (i = 0; i < ilen; i++) { > +    uint8_t byte = extract64(insn, 56 - (i * 8), 8); > +    translator_fake_ldb(byte, pc + i); > +    } > op = insn >> 56; > } else { > insn = ld_code2(env, s, pc); Acked-by: Ilya Leoshkevich

Re: [PATCH 1/9] target/s390x: Use a single return for helper_divs32/u32

2022-10-21 Thread Ilya Leoshkevich
gt;  target/s390x/tcg/translate.c  | 10 ++ >  3 files changed, 20 insertions(+), 18 deletions(-) Acked-by: Ilya Leoshkevich

Re: [PATCH 2/9] target/s390x: Use a single return for helper_divs64/u64

2022-10-25 Thread Ilya Leoshkevich
ard Henderson Acked-by: Ilya Leoshkevich

Re: [PATCH 3/9] target/s390x: Use Int128 for return from CLST

2022-10-25 Thread Ilya Leoshkevich
s(+), 10 deletions(-) Acked-by: Ilya Leoshkevich I wanted to make sure the ordering within a pair was right and wrote a small test. Feel free to add it to the series: From: Ilya Leoshkevich Subject: [PATCH] tests/tcg/s390x: Add clst.c Add a basic test to prevent regressions. Signed-off-by

[PATCH 1/1] tests/tcg/s390x: Add clst.c

2022-10-25 Thread Ilya Leoshkevich
Add a basic test to prevent regressions. Signed-off-by: Ilya Leoshkevich --- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/clst.c | 82 + 2 files changed, 83 insertions(+) create mode 100644 tests/tcg/s390x/clst.c diff --git a/tests/tcg/s390x

[PATCH 0/1] Re: target/s390x: Use Int128 for return from CLST

2022-10-25 Thread Ilya Leoshkevich
I wanted to make sure that the pair elements were not mixed up and wrote a small test. Feel free to add it to the series. Ilya Leoshkevich (1): tests/tcg/s390x: Add clst.c tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/clst.c | 82 + 2 files

Re: [PULL 15/20] include/hw/core: Create struct CPUJumpCache

2022-10-27 Thread Ilya Leoshkevich
On Thu, Oct 27, 2022 at 04:18:56PM +0200, Ilya Leoshkevich wrote: > On Tue, Oct 04, 2022 at 12:52:36PM -0700, Richard Henderson wrote: > > Wrap the bare TranslationBlock pointer into a structure. > > > > Reviewed-by: Alex Bennée > > Reviewed-by: Philippe Mathieu-Daudé

Re: [PATCH 6/9] target/s390x: Copy wout_x1 to wout_x1_P

2022-10-27 Thread Ilya Leoshkevich
chard Henderson > --- > target/s390x/tcg/translate.c | 8 > target/s390x/tcg/insn-data.def | 12 ++-- > 2 files changed, 14 insertions(+), 6 deletions(-) Acked-by: Ilya Leoshkevich

Re: [PATCH 8/9] target/s390x: Use Int128 for returning float128

2022-10-27 Thread Ilya Leoshkevich
On Fri, Oct 21, 2022 at 05:30:05PM +1000, Richard Henderson wrote: > Signed-off-by: Richard Henderson > --- > target/s390x/helper.h | 22 +++ > target/s390x/tcg/fpu_helper.c | 29 ++-- > target/s390x/tcg/translate.c | 49 +++---

Re: [PULL 15/20] include/hw/core: Create struct CPUJumpCache

2022-10-27 Thread Ilya Leoshkevich
On Tue, Oct 04, 2022 at 12:52:36PM -0700, Richard Henderson wrote: > Wrap the bare TranslationBlock pointer into a structure. > > Reviewed-by: Alex Bennée > Reviewed-by: Philippe Mathieu-Daudé > Signed-off-by: Richard Henderson > --- > accel/tcg/tb-hash.h | 1 + >

Re: [PATCH 7/9] tests/tcg/s390x: Add long-double.c

2022-10-27 Thread Ilya Leoshkevich
sts/tcg/s390x/long-double.c It might be better to do this in asm in order to be sure that a compiler doesn't perform any magic. But at least as of today gcc generates all the "interesting" instructions from this code. Acked-by: Ilya Leoshkevich

[PATCH] tests/vm: use -o IdentitiesOnly=yes for ssh

2022-10-27 Thread Ilya Leoshkevich
the ssh client consider only the keys specified on the command line. Signed-off-by: Ilya Leoshkevich --- tests/vm/basevm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 4fd9af10b7f..2276364c42f 100644 --- a/tests/vm/basevm.py

[PATCH 0/2] accel/tcg: Fix concurrent pthread_create() and munmap()

2022-10-28 Thread Ilya Leoshkevich
] https://lists.gnu.org/archive/html/qemu-devel/2022-10/msg05181.html Best regards, Ilya Ilya Leoshkevich (2): accel/tcg: Fix concurrent pthread_create() and munmap() tests/tcg/multiarch: Add munmap-pthread.c accel/tcg/tb-maint.c | 5 ++ tests/tcg/multiarch/Makefile.target

[PATCH 2/2] tests/tcg/multiarch: Add munmap-pthread.c

2022-10-28 Thread Ilya Leoshkevich
Add a test to detect races between munmap() and creating new threads. Signed-off-by: Ilya Leoshkevich --- tests/tcg/multiarch/Makefile.target | 3 ++ tests/tcg/multiarch/munmap-pthread.c | 71 2 files changed, 74 insertions(+) create mode 100644 tests/tcg

[PATCH 1/2] accel/tcg: Fix concurrent pthread_create() and munmap()

2022-10-28 Thread Ilya Leoshkevich
/core: Create struct CPUJumpCache") Signed-off-by: Ilya Leoshkevich --- accel/tcg/tb-maint.c | 5 + 1 file changed, 5 insertions(+) diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index c8e921089df..2a063f91aa6 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -241

Re: [PATCH 4/9] target/s390x: Use Int128 for return from CKSM

2022-10-27 Thread Ilya Leoshkevich
eletions(-) Acked-by: Ilya Leoshkevich

Re: [PATCH 5/9] target/s390x: Use Int128 for return from TRE

2022-10-27 Thread Ilya Leoshkevich
eletions(-) Acked-by: Ilya Leoshkevich

Re: [PATCH v2 19/36] tcg: Use TCG_CALL_ARG_EVEN for TCI special case

2022-10-25 Thread Ilya Leoshkevich
On Fri, Oct 21, 2022 at 05:15:32PM +1000, Richard Henderson wrote: > Change 32-bit tci TCG_TARGET_CALL_ARG_I32 to TCG_CALL_ARG_EVEN, to > force 32-bit values to be aligned to 64-bit. With a small reorg > to the argument processing loop, this neatly replaces an ifdef for > CONFIG_TCG_INTERPRETER.

Re: [PATCH] accel/tcg: Complete cpu initialization before registration

2022-10-31 Thread Ilya Leoshkevich
dex has been assigned. > > Fixes a problem with cross-cpu jump cache flushing, when the > jump cache has not yet been allocated. > > Fixes: a976a99a2975 ("include/hw/core: Create struct CPUJumpCache") > Reported-by: Ilya Leoshkevich > Signed-off-by: Richard Henders

[PATCH] linux-user/host/s390: Add vector instructions to host_signal_write()

2022-09-20 Thread Ilya Leoshkevich
to memory to host_signal_write(). Reported-by: Thomas Huth Fixes: ab12c95d3f19 ("target/s390x: Make translator stop before the end of a page") Signed-off-by: Ilya Leoshkevich --- linux-user/include/host/s390/host-signal.h | 25 ++ 1 file changed, 25 insertions(+) dif

Re: [PULL v3 00/20] tcg patch queue

2022-09-20 Thread Ilya Leoshkevich
04:26 +0100) > > > > > > Respect PROT_EXEC in user-only mode. > > Fix s390x, i386 and riscv for translations crossing a page. > > > > --

[PATCH RFC 0/1] tcg: add perfmap and jitdump

2022-10-11 Thread Ilya Leoshkevich
/msg04289.html v4: https://lists.gnu.org/archive/html/qemu-devel/2015-08/msg00095.html It addresses some of the feedback (among other things: symlink attacks, Elf64_Ehdr on 32-bit hosts, flockfile, license headers, style) and adds debuginfo support. Best regards, Ilya Ilya Leoshkevich (1): tcg

[PATCH 1/1] tcg: add perfmap and jitdump

2022-10-11 Thread Ilya Leoshkevich
perf report or perf record -k 1 qemu-x86_64 -jitdump ./a.out perf inject -j -i perf.data -o perf.data.jitted perf report -i perf.data.jitted Co-developed-by: Vanderson M. do Rosario Co-developed-by: Alex Bennée Signed-off-by: Ilya Leoshkevich --- accel/tcg/debuginfo.c | 108

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

2022-09-02 Thread Ilya Leoshkevich
make sure there are no regressions. [1] https://lists.gnu.org/archive/html/qemu-devel/2022-09/msg00034.html Signed-off-by: Ilya Leoshkevich --- tests/tcg/x86_64/Makefile.target| 6 +- tests/tcg/x86_64/cross-modifying-code.c | 80 + 2 files changed, 85 insertions(+),

Re: [PATCH 1/2] linux-user: Fix siginfo_t contents when jumping to non-readable pages

2022-08-05 Thread Ilya Leoshkevich
On Fri, 2022-08-05 at 09:50 +0100, Peter Maydell wrote: > On Thu, 4 Aug 2022 at 19:50, Ilya Leoshkevich > wrote: > > > > When the first instruction of a translation block is located in a > > non-readable page, qemu-user fills siginfo_t correctly. For the > > oth

[PATCH v2 4/4] tests/tcg: Test siginfo_t contents when jumping to non-readable pages

2022-08-05 Thread Ilya Leoshkevich
Add x86_64 and s390x tests to prevent regressions. Signed-off-by: Ilya Leoshkevich --- tests/tcg/multiarch/noexec.h | 114 tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/noexec.c | 145 +++ tests/tcg/x86_64

[PATCH v2 1/4] accel/tcg: Invalidate translations when clearing PAGE_READ

2022-08-05 Thread Ilya Leoshkevich
After mprotect(addr, PROT_NONE), addr can still be executed if there are cached translations. Drop them. Signed-off-by: Ilya Leoshkevich --- accel/tcg/translate-all.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg

[PATCH v2 0/4] linux-user: Fix siginfo_t contents when jumping to non-readable pages

2022-08-05 Thread Ilya Leoshkevich
-08/msg00822.html v1 -> v2: Fix individual translators instead of translator_loop (Peter). Ilya Leoshkevich (4): accel/tcg: Invalidate translations when clearing PAGE_READ target/s390x: Make translator stop before the end of a page target/i386: Make translator stop before the

[PATCH v2 3/4] target/i386: Make translator stop before the end of a page

2022-08-05 Thread Ilya Leoshkevich
it might be possible to rearrange the code to disassemble first, but this is too error-prone. Simply snapshot and restore the disassembly state instead. Signed-off-by: Ilya Leoshkevich --- target/i386/tcg/translate.c | 42 - 1 file changed, 41 insertions(+), 1

[PATCH v2 2/4] target/s390x: Make translator stop before the end of a page

2022-08-05 Thread Ilya Leoshkevich
Right now translator stops right *after* the end of a page, which breaks reporting of fault locations when the last instruction of a multi-insn translation block crosses a page boundary. Signed-off-by: Ilya Leoshkevich --- include/exec/translator.h| 10 ++ target/s390x/tcg

Re: [PATCH v3 1/4] accel/tcg: Invalidate translations when clearing PAGE_EXEC

2022-08-11 Thread Ilya Leoshkevich
On Wed, 2022-08-10 at 13:29 -0700, Richard Henderson wrote: > On 8/8/22 10:10, Ilya Leoshkevich wrote: > > After mprotect(addr, PROT_NONE), addr can still be executed if > > there > > are cached translations. Drop them. > > > > Signed-off-by: Ilya Leoshkevich

[PATCH v4 5/5] tests/tcg: Test siginfo_t contents when jumping to non-readable pages

2022-08-11 Thread Ilya Leoshkevich
Add x86_64 and s390x tests to prevent regressions. Signed-off-by: Ilya Leoshkevich --- tests/tcg/multiarch/noexec.h | 114 tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/noexec.c | 145 +++ tests/tcg/x86_64

[PATCH v4 1/5] accel/tcg: Invalidate translations when clearing PAGE_EXEC

2022-08-11 Thread Ilya Leoshkevich
In the following sequence: addr(); mprotect(addr, 0x1000, PROT_NONE); addr(); the second call must cause a SEGV, but it doesn't, because there is a cached translation. Drop it. Signed-off-by: Ilya Leoshkevich --- accel/tcg/translate-all.c | 17 - 1 file changed, 12

[PING] [PATCH v2] linux-user: Passthrough MADV_DONTNEED for certain file mappings

2022-08-11 Thread Ilya Leoshkevich
On Mon, 2022-07-25 at 14:50 +0200, Ilya Leoshkevich wrote: > This is a follow-up for commit 892a4f6a750a ("linux-user: Add partial > support for MADV_DONTNEED"), which added passthrough for anonymous > mappings. File mappings can be handled in a similar manner. > > In ord

[PATCH v4 3/5] target/s390x: Make translator stop before the end of a page

2022-08-11 Thread Ilya Leoshkevich
Right now translator stops right *after* the end of a page, which breaks reporting of fault locations when the last instruction of a multi-insn translation block crosses a page boundary. Signed-off-by: Ilya Leoshkevich --- target/s390x/tcg/translate.c | 15 +++ 1 file changed, 11

[PATCH v4 4/5] target/i386: Make translator stop before the end of a page

2022-08-11 Thread Ilya Leoshkevich
. Signed-off-by: Ilya Leoshkevich --- target/i386/tcg/translate.c | 25 - 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index b7972f0ff5..2287d22c3a 100644 --- a/target/i386/tcg/translate.c +++ b/target

[PATCH v4 2/5] accel/tcg: Introduce is_same_page()

2022-08-11 Thread Ilya Leoshkevich
Introduce a function that checks whether a given address is on the same page as where disassembly started. Having it improves readability of the following patches. Signed-off-by: Ilya Leoshkevich --- include/exec/translator.h | 10 ++ 1 file changed, 10 insertions(+) diff --git

[PATCH v4 0/5] linux-user: Fix siginfo_t contents when jumping to non-readable pages

2022-08-11 Thread Ilya Leoshkevich
e() patch (Richard). Do not touch the common code in the i386 fix (Richard). Ilya Leoshkevich (5): accel/tcg: Invalidate translations when clearing PAGE_EXEC accel/tcg: Introduce is_same_page() target/s390x: Make translator stop before the end of a page target/i386: Make translator st

Re: [PATCH v3 1/4] accel/tcg: Invalidate translations when clearing PAGE_EXEC

2022-08-12 Thread Ilya Leoshkevich
On Thu, 2022-08-11 at 08:42 -0700, Richard Henderson wrote: > On 8/11/22 02:28, Ilya Leoshkevich wrote: > > How is qemu-user's get_page_addr_code() involved here? > > > > I tried to experiment with it, and while I agree that it looks > > buggy, > > it's called

[PATCH 1/2] linux-user: Fix siginfo_t contents when jumping to non-readable pages

2022-08-04 Thread Ilya Leoshkevich
detection when only bytes on the second page are modified, but this is outside of the scope of this patch. Instead of chaning all the translators, do a much simpler thing: when such a situation is detected, start from scratch and stop right before the problematic instruction. Signed-off-by: Ilya

[PATCH 0/2] linux-user: Fix siginfo_t contents when jumping to non-readable pages

2022-08-04 Thread Ilya Leoshkevich
the issue, patch 2 adds tests. Best regards, Ilya Ilya Leoshkevich (2): linux-user: Fix siginfo_t contents when jumping to non-readable pages tests/tcg: Test siginfo_t contents when jumping to non-readable pages accel/tcg/translate-all.c| 16 ++-- accel/tcg/translator.c | 25

[PATCH 2/2] tests/tcg: Test siginfo_t contents when jumping to non-readable pages

2022-08-04 Thread Ilya Leoshkevich
Add x86_64 and s390x tests to prevent regressions. Signed-off-by: Ilya Leoshkevich --- tests/tcg/multiarch/noexec.h | 114 tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/noexec.c | 145 +++ tests/tcg/x86_64

[PATCH v3 1/4] accel/tcg: Invalidate translations when clearing PAGE_EXEC

2022-08-08 Thread Ilya Leoshkevich
After mprotect(addr, PROT_NONE), addr can still be executed if there are cached translations. Drop them. Signed-off-by: Ilya Leoshkevich --- accel/tcg/translate-all.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg

[PATCH v3 0/4] linux-user: Fix siginfo_t contents when jumping to non-readable pages

2022-08-08 Thread Ilya Leoshkevich
E_EXEC, not PAGE_READ (Peter, Richard). Ilya Leoshkevich (4): accel/tcg: Invalidate translations when clearing PAGE_EXEC target/s390x: Make translator stop before the end of a page target/i386: Make translator stop before the end of a page tests/tcg: Test siginfo_t contents when jumping

[PATCH v3 4/4] tests/tcg: Test siginfo_t contents when jumping to non-readable pages

2022-08-08 Thread Ilya Leoshkevich
Add x86_64 and s390x tests to prevent regressions. Signed-off-by: Ilya Leoshkevich --- tests/tcg/multiarch/noexec.h | 114 tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/noexec.c | 145 +++ tests/tcg/x86_64

[PATCH v3 2/4] target/s390x: Make translator stop before the end of a page

2022-08-08 Thread Ilya Leoshkevich
Right now translator stops right *after* the end of a page, which breaks reporting of fault locations when the last instruction of a multi-insn translation block crosses a page boundary. Signed-off-by: Ilya Leoshkevich --- include/exec/translator.h| 10 ++ target/s390x/tcg

[PATCH v3 3/4] target/i386: Make translator stop before the end of a page

2022-08-08 Thread Ilya Leoshkevich
. Even though i386 is the only architecture that does rollback, split it into common and architecture-dependent parts to improve readability. Signed-off-by: Ilya Leoshkevich --- accel/tcg/translator.c | 8 include/exec/translator.h | 3 +++ target/i386/tcg/translate.c | 21

Re: [PATCH for-7.2 00/21] accel/tcg: minimize tlb lookups during translate + user-only PROT_EXEC fixes

2022-08-16 Thread Ilya Leoshkevich
ought I'd go ahead and post this part. > > > r~ > > > Ilya Leoshkevich (1): >   accel/tcg: Introduce is_same_page() > > Richard Henderson (20): >   linux-user/arm: Mark the commpage executable >   linux-user/hppa: Allocate page zero as a commpage >   linux-u

Re: [PATCH for-7.2 14/21] accel/tcg: Hoist get_page_addr_code out of tb_lookup

2022-08-16 Thread Ilya Leoshkevich
On Fri, 2022-08-12 at 11:07 -0700, Richard Henderson wrote: > We will want to re-use the result of get_page_addr_code > beyond the scope of tb_lookup. > > Signed-off-by: Richard Henderson > --- >  accel/tcg/cpu-exec.c | 34 -- >  1 file changed, 24 insertions(+),

Re: [PATCH for-7.2 14/21] accel/tcg: Hoist get_page_addr_code out of tb_lookup

2022-08-17 Thread Ilya Leoshkevich
On Tue, 2022-08-16 at 20:42 -0500, Richard Henderson wrote: > On 8/16/22 18:43, Ilya Leoshkevich wrote: > > On Fri, 2022-08-12 at 11:07 -0700, Richard Henderson wrote: > > > We will want to re-use the result of get_page_addr_code > > > beyond the scope of tb_look

[PATCH] linux-user/s390x: Save/restore fpc when handling a signal

2022-08-17 Thread Ilya Leoshkevich
Linux kernel does this in fpregs_store() and fpregs_load(), so qemu-user should do this as well. Found by running valgrind's none/tests/s390x/test_sig. Signed-off-by: Ilya Leoshkevich --- linux-user/s390x/signal.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/s390x/signal.c

Re: [PATCH for-7.2 14/21] accel/tcg: Hoist get_page_addr_code out of tb_lookup

2022-08-17 Thread Ilya Leoshkevich
On Wed, 2022-08-17 at 08:15 -0500, Richard Henderson wrote: > On 8/17/22 06:08, Ilya Leoshkevich wrote: > > @@ -2243,6 +2250,13 @@ void page_set_flags(target_ulong start, > > target_ulong end, int flags) > >   (flags & PAGE_WRITE) &&a

Re: [PATCH v2 03/33] linux-user/x86_64: Allocate vsyscall page as a commpage

2022-08-17 Thread Ilya Leoshkevich
On Tue, 2022-08-16 at 15:33 -0500, Richard Henderson wrote: > We're about to start validating PAGE_EXEC, which means that we've > got to the vsyscall page executable.  We had been special casing > this entirely within translate. > > Signed-off-by: Richard Henderson > --- >  linux-user/elfload.c

Re: [PATCH for-7.2 14/21] accel/tcg: Hoist get_page_addr_code out of tb_lookup

2022-08-17 Thread Ilya Leoshkevich
On Wed, 2022-08-17 at 08:38 -0500, Richard Henderson wrote: > On 8/17/22 08:27, Ilya Leoshkevich wrote: > > On Wed, 2022-08-17 at 08:15 -0500, Richard Henderson wrote: > > > On 8/17/22 06:08, Ilya Leoshkevich wrote: > > > > @@ -2243,6 +2250,13 @@ void pag

[PATCH v5 2/4] target/s390x: Make translator stop before the end of a page

2022-08-17 Thread Ilya Leoshkevich
Right now translator stops right *after* the end of a page, which breaks reporting of fault locations when the last instruction of a multi-insn translation block crosses a page boundary. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson --- target/s390x/tcg/translate.c | 15

[PATCH v5 0/4] linux-user: Fix siginfo_t contents when jumping to non-readable pages

2022-08-17 Thread Ilya Leoshkevich
ists.gnu.org/archive/html/qemu-devel/2022-08/msg02472.html [2] https://lists.gnu.org/archive/html/qemu-devel/2022-08/msg02556.html Ilya Leoshkevich (4): linux-user: Clear tb_jmp_cache on mprotect() target/s390x: Make translator stop before the end of a page target/i386: Make translator stop be

[PATCH v5 4/4] tests/tcg: Test siginfo_t contents when jumping to non-readable pages

2022-08-17 Thread Ilya Leoshkevich
Add x86_64 and s390x tests to prevent regressions. Signed-off-by: Ilya Leoshkevich --- tests/tcg/multiarch/noexec.h | 114 tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/noexec.c | 145 +++ tests/tcg/x86_64

[PATCH v5 1/4] linux-user: Clear tb_jmp_cache on mprotect()

2022-08-17 Thread Ilya Leoshkevich
Currently it's possible to execute pages that do not have PAGE_EXEC if there is an existing translation block. Fix by clearing tb_jmp_cache, which forces HELPER(lookup_tb_ptr)() to recheck permission bits the next time. Signed-off-by: Ilya Leoshkevich --- linux-user/mmap.c | 14

[PATCH] target/s390x: Fix CLFIT and CLGIT immediate size

2022-08-17 Thread Ilya Leoshkevich
I2 is 16 bits, not 32. Found by running valgrind's none/tests/s390x/traps. Fixes: 1c2687518235 ("target-s390: Implement COMPARE AND TRAP") Signed-off-by: Ilya Leoshkevich --- target/s390x/tcg/insn-data.def | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target

[PATCH v5 3/4] target/i386: Make translator stop before the end of a page

2022-08-17 Thread Ilya Leoshkevich
. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1143 --- target/i386/tcg/translate.c | 25 - 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg

Re: [PATCH v5 0/4] linux-user: Fix siginfo_t contents when jumping to non-readable pages

2022-08-17 Thread Ilya Leoshkevich
On Wed, 2022-08-17 at 11:23 -0500, Richard Henderson wrote: > On 8/17/22 10:05, Ilya Leoshkevich wrote: > > Hi, > > > > I noticed that when we get a SEGV due to jumping to non-readable > > memory, sometimes si_addr and program counter in siginfo_t are > > slig

Re: [PATCH 9/9] target/s390x: Use Int128 for passing float128

2022-11-02 Thread Ilya Leoshkevich
On Fri, Oct 21, 2022 at 05:30:06PM +1000, Richard Henderson wrote: > Signed-off-by: Richard Henderson > --- > target/s390x/helper.h | 32 ++--- > target/s390x/tcg/fpu_helper.c | 88 ++ > target/s390x/tcg/translate.c | 76

Re: [PATCH 9/9] target/s390x: Use Int128 for passing float128

2022-11-02 Thread Ilya Leoshkevich
On Wed, Nov 02, 2022 at 08:47:24PM +1100, Richard Henderson wrote: > On 11/2/22 20:38, Ilya Leoshkevich wrote: > > On Fri, Oct 21, 2022 at 05:30:06PM +1000, Richard Henderson wrote: > > > Signed-off-by: Richard Henderson > > > --- > > >

[PATCH] s390x/tcg: Fix LDER instruction format

2022-11-02 Thread Ilya Leoshkevich
It's RRE, not RXE. Found by running valgrind's none/tests/s390x/bfp-2. Fixes: 86b59624c4aa ("s390x/tcg: Implement LOAD LENGTHENED short HFP to long HFP") Signed-off-by: Ilya Leoshkevich --- target/s390x/tcg/insn-data.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)

Re: [PULL v2 07/14] accel/tcg: Use interval tree for user-only page tracking

2022-12-23 Thread Ilya Leoshkevich
On Tue, Dec 20, 2022 at 09:03:06PM -0800, Richard Henderson wrote: > Finish weaning user-only away from PageDesc. > > Using an interval tree to track page permissions means that > we can represent very large regions efficiently. > > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/290 >

[PATCH] tests/tcg/multiarch: add vma-pthread.c

2022-12-23 Thread Ilya Leoshkevich
Add a test that locklessly changes and exercises page protection bits from various threads. This helps catch race conditions in the VMA handling. Signed-off-by: Ilya Leoshkevich --- tests/tcg/multiarch/Makefile.target | 3 + tests/tcg/multiarch/munmap-pthread.c | 16 +-- tests/tcg/multiarch

Re: [PATCH] tests/tcg/multiarch: add vma-pthread.c

2022-12-23 Thread Ilya Leoshkevich
On Fri, 2022-12-23 at 13:02 +0100, Ilya Leoshkevich wrote: > Add a test that locklessly changes and exercises page protection bits > from various threads. This helps catch race conditions in the VMA > handling. > > Signed-off-by: Ilya Leoshkevich > --- >  tests/tcg/mult

[PATCH v3 3/3] tcg: add perfmap and jitdump

2023-01-10 Thread Ilya Leoshkevich
perf report or perf record -k 1 qemu-x86_64 -jitdump ./a.out DEBUGINFOD_URLS= perf inject -j -i perf.data -o perf.data.jitted perf report -i perf.data.jitted Co-developed-by: Vanderson M. do Rosario Co-developed-by: Alex Bennée Signed-off-by: Ilya Leoshkevich --- accel/tcg

[PATCH v3 2/3] accel/tcg: Add debuginfo support

2023-01-10 Thread Ilya Leoshkevich
Add libdw-based functions for loading and querying debuginfo. Load debuginfo from the system and the linux-user loaders. This is useful for the upcoming perf support, which can then put human-readable guest symbols instead of raw guest PCs into perfmap and jitdump files. Signed-off-by: Ilya

[PATCH v3 0/3] tcg: add perfmap and jitdump

2023-01-10 Thread Ilya Leoshkevich
qemu-system-x86_64 and Linux kernel - it's not fast, but it works. * Minor const correctness and style improvements. Ilya Leoshkevich (3): linux-user: Clean up when exiting due to a signal accel/tcg: Add debuginfo support tcg: add perfmap and jitdump accel/tcg/debuginfo.c

[PATCH v3 1/3] linux-user: Clean up when exiting due to a signal

2023-01-10 Thread Ilya Leoshkevich
When exiting due to an exit() syscall, qemu-user calls preexit_cleanup(), but this is currently not the case when exiting due to a signal. This leads to various buffers not being flushed (e.g., for gprof, for gcov, and for the upcoming perf support). Add the missing call. Signed-off-by: Ilya

PING: [PATCH v2 0/1] tcg: add perfmap and jitdump

2023-01-03 Thread Ilya Leoshkevich
On Mon, 2022-11-14 at 17:13 +0100, Ilya Leoshkevich wrote: > v1: > https://lists.nongnu.org/archive/html/qemu-devel/2022-10/msg01824.html > https://lists.nongnu.org/archive/html/qemu-devel/2022-11/msg01073.html > > v1 -> v2: > * Use QEMU_LOCK_GUARD (Alex). > * Hand

[PATCH v4 1/3] linux-user: Clean up when exiting due to a signal

2023-01-12 Thread Ilya Leoshkevich
When exiting due to an exit() syscall, qemu-user calls preexit_cleanup(), but this is currently not the case when exiting due to a signal. This leads to various buffers not being flushed (e.g., for gprof, for gcov, and for the upcoming perf support). Add the missing call. Signed-off-by: Ilya

[PATCH v4 3/3] tcg: add perfmap and jitdump

2023-01-12 Thread Ilya Leoshkevich
perf report or perf record -k 1 qemu-x86_64 -jitdump ./a.out DEBUGINFOD_URLS= perf inject -j -i perf.data -o perf.data.jitted perf report -i perf.data.jitted Co-developed-by: Vanderson M. do Rosario Co-developed-by: Alex Bennée Signed-off-by: Ilya Leoshkevich --- accel/tcg

[PATCH v4 0/3] tcg: add perfmap and jitdump

2023-01-12 Thread Ilya Leoshkevich
and Linux kernel - it's not fast, but it works. * Minor const correctness and style improvements. Ilya Leoshkevich (3): linux-user: Clean up when exiting due to a signal accel/tcg: Add debuginfo support tcg: add perfmap and jitdump accel/tcg/debuginfo.c | 96 ++ accel/tcg/de

[PATCH v4 2/3] accel/tcg: Add debuginfo support

2023-01-12 Thread Ilya Leoshkevich
Add libdw-based functions for loading and querying debuginfo. Load debuginfo from the system and the linux-user loaders. This is useful for the upcoming perf support, which can then put human-readable guest symbols instead of raw guest PCs into perfmap and jitdump files. Signed-off-by: Ilya

Re: [PATCH v3 3/3] tcg: add perfmap and jitdump

2023-01-11 Thread Ilya Leoshkevich
On Wed, 2023-01-11 at 02:47 +0100, Ilya Leoshkevich wrote: > Add ability to dump /tmp/perf-.map and jit-.dump. > The first one allows the perf tool to map samples to each individual > translation block. The second one adds the ability to resolve symbol > names, line numbers and inspec

Re: [PATCH v3 01/13] tcg/s390x: Use register pair allocation for div and mulu2

2022-12-06 Thread Ilya Leoshkevich
target.c.inc | 43 +- > 3 files changed, 35 insertions(+), 20 deletions(-) Reviewed-by: Ilya Leoshkevich

Re: [PATCH v3 29/34] tcg: Reorg function calls

2022-12-06 Thread Ilya Leoshkevich
On Tue, 2022-12-06 at 09:49 -0600, Richard Henderson wrote: > On 12/6/22 09:28, Ilya Leoshkevich wrote: > > > +    switch (TCG_TARGET_CALL_ARG_I64) { > > > +    case TCG_CALL_ARG_EVEN: > > > > On a s390x host with gcc-11.0.1-0.3.1.ibm.fc34.s390

Re: [PATCH v3 29/34] tcg: Reorg function calls

2022-12-06 Thread Ilya Leoshkevich
On Thu, Dec 01, 2022 at 09:39:53PM -0800, Richard Henderson wrote: > Pre-compute the function call layout for each helper at startup. > Drop TCG_CALL_DUMMY_ARG, as we no longer need to leave gaps > in the op->args[] array. This allows several places to stop > checking for NULL TCGTemp, to which

Re: [PATCH v3 02/13] tcg/s390x: Remove TCG_REG_TB

2022-12-07 Thread Ilya Leoshkevich
On Wed, 2022-12-07 at 08:55 -0600, Richard Henderson wrote: > On 12/7/22 01:45, Thomas Huth wrote: > > On 06/12/2022 23.22, Richard Henderson wrote: > > > On 12/6/22 13:29, Ilya Leoshkevich wrote: > > > > This change doesn't seem to affect that, but what is the >

Re: [PATCH 22/26] target/s390x: Pass original r2 register to BCR

2022-11-30 Thread Ilya Leoshkevich
cg/translate.c | 10 ++ > target/s390x/tcg/insn-data.def | 2 +- > 2 files changed, 11 insertions(+), 1 deletion(-) Reviewed-by: Ilya Leoshkevich

Re: [PATCH 21/26] target/s390x: Remove PER check from use_goto_tb

2022-11-30 Thread Ilya Leoshkevich
,$0x4 goto_tb $0x1 exit_tb $0x7f73fc000401 /* check per_perc_atmid */ call per_check_exception,$0x0,$0,env set_label $L0 exit_tb $0x7f73fc000403 I will post the proposed fix and the test itself shortly. That said, the patch makes sense to me and does not make things worse, so: Reviewed-by: Ilya Leoshkevich

Re: [PATCH 24/26] tcg: Introduce tcg_temp_ebb_new_*

2022-11-30 Thread Ilya Leoshkevich
case TEMP_EBB: > case TEMP_LOCAL: > break; > default: > @@ -1063,7 +1055,7 @@ void tcg_temp_free_internal(TCGTemp *ts) > ts->temp_allocated = 0; > > idx = temp_idx(ts); > -k = ts->base_type + (ts->kind == TEMP_NORMAL ? 0 :

Re: [PATCH 23/26] tcg: Pass TCGTempKind to tcg_temp_new_internal

2022-11-30 Thread Ilya Leoshkevich
s(+), 12 deletions(-) Reviewed-by: Ilya Leoshkevich

<    1   2   3   4   5   6   7   8   9   10   >