linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] jump label: fix passing kbuild_cflags when checking for asm goto support
@ 2017-03-10 16:24 Gleb Fotengauer-Malinovskiy
  2017-03-10 17:04 ` Steven Rostedt
  0 siblings, 1 reply; 10+ messages in thread
From: Gleb Fotengauer-Malinovskiy @ 2017-03-10 16:24 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: David Lin, Steven Rostedt, Anton V. Boyarshinov, Dmitry V. Levin,
	Michal Marek, linux-kbuild, linux-kernel

The latest change of asm goto support check added passing of
KBUILD_CFLAGS to compiler.  When these flags reference gcc plugins,
there is a race condition between the build of these plugins and their
use in this asm goto support check.

This change moves the check before all these references are added
to KBUILD_CFLAGS.  This is correct because subsequent KBUILD_CFLAGS
modifications are not relevant to this check.

Reported-by: Anton V. Boyarshinov <boyarsh@altlinux.org>
Fixes: 35f860f9ba6a ("jump label: pass kbuild_cflags when checking for asm goto support")
Cc: stable@vger.kernel.org	# v4.10
Signed-off-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 Makefile | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 165cf97..7e3aade 100644
--- a/Makefile
+++ b/Makefile
@@ -653,6 +653,12 @@ KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \
 # Tell gcc to never replace conditional load with a non-conditional one
 KBUILD_CFLAGS	+= $(call cc-option,--param=allow-store-data-races=0)
 
+# check for 'asm goto'
+ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
+	KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
+	KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
+endif
+
 include scripts/Makefile.gcc-plugins
 
 ifdef CONFIG_READABLE_ASM
@@ -798,12 +804,6 @@ KBUILD_CFLAGS   += $(call cc-option,-Werror=incompatible-pointer-types)
 # use the deterministic mode of AR if available
 KBUILD_ARFLAGS := $(call ar-option,D)
 
-# check for 'asm goto'
-ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
-	KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
-	KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
-endif
-
 include scripts/Makefile.kasan
 include scripts/Makefile.extrawarn
 include scripts/Makefile.ubsan

-- 
glebfm

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] jump label: fix passing kbuild_cflags when checking for asm goto support
  2017-03-10 16:24 [PATCH] jump label: fix passing kbuild_cflags when checking for asm goto support Gleb Fotengauer-Malinovskiy
@ 2017-03-10 17:04 ` Steven Rostedt
  2017-03-10 17:39   ` Gleb Fotengauer-Malinovskiy
  0 siblings, 1 reply; 10+ messages in thread
From: Steven Rostedt @ 2017-03-10 17:04 UTC (permalink / raw)
  To: Gleb Fotengauer-Malinovskiy
  Cc: Masahiro Yamada, David Lin, Anton V. Boyarshinov,
	Dmitry V. Levin, Michal Marek, linux-kbuild, linux-kernel,
	Andrew Morton

On Fri, 10 Mar 2017 19:24:18 +0300
Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org> wrote:

> The latest change of asm goto support check added passing of
> KBUILD_CFLAGS to compiler.  When these flags reference gcc plugins,
> there is a race condition between the build of these plugins and their
> use in this asm goto support check.
> 
> This change moves the check before all these references are added
> to KBUILD_CFLAGS.  This is correct because subsequent KBUILD_CFLAGS
> modifications are not relevant to this check.

What exactly breaks when the race happens?

-- Steve

> 
> Reported-by: Anton V. Boyarshinov <boyarsh@altlinux.org>
> Fixes: 35f860f9ba6a ("jump label: pass kbuild_cflags when checking for asm goto support")
> Cc: stable@vger.kernel.org	# v4.10
> Signed-off-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---
>  Makefile | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 165cf97..7e3aade 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -653,6 +653,12 @@ KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \
>  # Tell gcc to never replace conditional load with a non-conditional one
>  KBUILD_CFLAGS	+= $(call cc-option,--param=allow-store-data-races=0)
>  
> +# check for 'asm goto'
> +ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
> +	KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
> +	KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
> +endif
> +
>  include scripts/Makefile.gcc-plugins
>  
>  ifdef CONFIG_READABLE_ASM
> @@ -798,12 +804,6 @@ KBUILD_CFLAGS   += $(call cc-option,-Werror=incompatible-pointer-types)
>  # use the deterministic mode of AR if available
>  KBUILD_ARFLAGS := $(call ar-option,D)
>  
> -# check for 'asm goto'
> -ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
> -	KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
> -	KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
> -endif
> -
>  include scripts/Makefile.kasan
>  include scripts/Makefile.extrawarn
>  include scripts/Makefile.ubsan
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] jump label: fix passing kbuild_cflags when checking for asm goto support
  2017-03-10 17:04 ` Steven Rostedt
