Skip to contentSkip to conversation

s390/jump_label: Correct asm contraint

PATCH In review Laura Abbott 2 participants 8 messages Jan 23, 2019 – Feb 20, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390/jump_label: Correct asm contraint

There's a build failure with gcc9:

./arch/s390/include/asm/jump_label.h: Assembler messages:
./arch/s390/include/asm/jump_label.h:23: Error: bad expression ./arch/s390/include/asm/jump_label.h:23: Error: junk at end of line, first unrecognized character is `r' make[1]: *** [scripts/Makefile.build:277: init/main.o] Error 1

According to the toolchain people, the actual issue is the use of "X" constraint which is too permissive. Switch to using "i" instead.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1668703

---
 arch/s390/include/asm/jump_label.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/include/asm/jump_label.h +2 -2
index e2d3e6c43395..41dabfd8518d 100644
@@ -22,7 +22,7 @@ static inline bool arch_static_branch(struct static_key *key, bool branch)
 			  ".long	0b-.,%l[label]-.\n"
 			  ".quad	%0-.\n"
 			  ".popsection\n"
-			  : : "X" (&((char *)key)[branch]) : : label);
+			  : : "i" (&((char *)key)[branch]) : : label);
 	return false;
 label:
 	return true;
@@ -36,7 +36,7 @@ static inline bool arch_static_branch_jump(struct static_key *key, bool branch)
 			  ".long	0b-.,%l[label]-.\n"
 			  ".quad	%0-.\n"
 			  ".popsection\n"
-			  : : "X" (&((char *)key)[branch]) : : label);
+			  : : "i" (&((char *)key)[branch]) : : label);
 	return false;
 label:
 	return true;
Signature · 1 line
2.20.1
#1 lore raw
Quoted 21 lines · Laura Abbott

There's a build failure with gcc9:

./arch/s390/include/asm/jump_label.h: Assembler messages:
./arch/s390/include/asm/jump_label.h:23: Error: bad expression ./arch/s390/include/asm/jump_label.h:23: Error: junk at end of line, first unrecognized character is `r' make[1]: *** [scripts/Makefile.build:277: init/main.o] Error 1

According to the toolchain people, the actual issue is the use of "X" constraint which is too permissive. Switch to using "i" instead.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1668703

---
 arch/s390/include/asm/jump_label.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/include/asm/jump_label.h +0 -0
index e2d3e6c43395..41dabfd8518d 100644

arch/s390/include/asm/jump_label.h static inline bool arch_static_branch(struct static_key *key, bool branch) · line 28

Quoted 8 lines
arch/s390/include/asm/jump_label.h +1 -1
@@ -22,7 +22,7 @@ static inline bool arch_static_branch(struct static_key *key, bool branch)
 			  ".long	0b-.,%l[label]-.\n"
 			  ".quad	%0-.\n"
 			  ".popsection\n"
-			  : : "X" (&((char *)key)[branch]) : : label);
+			  : : "i" (&((char *)key)[branch]) : : label);
 	return false;
 label:
 	return true;

Hmmm, this works only for the kernel image, but not for modules, which we compile with "-fPIC", which again doesn't work as described in the referenced bugzilla:

In file included from ././include/linux/compiler_types.h:68,
from <command-line>:
./arch/s390/include/asm/jump_label.h: In function 'kvm_vcpu_ioctl':
./include/linux/compiler-gcc.h:124:38: warning: asm operand 0 probably doesn't match constraints

 #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
                                      ^~~

./arch/s390/include/asm/jump_label.h:19:2: note: in expansion of macro 'asm_volatile_goto'
asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n" ^~~~~~~~~~~~~~~~~
./include/linux/compiler-gcc.h:124:38: error: impossible constraint in 'asm'

 #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
                                      ^~~

./arch/s390/include/asm/jump_label.h:19:2: note: in expansion of macro 'asm_volatile_goto'
asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n"

Andreas, Ilya, any idea how to fix this?

#2 lore raw
Quoted 45 lines · Heiko Carstens
Quoted 21 lines · Laura Abbott

There's a build failure with gcc9:

./arch/s390/include/asm/jump_label.h: Assembler messages:
./arch/s390/include/asm/jump_label.h:23: Error: bad expression ./arch/s390/include/asm/jump_label.h:23: Error: junk at end of line, first unrecognized character is `r' make[1]: *** [scripts/Makefile.build:277: init/main.o] Error 1

According to the toolchain people, the actual issue is the use of "X" constraint which is too permissive. Switch to using "i" instead.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1668703

---
  arch/s390/include/asm/jump_label.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/include/asm/jump_label.h +0 -0
index e2d3e6c43395..41dabfd8518d 100644

arch/s390/include/asm/jump_label.h static inline bool arch_static_branch(struct static_key *key, bool branch) · line 28

Quoted 8 lines
arch/s390/include/asm/jump_label.h +1 -1
@@ -22,7 +22,7 @@ static inline bool arch_static_branch(struct static_key *key, bool branch)
  			  ".long	0b-.,%l[label]-.\n"
  			  ".quad	%0-.\n"
  			  ".popsection\n"
-			  : : "X" (&((char *)key)[branch]) : : label);
+			  : : "i" (&((char *)key)[branch]) : : label);
  	return false;
  label:
  	return true;

Hmmm, this works only for the kernel image, but not for modules, which we compile with "-fPIC", which again doesn't work as described in the referenced bugzilla:

In file included from ././include/linux/compiler_types.h:68,
from <command-line>:
./arch/s390/include/asm/jump_label.h: In function 'kvm_vcpu_ioctl':
./include/linux/compiler-gcc.h:124:38: warning: asm operand 0 probably doesn't match constraints

  #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
                                       ^~~

./arch/s390/include/asm/jump_label.h:19:2: note: in expansion of macro 'asm_volatile_goto'
asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n" ^~~~~~~~~~~~~~~~~
./include/linux/compiler-gcc.h:124:38: error: impossible constraint in 'asm'

Quoted 7 lines
  #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
                                       ^~~

./arch/s390/include/asm/jump_label.h:19:2: note: in expansion of macro 'asm_volatile_goto'
asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n"

Andreas, Ilya, any idea how to fix this?

I've had to turn off s390 in Fedora until this gets fixed :(

#3 lore raw
Quoted 3 lines · Laura Abbott
Quoted 2 lines · Heiko Carstens
Quoted 1 line · Laura Abbott

There's a build failure with gcc9:

...

Quoted 10 lines
Quoted 8 lines

Hmmm, this works only for the kernel image, but not for modules, which we compile with "-fPIC", which again doesn't work as described in the referenced bugzilla:

                                      ^~~

./arch/s390/include/asm/jump_label.h:19:2: note: in expansion of macro 'asm_volatile_goto'
asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n"

Andreas, Ilya, any idea how to fix this?

I've had to turn off s390 in Fedora until this gets fixed :(

I assume this means you only turned off CONFIG_JUMP_LABEL on s390 until we have a fix for this?

#4 lore raw
In reply to Laura Abbott
Quoted 8 lines · Laura Abbott
Quoted 7 lines · Heiko Carstens
Quoted 6 lines · Laura Abbott

There's a build failure with gcc9:

./arch/s390/include/asm/jump_label.h: Assembler messages:
./arch/s390/include/asm/jump_label.h:23: Error: bad expression ./arch/s390/include/asm/jump_label.h:23: Error: junk at end of line, first unrecognized character is `r' make[1]: *** [scripts/Makefile.build:277: init/main.o] Error 1

...

Quoted 1 line

I've had to turn off s390 in Fedora until this gets fixed :(

Laura, the patch below should fix this (temporarily). If possible, could you give it a try? It seems to work for me.

rom 4067027c2ccc8d3f1dc3bb19fe2d00da0c65bcd8 Mon Sep 17 00:00:00 2001
From: Heiko Carstens <[email protected]>
Date: Tue, 5 Feb 2019 13:21:56 +0100
Subject: [PATCH] s390: disable section anchors

Disable section anchors to allow to compile with the current gcc 9 experimental version. The section anchors is a new feature for s390 with gcc 9, however it breaks our current usage of the 'X' constraint within the asm goto construct within our jump label implementation.

Fixing this seems to be non-trivial, therefore (hopefully) temporarily disable section anchors. We will hopefully have a better solution before gcc 9 is released, so that this can be removed again.

---
 arch/s390/Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/s390/Makefile +8 -0
index e21053e5e0da..1eac75bc3a29 100644
@@ -62,6 +62,14 @@ cflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
 #
 cflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
 
+#
+# Disable section anchors. This gcc 9 feature currently breaks the 'X'
+# constraint like it is used in the asm goto construct.
+#
+ifeq ($(call cc-option-yn,-fno-section-anchors),y)
+cflags-y += -fno-section-anchors
+endif
+
 ifeq ($(call cc-option-yn,-mpacked-stack),y)
 cflags-$(CONFIG_PACK_STACK)  += -mpacked-stack -D__PACK_STACK
 aflags-$(CONFIG_PACK_STACK)  += -D__PACK_STACK
Signature · 1 line
2.16.4
author Tested-by
#5 lore raw
Quoted 46 lines · Heiko Carstens
Quoted 8 lines · Laura Abbott
Quoted 7 lines · Heiko Carstens
Quoted 6 lines · Laura Abbott

There's a build failure with gcc9:

