Skip to contentSkip to conversation

s390x/selftest: Fix constraint of inline assembly

PATCH In review Thomas Huth 2 participants 2 messages Sep 24, 2020 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390x/selftest: Fix constraint of inline assembly

Clang on s390x compains:

/home/thuth/devel/kvm-unit-tests/s390x/selftest.c:39:15: error:
%r0 used in an address

        asm volatile("  stg %0,0(%0)\n" : : "r"(-1L));
                     ^
<inline asm>:1:13: note: instantiated into assembly here
                stg %r0,0(%r0)
                          ^

Right it is. We should not use address register 0 for STG. Thus let's use the "a" constraint to avoid register 0 here.

---
 s390x/selftest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
s390x/selftest.c +1 -1
index 4c16646..eaf5b18 100644
@@ -36,7 +36,7 @@ static void test_pgm_int(void)
 	check_pgm_int_code(PGM_INT_CODE_OPERATION);
 
 	expect_pgm_int();
-	asm volatile("	stg %0,0(%0)\n" : : "r"(-1L));
+	asm volatile("	stg %0,0(%0)\n" : : "a"(-1L));
 	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
 }
 
Signature · 1 line
2.18.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Thomas Huth

Clang on s390x compains:

/home/thuth/devel/kvm-unit-tests/s390x/selftest.c:39:15: error:
%r0 used in an address

        asm volatile("  stg %0,0(%0)\n" : : "r"(-1L));
                     ^
<inline asm>:1:13: note: instantiated into assembly here
                stg %r0,0(%r0)
                          ^

Right it is. We should not use address register 0 for STG. Thus let's use the "a" constraint to avoid register 0 here.

---
 s390x/selftest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
s390x/selftest.c +0 -0
index 4c16646..eaf5b18 100644

s390x/selftest.c static void test_pgm_int(void) · line 42

Quoted 8 lines
s390x/selftest.c +1 -1
@@ -36,7 +36,7 @@ static void test_pgm_int(void)
 	check_pgm_int_code(PGM_INT_CODE_OPERATION);
 
 	expect_pgm_int();
-	asm volatile("	stg %0,0(%0)\n" : : "r"(-1L));
+	asm volatile("	stg %0,0(%0)\n" : : "a"(-1L));
 	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
 }
 
Signature · 3 lines
Thanks,

David / dhildenb