@ 2017-03-10 17:39   ` Gleb Fotengauer-Malinovskiy
  2017-03-10 17:42     ` Steven Rostedt
  0 siblings, 1 reply; 10+ messages in thread
From: Gleb Fotengauer-Malinovskiy @ 2017-03-10 17:39 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Masahiro Yamada, David Lin, Anton V. Boyarshinov,
	Dmitry V. Levin, Michal Marek, linux-kbuild, linux-kernel,
	Andrew Morton

On Fri, Mar 10, 2017 at 12:04:22PM -0500, Steven Rostedt wrote:
> On Fri, 10 Mar 2017 19:24:18 +0300
> Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org> wrote:
> 
> > The latest change of asm goto support check added passing of
> > KBUILD_CFLAGS to compiler.  When these flags reference gcc plugins,
> > there is a race condition between the build of these plugins and their
> > use in this asm goto support check.
> > 
> > This change moves the check before all these references are added
> > to KBUILD_CFLAGS.  This is correct because subsequent KBUILD_CFLAGS
> > modifications are not relevant to this check.
> 
> What exactly breaks when the race happens?

Actually, this is not quite a race.  When you run "make bzImage" followed
by "make modules", the kernel is always built with HAVE_JUMP_LABEL
disabled, while the modules are built depending on CONFIG_JUMP_LABEL.
If HAVE_JUMP_LABEL macro happens to be different, modules are built
with undefined references:

ERROR: "static_key_slow_inc" [net/netfilter/xt_TEE.ko] undefined!
ERROR: "static_key_slow_dec" [net/netfilter/xt_TEE.ko] undefined!
ERROR: "static_key_slow_dec" [net/netfilter/nft_meta.ko] undefined!
ERROR: "static_key_slow_inc" [net/netfilter/nft_meta.ko] undefined!
ERROR: "nf_hooks_needed" [net/netfilter/ipvs/ip_vs.ko] undefined!
ERROR: "nf_hooks_needed" [net/ipv6/ipv6.ko] undefined!
ERROR: "static_key_count" [net/ipv6/ipv6.ko] undefined!
ERROR: "static_key_slow_inc" [net/ipv6/ipv6.ko] undefined!
ERROR: "nf_hooks_needed" [net/decnet/decnet.ko] undefined!

