Skip to contentSkip to conversation

native_save_fl() causes a warning

PATCH In review Jean Delvare 7 participants 11 messages Aug 3, 2018 – Aug 7, 2018

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

Hi Nick,

It seems that this linux kernel commit of yours:

commit d0a8d9378d16eb3c69bd8e6d23779fbdbee3a8c7

Author: Nick Desaulniers
Date:   Thu Jun 21 09:23:24 2018 -0700

x86/paravirt: Make native_save_fl() extern inline

introduced a new warning (with W=1):

./arch/x86/include/asm/irqflags.h:16:29: warning: no previous prototype for ‘native_save_fl’ [-Wmissing-prototypes]
extern inline unsigned long native_save_fl(void)

                             ^

Please fix it.

Secondly, I am quite curious why you changed only native_save_fl() from static inline to extern inline, when native_restore_fl(), native_irq_disable() and native_irq_enable() are equally referenced by address in arch/x86/kernel/paravirt.c and thus should suffer from the same problem. Can you explain?

Thanks,

Signature · 2 lines
Jean Delvare
SUSE L3 Support
#1 lore raw
Quoted 11 lines · Jean Delvare

Hi Nick,

It seems that this linux kernel commit of yours:

commit d0a8d9378d16eb3c69bd8e6d23779fbdbee3a8c7

Author: Nick Desaulniers
Date:   Thu Jun 21 09:23:24 2018 -0700

x86/paravirt: Make native_save_fl() extern inline

Quoted 7 lines

introduced a new warning (with W=1):

./arch/x86/include/asm/irqflags.h:16:29: warning: no previous prototype for ‘native_save_fl’ [-Wmissing-prototypes]
extern inline unsigned long native_save_fl(void)

                             ^

Please fix it.

Hi Jean, thanks for the report. David Laight also reported this warning; he tested a patch I sent him overnight.

Let me guess, you're using a version of GCC < 4.9? It seems that GCC < 4.9 will produce that warning for extern inline functions without previous declarations.

I'll add your Reported-By tag to the patch that I will send out in a few minutes.

Quoted 5 lines

Secondly, I am quite curious why you changed only native_save_fl() from static inline to extern inline, when native_restore_fl(), native_irq_disable() and native_irq_enable() are equally referenced by address in arch/x86/kernel/paravirt.c and thus should suffer from the same problem. Can you explain?

This is a good point. With native_save_fl, we were not able to boot the kernel at all. Maybe this was called from the boot sequence (maybe Juergen knows more)? It seems that the other functions aren't preventing us from booting, but maybe exercising other paths in paravirt would expose such an issue? Or maybe paravirt doesn't have the same calling convention requirements for those functions?

Is there a standard testing procedure for paravirt? I'd be happy to try it to see if we can expose more things that should have the same cleanup.

Signature · 2 lines
Thanks,
~Nick Desaulniers
#2 lore raw

PATCH 1/1 x86/irqflags: provide a declaration for native_save_fl

Fixes commit d0a8d9378d16 ("x86/paravirt: Make native_save_fl() extern inline").

It was reported that the above commit was causing users of gcc < 4.9 to observe -Werror=missing-prototypes errors.

Indeed, it seems that:
extern inline unsigned long native_save_fl(void) { return 0; }

compiled with -Werror=missing-prototypes produces this warning in gcc < 4.9, but not gcc >= 4.9.

---
 arch/x86/include/asm/irqflags.h | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/include/asm/irqflags.h +2 -0
index c4fc17220df9..c14f2a74b2be 100644
@@ -13,6 +13,8 @@
  * Interrupt control:
  */
 
