All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] b/arch/x86/mm/pti.c - make local symbols static
@ 2019-03-12  7:47 Valdis Klētnieks
  2019-03-13  0:02 ` Dave Hansen
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Valdis Klētnieks @ 2019-03-12  7:47 UTC (permalink / raw)
  To: Dave Hansen, Andy Lutomirski, Peter Zijlstra; +Cc: x86, linux-kernel

With 'make C=2 W=1', sparse and gcc both complain:

  CHECK   arch/x86/mm/pti.c
arch/x86/mm/pti.c:84:3: warning: symbol 'pti_mode' was not declared. Should it be static?
arch/x86/mm/pti.c:605:6: warning: symbol 'pti_set_kernel_image_nonglobal' was not declared. Should it be static?
  CC      arch/x86/mm/pti.o
arch/x86/mm/pti.c:605:6: warning: no previous prototype for 'pti_set_kernel_image_nonglobal' [-Wmissing-prototypes]
  605 | void pti_set_kernel_image_nonglobal(void)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

And indeed, the function at line 605 is only used locally. 'pti_mode' is more
subtle - there is another pti_mode in drivers/hwtracing/intel_th/pti.c, but
it's an array declared static, not an enum

Make both variables static.

Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>

---
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index 4fee5c3003ed..139b28a01ce4 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -77,7 +77,7 @@ static void __init pti_print_if_secure(const char *reason)
 		pr_info("%s\n", reason);
 }
 
-enum pti_mode {
+static enum pti_mode {
 	PTI_AUTO = 0,
 	PTI_FORCE_OFF,
 	PTI_FORCE_ON
@@ -602,7 +602,7 @@ static void pti_clone_kernel_text(void)
 	set_memory_global(start, (end_global - start) >> PAGE_SHIFT);
 }
 
-void pti_set_kernel_image_nonglobal(void)
+static void pti_set_kernel_image_nonglobal(void)
 {
 	/*
 	 * The identity map is created with PMDs, regardless of the


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

* Re: [PATCH] b/arch/x86/mm/pti.c - make local symbols static
  2019-03-12  7:47 [PATCH] b/arch/x86/mm/pti.c - make local symbols static Valdis Klētnieks
@ 2019-03-13  0:02 ` Dave Hansen
  2019-03-21 14:33   ` Thomas Gleixner
  2019-03-22 12:46 ` Thomas Gleixner
  2019-03-22 13:22 ` [tip:x86/urgent] x86/mm/pti: Make " tip-bot for Valdis Kletnieks
  2 siblings, 1 reply; 5+ messages in thread
From: Dave Hansen @ 2019-03-13  0:02 UTC (permalink / raw)
  To: Valdis Klētnieks, Dave Hansen, Andy Lutomirski, Peter Zijlstra
  Cc: x86, linux-kernel

> Make both variables static.

"pti_set_kernel_image_nonglobal(void)" is an awfully funny looking
variable. ;)

> Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
> 
> ---
> diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
> index 4fee5c3003ed..139b28a01ce4 100644
> --- a/arch/x86/mm/pti.c
> +++ b/arch/x86/mm/pti.c
> @@ -77,7 +77,7 @@ static void __init pti_print_if_secure(const char *reason)
>  		pr_info("%s\n", reason);
>  }
>  
> -enum pti_mode {
> +static enum pti_mode {

I'm struggling to figure out why we would want to do this.  If there's a
really good reason, I think we probably need to do it en masse:

$ grep -r '^enum.{' arch/x86/ | wc -l
48

>  	PTI_AUTO = 0,
>  	PTI_FORCE_OFF,
>  	PTI_FORCE_ON
> @@ -602,7 +602,7 @@ static void pti_clone_kernel_text(void)
>  	set_memory_global(start, (end_global - start) >> PAGE_SHIFT);
>  }
>  
> -void pti_set_kernel_image_nonglobal(void)
> +static void pti_set_kernel_image_nonglobal(void)

Yes, this function should be static.

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

* Re: [PATCH] b/arch/x86/mm/pti.c - make local symbols static
  2019-03-13  0:02 ` Dave Hansen