-- 
glebfm

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] jump label: fix passing kbuild_cflags when checking for asm goto support
  2017-03-10 17:39   ` Gleb Fotengauer-Malinovskiy
@ 2017-03-10 17:42     ` Steven Rostedt
  2017-03-10 17:55       ` [PATCH v2] " Gleb Fotengauer-Malinovskiy
  0 siblings, 1 reply; 10+ messages in thread
From: Steven Rostedt @ 2017-03-10 17:42 UTC (permalink / raw)
  To: Gleb Fotengauer-Malinovskiy
  Cc: Masahiro Yamada, David Lin, Anton V. Boyarshinov,
	Dmitry V. Levin, Michal Marek, linux-kbuild, linux-kernel,
	Andrew Morton

On Fri, 10 Mar 2017 20:39:52 +0300
Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org> wrote:

> On Fri, Mar 10, 2017 at 12:04:22PM -0500, Steven Rostedt wrote:
> > On Fri, 10 Mar 2017 19:24:18 +0300
> > Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org> wrote:
> >   
> > > The latest change of asm goto support check added passing of
> > > KBUILD_CFLAGS to compiler.  When these flags reference gcc plugins,
> > > there is a race condition between the build of these plugins and their
> > > use in this asm goto support check.
> > > 
> > > This change moves the check before all these references are added
> > > to KBUILD_CFLAGS.  This is correct because subsequent KBUILD_CFLAGS
> > > modifications are not relevant to this check.  
> > 
> > What exactly breaks when the race happens?  
> 
> Actually, this is not quite a race.  When you run "make bzImage" followed
> by "make modules", the kernel is always built with HAVE_JUMP_LABEL
> disabled, while the modules are built depending on CONFIG_JUMP_LABEL.
> If HAVE_JUMP_LABEL macro happens to be different, modules are built
> with undefined references:
> 
> ERROR: "static_key_slow_inc" [net/netfilter/xt_TEE.ko] undefined!
> ERROR: "static_key_slow_dec" [net/netfilter/xt_TEE.ko] undefined!
> ERROR: "static_key_slow_dec" [net/netfilter/nft_meta.ko] undefined!
> ERROR: "static_key_slow_inc" [net/netfilter/nft_meta.ko] undefined!
> ERROR: "nf_hooks_needed" [net/netfilter/ipvs/ip_vs.ko] undefined!
> ERROR: "nf_hooks_needed" [net/ipv6/ipv6.ko] undefined!
> ERROR: "static_key_count" [net/ipv6/ipv6.ko] undefined!
> ERROR: "static_key_slow_inc" [net/ipv6/ipv6.ko] undefined!
> ERROR: "nf_hooks_needed" [net/decnet/decnet.ko] undefined!
> 

Can you add the above info in the change log and repost?

Thanks,

-- Steve

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2] jump label: fix passing kbuild_cflags when checking for asm goto support
  2017-03-10 17:42     ` Steven Rostedt
@ 2017-03-10 17:55       ` Gleb Fotengauer-Malinovskiy
  2017-03-10 18:04         ` Steven Rostedt
                           ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Gleb Fotengauer-Malinovskiy @ 2017-03-10 17:55 UTC (permalink / raw)
  To: Masahiro Yamada, Steven Rostedt
  Cc: David Lin, Anton V. Boyarshinov, Dmitry V. Levin, Michal Marek,
	linux-kbuild, linux-kernel, Andrew Morton

The latest change of asm goto support check added passing of KBUILD_CFLAGS
to compiler.  When these flags reference gcc plugins that are not built yet,
the check fails.

When one runs "make bzImage" followed by "make modules", the kernel is always
built with HAVE_JUMP_LABEL disabled, while the modules are built depending on
CONFIG_JUMP_LABEL.  If HAVE_JUMP_LABEL macro happens to be different, modules
are built with undefined references, e.g.:

ERROR: "static_key_slow_inc" [net/netfilter/xt_TEE.ko] undefined!
ERROR: "static_key_slow_dec" [net/netfilter/xt_TEE.ko] undefined!
ERROR: "static_key_slow_dec" [net/netfilter/nft_meta.ko] undefined!
ERROR: "static_key_slow_inc" [net/netfilter/nft_meta.ko] undefined!
ERROR: "nf_hooks_needed" [net/netfilter/ipvs/ip_vs.ko] undefined!
ERROR: "nf_hooks_needed" [net/ipv6/ipv6.ko] undefined!
ERROR: "static_key_count" [net/ipv6/ipv6.ko] undefined!
ERROR: "static_key_slow_inc" [net/ipv6/ipv6.ko] undefined!

This change moves the check before all these references are added
to KBUILD_CFLAGS.  This is correct because subsequent KBUILD_CFLAGS
modifications are not relevant to this check.

