diff options
author | florian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2011-07-11 01:51:39 +0000 |
---|---|---|
committer | florian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2011-07-11 01:51:39 +0000 |
commit | 036113b63389de28f972414b684c01f414c13714 (patch) | |
tree | 2dba4c802639f22703bec1c2ec9d5a8b99198488 /none | |
parent | 3f52be4640aafb1186950b780df7ab933332ba06 (diff) |
Valgrind-side changes to fix bug #271776.
Add testcase for s390x's STFLE instruction.
Patch provided by Divya Vyas <divyvyas@linux.vnet.ibm.com>
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11864 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'none')
-rw-r--r-- | none/tests/s390x/Makefile.am | 2 | ||||
-rw-r--r-- | none/tests/s390x/stfle.c | 56 | ||||
-rw-r--r-- | none/tests/s390x/stfle.stderr.exp | 2 | ||||
-rw-r--r-- | none/tests/s390x/stfle.stdout.exp | 8 | ||||
-rw-r--r-- | none/tests/s390x/stfle.vgtest | 2 |
5 files changed, 69 insertions, 1 deletions
diff --git a/none/tests/s390x/Makefile.am b/none/tests/s390x/Makefile.am index a100e886..2ead0a3a 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 00000000..7bfe2d64 --- /dev/null +++ b/none/tests/s390x/stfle.c @@ -0,0 +1,56 @@ +#include <stdio.h> + +/* 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 00000000..139597f9 --- /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 00000000..c4653a98 --- /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 00000000..76644b54 --- /dev/null +++ b/none/tests/s390x/stfle.vgtest @@ -0,0 +1,2 @@ +prog:stfle +prereq: ../../../tests/s390x_features s390x-stfle z196 |