@ 2019-03-21 14:33   ` Thomas Gleixner
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Gleixner @ 2019-03-21 14:33 UTC (permalink / raw)
  To: Dave Hansen
  Cc: Valdis Klētnieks, Dave Hansen, Andy Lutomirski,
	Peter Zijlstra, x86, linux-kernel

On Tue, 12 Mar 2019, Dave Hansen wrote:

> > Make both variables static.
> 
> "pti_set_kernel_image_nonglobal(void)" is an awfully funny looking
> variable. ;)
> 
> > Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
> > 
> > ---
> > diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
> > index 4fee5c3003ed..139b28a01ce4 100644
> > --- a/arch/x86/mm/pti.c
> > +++ b/arch/x86/mm/pti.c
> > @@ -77,7 +77,7 @@ static void __init pti_print_if_secure(const char *reason)
> >  		pr_info("%s\n", reason);
> >  }
> >  
> > -enum pti_mode {
> > +static enum pti_mode {
> 
> I'm struggling to figure out why we would want to do this.  If there's a
> really good reason, I think we probably need to do it en masse:

Because its:

enum pti_mode {
 ....
} pti_mode;

So that's both enum and variable declaration. 

> $ grep -r '^enum.{' arch/x86/ | wc -l
> 48

In the other cases it's a enum declaration without declaring a variable at
the same time. Making them static would be obviously bogus.

Thanks,

	tglx

 

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

* Re: [PATCH] b/arch/x86/mm/pti.c - make local symbols static
  2019-03-12  7:47 [PATCH] b/arch/x86/mm/pti.c - make local symbols static Valdis Klētnieks
  2019-03-13  0:02 ` Dave Hansen
@ 2019-03-22 12:46 ` Thomas Gleixner
  2019-03-22 13:22 ` [tip:x86/urgent] x86/mm/pti: Make " tip-bot for Valdis Kletnieks
  2 siblings, 0 replies; 5+ messages in thread
From: Thomas Gleixner @ 2019-03-22 12:46 UTC (permalink / raw)
  To: Valdis Klētnieks
  Cc: Dave Hansen, Andy Lutomirski, Peter Zijlstra, x86, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 265 bytes --]

Valdis,

On Tue, 12 Mar 2019, Valdis Klētnieks wrote:

I've applied the lot, but I had to fixup the subject lines.

# git log path/to/file

gives you a decent hint on what the usual prefix and format is.

 'b/arch/x86/mm/pti.c -'

is obviously not.

Thanks,

	tglx

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

* [tip:x86/urgent] x86/mm/pti: Make local symbols static
  2019-03-12  7:47 [PATCH] b/arch/x86/mm/pti.c - make local symbols static Valdis Klētnieks
  2019-03-13  0:02 ` Dave Hansen
  2019-03-22 12:46 ` Thomas Gleixner
@ 2019-03-22 13:22 ` tip-bot for Valdis Kletnieks
  2 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Valdis Kletnieks @ 2019-03-22 13:22 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, linux-kernel, dave.hansen, tglx, hpa, mingo, luto,
	valdis.kletnieks

Commit-ID:  4fe64a62e04cfb2dc1daab0d8f05d212aa014161
Gitweb:     https://git.kernel.org/tip/4fe64a62e04cfb2dc1daab0d8f05d212aa014161
Author:     Valdis Kletnieks <valdis.kletnieks@vt.edu>
AuthorDate: Tue, 12 Mar 2019 03:47:53 -0400
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 22 Mar 2019 13:31:28 +0100

x86/mm/pti: Make local symbols static

With 'make C=2 W=1', sparse and gcc both complain:

  CHECK   arch/x86/mm/pti.c
arch/x86/mm/pti.c:84:3: warning: symbol 'pti_mode' was not declared. Should it be static?
arch/x86/mm/pti.c:605:6: warning: symbol 'pti_set_kernel_image_nonglobal' was not declared. Should it be static?
  CC      arch/x86/mm/pti.o
arch/x86/mm/pti.c:605:6: warning: no previous prototype for 'pti_set_kernel_image_nonglobal' [-Wmissing-prototypes]
  605 | void pti_set_kernel_image_nonglobal(void)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

pti_set_kernel_image_nonglobal() is only used locally. 'pti_mode' exists in
drivers/hwtracing/intel_th/pti.c as well, but it's a completely unrelated
local (static) symbol.

Make both static.

Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lkml.kernel.org/r/27680.1552376873@turing-police


---
 arch/x86/mm/pti.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index 4fee5c3003ed..139b28a01ce4 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -77,7 +77,7 @@ static void __init pti_print_if_secure(const char *reason)
 		pr_info("%s\n", reason);
 }
 
-enum pti_mode {
+static enum pti_mode {
 	PTI_AUTO = 0,
 	PTI_FORCE_OFF,
 	PTI_FORCE_ON
@@ -602,7 +602,7 @@ static void pti_clone_kernel_text(void)
 	set_memory_global(start, (end_global - start) >> PAGE_SHIFT);
 }
 
-void pti_set_kernel_image_nonglobal(void)
+static void pti_set_kernel_image_nonglobal(void)
 {
 	/*
 	 * The identity map is created with PMDs, regardless of the

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

end of thread, other threads:[~2019-03-22 13:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-12  7:47 [PATCH] b/arch/x86/mm/pti.c - make local symbols static Valdis Klētnieks
2019-03-13  0:02 ` Dave Hansen
2019-03-21 14:33   ` Thomas Gleixner
2019-03-22 12:46 ` Thomas Gleixner
2019-03-22 13:22 ` [tip:x86/urgent] x86/mm/pti: Make " tip-bot for Valdis Kletnieks

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.