Reported-by: Anton V. Boyarshinov <boyarsh@altlinux.org>
Fixes: 35f860f9ba6a ("jump label: pass kbuild_cflags when checking for asm goto support")
Cc: stable@vger.kernel.org	# v4.10
Signed-off-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: update description of the problem fixed by this patch

 Makefile | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 165cf97..7e3aade 100644
--- a/Makefile
+++ b/Makefile
@@ -653,6 +653,12 @@ KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \
 # Tell gcc to never replace conditional load with a non-conditional one
 KBUILD_CFLAGS	+= $(call cc-option,--param=allow-store-data-races=0)
 
+# check for 'asm goto'
+ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
+	KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
+	KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
+endif
+
 include scripts/Makefile.gcc-plugins
 
 ifdef CONFIG_READABLE_ASM
@@ -798,12 +804,6 @@ KBUILD_CFLAGS   += $(call cc-option,-Werror=incompatible-pointer-types)
 # use the deterministic mode of AR if available
 KBUILD_ARFLAGS := $(call ar-option,D)
 
-# check for 'asm goto'
-ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
-	KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
-	KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
-endif
-
 include scripts/Makefile.kasan
 include scripts/Makefile.extrawarn
 include scripts/Makefile.ubsan
-- 
glebfm

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] jump label: fix passing kbuild_cflags when checking for asm goto support
  2017-03-10 17:55       ` [PATCH v2] " Gleb Fotengauer-Malinovskiy
@ 2017-03-10 18:04         ` Steven Rostedt
  2017-03-10 18:30         ` David Lin
  2017-03-20 17:15         ` [PING PATCH " Gleb Fotengauer-Malinovskiy
  2 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2017-03-10 18:04 UTC (permalink / raw)
  To: Gleb Fotengauer-Malinovskiy
  Cc: Masahiro Yamada, David Lin, Anton V. Boyarshinov,
	Dmitry V. Levin, Michal Marek, linux-kbuild, linux-kernel,
	Andrew Morton


Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

Andrew, want to take this through your tree?

Thanks,

-- Steve


On Fri, 10 Mar 2017 20:55:36 +0300
Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org> wrote:

> The latest change of asm goto support check added passing of KBUILD_CFLAGS
> to compiler.  When these flags reference gcc plugins that are not built yet,
> the check fails.
> 
> When one runs "make bzImage" followed by "make modules", the kernel is always
> built with HAVE_JUMP_LABEL disabled, while the modules are built depending on
> CONFIG_JUMP_LABEL.  If HAVE_JUMP_LABEL macro happens to be different, modules
> are built with undefined references, e.g.:
> 
> ERROR: "static_key_slow_inc" [net/netfilter/xt_TEE.ko] undefined!
> ERROR: "static_key_slow_dec" [net/netfilter/xt_TEE.ko] undefined!
> ERROR: "static_key_slow_dec" [net/netfilter/nft_meta.ko] undefined!
> ERROR: "static_key_slow_inc" [net/netfilter/nft_meta.ko] undefined!
> ERROR: "nf_hooks_needed" [net/netfilter/ipvs/ip_vs.ko] undefined!
> ERROR: "nf_hooks_needed" [net/ipv6/ipv6.ko] undefined!
> ERROR: "static_key_count" [net/ipv6/ipv6.ko] undefined!
> ERROR: "static_key_slow_inc" [net/ipv6/ipv6.ko] undefined!
> 
> This change moves the check before all these references are added
> to KBUILD_CFLAGS.  This is correct because subsequent KBUILD_CFLAGS
> modifications are not relevant to this check.
> 
> Reported-by: Anton V. Boyarshinov <boyarsh@altlinux.org>
> Fixes: 35f860f9ba6a ("jump label: pass kbuild_cflags when checking for asm goto support")
> Cc: stable@vger.kernel.org	# v4.10
> Signed-off-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---
> v2: update description of the problem fixed by this patch
> 
>  Makefile | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 165cf97..7e3aade 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -653,6 +653,12 @@ KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \
>  # Tell gcc to never replace conditional load with a non-conditional one
>  KBUILD_CFLAGS	+= $(call cc-option,--param=allow-store-data-races=0)
>  
> +# check for 'asm goto'
> +ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
> +	KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
> +	KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
> +endif
> +
>  include scripts/Makefile.gcc-plugins
>  
>  ifdef CONFIG_READABLE_ASM
> @@ -798,12 +804,6 @@ KBUILD_CFLAGS   += $(call cc-option,-Werror=incompatible-pointer-types)
>  # use the deterministic mode of AR if available
>  KBUILD_ARFLAGS := $(call ar-option,D)
>  
> -# check for 'asm goto'
> -ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
> -	KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
> -	KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
> -endif
> -
>  include scripts/Makefile.kasan
>  include scripts/Makefile.extrawarn
>  include scripts/Makefile.ubsan

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] jump label: fix passing kbuild_cflags when checking for asm goto support
  2017-03-10 17:55       ` [PATCH v2] " Gleb Fotengauer-Malinovskiy
  2017-03-10 18:04         ` Steven Rostedt
