From: David Hildenbrand <david@redhat.com>
To: Ilya Leoshkevich <iii@linux.ibm.com>,
Thomas Huth <thuth@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Laurent Vivier <laurent@vivier.eu>,
Cornelia Huck <cohuck@redhat.com>
Cc: "jonathan . albrecht" <jonathan.albrecht@linux.vnet.ibm.com>,
Ulrich Weigand <ulrich.weigand@de.ibm.com>,
qemu-devel@nongnu.org,
Christian Borntraeger <borntraeger@de.ibm.com>,
qemu-s390x@nongnu.org, Andreas Krebbel <krebbel@linux.ibm.com>
Subject: Re: [PATCH v8] tests/tcg/s390x: Test SIGILL and SIGSEGV handling
Date: Thu, 5 Aug 2021 11:37:55 +0200 [thread overview]
Message-ID: <44c8dc22-c243-6260-c6af-62fd209f21e9@redhat.com> (raw)
In-Reply-To: <20210804225146.154513-1-iii@linux.ibm.com>
On 05.08.21 00:51, Ilya Leoshkevich wrote:
> Verify that s390x-specific uc_mcontext.psw.addr is reported correctly
> and that signal handling interacts properly with debugging.
>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>
> v7: https://lists.nongnu.org/archive/html/qemu-devel/2021-08/msg00463.html
> v7 -> v8: Another rebase needed due to the conflict with Jonathan's
> 50e36dd61652.
>
> tests/tcg/s390x/Makefile.target | 17 +-
> tests/tcg/s390x/gdbstub/test-signals-s390x.py | 76 ++++++++
> tests/tcg/s390x/signals-s390x.c | 165 ++++++++++++++++++
> 3 files changed, 257 insertions(+), 1 deletion(-)
> create mode 100644 tests/tcg/s390x/gdbstub/test-signals-s390x.py
> create mode 100644 tests/tcg/s390x/signals-s390x.c
>
> diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
> index bd084c7840..cc64dd32d2 100644
> --- a/tests/tcg/s390x/Makefile.target
> +++ b/tests/tcg/s390x/Makefile.target
> @@ -1,4 +1,5 @@
> -VPATH+=$(SRC_PATH)/tests/tcg/s390x
> +S390X_SRC=$(SRC_PATH)/tests/tcg/s390x
> +VPATH+=$(S390X_SRC)
> CFLAGS+=-march=zEC12 -m64
> TESTS+=hello-s390x
> TESTS+=csst
> @@ -9,3 +10,17 @@ TESTS+=pack
> TESTS+=mvo
> TESTS+=mvc
> TESTS+=trap
> +TESTS+=signals-s390x
> +
> +ifneq ($(HAVE_GDB_BIN),)
> +GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py
> +
> +run-gdbstub-signals-s390x: signals-s390x
> + $(call run-test, $@, $(GDB_SCRIPT) \
> + --gdb $(HAVE_GDB_BIN) \
> + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
> + --bin $< --test $(S390X_SRC)/gdbstub/test-signals-s390x.py, \
> + "mixing signals and debugging on s390x")
> +
> +EXTRA_RUNS += run-gdbstub-signals-s390x
> +endif
> diff --git a/tests/tcg/s390x/gdbstub/test-signals-s390x.py b/tests/tcg/s390x/gdbstub/test-signals-s390x.py
> new file mode 100644
> index 0000000000..80a284b475
> --- /dev/null
> +++ b/tests/tcg/s390x/gdbstub/test-signals-s390x.py
> @@ -0,0 +1,76 @@
> +from __future__ import print_function
> +
> +#
> +# Test that signals and debugging mix well together on s390x.
> +#
> +# This is launched via tests/guest-debug/run-test.py
> +#
> +
> +import gdb
> +import sys
> +
> +failcount = 0
> +
> +
> +def report(cond, msg):
> + """Report success/fail of test"""
> + if cond:
> + print("PASS: %s" % (msg))
> + else:
> + print("FAIL: %s" % (msg))
> + global failcount
> + failcount += 1
> +
> +
> +def run_test():
> + """Run through the tests one by one"""
> + illegal_op = gdb.Breakpoint("illegal_op")
> + stg = gdb.Breakpoint("stg")
> + mvc_8 = gdb.Breakpoint("mvc_8")
> +
> + # Expect the following events:
> + # 1x illegal_op breakpoint
> + # 2x stg breakpoint, segv, breakpoint
> + # 2x mvc_8 breakpoint, segv, breakpoint
> + for _ in range(14):
How do we come up with the value 14?
> + gdb.execute("c")
> + report(illegal_op.hit_count == 1, "illegal_op.hit_count == 1")
> + report(stg.hit_count == 4, "stg.hit_count == 4")
The doc above says we should see this twice, why do we see it 4 times?
> + report(mvc_8.hit_count == 4, "mvc_8.hit_count == 4")
> +
Dito
[...]
> diff --git a/tests/tcg/s390x/signals-s390x.c b/tests/tcg/s390x/signals-s390x.c
> new file mode 100644
> index 0000000000..dc2f8ee59a
> --- /dev/null
> +++ b/tests/tcg/s390x/signals-s390x.c
> @@ -0,0 +1,165 @@
> +#include <assert.h>
> +#include <signal.h>
> +#include <string.h>
> +#include <sys/mman.h>
> +#include <ucontext.h>
> +#include <unistd.h>
> +
> +/*
> + * Various instructions that generate SIGILL and SIGSEGV. They could have been
> + * defined in a separate .s file, but this would complicate the build, so the
> + * inline asm is used instead.
> + */
> +
> +void illegal_op(void);
> +void after_illegal_op(void);
> +asm(".globl\tillegal_op\n"
> + "illegal_op:\t.byte\t0x00,0x00\n"
> + "\t.globl\tafter_illegal_op\n"
> + "after_illegal_op:\tbr\t%r14");
> +
> +void stg(void *dst, unsigned long src);
> +asm(".globl\tstg\n"
> + "stg:\tstg\t%r3,0(%r2)\n"
> + "\tbr\t%r14");
> +
> +void mvc_8(void *dst, void *src);
> +asm(".globl\tmvc_8\n"
> + "mvc_8:\tmvc\t0(8,%r2),0(%r3)\n"
> + "\tbr\t%r14");
I was wondering if there would be any nicer way to write this,
like (very prototype and wrong)
static void stg(void *dst, unsigned long src)
{
asm volatile("stg %r3,0(%r2)\n");
}
static void mvc_8(void *dst, void *src)
{
asm volatile("mvc 0(8,%r2),0(%r3)\n");
}
Please ignore if that just doesn't make any sense.
Nothing else jumped at me :)
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2021-08-05 9:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-04 22:51 [PATCH v8] tests/tcg/s390x: Test SIGILL and SIGSEGV handling Ilya Leoshkevich
2021-08-05 9:37 ` David Hildenbrand [this message]
2021-08-05 9:57 ` Ilya Leoshkevich
2021-08-05 10:01 ` David Hildenbrand
2021-08-06 5:25 ` Thomas Huth
2021-08-06 9:40 ` Ilya Leoshkevich
2021-08-06 14:33 ` Alex Bennée
2021-08-10 12:24 ` Cornelia Huck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44c8dc22-c243-6260-c6af-62fd209f21e9@redhat.com \
--to=david@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=iii@linux.ibm.com \
--cc=jonathan.albrecht@linux.vnet.ibm.com \
--cc=krebbel@linux.ibm.com \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
--cc=ulrich.weigand@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).