+/* Declaration required for gcc < 4.9 to prevent -Werror=missing-prototypes */
+extern inline unsigned long native_save_fl(void);
 extern inline unsigned long native_save_fl(void)
 {
 	unsigned long flags;
Signature · 1 line
2.18.0.597.ga71716f1ad-goog
#3 lore raw

[tip:x86/urgent] x86/irqflags: Provide a declaration for native_save_fl

x86/irqflags: Provide a declaration for native_save_fl
Commit-ID:  208cbb32558907f68b3b2a081ca2337ac3744794
Gitweb:     https://git.kernel.org/tip/208cbb32558907f68b3b2a081ca2337ac3744794
Author:     Nick Desaulniers <[email protected]>
AuthorDate: Fri, 3 Aug 2018 10:05:50 -0700
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Sun, 5 Aug 2018 22:30:37 +0200

x86/irqflags: Provide a declaration for native_save_fl

It was reported that the commit d0a8d9378d16 is causing users of gcc < 4.9 to observe -Werror=missing-prototypes errors.

Indeed, it seems that:
extern inline unsigned long native_save_fl(void) { return 0; }

compiled with -Werror=missing-prototypes produces this warning in gcc < 4.9, but not gcc >= 4.9.

---
 arch/x86/include/asm/irqflags.h | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/include/asm/irqflags.h +2 -0
index c4fc17220df9..c14f2a74b2be 100644
@@ -13,6 +13,8 @@
  * Interrupt control:
  */
 
+/* Declaration required for gcc < 4.9 to prevent -Werror=missing-prototypes */
+extern inline unsigned long native_save_fl(void);
 extern inline unsigned long native_save_fl(void)
 {
 	unsigned long flags;
Tested-by David Laight Tested-by Sedat Dilek
#4 lore raw

Re: [tip:x86/urgent] x86/irqflags: Provide a declaration for native_save_fl

Quoted 28 lines · tip-bot for Nick Desaulniers
Commit-ID:  208cbb32558907f68b3b2a081ca2337ac3744794
Gitweb:     https://git.kernel.org/tip/208cbb32558907f68b3b2a081ca2337ac3744794
Author:     Nick Desaulniers <[email protected]>
AuthorDate: Fri, 3 Aug 2018 10:05:50 -0700
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Sun, 5 Aug 2018 22:30:37 +0200

x86/irqflags: Provide a declaration for native_save_fl

It was reported that the commit d0a8d9378d16 is causing users of gcc < 4.9 to observe -Werror=missing-prototypes errors.

Indeed, it seems that:
extern inline unsigned long native_save_fl(void) { return 0; }

compiled with -Werror=missing-prototypes produces this warning in gcc < 4.9, but not gcc >= 4.9.

Quoted 8 lines

Not sure if this was going to be cleaned up in an automated way, but looks like this commit message drops the comment to stable as to how far back it should go:

# 4.17, 4.14, 4.9, 4.4

also, there were tested by's reported:

--
Thanks,
~Nick Desaulniers

#5 lore raw

Re: [tip:x86/urgent] x86/irqflags: Provide a declaration for native_save_fl

Quoted 9 lines · Nick Desaulniers
Quoted 1 line · tip-bot for Nick Desaulniers

Not sure if this was going to be cleaned up in an automated way, but looks like this commit message drops the comment to stable as to how far back it should go:

# 4.17, 4.14, 4.9, 4.4

The Fixes tag is enough. If the upstream commit was backported, then the tools of the stable folks will find it and know exactly how far it needs to go back.

Quoted 4 lines

also, there were tested by's reported:

Which came in after I applied it....

Thanks,

tglx

#6 lore raw

Re: [tip:x86/urgent] x86/irqflags: Provide a declaration for native_save_fl

Quoted 10 lines · Thomas Gleixner
Quoted 8 lines · Nick Desaulniers
Quoted 1 line · tip-bot for Nick Desaulniers

Not sure if this was going to be cleaned up in an automated way, but looks like this commit message drops the comment to stable as to how far back it should go:

Quoted 5 lines
Quoted 1 line

# 4.17, 4.14, 4.9, 4.4

The Fixes tag is enough. If the upstream commit was backported, then the tools of the stable folks will find it and know exactly how far it needs to go back.

Oh, cool.

Quoted 6 lines
Quoted 4 lines

also, there were tested by's reported:

Which came in after I applied it....

I've seen other maintainers revise commit messages before sending pull requests along, but I guess that's problematic as anyone else who has pulled before the revision would then have a merge conflict.

Signature · 2 lines
Thanks,
~Nick Desaulniers
#7 lore raw

Re: [tip:x86/urgent] x86/irqflags: Provide a declaration for native_save_fl

Quoted 4 lines · Nick Desaulniers
Quoted 3 lines · Thomas Gleixner
Quoted 2 lines · Nick Desaulniers

also, there were tested by's reported:

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Which came in after I applied it....

I've seen other maintainers revise commit messages before sending pull requests along, but I guess that's problematic as anyone else who has pulled before the revision would then have a merge conflict.

In general I avoid redoing commits for that reason and others and one of the reasons why we have the Link: tag in the commit message is to be able to look up such additional information easily - assumed that the archives have not vanished from the planet.

Thanks,

tglx

Tested-by on v1 1/1
#8 lore raw

RE: [PATCH] x86/irqflags: provide a declaration for native_save_fl

In reply to Nick Desaulniers

From: Nick Desaulniers

Quoted 10 lines

Sent: 03 August 2018 18:06
Fixes commit d0a8d9378d16 ("x86/paravirt: Make native_save_fl() extern inline").

It was reported that the above commit was causing users of gcc < 4.9 to observe -Werror=missing-prototypes errors.

Indeed, it seems that:
extern inline unsigned long native_save_fl(void) { return 0; }

Quoted 7 lines

compiled with -Werror=missing-prototypes produces this warning in gcc < 4.9, but not gcc >= 4.9.

You can add my:

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

Tested-by
#9 lore raw

Re: [PATCH] x86/irqflags: provide a declaration for native_save_fl

Quoted 14 lines · David Laight

From: Nick Desaulniers

Quoted 13 lines

Sent: 03 August 2018 18:06
Fixes commit d0a8d9378d16 ("x86/paravirt: Make native_save_fl() extern inline").

It was reported that the above commit was causing users of gcc < 4.9 to observe -Werror=missing-prototypes errors.

Indeed, it seems that:
extern inline unsigned long native_save_fl(void) { return 0; }

compiled with -Werror=missing-prototypes produces this warning in gcc < 4.9, but not gcc >= 4.9.

Quoted 9 lines
Quoted 4 lines

You can add my:

On top of Linux v4.18-rc8 with clang version 7.0.0-svn338205.

- sed@ -

#10 lore raw
In reply to Nick Desaulniers
Quoted 37 lines · Nick Desaulniers
Quoted 11 lines · Jean Delvare

Hi Nick,

It seems that this linux kernel commit of yours:

commit d0a8d9378d16eb3c69bd8e6d23779fbdbee3a8c7

Author: Nick Desaulniers
Date:   Thu Jun 21 09:23:24 2018 -0700

x86/paravirt: Make native_save_fl() extern inline

Quoted 7 lines

introduced a new warning (with W=1):

./arch/x86/include/asm/irqflags.h:16:29: warning: no previous prototype for ‘native_save_fl’ [-Wmissing-prototypes]
extern inline unsigned long native_save_fl(void)

                             ^

Please fix it.

Hi Jean, thanks for the report. David Laight also reported this warning; he tested a patch I sent him overnight.

Let me guess, you're using a version of GCC < 4.9? It seems that GCC < 4.9 will produce that warning for extern inline functions without previous declarations.

I'll add your Reported-By tag to the patch that I will send out in a few minutes.

Quoted 5 lines

Secondly, I am quite curious why you changed only native_save_fl() from static inline to extern inline, when native_restore_fl(), native_irq_disable() and native_irq_enable() are equally referenced by address in arch/x86/kernel/paravirt.c and thus should suffer from the same problem. Can you explain?

Quoted 6 lines

This is a good point. With native_save_fl, we were not able to boot the kernel at all. Maybe this was called from the boot sequence (maybe Juergen knows more)? It seems that the other functions aren't preventing us from booting, but maybe exercising other paths in paravirt would expose such an issue? Or maybe paravirt doesn't have the same calling convention requirements for those functions?

The core issue these patches worked around was the automatic/heuristic generation of stack guard code by clang, which ended up clobbering %ecx/%rcx in a way not expected by the contract of the paravirt code. The only function affected by this problem was native_save_fl(), because only it has a C stack (and thus, has a stack that requires guarding).

The other functions could have been converted at the same time, and they will have to be converted if (down the line) somebody adds C stack variables to them. But, for now, the patch series seems to correctly work around this issue.

Quoted 3 lines

Is there a standard testing procedure for paravirt? I'd be happy to try it to see if we can expose more things that should have the same cleanup.

This bug was so obvious you just enabled CONFIG_PARAVIRT, built with CC=clang, and booted the x86_64 bzImage on any qemu. The minute the paravirt alternatives were patched in, it exploded.

Quoted 3 lines

--
Thanks,
~Nick Desaulniers