diff mbox series

[kvm-unit-tests] s390x/selftest: Fix constraint of inline assembly

Message ID 20200924111746.131633-1-thuth@redhat.com (mailing list archive)
State New, archived
Headers show
Series [kvm-unit-tests] s390x/selftest: Fix constraint of inline assembly | expand

Commit Message

Thomas Huth Sept. 24, 2020, 11:17 a.m. UTC
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.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 s390x/selftest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Hildenbrand Sept. 24, 2020, 11:28 a.m. UTC | #1
On 24.09.20 13:17, Thomas Huth wrote:
> 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.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  s390x/selftest.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/s390x/selftest.c b/s390x/selftest.c
> index 4c16646..eaf5b18 100644
> --- a/s390x/selftest.c
> +++ b/s390x/selftest.c
> @@ -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);
>  }
>  
> 

Reviewed-by: David Hildenbrand <david@redhat.com>
diff mbox series

Patch

diff --git a/s390x/selftest.c b/s390x/selftest.c
index 4c16646..eaf5b18 100644
--- a/s390x/selftest.c
+++ b/s390x/selftest.c
@@ -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);
 }