All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Ilya Leoshkevich <iii@linux.ibm.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	Laurent Vivier <laurent@vivier.eu>,
	Cornelia Huck <cohuck@redhat.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
	qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
	Andreas Krebbel <krebbel@linux.ibm.com>
Subject: Re: [PATCH v2 2/2] tests/tcg/s390x: Test SIGILL handling
Date: Fri, 21 May 2021 13:22:55 +0200	[thread overview]
Message-ID: <a8e6cf34-fbc3-3a58-c78d-802395f0ad3d@redhat.com> (raw)
In-Reply-To: <20210521111908.2843735-3-iii@linux.ibm.com>

On 21.05.21 13:19, Ilya Leoshkevich wrote:
> Verify that s390x-specific uc_mcontext.psw.addr is reported correctly.
> 
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>   tests/tcg/s390x/Makefile.target |  1 +
>   tests/tcg/s390x/sigill.c        | 52 +++++++++++++++++++++++++++++++++
>   2 files changed, 53 insertions(+)
>   create mode 100644 tests/tcg/s390x/sigill.c
> 
> diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
> index 241ef28f61..8699d829a5 100644
> --- a/tests/tcg/s390x/Makefile.target
> +++ b/tests/tcg/s390x/Makefile.target
> @@ -8,3 +8,4 @@ TESTS+=exrl-trtr
>   TESTS+=pack
>   TESTS+=mvo
>   TESTS+=mvc
> +TESTS+=sigill
> diff --git a/tests/tcg/s390x/sigill.c b/tests/tcg/s390x/sigill.c
> new file mode 100644
> index 0000000000..aab560b30f
> --- /dev/null
> +++ b/tests/tcg/s390x/sigill.c
> @@ -0,0 +1,52 @@
> +#include <assert.h>
> +#include <signal.h>
> +#include <string.h>
> +#include <ucontext.h>
> +#include <unistd.h>
> +
> +/*
> + * The labels for the instruction that generates a SIGILL and for the one that
> + * follows it. They could have been defined in a separate .s file, but this
> + * would complicate the build, so use the inline asm instead.
> + */
> +
> +void expected_si_addr(void);
> +void expected_psw_addr(void);
> +
> +asm(".globl\texpected_si_addr\n"
> +    "expected_si_addr:\t.byte\t0x00,0x00\n"
> +    "\t.globl\texpected_psw_addr\n"
> +    "expected_psw_addr:\tbr\t%r14");
> +
> +static void handle_signal(int sig, siginfo_t *info, void *ucontext)
> +{
> +    if (sig != SIGILL) {
> +        _exit(1);
> +    }
> +
> +    if (info->si_addr != expected_si_addr) {
> +        _exit(2);
> +    }
> +
> +    if (((ucontext_t *)ucontext)->uc_mcontext.psw.addr !=
> +            (unsigned long)expected_psw_addr) {
> +        _exit(3);
> +    }
> +}
> +
> +int main(void)
> +{
> +    struct sigaction act;
> +    int ret;
> +
> +    memset(&act, 0, sizeof(act));
> +    act.sa_sigaction = handle_signal;
> +    act.sa_flags = SA_SIGINFO;
> +
> +    ret = sigaction(SIGILL, &act, NULL);
> +    assert(ret == 0);
> +
> +    expected_si_addr();
> +
> +    return 0;
> +}
> 

That makes it much clearer, thanks.

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb



  reply	other threads:[~2021-05-21 11:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21 11:19 [PATCH v2 0/2] target/s390x: Fix SIGILL psw.addr reporting Ilya Leoshkevich
2021-05-21 11:19 ` [PATCH v2 1/2] " Ilya Leoshkevich
2021-05-21 11:19 ` [PATCH v2 2/2] tests/tcg/s390x: Test SIGILL handling Ilya Leoshkevich
2021-05-21 11:22   ` David Hildenbrand [this message]
2021-05-21 11:30 ` [PATCH v2 0/2] target/s390x: Fix SIGILL psw.addr reporting no-reply
2021-06-01 12:38 ` Ilya Leoshkevich
2021-06-01 15:52   ` Ilya Leoshkevich

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=a8e6cf34-fbc3-3a58-c78d-802395f0ad3d@redhat.com \
    --to=david@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=iii@linux.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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.