All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/boot/compressed: enable -Wundef
@ 2021-04-22 19:04 Nick Desaulniers
  2021-04-22 19:21 ` Kees Cook
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Nick Desaulniers @ 2021-04-22 19:04 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov
  Cc: Nick Desaulniers, Nathan Chancellor, Joe Perches, x86,
	H. Peter Anvin, Kees Cook, Ard Biesheuvel, Arvind Sankar,
	Joerg Roedel, Masahiro Yamada, Nick Terrell, Martin Radev,
	Vincenzo Frascino, Andrey Konovalov, linux-kernel

A discussion around -Wundef showed that there were still a few boolean
Kconfigs where #if was used rather than #ifdef to guard different code.
Kconfig doesn't define boolean configs, which can result in -Wundef
warnings.

arch/x86/boot/compressed/Makefile resets the CFLAGS used for this
directory, and doesn't re-enable -Wundef as the top level Makefile does.
If re-added, with RANDOMIZE_BASE and X86_NEED_RELOCS disabled, the
following warnings are visible.

arch/x86/boot/compressed/misc.h:82:5: warning: 'CONFIG_RANDOMIZE_BASE'
is not defined, evaluates to 0 [-Wundef]
    ^
arch/x86/boot/compressed/misc.c:175:5: warning: 'CONFIG_X86_NEED_RELOCS'
is not defined, evaluates to 0 [-Wundef]
    ^

Simply fix these and re-enable this warning for this directory.

Suggested-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Joe Perches <joe@perches.com>
Link: https://github.com/ClangBuiltLinux/linux/issues/570
Link: https://lore.kernel.org/lkml/67f6cd269684c9aa8463ff4812c3b4605e6739c3.camel@perches.com/
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 arch/x86/boot/compressed/Makefile | 1 +
 arch/x86/boot/compressed/misc.c   | 2 +-
 arch/x86/boot/compressed/misc.h   | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index e0bc3988c3fa..77cc373c1036 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -30,6 +30,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
 
 KBUILD_CFLAGS := -m$(BITS) -O2
 KBUILD_CFLAGS += -fno-strict-aliasing -fPIE
+KBUILD_CFLAGS += -Wundef
 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
 cflags-$(CONFIG_X86_32) := -march=i386
 cflags-$(CONFIG_X86_64) := -mcmodel=small -mno-red-zone
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 267e7f93050e..3a214cc3239f 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -172,7 +172,7 @@ void __puthex(unsigned long value)
 	}
 }
 
-#if CONFIG_X86_NEED_RELOCS
+#ifdef CONFIG_X86_NEED_RELOCS
 static void handle_relocations(void *output, unsigned long output_len,
 			       unsigned long virt_addr)
 {
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
index 901ea5ebec22..b140f988a233 100644
--- a/arch/x86/boot/compressed/misc.h
+++ b/arch/x86/boot/compressed/misc.h
@@ -79,7 +79,7 @@ struct mem_vector {
 	u64 size;
 };
 
-#if CONFIG_RANDOMIZE_BASE
+#ifdef CONFIG_RANDOMIZE_BASE
 /* kaslr.c */
 void choose_random_location(unsigned long input,
 			    unsigned long input_size,

base-commit: 16fc44d6387e260f4932e9248b985837324705d8
-- 
2.31.1.498.g6c1eba8ee3d-goog


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

* Re: [PATCH] x86/boot/compressed: enable -Wundef
  2021-04-22 19:04 [PATCH] x86/boot/compressed: enable -Wundef Nick Desaulniers
@ 2021-04-22 19:21 ` Kees Cook
  2021-04-23  0:32 ` Nathan Chancellor
  2021-05-12 20:01 ` [tip: x86/urgent] x86/boot/compressed: Enable -Wundef tip-bot2 for Nick Desaulniers
  2 siblings, 0 replies; 5+ messages in thread
From: Kees Cook @ 2021-04-22 19:21 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Nathan Chancellor,
	Joe Perches, x86, H. Peter Anvin, Ard Biesheuvel, Arvind Sankar,
	Joerg Roedel, Masahiro Yamada, Nick Terrell, Martin Radev,
	Vincenzo Frascino, Andrey Konovalov, linux-kernel

On Thu, Apr 22, 2021 at 12:04:42PM -0700, Nick Desaulniers wrote:
> A discussion around -Wundef showed that there were still a few boolean
> Kconfigs where #if was used rather than #ifdef to guard different code.
> Kconfig doesn't define boolean configs, which can result in -Wundef
> warnings.
> 
> arch/x86/boot/compressed/Makefile resets the CFLAGS used for this
> directory, and doesn't re-enable -Wundef as the top level Makefile does.
> If re-added, with RANDOMIZE_BASE and X86_NEED_RELOCS disabled, the
> following warnings are visible.
> 
> arch/x86/boot/compressed/misc.h:82:5: warning: 'CONFIG_RANDOMIZE_BASE'
> is not defined, evaluates to 0 [-Wundef]
>     ^
> arch/x86/boot/compressed/misc.c:175:5: warning: 'CONFIG_X86_NEED_RELOCS'
> is not defined, evaluates to 0 [-Wundef]
>     ^
> 
> Simply fix these and re-enable this warning for this directory.
> 
> Suggested-by: Nathan Chancellor <nathan@kernel.org>
> Suggested-by: Joe Perches <joe@perches.com>
> Link: https://github.com/ClangBuiltLinux/linux/issues/570
> Link: https://lore.kernel.org/lkml/67f6cd269684c9aa8463ff4812c3b4605e6739c3.camel@perches.com/
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Thanks!

