From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
clang-built-linux@googlegroups.com,
Nick Desaulniers <ndesaulniers@google.com>,
Nathan Chancellor <natechancellor@gmail.com>,
linux-s390@vger.kernel.org, Vasily Gorbik <gor@linux.ibm.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 12/12] [PROBABLY WRONG] s390: void '0' constraint in inline assembly
Date: Wed, 10 Apr 2019 15:55:13 +0200 [thread overview]
Message-ID: <20190410155513.1609f1a1@mschwideX1> (raw)
In-Reply-To: <20190408212648.2407234-12-arnd@arndb.de>
On Mon, 8 Apr 2019 23:26:25 +0200
Arnd Bergmann <arnd@arndb.de> wrote:
> clang does not understand the contraint "0" in the CALL_ON_STACK()
> macro:
>
> ../arch/s390/mm/maccess.c:117:10: error: invalid input constraint '0' in asm
> return CALL_ON_STACK(_memcpy_real, S390_lowcore.nodat_stack,
> ^
> ../arch/s390/include/asm/processor.h:292:20: note: expanded from macro 'CALL_ON_STACK'
> [_fn] "X" (fn) CALL_FMT_##nr : CALL_CLOBBER_##nr); \
> ^
> <scratch space>:207:1: note: expanded from here
> CALL_FMT_3
> ^
> ../arch/s390/include/asm/processor.h:267:20: note: expanded from macro 'CALL_FMT_3'
> #define CALL_FMT_3 CALL_FMT_2, "d" (r4)
> ^
> ../arch/s390/include/asm/processor.h:266:20: note: expanded from macro 'CALL_FMT_2'
> #define CALL_FMT_2 CALL_FMT_1, "d" (r3)
> ^
> ../arch/s390/include/asm/processor.h:265:32: note: expanded from macro 'CALL_FMT_1'
> #define CALL_FMT_1 CALL_FMT_0, "0" (r2)
> ^
>
> I don't know what the correct fix here would be, changing it to "d" made
> it build, since clang does understand this one.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/s390/include/asm/processor.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h
> index 700c650ffd4f..84c59c99668a 100644
> --- a/arch/s390/include/asm/processor.h
> +++ b/arch/s390/include/asm/processor.h
> @@ -262,7 +262,7 @@ static __no_kasan_or_inline unsigned short stap(void)
> register unsigned long r4 asm("6") = (unsigned long)(arg5)
>
> #define CALL_FMT_0
> -#define CALL_FMT_1 CALL_FMT_0, "0" (r2)
> +#define CALL_FMT_1 CALL_FMT_0, "d" (r2)
> #define CALL_FMT_2 CALL_FMT_1, "d" (r3)
> #define CALL_FMT_3 CALL_FMT_2, "d" (r4)
> #define CALL_FMT_4 CALL_FMT_3, "d" (r5)
This is (slightly) wrong. %r2 is used as the input register for the first argument
and the result value for the call. With your patch you force the compiler to load
the first argument in two registers. One solution would be to CALL_FMT1 as
#define CALL_FMT1 CALL_FMT_0
It still is not optimal though as for CALL_FMT_0 the "+&d" (r2) indicates an
input but CALL_ARGS_0 does not initialize r2.
I am thinking about the following patch to cover all cases:
--
From 91a4abbec91a9f26f84f7386f2c0f96de669b0eb Mon Sep 17 00:00:00 2001
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
Date: Wed, 10 Apr 2019 15:48:43 +0200
Subject: [PATCH] s390: fine-tune stack switch helper
The CALL_ON_STACK helper currently does not work with clang and for
calls without arguments it does not initialize r2 although the contraint
is "+&d". Rework the CALL_FMT_x and the CALL_ON_STACK macros to work
with clang and produce optimal code in all cases.
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---
arch/s390/include/asm/processor.h | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h
index 81038ab357ce..0ee022247580 100644
--- a/arch/s390/include/asm/processor.h
+++ b/arch/s390/include/asm/processor.h
@@ -261,12 +261,12 @@ static __no_kasan_or_inline unsigned short stap(void)
CALL_ARGS_4(arg1, arg2, arg3, arg4); \
register unsigned long r4 asm("6") = (unsigned long)(arg5)
-#define CALL_FMT_0
-#define CALL_FMT_1 CALL_FMT_0, "0" (r2)
-#define CALL_FMT_2 CALL_FMT_1, "d" (r3)
-#define CALL_FMT_3 CALL_FMT_2, "d" (r4)
-#define CALL_FMT_4 CALL_FMT_3, "d" (r5)
-#define CALL_FMT_5 CALL_FMT_4, "d" (r6)
+#define CALL_FMT_0 "=&d" (r2) :
+#define CALL_FMT_1 "+&d" (r2) :
+#define CALL_FMT_2 CALL_FMT_1 "d" (r3),
+#define CALL_FMT_3 CALL_FMT_2 "d" (r4),
+#define CALL_FMT_4 CALL_FMT_3 "d" (r5),
+#define CALL_FMT_5 CALL_FMT_4 "d" (r6),
#define CALL_CLOBBER_5 "0", "1", "14", "cc", "memory"
#define CALL_CLOBBER_4 CALL_CLOBBER_5
@@ -286,10 +286,10 @@ static __no_kasan_or_inline unsigned short stap(void)
" stg %[_prev],%[_bc](15)\n" \
" brasl 14,%[_fn]\n" \
" la 15,0(%[_prev])\n" \
- : "+&d" (r2), [_prev] "=&a" (prev) \
- : [_stack] "a" (stack), \
+ : [_prev] "=&a" (prev), CALL_FMT_##nr \
+ [_stack] "a" (stack), \
[_bc] "i" (offsetof(struct stack_frame, back_chain)), \
- [_fn] "X" (fn) CALL_FMT_##nr : CALL_CLOBBER_##nr); \
+ [_fn] "X" (fn) : CALL_CLOBBER_##nr); \
r2; \
})
--
2.16.4
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
next prev parent reply other threads:[~2019-04-10 13:56 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-08 21:26 [PATCH 01/12] s390: remove -fno-strength-reduce flag Arnd Bergmann
2019-04-08 21:26 ` [PATCH 02/12] s390: don't build vdso32 with clang Arnd Bergmann
2019-04-10 15:57 ` Martin Schwidefsky
2019-04-10 16:26 ` Nick Desaulniers
2019-04-10 19:00 ` Arnd Bergmann
2019-04-08 21:26 ` [PATCH 03/12] s390: purgatory: pass --target option to clang Arnd Bergmann
2019-04-08 22:03 ` Nathan Chancellor
2019-04-09 6:43 ` Arnd Bergmann
2019-04-09 16:30 ` Nathan Chancellor
2019-04-09 18:11 ` Nick Desaulniers
2019-04-08 21:26 ` [PATCH 04/12] s390: qeth: address type mismatch warning Arnd Bergmann
2019-04-08 22:16 ` Nathan Chancellor
2019-04-09 6:44 ` Arnd Bergmann
2019-04-10 15:58 ` Martin Schwidefsky
2019-04-08 21:26 ` [PATCH 05/12] s390: zcrypt: initialize variables before_use Arnd Bergmann
2019-04-08 22:31 ` Nathan Chancellor
2019-04-09 9:54 ` Harald Freudenberger
2019-04-09 10:13 ` Arnd Bergmann
2019-04-10 15:59 ` Martin Schwidefsky
2019-04-10 18:57 ` Arnd Bergmann
2019-04-11 7:40 ` Martin Schwidefsky
2019-04-08 21:26 ` [PATCH 06/12] s390: ctcm: fix ctcm_new_device error return code Arnd Bergmann
2019-04-08 22:33 ` Nathan Chancellor
2019-04-10 16:00 ` Martin Schwidefsky
2019-04-08 21:26 ` [PATCH 07/12] s390: cio: fix cio_irb declaration Arnd Bergmann
2019-04-08 22:35 ` Nathan Chancellor
2019-04-09 13:13 ` Sebastian Ott
2019-04-08 21:26 ` [PATCH 08/12] s390: syscall_wrapper: avoid clang warning Arnd Bergmann
2019-04-10 16:00 ` Martin Schwidefsky
2019-04-08 21:26 ` [PATCH 09/12] s390: make __load_psw_mask work with clang Arnd Bergmann
2019-04-10 16:01 ` Martin Schwidefsky
2019-04-08 21:26 ` [PATCH 10/12] s390: avoid __builtin_return_address(n) on clang Arnd Bergmann
2019-04-10 16:03 ` Martin Schwidefsky
2019-04-10 16:14 ` Steven Rostedt
2019-04-10 19:07 ` Arnd Bergmann
2019-04-11 7:32 ` Martin Schwidefsky
2019-04-08 21:26 ` [PATCH 11/12] s390: make chkbss work with clang Arnd Bergmann
2019-04-10 16:02 ` Martin Schwidefsky
2019-04-08 21:26 ` [PATCH 12/12] [PROBABLY WRONG] s390: void '0' constraint in inline assembly Arnd Bergmann
2019-04-10 13:55 ` Martin Schwidefsky [this message]
2019-04-10 16:35 ` Nick Desaulniers
2019-04-10 18:55 ` Arnd Bergmann
2019-04-10 15:57 ` [PATCH 01/12] s390: remove -fno-strength-reduce flag Martin Schwidefsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190410155513.1609f1a1@mschwideX1 \
--to=schwidefsky@de.ibm.com \
--cc=arnd@arndb.de \
--cc=clang-built-linux@googlegroups.com \
--cc=gor@linux.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox