qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Ilya Leoshkevich <iii@linux.ibm.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	Thomas Huth <thuth@redhat.com>
Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [PATCH 2/4] tests/tcg/s390x: Test LCBB
Date: Sun, 28 May 2023 20:55:28 +0200	[thread overview]
Message-ID: <729f5354-36a4-13bd-7472-de133600371c@redhat.com> (raw)
In-Reply-To: <20230526181240.1425579-3-iii@linux.ibm.com>

On 26.05.23 20:12, Ilya Leoshkevich wrote:
> Add a test to prevent regressions.
> 
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>   tests/tcg/s390x/Makefile.target |  1 +
>   tests/tcg/s390x/lcbb.c          | 51 +++++++++++++++++++++++++++++++++
>   2 files changed, 52 insertions(+)
>   create mode 100644 tests/tcg/s390x/lcbb.c
> 
> diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
> index 73f7cb828e3..c48de439625 100644
> --- a/tests/tcg/s390x/Makefile.target
> +++ b/tests/tcg/s390x/Makefile.target
> @@ -47,6 +47,7 @@ $(PGM_SPECIFICATION_TESTS): LDFLAGS+=pgm-specification-user.o
>   TESTS += $(PGM_SPECIFICATION_TESTS)
>   
>   Z13_TESTS=vistr
> +Z13_TESTS+=lcbb
>   $(Z13_TESTS): CFLAGS+=-march=z13 -O2
>   TESTS+=$(Z13_TESTS)
>   
> diff --git a/tests/tcg/s390x/lcbb.c b/tests/tcg/s390x/lcbb.c
> new file mode 100644
> index 00000000000..8d368e0998d
> --- /dev/null
> +++ b/tests/tcg/s390x/lcbb.c
> @@ -0,0 +1,51 @@
> +/*
> + * Test the LCBB instruction.
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +#include <assert.h>
> +#include <stdlib.h>
> +
> +static inline __attribute__((__always_inline__)) void
> +lcbb(long *r1, void *dxb2, int m3, int *cc)
> +{
> +    asm("lcbb %[r1],%[dxb2],%[m3]\n"
> +        "ipm %[cc]"
> +        : [r1] "+r" (*r1), [cc] "=r" (*cc)
> +        : [dxb2] "R" (*(char *)dxb2), [m3] "i" (m3)
> +        : "cc");
> +    *cc = (*cc >> 28) & 3;
> +}
> +
> +static char buf[0x1000] __attribute__((aligned(0x1000)));
> +
> +static inline __attribute__((__always_inline__)) void
> +test_lcbb(void *p, int m3, int exp_r1, int exp_cc)
> +{
> +    long r1 = 0xfedcba9876543210;
> +    int cc;
> +
> +    lcbb(&r1, p, m3, &cc);
> +    assert(r1 == (0xfedcba9800000000 | exp_r1));
> +    assert(cc == exp_cc);
> +}
> +
> +int main(void)
> +{
> +    test_lcbb(&buf[0],    0, 16, 0);
> +    test_lcbb(&buf[63],   0,  1, 3);
> +    test_lcbb(&buf[0],    1, 16, 0);
> +    test_lcbb(&buf[127],  1,  1, 3);
> +    test_lcbb(&buf[0],    2, 16, 0);
> +    test_lcbb(&buf[255],  2,  1, 3);
> +    test_lcbb(&buf[0],    3, 16, 0);
> +    test_lcbb(&buf[511],  3,  1, 3);
> +    test_lcbb(&buf[0],    4, 16, 0);
> +    test_lcbb(&buf[1023], 4,  1, 3);
> +    test_lcbb(&buf[0],    5, 16, 0);
> +    test_lcbb(&buf[2047], 5,  1, 3);
> +    test_lcbb(&buf[0],    6, 16, 0);
> +    test_lcbb(&buf[4095], 6,  1, 3);
> +
> +    return EXIT_SUCCESS;
> +}

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

-- 
Thanks,

David / dhildenb



  parent reply	other threads:[~2023-05-28 18:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-26 18:12 [PATCH 0/4] Fix Fedora 38 Clang on s390x Ilya Leoshkevich
2023-05-26 18:12 ` [PATCH 1/4] target/s390x: Fix LCBB overwriting the top 32 bits Ilya Leoshkevich
2023-05-26 23:11   ` Richard Henderson
2023-05-28 18:55   ` David Hildenbrand
2023-05-26 18:12 ` [PATCH 2/4] tests/tcg/s390x: Test LCBB Ilya Leoshkevich
2023-05-26 23:13   ` Richard Henderson
2023-05-28 18:55   ` David Hildenbrand [this message]
2023-05-26 18:12 ` [PATCH 3/4] target/s390x: Fix LOCFHR taking the wrong half of R2 Ilya Leoshkevich
2023-05-26 23:03   ` Richard Henderson
2023-05-28 18:55   ` David Hildenbrand
2023-05-26 18:12 ` [PATCH 4/4] tests/tcg/s390x: Test LOCFHR Ilya Leoshkevich
2023-05-26 23:14   ` Richard Henderson
2023-05-28 18:56   ` David Hildenbrand

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=729f5354-36a4-13bd-7472-de133600371c@redhat.com \
    --to=david@redhat.com \
    --cc=iii@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.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).