Acked-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

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

* Re: [PATCH] x86/boot/compressed: enable -Wundef
  2021-04-22 19:04 [PATCH] x86/boot/compressed: enable -Wundef Nick Desaulniers
  2021-04-22 19:21 ` Kees Cook
@ 2021-04-23  0:32 ` Nathan Chancellor
  2021-04-23  7:53   ` Borislav Petkov
  2021-05-12 20:01 ` [tip: x86/urgent] x86/boot/compressed: Enable -Wundef tip-bot2 for Nick Desaulniers
  2 siblings, 1 reply; 5+ messages in thread
From: Nathan Chancellor @ 2021-04-23  0:32 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Joe Perches, x86,
	H. Peter Anvin, Kees Cook, Ard Biesheuvel, Arvind Sankar,
	Joerg Roedel, Masahiro Yamada, Nick Terrell, Martin Radev,
	Vincenzo Frascino, Andrey Konovalov, linux-kernel

On Thu, Apr 22, 2021 at 12:04:42PM -0700, Nick Desaulniers wrote:
> A discussion around -Wundef showed that there were still a few boolean
> Kconfigs where #if was used rather than #ifdef to guard different code.
> Kconfig doesn't define boolean configs, which can result in -Wundef
> warnings.
> 
> arch/x86/boot/compressed/Makefile resets the CFLAGS used for this
> directory, and doesn't re-enable -Wundef as the top level Makefile does.
> If re-added, with RANDOMIZE_BASE and X86_NEED_RELOCS disabled, the
> following warnings are visible.
> 
> arch/x86/boot/compressed/misc.h:82:5: warning: 'CONFIG_RANDOMIZE_BASE'
> is not defined, evaluates to 0 [-Wundef]
>     ^
> arch/x86/boot/compressed/misc.c:175:5: warning: 'CONFIG_X86_NEED_RELOCS'
> is not defined, evaluates to 0 [-Wundef]
>     ^
> 
> Simply fix these and re-enable this warning for this directory.

I wonder if it is worth turning on -Wall for this directory...

