From: Florian Krohm Date: Mon, 11 Jul 2011 01:51:39 +0000 (+0000) Subject: Valgrind-side changes to fix bug #271776. X-Git-Tag: svn/VALGRIND_3_7_0~373 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=210fd226e26b542fcc829e56cf8a001e2645763e;p=thirdparty%2Fvalgrind.git Valgrind-side changes to fix bug #271776. Add testcase for s390x's STFLE instruction. Patch provided by Divya Vyas git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11864 --- diff --git a/NEWS b/NEWS index 5b758ac0a6..8f027ef4dd 100644 --- a/NEWS +++ b/NEWS @@ -262,6 +262,8 @@ fixed 275710 - s390x: get rid of redundant address mode calculation +271776 - s390x: Support STFLE instruction + Release 3.6.1 (16 February 2011) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/none/tests/s390x/Makefile.am b/none/tests/s390x/Makefile.am index a100e88676..2ead0a3a15 100644 --- a/none/tests/s390x/Makefile.am +++ b/none/tests/s390x/Makefile.am @@ -5,7 +5,7 @@ dist_noinst_SCRIPTS = filter_stderr INSN_TESTS = clc clcle cvb cvd icm lpr tcxb lam_stam xc mvst add sub mul \ and or xor insert div srst fold_And16 flogr sub_EI add_EI \ and_EI or_EI xor_EI insert_EI mul_GE add_GE condloadstore \ - op_exception fgx stck stckf stcke + op_exception fgx stck stckf stcke stfle check_PROGRAMS = $(INSN_TESTS) \ ex_sig \ diff --git a/none/tests/s390x/stfle.c b/none/tests/s390x/stfle.c new file mode 100644 index 0000000000..7bfe2d6461 --- /dev/null +++ b/none/tests/s390x/stfle.c @@ -0,0 +1,56 @@ +#include + +/* Number of double words needed to store all facility bits. */ +#define S390_NUM_FACILITY_DW 2 + + +unsigned long long stfle(unsigned long dw, unsigned bit_to_test) +{ + unsigned long long hoststfle[S390_NUM_FACILITY_DW], match; + register unsigned long long __nr asm("0") = dw - 1; + int cc; + + asm volatile(" .insn s,0xb2b00000,%0 \n" /* stfle */ + "ipm %2\n" + "srl %2,28\n" + : "=m" (*hoststfle), "+d" (__nr), "=d" (cc) : : "cc", "memory"); + + printf("the value of cc is %d and #double words is %llu\n", cc, __nr + 1); + if (bit_to_test < 64) + match = (hoststfle[0] & (1ULL << (63 - bit_to_test))); + else if (bit_to_test < 128) + match = (hoststfle[1] & (1ULL << (63 - bit_to_test))); + else + printf("code needs to be updated\n"); + + return match; +} + +int main() +{ + int dw = S390_NUM_FACILITY_DW; + + /* Test #1: Make sure STFLE returns sensible values. z/Arch facilities + must be present. */ + if ((stfle(dw, 1)) && stfle(dw, 2)) + printf("The z/Architecture architectural mode is installed and active\n"); + else + printf("The z/Architecture architectural mode is not installed\n"); + + /* Test #2: Make sure the STFLE is supported. */ + if (stfle(dw, 7)) + printf("STFLE facility is installed\n"); + else + printf("STFLE facility is not installed\n"); + + /* Test #3: Tell STFLE to only write 1 DW of facility bits. Expected condition + code should be 3 because this test is run on those machines only + that need 2 do double words to store facility bits. */ + dw = 1; + if ((stfle(dw, 1)) && stfle(dw, 2)) + printf("The z/Architecture architectural mode is installed and active\n"); + else + printf("The z/Architecture architectural mode is not installed\n"); + + return 0; +} diff --git a/none/tests/s390x/stfle.stderr.exp b/none/tests/s390x/stfle.stderr.exp new file mode 100644 index 0000000000..139597f9cb --- /dev/null +++ b/none/tests/s390x/stfle.stderr.exp @@ -0,0 +1,2 @@ + + diff --git a/none/tests/s390x/stfle.stdout.exp b/none/tests/s390x/stfle.stdout.exp new file mode 100644 index 0000000000..c4653a9859 --- /dev/null +++ b/none/tests/s390x/stfle.stdout.exp @@ -0,0 +1,8 @@ +the value of cc is 0 and #double words is 2 +the value of cc is 0 and #double words is 2 +The z/Architecture architectural mode is installed and active +the value of cc is 0 and #double words is 2 +STFLE facility is installed +the value of cc is 3 and #double words is 2 +the value of cc is 3 and #double words is 2 +The z/Architecture architectural mode is installed and active diff --git a/none/tests/s390x/stfle.vgtest b/none/tests/s390x/stfle.vgtest new file mode 100644 index 0000000000..76644b54a3 --- /dev/null +++ b/none/tests/s390x/stfle.vgtest @@ -0,0 +1,2 @@ +prog:stfle +prereq: ../../../tests/s390x_features s390x-stfle z196