diff mbox series

[09/12] tests/tcg/s390x: Test LARL with a large offset

Message ID 20230703155801.179167-10-iii@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series target/s390x: Miscellaneous TCG fixes | expand

Commit Message

Ilya Leoshkevich July 3, 2023, 3:50 p.m. UTC
Add a small test to prevent regressions.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 tests/tcg/s390x/Makefile.target |  1 +
 tests/tcg/s390x/larl.c          | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)
 create mode 100644 tests/tcg/s390x/larl.c

Comments

David Hildenbrand July 4, 2023, 7:56 a.m. UTC | #1
On 03.07.23 17:50, Ilya Leoshkevich wrote:
> Add a small test to prevent regressions.
> 
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>   tests/tcg/s390x/Makefile.target |  1 +
>   tests/tcg/s390x/larl.c          | 17 +++++++++++++++++
>   2 files changed, 18 insertions(+)
>   create mode 100644 tests/tcg/s390x/larl.c
> 
> diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
> index 2ef22c88d95..dbf64c991e9 100644
> --- a/tests/tcg/s390x/Makefile.target
> +++ b/tests/tcg/s390x/Makefile.target
> @@ -37,6 +37,7 @@ TESTS+=ex-relative-long
>   TESTS+=ex-branch
>   TESTS+=mxdb
>   TESTS+=epsw
> +TESTS+=larl
>   
>   cdsg: CFLAGS+=-pthread
>   cdsg: LDFLAGS+=-pthread
> diff --git a/tests/tcg/s390x/larl.c b/tests/tcg/s390x/larl.c
> new file mode 100644
> index 00000000000..b9ced99a023
> --- /dev/null
> +++ b/tests/tcg/s390x/larl.c
> @@ -0,0 +1,17 @@
> +/*
> + * Test the LARL instruction.
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +#include <stdlib.h>
> +
> +int main(void)
> +{
> +    long algfi = (long)main;
> +    long larl;
> +
> +    asm("algfi %[r],0xd0000000" : [r] "+r" (algfi) : : "cc");
> +    asm("larl %[r],main+0xd0000000" : [r] "=r" (larl));

Not sure if worth combining both statements.

> +
> +    return algfi == larl ? EXIT_SUCCESS : EXIT_FAILURE;
> +}

Acked-by: David Hildenbrand <david@redhat.com>
Ilya Leoshkevich July 4, 2023, 7:59 a.m. UTC | #2
On Tue, 2023-07-04 at 09:56 +0200, David Hildenbrand wrote:
> On 03.07.23 17:50, Ilya Leoshkevich wrote:
> > Add a small test to prevent regressions.
> > 
> > Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> > ---
> >   tests/tcg/s390x/Makefile.target |  1 +
> >   tests/tcg/s390x/larl.c          | 17 +++++++++++++++++
> >   2 files changed, 18 insertions(+)
> >   create mode 100644 tests/tcg/s390x/larl.c
> > 
> > diff --git a/tests/tcg/s390x/Makefile.target
> > b/tests/tcg/s390x/Makefile.target
> > index 2ef22c88d95..dbf64c991e9 100644
> > --- a/tests/tcg/s390x/Makefile.target
> > +++ b/tests/tcg/s390x/Makefile.target
> > @@ -37,6 +37,7 @@ TESTS+=ex-relative-long
> >   TESTS+=ex-branch
> >   TESTS+=mxdb
> >   TESTS+=epsw
> > +TESTS+=larl
> >   
> >   cdsg: CFLAGS+=-pthread
> >   cdsg: LDFLAGS+=-pthread
> > diff --git a/tests/tcg/s390x/larl.c b/tests/tcg/s390x/larl.c
> > new file mode 100644
> > index 00000000000..b9ced99a023
> > --- /dev/null
> > +++ b/tests/tcg/s390x/larl.c
> > @@ -0,0 +1,17 @@
> > +/*
> > + * Test the LARL instruction.
> > + *
> > + * SPDX-License-Identifier: GPL-2.0-or-later
> > + */
> > +#include <stdlib.h>
> > +
> > +int main(void)
> > +{
> > +    long algfi = (long)main;
> > +    long larl;
> > +
> > +    asm("algfi %[r],0xd0000000" : [r] "+r" (algfi) : : "cc");
> > +    asm("larl %[r],main+0xd0000000" : [r] "=r" (larl));
> 
> Not sure if worth combining both statements.

I thought it would be easier on the eyes; this way one immediately sees
that they are independent.

And maybe I should've added a comment about this, but the reason I used
algfi instead of C addition was that I feared that the compiler might
generate larl, making the test useless.

> 
> > +
> > +    return algfi == larl ? EXIT_SUCCESS : EXIT_FAILURE;
> > +}
> 
> Acked-by: David Hildenbrand <david@redhat.com>
>
diff mbox series

Patch

diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
index 2ef22c88d95..dbf64c991e9 100644
--- a/tests/tcg/s390x/Makefile.target
+++ b/tests/tcg/s390x/Makefile.target
@@ -37,6 +37,7 @@  TESTS+=ex-relative-long
 TESTS+=ex-branch
 TESTS+=mxdb
 TESTS+=epsw
+TESTS+=larl
 
 cdsg: CFLAGS+=-pthread
 cdsg: LDFLAGS+=-pthread
diff --git a/tests/tcg/s390x/larl.c b/tests/tcg/s390x/larl.c
new file mode 100644
index 00000000000..b9ced99a023
--- /dev/null
+++ b/tests/tcg/s390x/larl.c
@@ -0,0 +1,17 @@ 
+/*
+ * Test the LARL instruction.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include <stdlib.h>
+
+int main(void)
+{
+    long algfi = (long)main;
+    long larl;
+
+    asm("algfi %[r],0xd0000000" : [r] "+r" (algfi) : : "cc");
+    asm("larl %[r],main+0xd0000000" : [r] "=r" (larl));
+
+    return algfi == larl ? EXIT_SUCCESS : EXIT_FAILURE;
+}