> Suggested-by: Nathan Chancellor <nathan@kernel.org>
> Suggested-by: Joe Perches <joe@perches.com>
> Link: https://github.com/ClangBuiltLinux/linux/issues/570
> Link: https://lore.kernel.org/lkml/67f6cd269684c9aa8463ff4812c3b4605e6739c3.camel@perches.com/
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  arch/x86/boot/compressed/Makefile | 1 +
>  arch/x86/boot/compressed/misc.c   | 2 +-
>  arch/x86/boot/compressed/misc.h   | 2 +-
>  3 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
> index e0bc3988c3fa..77cc373c1036 100644
> --- a/arch/x86/boot/compressed/Makefile
> +++ b/arch/x86/boot/compressed/Makefile
> @@ -30,6 +30,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
>  
>  KBUILD_CFLAGS := -m$(BITS) -O2
>  KBUILD_CFLAGS += -fno-strict-aliasing -fPIE
> +KBUILD_CFLAGS += -Wundef
>  KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
>  cflags-$(CONFIG_X86_32) := -march=i386
>  cflags-$(CONFIG_X86_64) := -mcmodel=small -mno-red-zone
> diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
> index 267e7f93050e..3a214cc3239f 100644
> --- a/arch/x86/boot/compressed/misc.c
> +++ b/arch/x86/boot/compressed/misc.c
> @@ -172,7 +172,7 @@ void __puthex(unsigned long value)
>  	}
>  }
>  
> -#if CONFIG_X86_NEED_RELOCS
> +#ifdef CONFIG_X86_NEED_RELOCS
>  static void handle_relocations(void *output, unsigned long output_len,
>  			       unsigned long virt_addr)
>  {
> diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
> index 901ea5ebec22..b140f988a233 100644
> --- a/arch/x86/boot/compressed/misc.h
> +++ b/arch/x86/boot/compressed/misc.h
> @@ -79,7 +79,7 @@ struct mem_vector {
>  	u64 size;
>  };
>  
> -#if CONFIG_RANDOMIZE_BASE
> +#ifdef CONFIG_RANDOMIZE_BASE
>  /* kaslr.c */
>  void choose_random_location(unsigned long input,
>  			    unsigned long input_size,
> 
> base-commit: 16fc44d6387e260f4932e9248b985837324705d8
> -- 
> 2.31.1.498.g6c1eba8ee3d-goog
> 

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

* Re: [PATCH] x86/boot/compressed: enable -Wundef
  2021-04-23  0:32 ` Nathan Chancellor
@ 2021-04-23  7:53   ` Borislav Petkov
  0 siblings, 0 replies; 5+ messages in thread
From: Borislav Petkov @ 2021-04-23  7:53 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Nick Desaulniers, Thomas Gleixner, Ingo Molnar, Joe Perches, x86,
	H. Peter Anvin, Kees Cook, Ard Biesheuvel, Arvind Sankar,
	Joerg Roedel, Masahiro Yamada, Nick Terrell, Martin Radev,
	Vincenzo Frascino, Andrey Konovalov, linux-kernel

On Thu, Apr 22, 2021 at 05:32:21PM -0700, Nathan Chancellor wrote:
> I wonder if it is worth turning on -Wall for this directory...

Yeah, I don't see why not. That is, until someone sits down and converts
that file to include the toplevel Makefile flags...

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

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

* [tip: x86/urgent] x86/boot/compressed: Enable -Wundef
  2021-04-22 19:04 [PATCH] x86/boot/compressed: enable -Wundef Nick Desaulniers
  2021-04-22 19:21 ` Kees Cook
  2021-04-23  0:32 ` Nathan Chancellor
@ 2021-05-12 20:01 ` tip-bot2 for Nick Desaulniers
  2 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Nick Desaulniers @ 2021-05-12 20:01 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Nathan Chancellor, Joe Perches, Nick Desaulniers, Ingo Molnar,
	Kees Cook, x86, linux-kernel

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     a554e740b66a83c7560b30e6b50bece37555ced3
Gitweb:        https://git.kernel.org/tip/a554e740b66a83c7560b30e6b50bece37555ced3
Author:        Nick Desaulniers <ndesaulniers@google.com>
AuthorDate:    Thu, 22 Apr 2021 12:04:42 -07:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 12 May 2021 21:39:56 +02:00

x86/boot/compressed: Enable -Wundef

A discussion around -Wundef showed that there were still a few boolean
Kconfigs where #if was used rather than #ifdef to guard different code.
Kconfig doesn't define boolean configs, which can result in -Wundef
warnings.

arch/x86/boot/compressed/Makefile resets the CFLAGS used for this
directory, and doesn't re-enable -Wundef as the top level Makefile does.
If re-added, with RANDOMIZE_BASE and X86_NEED_RELOCS disabled, the
following warnings are visible.

  arch/x86/boot/compressed/misc.h:82:5: warning: 'CONFIG_RANDOMIZE_BASE'
  is not defined, evaluates to 0 [-Wundef]
      ^
  arch/x86/boot/compressed/misc.c:175:5: warning: 'CONFIG_X86_NEED_RELOCS'
  is not defined, evaluates to 0 [-Wundef]
      ^

Simply fix these and re-enable this warning for this directory.

Suggested-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20210422190450.3903999-1-ndesaulniers@google.com
---
 arch/x86/boot/compressed/Makefile | 1 +
 arch/x86/boot/compressed/misc.c   | 2 +-
 arch/x86/boot/compressed/misc.h   | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index 2a29752..431bf7f 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -30,6 +30,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
 
 KBUILD_CFLAGS := -m$(BITS) -O2
 KBUILD_CFLAGS += -fno-strict-aliasing -fPIE
+KBUILD_CFLAGS += -Wundef
 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
 cflags-$(CONFIG_X86_32) := -march=i386
 cflags-$(CONFIG_X86_64) := -mcmodel=small -mno-red-zone
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index dde042f..743f13e 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -172,7 +172,7 @@ void __puthex(unsigned long value)
 	}
 }
 
-#if CONFIG_X86_NEED_RELOCS
+#ifdef CONFIG_X86_NEED_RELOCS
 static void handle_relocations(void *output, unsigned long output_len,
 			       unsigned long virt_addr)
 {
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
index e5612f0..3113925 100644
--- a/arch/x86/boot/compressed/misc.h
+++ b/arch/x86/boot/compressed/misc.h
@@ -79,7 +79,7 @@ struct mem_vector {
 	u64 size;
 };
 
-#if CONFIG_RANDOMIZE_BASE
+#ifdef CONFIG_RANDOMIZE_BASE
 /* kaslr.c */
 void choose_random_location(unsigned long input,
 			    unsigned long input_size,

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

end of thread, other threads:[~2021-05-12 20:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 19:04 [PATCH] x86/boot/compressed: enable -Wundef Nick Desaulniers
2021-04-22 19:21 ` Kees Cook
2021-04-23  0:32 ` Nathan Chancellor
2021-04-23  7:53   ` Borislav Petkov
2021-05-12 20:01 ` [tip: x86/urgent] x86/boot/compressed: Enable -Wundef tip-bot2 for Nick Desaulniers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.