s390x: Use the right constraints in intercept.c
PATCH 1/1 s390x: Use the right constraints in intercept.c
stpx, spx, stap and stidp use addressing via "base register", i.e. if register 0 is used, the base address will be 0, independent from the value of the register. Thus we must not use the "r" constraint here to avoid register 0. This fixes test failures when compiling with Clang instead of GCC, since Clang apparently prefers to use register 0 in some cases where GCC never uses register 0.
--- s390x/intercept.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
s390x/intercept.c +11 -11
@@ -36,16 +36,16 @@ static void test_stpx(void)expect_pgm_int ();low_prot_enable (); - asmvolatile (" stpx 0(%0) " : :"r" (8 )); + asmvolatile (" stpx 0(%0) " : :"a" (8 ));low_prot_disable ();check_pgm_int_code (PGM_INT_CODE_PROTECTION );expect_pgm_int (); - asmvolatile (" stpx 0(%0) " : :"r" (1 )); + asmvolatile (" stpx 0(%0) " : :"a" (1 ));check_pgm_int_code (PGM_INT_CODE_SPECIFICATION );expect_pgm_int (); - asmvolatile (" stpx 0(%0) " : :"r" (-8L )); + asmvolatile (" stpx 0(%0) " : :"a" (-8L ));check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); }
@@ -70,13 +70,13 @@ static void test_spx(void)report_prefix_push ("operand not word aligned" );expect_pgm_int (); - asmvolatile (" spx 0(%0) " : :"r" (1 )); + asmvolatile (" spx 0(%0) " : :"a" (1 ));check_pgm_int_code (PGM_INT_CODE_SPECIFICATION );report_prefix_pop ();report_prefix_push ("operand outside memory" );expect_pgm_int (); - asmvolatile (" spx 0(%0) " : :"r" (-8L )); + asmvolatile (" spx 0(%0) " : :"a" (-8L ));check_pgm_int_code (PGM_INT_CODE_ADDRESSING );report_prefix_pop ();
@@ -113,16 +113,16 @@ static void test_stap(void)expect_pgm_int ();low_prot_enable (); - asmvolatile ("stap 0(%0)\n" : :"r" (8 )); + asmvolatile ("stap 0(%0)\n" : :"a" (8 ));low_prot_disable ();check_pgm_int_code (PGM_INT_CODE_PROTECTION );expect_pgm_int (); - asmvolatile ("stap 0(%0)\n" : :"r" (1 )); + asmvolatile ("stap 0(%0)\n" : :"a" (1 ));check_pgm_int_code (PGM_INT_CODE_SPECIFICATION );expect_pgm_int (); - asmvolatile ("stap 0(%0)\n" : :"r" (-8L )); + asmvolatile ("stap 0(%0)\n" : :"a" (-8L ));check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); }
@@ -138,16 +138,16 @@ static void test_stidp(void)expect_pgm_int ();low_prot_enable (); - asmvolatile ("stidp 0(%0)\n" : :"r" (8 )); + asmvolatile ("stidp 0(%0)\n" : :"a" (8 ));low_prot_disable ();check_pgm_int_code (PGM_INT_CODE_PROTECTION );expect_pgm_int (); - asmvolatile ("stidp 0(%0)\n" : :"r" (1 )); + asmvolatile ("stidp 0(%0)\n" : :"a" (1 ));check_pgm_int_code (PGM_INT_CODE_SPECIFICATION );expect_pgm_int (); - asmvolatile ("stidp 0(%0)\n" : :"r" (-8L )); + asmvolatile ("stidp 0(%0)\n" : :"a" (-8L ));check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); }
Signature · 1 line
2.31.1
Quoted 8 lines · On Tue, 4 Apr 2023 12:24:37 +0200 Thomas Huth <[email protected]> wrote:
stpx, spx, stap and stidp use addressing via "base register", i.e. if register 0 is used, the base address will be 0, independent from the value of the register. Thus we must not use the "r" constraint here to avoid register 0. This fixes test failures when compiling with Clang instead of GCC, since Clang apparently prefers to use register 0 in some cases where GCC never uses register 0.
Signed-off-by Thomas Huth <[email protected]>
maybe you can also add a couple of Fixes tags:
in any case:
Quoted 84 lines
--- s390x/intercept.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)s390x/intercept.c +11
-11@@ -36,16 +36,16 @@ static void test_stpx(void)expect_pgm_int ();low_prot_enable (); - asmvolatile (" stpx 0(%0) " : :"r" (8 )); + asmvolatile (" stpx 0(%0) " : :"a" (8 ));low_prot_disable ();check_pgm_int_code (PGM_INT_CODE_PROTECTION );expect_pgm_int (); - asmvolatile (" stpx 0(%0) " : :"r" (1 )); + asmvolatile (" stpx 0(%0) " : :"a" (1 ));check_pgm_int_code (PGM_INT_CODE_SPECIFICATION );expect_pgm_int (); - asmvolatile (" stpx 0(%0) " : :"r" (-8L )); + asmvolatile (" stpx 0(%0) " : :"a" (-8L ));check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); }@@ -70,13 +70,13 @@ static void test_spx(void)report_prefix_push ("operand not word aligned" );expect_pgm_int (); - asmvolatile (" spx 0(%0) " : :"r" (1 )); + asmvolatile (" spx 0(%0) " : :"a" (1 ));check_pgm_int_code (PGM_INT_CODE_SPECIFICATION );report_prefix_pop ();report_prefix_push ("operand outside memory" );expect_pgm_int (); - asmvolatile (" spx 0(%0) " : :"r" (-8L )); + asmvolatile (" spx 0(%0) " : :"a" (-8L ));check_pgm_int_code (PGM_INT_CODE_ADDRESSING );report_prefix_pop ();@@ -113,16 +113,16 @@ static void test_stap(void)expect_pgm_int ();low_prot_enable (); - asmvolatile ("stap 0(%0)\n" : :"r" (8 )); + asmvolatile ("stap 0(%0)\n" : :"a" (8 ));low_prot_disable ();check_pgm_int_code (PGM_INT_CODE_PROTECTION );expect_pgm_int (); - asmvolatile ("stap 0(%0)\n" : :"r" (1 )); + asmvolatile ("stap 0(%0)\n" : :"a" (1 ));check_pgm_int_code (PGM_INT_CODE_SPECIFICATION );expect_pgm_int (); - asmvolatile ("stap 0(%0)\n" : :"r" (-8L )); + asmvolatile ("stap 0(%0)\n" : :"a" (-8L ));check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); }@@ -138,16 +138,16 @@ static void test_stidp(void)expect_pgm_int ();low_prot_enable (); - asmvolatile ("stidp 0(%0)\n" : :"r" (8 )); + asmvolatile ("stidp 0(%0)\n" : :"a" (8 ));low_prot_disable ();check_pgm_int_code (PGM_INT_CODE_PROTECTION );expect_pgm_int (); - asmvolatile ("stidp 0(%0)\n" : :"r" (1 )); + asmvolatile ("stidp 0(%0)\n" : :"a" (1 ));check_pgm_int_code (PGM_INT_CODE_SPECIFICATION );expect_pgm_int (); - asmvolatile ("stidp 0(%0)\n" : :"r" (-8L )); + asmvolatile ("stidp 0(%0)\n" : :"a" (-8L ));check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); }
Quoting Thomas Huth (2023-04-04 12:24:37)
Quoted 8 lines
stpx, spx, stap and stidp use addressing via "base register", i.e. if register 0 is used, the base address will be 0, independent from the value of the register. Thus we must not use the "r" constraint here to avoid register 0. This fixes test failures when compiling with Clang instead of GCC, since Clang apparently prefers to use register 0 in some cases where GCC never uses register 0.
Signed-off-by Thomas Huth <[email protected]>