./arch/s390/include/asm/jump_label.h: Assembler messages:
./arch/s390/include/asm/jump_label.h:23: Error: bad expression ./arch/s390/include/asm/jump_label.h:23: Error: junk at end of line, first unrecognized character is `r' make[1]: *** [scripts/Makefile.build:277: init/main.o] Error 1

...

Quoted 1 line

I've had to turn off s390 in Fedora until this gets fixed :(

Laura, the patch below should fix this (temporarily). If possible, could you give it a try? It seems to work for me.

rom 4067027c2ccc8d3f1dc3bb19fe2d00da0c65bcd8 Mon Sep 17 00:00:00 2001
From: Heiko Carstens <[email protected]>
Date: Tue, 5 Feb 2019 13:21:56 +0100
Subject: [PATCH] s390: disable section anchors

Disable section anchors to allow to compile with the current gcc 9 experimental version. The section anchors is a new feature for s390 with gcc 9, however it breaks our current usage of the 'X' constraint within the asm goto construct within our jump label implementation.

Fixing this seems to be non-trivial, therefore (hopefully) temporarily disable section anchors. We will hopefully have a better solution before gcc 9 is released, so that this can be removed again.

---
  arch/s390/Makefile | 8 ++++++++
  1 file changed, 8 insertions(+)
arch/s390/Makefile +1 -0
index e21053e5e0da..1eac75bc3a29 100644
@@ -62,6 +62,14 @@ cflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
  #
  cflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
 
+#

arch/s390/Makefile cflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include · line 75

Quoted 10 lines
arch/s390/Makefile +7 -0
+# Disable section anchors. This gcc 9 feature currently breaks the 'X'
+# constraint like it is used in the asm goto construct.
+#
+ifeq ($(call cc-option-yn,-fno-section-anchors),y)
+cflags-y += -fno-section-anchors
+endif
+
  ifeq ($(call cc-option-yn,-mpacked-stack),y)
  cflags-$(CONFIG_PACK_STACK)  += -mpacked-stack -D__PACK_STACK
  aflags-$(CONFIG_PACK_STACK)  += -D__PACK_STACK
#6 lore raw
Quoted 10 lines · Laura Abbott
Quoted 9 lines · Heiko Carstens
Quoted 8 lines · Laura Abbott
Quoted 7 lines · Heiko Carstens
Quoted 6 lines · Laura Abbott

There's a build failure with gcc9:

./arch/s390/include/asm/jump_label.h: Assembler messages:
./arch/s390/include/asm/jump_label.h:23: Error: bad expression ./arch/s390/include/asm/jump_label.h:23: Error: junk at end of line, first unrecognized character is `r' make[1]: *** [scripts/Makefile.build:277: init/main.o] Error 1

Quoted 8 lines
Quoted 7 lines

...

Quoted 1 line

I've had to turn off s390 in Fedora until this gets fixed :(

Laura, the patch below should fix this (temporarily). If possible, could you give it a try? It seems to work for me.

Subject: [PATCH] s390: disable section anchors

The patch won't be used. In the meantime Ilya provided a gcc 9 and kernel patch which should fix this. The kernel patch is available here
https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=features&id=146448524bddbf6dfc62de31957e428de001cbda
and will go upstream during the next merge window.

Note: this obviously also requires to update the gcc 9 version in Fedora, so it contains Ilya's patch, to be able to compile the kernel.

Thanks,
Heiko

#7 lore raw
Quoted 25 lines · Heiko Carstens
Quoted 10 lines · Laura Abbott
Quoted 9 lines · Heiko Carstens
Quoted 8 lines · Laura Abbott
Quoted 7 lines · Heiko Carstens
Quoted 6 lines · Laura Abbott

There's a build failure with gcc9:

./arch/s390/include/asm/jump_label.h: Assembler messages:
./arch/s390/include/asm/jump_label.h:23: Error: bad expression ./arch/s390/include/asm/jump_label.h:23: Error: junk at end of line, first unrecognized character is `r' make[1]: *** [scripts/Makefile.build:277: init/main.o] Error 1

Quoted 8 lines
Quoted 7 lines

...

Quoted 1 line

I've had to turn off s390 in Fedora until this gets fixed :(

Laura, the patch below should fix this (temporarily). If possible, could you give it a try? It seems to work for me.

Subject: [PATCH] s390: disable section anchors

The patch won't be used. In the meantime Ilya provided a gcc 9 and kernel patch which should fix this. The kernel patch is available here
https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=features&id=146448524bddbf6dfc62de31957e428de001cbda
and will go upstream during the next merge window.

Quoted 6 lines

Note: this obviously also requires to update the gcc 9 version in Fedora, so it contains Ilya's patch, to be able to compile the kernel.

Thanks,
Heiko

Thanks. I'll keep an eye out for that during the next merge window.