s390x: Fix for vistr instruction & addition to TCG tests
cover s390x: Fix for vistr instruction & addition to TCG tests
1) Improve tests/tcg/s390x/Makefile.target to look for -march flags only once
2) Fix a problem with the vistr instruction
3) Add a test for the vistr instruction
Thomas Huth (3):
tests/tcg/s390x: Test compiler flags only once, not every time target/s390x: Fix emulation of the VISTR instruction tests/tcg/s390x: Add a test for the vistr instruction
tests/tcg/s390x/vistr.c | 45 +++++++++++++++++++++++++++++ target/s390x/tcg/translate_vx.c.inc | 2 +- tests/tcg/s390x/Makefile.target | 31 +++++++++++++------- 3 files changed, 67 insertions(+), 11 deletions(-) create mode 100644 tests/tcg/s390x/vistr.c
Signature · 1 line
2.31.1
PATCH 1/3 tests/tcg/s390x: Test compiler flags only once, not every time
This is common practice, see the Makefile.target in the aarch64 folder for example.
--- tests/tcg/s390x/Makefile.target | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
tests/tcg/s390x/Makefile.target +17 -10
@@ -1,6 +1,13 @@ S390X_SRC=$(SRC_PATH)/tests/tcg/s390x VPATH+=$(S390X_SRC) CFLAGS+=-march=zEC12 -m64 + +config-cc.mak: Makefile + $(quiet-@)( \ + $(call cc-option,-march=z14, CROSS_CC_HAS_Z14); \ + $(call cc-option,-march=z15, CROSS_CC_HAS_Z15)) 3> config-cc.mak +-include config-cc.mak + TESTS+=hello-s390x TESTS+=csst TESTS+=ipm
@@ -18,20 +25,20 @@ TESTS+=signals-s390x TESTS+=branch-relative-long TESTS+=noexec +ifneq ($(CROSS_CC_HAS_Z14),) Z14_TESTS=vfminmax vfminmax: LDFLAGS+=-lm $(Z14_TESTS): CFLAGS+=-march=z14 -O2 +TESTS+=$(Z14_TESTS) +endif -TESTS+=$(if $(shell $(CC) -march=z14 -S -o /dev/null -xc /dev/null \ - >/dev/null 2>&1 && echo OK),$(Z14_TESTS)) - -VECTOR_TESTS=vxeh2_vs -VECTOR_TESTS+=vxeh2_vcvt -VECTOR_TESTS+=vxeh2_vlstr -$(VECTOR_TESTS): CFLAGS+=-march=z15 -O2 - -TESTS+=$(if $(shell $(CC) -march=z15 -S -o /dev/null -xc /dev/null \ - >/dev/null 2>&1 && echo OK),$(VECTOR_TESTS)) +ifneq ($(CROSS_CC_HAS_Z15),) +Z15_TESTS=vxeh2_vs +Z15_TESTS+=vxeh2_vcvt +Z15_TESTS+=vxeh2_vlstr +$(Z15_TESTS): CFLAGS+=-march=z15 -O2 +TESTS+=$(Z15_TESTS) +endif ifneq ($(HAVE_GDB_BIN),) GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py
Signature · 1 line
2.31.1
Re: [PATCH 1/3] tests/tcg/s390x: Test compiler flags only once, not every time
Quoted 48 lines · Thomas Huth
This is common practice, see the Makefile.target in the aarch64 folder for example.
Suggested-by Alex Bennée <[email protected]>Signed-off-by Thomas Huth <[email protected]>--- tests/tcg/s390x/Makefile.target | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)tests/tcg/s390x/Makefile.target +10
-10@@ -1,6 +1,13 @@ S390X_SRC=$(SRC_PATH)/tests/tcg/s390x VPATH+=$(S390X_SRC) CFLAGS+=-march=zEC12 -m64 + +config-cc.mak: Makefile + $(quiet-@)( \ + $(call cc-option,-march=z14, CROSS_CC_HAS_Z14); \ + $(call cc-option,-march=z15, CROSS_CC_HAS_Z15)) 3> config-cc.mak +-include config-cc.mak + TESTS+=hello-s390x TESTS+=csst TESTS+=ipm@@ -18,20 +25,20 @@ TESTS+=signals-s390x TESTS+=branch-relative-long TESTS+=noexec +ifneq ($(CROSS_CC_HAS_Z14),) Z14_TESTS=vfminmax vfminmax: LDFLAGS+=-lm $(Z14_TESTS): CFLAGS+=-march=z14 -O2 +TESTS+=$(Z14_TESTS) +endif -TESTS+=$(if $(shell $(CC) -march=z14 -S -o /dev/null -xc /dev/null \ - >/dev/null 2>&1 && echo OK),$(Z14_TESTS)) - -VECTOR_TESTS=vxeh2_vs -VECTOR_TESTS+=vxeh2_vcvt -VECTOR_TESTS+=vxeh2_vlstr -$(VECTOR_TESTS): CFLAGS+=-march=z15 -O2 - -TESTS+=$(if $(shell $(CC) -march=z15 -S -o /dev/null -xc /dev/null \ - >/dev/null 2>&1 && echo OK),$(VECTOR_TESTS))
tests/tcg/s390x/Makefile.target TESTS+=signals-s390x · line 44
Quoted 10 lines
tests/tcg/s390x/Makefile.target +7
-0+ifneq ($(CROSS_CC_HAS_Z15),) +Z15_TESTS=vxeh2_vs +Z15_TESTS+=vxeh2_vcvt +Z15_TESTS+=vxeh2_vlstr +$(Z15_TESTS): CFLAGS+=-march=z15 -O2 +TESTS+=$(Z15_TESTS) +endif ifneq ($(HAVE_GDB_BIN),) GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py
Signature · 3 lines
Thanks, David / dhildenb
Re: [PATCH 1/3] tests/tcg/s390x: Test compiler flags only once, not every time
In reply to Thomas HuthQuoted 8 lines · Thomas Huth
This is common practice, see the Makefile.target in the aarch64 folder for example.
Suggested-by Alex Bennée <[email protected]>Signed-off-by Thomas Huth <[email protected]>--- tests/tcg/s390x/Makefile.target | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
r~
PATCH 2/3 target/s390x: Fix emulation of the VISTR instruction
In reply to Thomas HuthThe element size is encoded in the M3 field, not in the M4 field.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1248
--- target/s390x/tcg/translate_vx.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/tcg/translate_vx.c.inc +1 -1
@@ -2723,7 +2723,7 @@ static DisasJumpType op_vfene(DisasContext *s, DisasOps *o) static DisasJumpType op_vistr(DisasContext *s, DisasOps *o) { - const uint8_t es = get_field(s, m4); + const uint8_t es = get_field(s, m3); const uint8_t m5 = get_field(s, m5); static gen_helper_gvec_2 * const g[3] = { gen_helper_gvec_vistr8,
Signature · 1 line
2.31.1
Re: [PATCH 2/3] target/s390x: Fix emulation of the VISTR instruction
Quoted 8 lines · Thomas Huth
The element size is encoded in the M3 field, not in the M4 field.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1248
Fixes be6324c6b734 ("s390x/tcg: Implement VECTOR ISOLATE STRING")Reviewed-by Richard Henderson <[email protected]>Signed-off-by Thomas Huth <[email protected]>---
Signature · 3 lines
Thanks, David / dhildenb
PATCH 3/3 tests/tcg/s390x: Add a test for the vistr instruction
In reply to Thomas HuthThis test can be used to verify that the change in the previous commit is indeed fixing the problem with the M3 vs. M4 field mixup.
--- tests/tcg/s390x/vistr.c | 45 +++++++++++++++++++++++++++++++++ tests/tcg/s390x/Makefile.target | 4 +++ 2 files changed, 49 insertions(+) create mode 100644 tests/tcg/s390x/vistr.c
tests/tcg/s390x/vistr.c new file +45 -0
@@ -0,0 +1,45 @@ +/* +* Test the VECTOR ISOLATE STRING (vistr) instruction +*/ +#include <stdint.h> +#include <stdio.h> +#include "vx.h" + +static inline void vistr (S390Vector *v1,S390Vector *v2, +const uint8_t m3,const uint8_t m5) +{ + asmvolatile ("vistr %[v1], %[v2], %[m3], %[m5]\n" + : [v1]"=v" (v1->v) + : [v2]"v" (v2->v) + , [m3]"i" (m3) + , [m5]"i" (m5) + :"cc" ); +} + +int main (int argc,char *argv[]) +{ +S390Vector vd = {}; +S390Vector vs16 = { + .h[0 ] =0x1234 , .h[1 ] =0x0056 , .h[2 ] =0x7800 , .h[3 ] =0x0000 , + .h[4 ] =0x0078 , .h[5 ] =0x0000 , .h[6 ] =0x6543 , .h[7 ] =0x2100 + }; +S390Vector vs32 = { + .w[0 ] =0x12340000 , .w[1 ] =0x78654300 , + .w[2 ] =0x0 , .w[3 ] =0x12 , + }; + +vistr (&vd, &vs16,1 ,0 ); +if (vd.h[0 ] !=0x1234 || vd.h[1 ] !=0x0056 || vd.h[2 ] !=0x7800 || + vd.h[3 ] || vd.h[4 ] || vd.h[5 ] || vd.h[6 ] || vd.h[7 ]) { +puts ("ERROR: vitrh failed!" ); +return 1 ; + } + +vistr (&vd, &vs32,2 ,0 ); +if (vd.w[0 ] !=0x12340000 || vd.w[1 ] !=0x78654300 || vd.w[2 ] || vd.w[3 ]) { +puts ("ERROR: vitrf failed!" ); +return 1 ; + } + +return 0 ; +}
tests/tcg/s390x/Makefile.target +4 -0
@@ -25,6 +25,10 @@ TESTS+=signals-s390x TESTS+=branch-relative-long TESTS+=noexec +Z13_TESTS=vistr +$(Z13_TESTS): CFLAGS+=-march=z13 -O2 +TESTS+=$(Z13_TESTS) + ifneq ($(CROSS_CC_HAS_Z14),) Z14_TESTS=vfminmax vfminmax: LDFLAGS+=-lm
Signature · 1 line
2.31.1
Re: [PATCH 3/3] tests/tcg/s390x: Add a test for the vistr instruction
Quoted 6 lines · Thomas Huth
This test can be used to verify that the change in the previous commit is indeed fixing the problem with the M3 vs. M4 field mixup.
Signed-off-by Thomas Huth <[email protected]>---
Signature · 3 lines
Thanks, David / dhildenb
Re: [PATCH 3/3] tests/tcg/s390x: Add a test for the vistr instruction
In reply to Thomas HuthQuoted 10 lines · Thomas Huth
This test can be used to verify that the change in the previous commit is indeed fixing the problem with the M3 vs. M4 field mixup.
Signed-off-by Thomas Huth<[email protected]>--- tests/tcg/s390x/vistr.c | 45 +++++++++++++++++++++++++++++++++ tests/tcg/s390x/Makefile.target | 4 +++ 2 files changed, 49 insertions(+)create mode 100644
tests/tcg/s390x/vistr.c
r~