[PATCH] tests/tcg/s390x: Fix mvc, mvo and pack tests with Clang

Thomas Huth posted 1 patch 2 years, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220301093911.1450719-1-thuth@redhat.com
Test checkpatch passed
Maintainers: Richard Henderson <richard.henderson@linaro.org>, David Hildenbrand <david@redhat.com>, Cornelia Huck <cohuck@redhat.com>, Thomas Huth <thuth@redhat.com>
tests/tcg/s390x/mvc.c  | 4 ++--
tests/tcg/s390x/mvo.c  | 4 ++--
tests/tcg/s390x/pack.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
[PATCH] tests/tcg/s390x: Fix mvc, mvo and pack tests with Clang
Posted by Thomas Huth 2 years, 2 months ago
These instructions use addressing with a "base address", meaning
that if register r0 is used, it is always treated as zero, no matter
what value is stored in the register. So we have to make sure not
to use register r0 for these instructions in our tests. There was
no problem with GCC so far since it seems to always pick other
registers by default, but Clang likes to chose register r0, too,
so we have to use the "a" constraint to make sure that it does
not pick r0 here.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/tcg/s390x/mvc.c  | 4 ++--
 tests/tcg/s390x/mvo.c  | 4 ++--
 tests/tcg/s390x/pack.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/tcg/s390x/mvc.c b/tests/tcg/s390x/mvc.c
index aa552d52e5..7ae4c44550 100644
--- a/tests/tcg/s390x/mvc.c
+++ b/tests/tcg/s390x/mvc.c
@@ -20,8 +20,8 @@ static inline void mvc_256(const char *dst, const char *src)
     asm volatile (
         "    mvc 0(256,%[dst]),0(%[src])\n"
         :
-        : [dst] "d" (dst),
-          [src] "d" (src)
+        : [dst] "a" (dst),
+          [src] "a" (src)
         : "memory");
 }
 
diff --git a/tests/tcg/s390x/mvo.c b/tests/tcg/s390x/mvo.c
index 5546fe2a97..0c3ecdde2e 100644
--- a/tests/tcg/s390x/mvo.c
+++ b/tests/tcg/s390x/mvo.c
@@ -11,8 +11,8 @@ int main(void)
     asm volatile (
         "    mvo 0(4,%[dest]),0(3,%[src])\n"
         :
-        : [dest] "d" (dest + 1),
-          [src] "d" (src + 1)
+        : [dest] "a" (dest + 1),
+          [src] "a" (src + 1)
         : "memory");
 
     for (i = 0; i < sizeof(expected); i++) {
diff --git a/tests/tcg/s390x/pack.c b/tests/tcg/s390x/pack.c
index 4be36f29a7..55e7e214e8 100644
--- a/tests/tcg/s390x/pack.c
+++ b/tests/tcg/s390x/pack.c
@@ -9,7 +9,7 @@ int main(void)
     asm volatile(
         "    pack 2(4,%[data]),2(4,%[data])\n"
         :
-        : [data] "r" (&data[0])
+        : [data] "a" (&data[0])
         : "memory");
     for (i = 0; i < 8; i++) {
         if (data[i] != exp[i]) {
-- 
2.27.0
Re: [PATCH] tests/tcg/s390x: Fix mvc, mvo and pack tests with Clang
Posted by David Hildenbrand 2 years, 2 months ago
On 01.03.22 10:39, Thomas Huth wrote:
> These instructions use addressing with a "base address", meaning
> that if register r0 is used, it is always treated as zero, no matter
> what value is stored in the register. So we have to make sure not
> to use register r0 for these instructions in our tests. There was
> no problem with GCC so far since it seems to always pick other
> registers by default, but Clang likes to chose register r0, too,
> so we have to use the "a" constraint to make sure that it does
> not pick r0 here.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  tests/tcg/s390x/mvc.c  | 4 ++--
>  tests/tcg/s390x/mvo.c  | 4 ++--
>  tests/tcg/s390x/pack.c | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/tests/tcg/s390x/mvc.c b/tests/tcg/s390x/mvc.c
> index aa552d52e5..7ae4c44550 100644
> --- a/tests/tcg/s390x/mvc.c
> +++ b/tests/tcg/s390x/mvc.c
> @@ -20,8 +20,8 @@ static inline void mvc_256(const char *dst, const char *src)
>      asm volatile (
>          "    mvc 0(256,%[dst]),0(%[src])\n"
>          :
> -        : [dst] "d" (dst),
> -          [src] "d" (src)
> +        : [dst] "a" (dst),
> +          [src] "a" (src)
>          : "memory");
>  }
>  
> diff --git a/tests/tcg/s390x/mvo.c b/tests/tcg/s390x/mvo.c
> index 5546fe2a97..0c3ecdde2e 100644
> --- a/tests/tcg/s390x/mvo.c
> +++ b/tests/tcg/s390x/mvo.c
> @@ -11,8 +11,8 @@ int main(void)
>      asm volatile (
>          "    mvo 0(4,%[dest]),0(3,%[src])\n"
>          :
> -        : [dest] "d" (dest + 1),
> -          [src] "d" (src + 1)
> +        : [dest] "a" (dest + 1),
> +          [src] "a" (src + 1)
>          : "memory");
>  
>      for (i = 0; i < sizeof(expected); i++) {
> diff --git a/tests/tcg/s390x/pack.c b/tests/tcg/s390x/pack.c
> index 4be36f29a7..55e7e214e8 100644
> --- a/tests/tcg/s390x/pack.c
> +++ b/tests/tcg/s390x/pack.c
> @@ -9,7 +9,7 @@ int main(void)
>      asm volatile(
>          "    pack 2(4,%[data]),2(4,%[data])\n"
>          :
> -        : [data] "r" (&data[0])
> +        : [data] "a" (&data[0])
>          : "memory");
>      for (i = 0; i < 8; i++) {
>          if (data[i] != exp[i]) {

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

-- 
Thanks,

David / dhildenb
Re: [PATCH] tests/tcg/s390x: Fix mvc, mvo and pack tests with Clang
Posted by Richard Henderson 2 years, 2 months ago
On 2/28/22 23:39, Thomas Huth wrote:
> These instructions use addressing with a "base address", meaning
> that if register r0 is used, it is always treated as zero, no matter
> what value is stored in the register. So we have to make sure not
> to use register r0 for these instructions in our tests. There was
> no problem with GCC so far since it seems to always pick other
> registers by default, but Clang likes to chose register r0, too,
> so we have to use the "a" constraint to make sure that it does
> not pick r0 here.
> 
> Signed-off-by: Thomas Huth<thuth@redhat.com>
> ---
>   tests/tcg/s390x/mvc.c  | 4 ++--
>   tests/tcg/s390x/mvo.c  | 4 ++--
>   tests/tcg/s390x/pack.c | 2 +-
>   3 files changed, 5 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~