@ 2017-03-10 18:30         ` David Lin
  2017-03-20 17:15         ` [PING PATCH " Gleb Fotengauer-Malinovskiy
  2 siblings, 0 replies; 10+ messages in thread
From: David Lin @ 2017-03-10 18:30 UTC (permalink / raw)
  To: Gleb Fotengauer-Malinovskiy
  Cc: Masahiro Yamada, Steven Rostedt, Anton V. Boyarshinov,
	Dmitry V. Levin, Michal Marek, linux-kbuild, linux-kernel,
	Andrew Morton

On Fri, Mar 10, 2017 at 9:55 AM, Gleb Fotengauer-Malinovskiy
<glebfm@altlinux.org> wrote:
>
> The latest change of asm goto support check added passing of KBUILD_CFLAGS
> to compiler.  When these flags reference gcc plugins that are not built yet,
> the check fails.
>
> When one runs "make bzImage" followed by "make modules", the kernel is always
> built with HAVE_JUMP_LABEL disabled, while the modules are built depending on
> CONFIG_JUMP_LABEL.  If HAVE_JUMP_LABEL macro happens to be different, modules
> are built with undefined references, e.g.:
>
> ERROR: "static_key_slow_inc" [net/netfilter/xt_TEE.ko] undefined!
> ERROR: "static_key_slow_dec" [net/netfilter/xt_TEE.ko] undefined!
> ERROR: "static_key_slow_dec" [net/netfilter/nft_meta.ko] undefined!
> ERROR: "static_key_slow_inc" [net/netfilter/nft_meta.ko] undefined!
> ERROR: "nf_hooks_needed" [net/netfilter/ipvs/ip_vs.ko] undefined!
> ERROR: "nf_hooks_needed" [net/ipv6/ipv6.ko] undefined!
> ERROR: "static_key_count" [net/ipv6/ipv6.ko] undefined!
> ERROR: "static_key_slow_inc" [net/ipv6/ipv6.ko] undefined!
>
> This change moves the check before all these references are added
> to KBUILD_CFLAGS.  This is correct because subsequent KBUILD_CFLAGS
> modifications are not relevant to this check.
>
> Reported-by: Anton V. Boyarshinov <boyarsh@altlinux.org>
> Fixes: 35f860f9ba6a ("jump label: pass kbuild_cflags when checking for asm goto support")
> Cc: stable@vger.kernel.org      # v4.10
> Signed-off-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---

Acked-by: David Lin <dtwlin@google.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PING PATCH v2] jump label: fix passing kbuild_cflags when checking for asm goto support
  2017-03-10 17:55       ` [PATCH v2] " Gleb Fotengauer-Malinovskiy
  2017-03-10 18:04         ` Steven Rostedt
  2017-03-10 18:30         ` David Lin
@ 2017-03-20 17:15         ` Gleb Fotengauer-Malinovskiy
  2017-03-21 17:48           ` Masahiro Yamada
  2 siblings, 1 reply; 10+ messages in thread
From: Gleb Fotengauer-Malinovskiy @ 2017-03-20 17:15 UTC (permalink / raw)
  To: Masahiro Yamada, Steven Rostedt
  Cc: David Lin, Anton V. Boyarshinov, Dmitry V. Levin, Michal Marek,
	linux-kbuild, linux-kernel, Andrew Morton

The latest change of asm goto support check added passing of KBUILD_CFLAGS
to compiler.  When these flags reference gcc plugins that are not built yet,
the check fails.

When one runs "make bzImage" followed by "make modules", the kernel is always
built with HAVE_JUMP_LABEL disabled, while the modules are built depending on
CONFIG_JUMP_LABEL.  If HAVE_JUMP_LABEL macro happens to be different, modules
are built with undefined references, e.g.:

ERROR: "static_key_slow_inc" [net/netfilter/xt_TEE.ko] undefined!
ERROR: "static_key_slow_dec" [net/netfilter/xt_TEE.ko] undefined!
ERROR: "static_key_slow_dec" [net/netfilter/nft_meta.ko] undefined!
ERROR: "static_key_slow_inc" [net/netfilter/nft_meta.ko] undefined!
ERROR: "nf_hooks_needed" [net/netfilter/ipvs/ip_vs.ko] undefined!
ERROR: "nf_hooks_needed" [net/ipv6/ipv6.ko] undefined!
ERROR: "static_key_count" [net/ipv6/ipv6.ko] undefined!
ERROR: "static_key_slow_inc" [net/ipv6/ipv6.ko] undefined!

This change moves the check before all these references are added
to KBUILD_CFLAGS.  This is correct because subsequent KBUILD_CFLAGS
modifications are not relevant to this check.

Reported-by: Anton V. Boyarshinov <boyarsh@altlinux.org>
Fixes: 35f860f9ba6a ("jump label: pass kbuild_cflags when checking for asm goto support")
Cc: stable@vger.kernel.org	# v4.10
Signed-off-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Acked-by: David Lin <dtwlin@google.com>
---
v2: update description of the problem fixed by this patch

 Makefile | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 165cf97..7e3aade 100644
--- a/Makefile
+++ b/Makefile
@@ -653,6 +653,12 @@ KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \
 # Tell gcc to never replace conditional load with a non-conditional one
 KBUILD_CFLAGS	+= $(call cc-option,--param=allow-store-data-races=0)
 
+# check for 'asm goto'
+ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
+	KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
+	KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
+endif
+
 include scripts/Makefile.gcc-plugins
 
 ifdef CONFIG_READABLE_ASM
@@ -798,12 +804,6 @@ KBUILD_CFLAGS   += $(call cc-option,-Werror=incompatible-pointer-types)
 # use the deterministic mode of AR if available
 KBUILD_ARFLAGS := $(call ar-option,D)
 
-# check for 'asm goto'
-ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
-	KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
-	KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
-endif
-
 include scripts/Makefile.kasan
 include scripts/Makefile.extrawarn
 include scripts/Makefile.ubsan

-- 
glebfm

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PING PATCH v2] jump label: fix passing kbuild_cflags when checking for asm goto support
  2017-03-20 17:15         ` [PING PATCH " Gleb Fotengauer-Malinovskiy
@ 2017-03-21 17:48           ` Masahiro Yamada
  2017-03-21 18:04             ` Steven Rostedt
  0 siblings, 1 reply; 10+ messages in thread
From: Masahiro Yamada @ 2017-03-21 17:48 UTC (permalink / raw)
  To: Gleb Fotengauer-Malinovskiy
  Cc: Steven Rostedt, David Lin, Anton V. Boyarshinov, Dmitry V. Levin,
	Michal Marek, Linux Kbuild mailing list,
	Linux Kernel Mailing List, Andrew Morton

2017-03-21 2:15 GMT+09:00 Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>:
> The latest change of asm goto support check added passing of KBUILD_CFLAGS
> to compiler.  When these flags reference gcc plugins that are not built yet,
> the check fails.
>
> When one runs "make bzImage" followed by "make modules", the kernel is always
> built with HAVE_JUMP_LABEL disabled, while the modules are built depending on
> CONFIG_JUMP_LABEL.  If HAVE_JUMP_LABEL macro happens to be different, modules
> are built with undefined references, e.g.:
>
> ERROR: "static_key_slow_inc" [net/netfilter/xt_TEE.ko] undefined!
> ERROR: "static_key_slow_dec" [net/netfilter/xt_TEE.ko] undefined!
> ERROR: "static_key_slow_dec" [net/netfilter/nft_meta.ko] undefined!
> ERROR: "static_key_slow_inc" [net/netfilter/nft_meta.ko] undefined!
> ERROR: "nf_hooks_needed" [net/netfilter/ipvs/ip_vs.ko] undefined!
> ERROR: "nf_hooks_needed" [net/ipv6/ipv6.ko] undefined!
> ERROR: "static_key_count" [net/ipv6/ipv6.ko] undefined!
> ERROR: "static_key_slow_inc" [net/ipv6/ipv6.ko] undefined!
>
> This change moves the check before all these references are added
> to KBUILD_CFLAGS.  This is correct because subsequent KBUILD_CFLAGS
> modifications are not relevant to this check.
>
> Reported-by: Anton V. Boyarshinov <boyarsh@altlinux.org>
> Fixes: 35f860f9ba6a ("jump label: pass kbuild_cflags when checking for asm goto support")
> Cc: stable@vger.kernel.org      # v4.10
> Signed-off-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> Acked-by: David Lin <dtwlin@google.com>
> ---
> v2: update description of the problem fixed by this patch
>


I assume this PING is addressed to me.

First, Steven asked Andrew to pick up this,
but I have not seen it in linux-next yet. So,

Applied to linux-kbuild/fixes.  Thanks!




-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PING PATCH v2] jump label: fix passing kbuild_cflags when checking for asm goto support
  2017-03-21 17:48           ` Masahiro Yamada
@ 2017-03-21 18:04             ` Steven Rostedt
  0 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2017-03-21 18:04 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Gleb Fotengauer-Malinovskiy, David Lin, Anton V. Boyarshinov,
	Dmitry V. Levin, Michal Marek, Linux Kbuild mailing list,
	Linux Kernel Mailing List, Andrew Morton

On Wed, 22 Mar 2017 02:48:44 +0900
Masahiro Yamada <yamada.masahiro@socionext.com> wrote:

> 
> I assume this PING is addressed to me.
> 
> First, Steven asked Andrew to pick up this,
> but I have not seen it in linux-next yet. So,
> 
> Applied to linux-kbuild/fixes.  Thanks!

Thanks Masahiro!

-- Steve

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-03-21 18:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-10 16:24 [PATCH] jump label: fix passing kbuild_cflags when checking for asm goto support Gleb Fotengauer-Malinovskiy
2017-03-10 17:04 ` Steven Rostedt
2017-03-10 17:39   ` Gleb Fotengauer-Malinovskiy
2017-03-10 17:42     ` Steven Rostedt
2017-03-10 17:55       ` [PATCH v2] " Gleb Fotengauer-Malinovskiy
2017-03-10 18:04         ` Steven Rostedt
2017-03-10 18:30         ` David Lin
2017-03-20 17:15         ` [PING PATCH " Gleb Fotengauer-Malinovskiy
2017-03-21 17:48           ` Masahiro Yamada
2017-03-21 18:04             ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).