linux-next: build warning after merge of the tip tree
Subsystems (2)
Hi all,
After merging the tip tree, today's linux-next build (arm multi_v7_defconfig) produced this warning:
kernel/futex.c: In function 'do_futex':kernel/futex.c:1676:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized]
1676 | return oldval == cmparg;
| ~~~~~~~^~~~~~~~~
kernel/futex.c:1652:6: note: 'oldval' was declared here
1652 | int oldval, ret;
| ^~~~~~Introduced by commit
a08971e9488d ("futex: arch_futex_atomic_op_inuser() calling conventions change")
but I don't see how it makes this difference :-(
Signature · 2 lines
Cheers, Stephen Rothwell
Hi all,
Quoted 14 lines · On Mon, 30 Mar 2020 13:47:46 +1100 Stephen Rothwell <[email protected]>…
Hi all,
After merging the tip tree, today's linux-next build (arm
multi_v7_defconfig) produced this warning:
kernel/futex.c: In function 'do_futex':kernel/futex.c:1676:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized]1676 | return oldval == cmparg; | ~~~~~~~^~~~~~~~~ kernel/futex.c:1652:6: note: 'oldval' was declared here 1652 | int oldval, ret; | ^~~~~~
Quoted 5 lines
Introduced by commit
a08971e9488d("futex:arch_futex_atomic_op_inuser()calling conventions change")but I don't see how it makes this difference :-(
I now get this warning from building Linus' tree :-(
Signature · 2 lines
Cheers, Stephen Rothwell
Quoted 21 lines · Stephen Rothwell
Hi all,
Quoted 18 lines · On Mon, 30 Mar 2020 13:47:46 +1100 Stephen Rothwell <[email protected]>…
Hi all,
After merging the tip tree, today's linux-next build (arm
multi_v7_defconfig) produced this warning:
kernel/futex.c: In function 'do_futex':kernel/futex.c:1676:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized]1676 | return oldval == cmparg; | ~~~~~~~^~~~~~~~~ kernel/futex.c:1652:6: note: 'oldval' was declared here 1652 | int oldval, ret; | ^~~~~~Introduced by commit
a08971e9488d("futex:arch_futex_atomic_op_inuser()calling conventions change")
Huch?
Quoted 1 line
Quoted 1 line
but I don't see how it makes this difference :-(
Me neither. Which compiler version?
I'm using arm-linux-gnueabi-gcc (Debian 8.3.0-2) 8.3.0 which does not show that oddity.
Thanks,
tglx
Hi Thomas,
Quoted 18 lines · On Wed, 01 Apr 2020 12:25:25 +0200 Thomas Gleixner <[email protected]> wrote:
Quoted 16 lines · Stephen Rothwell
Quoted 14 lines · On Mon, 30 Mar 2020 13:47:46 +1100 Stephen Rothwell <[email protected]>…
After merging the tip tree, today's linux-next build (arm
multi_v7_defconfig) produced this warning:
kernel/futex.c: In function 'do_futex':kernel/futex.c:1676:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized]1676 | return oldval == cmparg; | ~~~~~~~^~~~~~~~~ kernel/futex.c:1652:6: note: 'oldval' was declared here 1652 | int oldval, ret; | ^~~~~~Introduced by commit
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
a08971e9488d("futex:arch_futex_atomic_op_inuser()calling conventions change")Huch?
Quoted 1 line
Quoted 1 line
but I don't arm-linux-gnueabi-gcc (Debian 9.2.1-21) 9.2.1 20191130see how it makes this difference :-(
Me neither. Which compiler version?
arm-linux-gnueabi-gcc (Debian 9.2.1-21) 9.2.1 20191130
Quoted 2 lines
I'm using arm-linux-gnueabi-gcc (Debian 8.3.0-2) 8.3.0 which does not show that oddity.
I assume it is because of the change to arch_futex_atomic_op_inuser() for arm and the compiler is not clever enough to work out that the early return from arch_futex_atomic_op_inuser() means that oldval is not referenced in its caller.
Signature · 2 lines
Cheers, Stephen Rothwell
Stephen,
Quoted 5 lines · Stephen Rothwell
Quoted 1 line · On Wed, 01 Apr 2020 12:25:25 +0200 Thomas Gleixner <[email protected]> wrote:
Me neither. Which compiler version?
arm-linux-gnueabi-gcc (Debian 9.2.1-21) 9.2.1 20191130
Quoted 7 lines
Quoted 2 lines
I'm using arm-linux-gnueabi-gcc (Debian 8.3.0-2) 8.3.0 which does not show that oddity.
I assume it is because of the change to
arch_futex_atomic_op_inuser()for arm and the compiler is not clever enough to work out that the early return fromarch_futex_atomic_op_inuser()means that oldval is not referenced in its caller.
Actually no. It's the ASM part which causes this. With the following hack applied it compiles:
arch/arm/include/asm/futex.h +3 -1
@@ -132,7 +132,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,static inline int arch_futex_atomic_op_inuser (int op,int oparg,int *oval,u32 __user *uaddr) { -int oldval =0 , ret, tmp; +int oldval =0 , ret;if (!access_ok (uaddr,sizeof (u32)))return -EFAULT ;
@@ -142,6 +142,7 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)#endif switch (op) { +#if 0 case FUTEX_OP_SET :__futex_atomic_op ("mov %0, %4" , ret, oldval, tmp, uaddr, oparg);break ;
@@ -157,6 +158,7 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)case FUTEX_OP_XOR :__futex_atomic_op ("eor %0, %1, %4" , ret, oldval, tmp, uaddr, oparg);break ; +#endif default : ret = -ENOSYS ; }
but with this is emits the warning:
arch/arm/include/asm/futex.h +2 -0
@@ -145,6 +145,7 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)case FUTEX_OP_SET :__futex_atomic_op ("mov %0, %4" , ret, oldval, tmp, uaddr, oparg);break ; +#if 0 case FUTEX_OP_ADD :__futex_atomic_op ("add %0, %1, %4" , ret, oldval, tmp, uaddr, oparg);break ;
@@ -157,6 +158,7 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)case FUTEX_OP_XOR :__futex_atomic_op ("eor %0, %1, %4" , ret, oldval, tmp, uaddr, oparg);break ; +#endif default : ret = -ENOSYS ; }
and the below proves it:
arch/arm/include/asm/futex.h +7 -2
@@ -165,8 +165,13 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)preempt_enable ();#endif -if (!ret) - *oval = oldval; +/* +* Store unconditionally. If ret != 0 the extra store is the least +* of the worries but GCC cannot figure out that __futex_atomic_op() +* is either setting ret to -EFAULT or storing the old value in +* oldval which results in a uninitialized warning at the call site. +*/ + *oval = oldval;return ret; }
I think that's the right thing to do anyway. The conditional is pointless.
Thanks,
tglx
Hi Thomas,
Quoted 94 lines · On Thu, 02 Apr 2020 00:39:55 +0200 Thomas Gleixner <[email protected]> wrote:
Quoted 5 lines · Stephen Rothwell
Quoted 1 line · On Wed, 01 Apr 2020 12:25:25 +0200 Thomas Gleixner <[email protected]> wrote:
Me neither. Which compiler version?
arm-linux-gnueabi-gcc (Debian 9.2.1-21) 9.2.1 20191130
Quoted 7 lines
Quoted 2 lines
I'm using arm-linux-gnueabi-gcc (Debian 8.3.0-2) 8.3.0 which does not show that oddity.
I assume it is because of the change to
arch_futex_atomic_op_inuser()for arm and the compiler is not clever enough to work out that the early return fromarch_futex_atomic_op_inuser()means that oldval is not referenced in its caller.Actually no. It's the ASM part which causes this. With the following hack applied it compiles:
arch/arm/include/asm/futex.h +3
-1@@ -132,7 +132,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,static inline int arch_futex_atomic_op_inuser (int op,int oparg,int *oval,u32 __user *uaddr) { -int oldval =0 , ret, tmp; +int oldval =0 , ret;if (!access_ok (uaddr,sizeof (u32)))return -EFAULT ;@@ -142,6 +142,7 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)#endif switch (op) { +#if 0 case FUTEX_OP_SET :__futex_atomic_op ("mov %0, %4" , ret, oldval, tmp, uaddr, oparg);break ;@@ -157,6 +158,7 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)case FUTEX_OP_XOR :__futex_atomic_op ("eor %0, %1, %4" , ret, oldval, tmp, uaddr, oparg);break ; +#endif default : ret = -ENOSYS ; }but with this is emits the warning:
arch/arm/include/asm/futex.h +2
-0@@ -145,6 +145,7 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)case FUTEX_OP_SET :__futex_atomic_op ("mov %0, %4" , ret, oldval, tmp, uaddr, oparg);break ; +#if 0 case FUTEX_OP_ADD :__futex_atomic_op ("add %0, %1, %4" , ret, oldval, tmp, uaddr, oparg);break ;@@ -157,6 +158,7 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)case FUTEX_OP_XOR :__futex_atomic_op ("eor %0, %1, %4" , ret, oldval, tmp, uaddr, oparg);break ; +#endif default : ret = -ENOSYS ; }and the below proves it:
arch/arm/include/asm/futex.h +7
-2@@ -165,8 +165,13 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)preempt_enable ();#endif -if (!ret) - *oval = oldval; +/* +* Store unconditionally. If ret != 0 the extra store is the least +* of the worries but GCC cannot figure out that __futex_atomic_op() +* is either setting ret to -EFAULT or storing the old value in +* oldval which results in a uninitialized warning at the call site. +*/ + *oval = oldval;return ret; }
Quoted 1 line
I think that's the right thing to do anyway. The conditional is pointless.
Thanks for the analysis.
I am still getting this warning, now from Linus' tree builds.
Signature · 2 lines
Cheers, Stephen Rothwell
Stephen,
Quoted 21 lines · Stephen Rothwell
Quoted 20 lines · On Thu, 02 Apr 2020 00:39:55 +0200 Thomas Gleixner <[email protected]> wrote:
and the below proves it:
arch/arm/include/asm/futex.h +7
-2@@ -165,8 +165,13 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)preempt_enable ();#endif -if (!ret) - *oval = oldval; +/* +* Store unconditionally. If ret != 0 the extra store is the least +* of the worries but GCC cannot figure out that __futex_atomic_op() +* is either setting ret to -EFAULT or storing the old value in +* oldval which results in a uninitialized warning at the call site. +*/ + *oval = oldval;
Quoted 8 lines
Quoted 4 lines
arch/arm/include/asm/futex.h +0
-0return ret; }I think that's the right thing to do anyway. The conditional is pointless.
Thanks for the analysis.
I am still getting this warning, now from Linus' tree builds.
Yeah. Just noticed that both of us failed to CC the arm folks. :(
Let me send out a proper patch.
Thanks,
tglx
ARM: futex: Address build warning
In reply to Stephen RothwellStephen reported the following build warning on a ARM multi_v7_defconfig build with GCC 9.2.1:
kernel/futex.c: In function 'do_futex':kernel/futex.c:1676:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized]
1676 | return oldval == cmparg;
| ~~~~~~~^~~~~~~~~
kernel/futex.c:1652:6: note: 'oldval' was declared here
1652 | int oldval, ret;
| ^~~~~~introduced by commit a08971e9488d ("futex: arch_futex_atomic_op_inuser() calling conventions change").
While that change should not make any difference it confuses GCC which fails to work out that oldval is not referenced when the return value is not zero.
GCC fails to properly analyze arch_futex_atomic_op_inuser(). It's not the early return, the issue is with the assembly macros. GCC fails to detect that those either set 'ret' to 0 and set oldval or set 'ret' to -EFAULT which makes oldval uninteresting. The store to the callsite supplied oldval pointer is conditional on ret == 0.
The straight forward way to solve this is to make the store unconditional.
Aside of addressing the build warning this makes sense anyway because it removes the conditional from the fastpath. In the error case the stored value is uninteresting and the extra store does not matter at all.
--- arch/arm/include/asm/futex.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/include/asm/futex.h +7 -2
@@ -165,8 +165,13 @@ arch_futex_atomic_op_inuser(int op, intpreempt_enable ();#endif -if (!ret) - *oval = oldval; +/* +* Store unconditionally. If ret != 0 the extra store is the least +* of the worries but GCC cannot figure out that __futex_atomic_op() +* is either setting ret to -EFAULT or storing the old value in +* oldval which results in a uninitialized warning at the call site. +*/ + *oval = oldval;return ret; }
Re: ARM: futex: Address build warning
Hi all,
Quoted 46 lines · On Tue, 14 Apr 2020 11:07:22 +0200 Thomas Gleixner <[email protected]> wrote:
Stephen reported the following build warning on a ARM
multi_v7_defconfigbuild with GCC 9.2.1:
kernel/futex.c: In function 'do_futex':kernel/futex.c:1676:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized]1676 | return oldval == cmparg; | ~~~~~~~^~~~~~~~~ kernel/futex.c:1652:6: note: 'oldval' was declared here 1652 | int oldval, ret; | ^~~~~~introduced by commit
a08971e9488d("futex:arch_futex_atomic_op_inuser()calling conventions change").While that change should not make any difference it confuses GCC which fails to work out that oldval is not referenced when the return value is not zero.
GCC fails to properly analyze
arch_futex_atomic_op_inuser(). It's not the early return, the issue is with the assembly macros. GCC fails to detect that those either set 'ret' to 0 and set oldval or set 'ret' to-EFAULTwhich makes oldval uninteresting. The store to the callsite supplied oldval pointer is conditional on ret == 0.The straight forward way to solve this is to make the store unconditional.
Aside of addressing the build warning this makes sense anyway because it removes the conditional from the fastpath. In the error case the stored value is uninteresting and the extra store does not matter at all.
Reported-by Stephen Rothwell <[email protected]>Signed-off-by Thomas Gleixner <[email protected]>--- arch/arm/include/asm/futex.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)arch/arm/include/asm/futex.h +0
-2@@ -165,8 +165,13 @@ arch_futex_atomic_op_inuser(int op, intpreempt_enable ();#endif -if (!ret) - *oval = oldval;
arch/arm/include/asm/futex.h arch_futex_atomic_op_inuser(int op, int · line 177
Quoted 10 lines
arch/arm/include/asm/futex.h +7
-0+/* +* Store unconditionally. If ret != 0 the extra store is the least +* of the worries but GCC cannot figure out that __futex_atomic_op() +* is either setting ret to -EFAULT or storing the old value in +* oldval which results in a uninitialized warning at the call site. +*/ + *oval = oldval;return ret; }
Any response to this? I am still getting the warning ...
The warning was introduced by commit
a08971e9488d ("futex: arch_futex_atomic_op_inuser() calling conventions change")
Which has been in Linus' tree since before v5.7-rc1. Should this go in via the tip tree, the arm tree, or will I just send ti to Linus myself?
Signature · 2 lines
Cheers, Stephen Rothwell
[tip: locking/urgent] ARM: futex: Address build warning
In reply to Thomas GleixnerThe following commit has been merged into the locking/urgent branch of tip:
The following commit has been merged into the locking/urgent branch of tip:
Commit-ID: 8101b5a1531f3390b3a69fa7934c70a8fd6566ad Gitweb: https://git.kernel.org/tip/8101b5a1531f3390b3a69fa7934c70a8fd6566ad Author: Thomas Gleixner <[email protected]> AuthorDate: Tue, 14 Apr 2020 11:07:22 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 07 May 2020 00:41:47 +02:00
ARM: futex: Address build warning
Stephen reported the following build warning on a ARM multi_v7_defconfig build with GCC 9.2.1:
kernel/futex.c: In function 'do_futex':kernel/futex.c:1676:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized]
1676 | return oldval == cmparg;
| ~~~~~~~^~~~~~~~~
kernel/futex.c:1652:6: note: 'oldval' was declared here
1652 | int oldval, ret;
| ^~~~~~introduced by commit a08971e9488d ("futex: arch_futex_atomic_op_inuser() calling conventions change").
While that change should not make any difference it confuses GCC which fails to work out that oldval is not referenced when the return value is not zero.
GCC fails to properly analyze arch_futex_atomic_op_inuser(). It's not the early return, the issue is with the assembly macros. GCC fails to detect that those either set 'ret' to 0 and set oldval or set 'ret' to -EFAULT which makes oldval uninteresting. The store to the callsite supplied oldval pointer is conditional on ret == 0.
The straight forward way to solve this is to make the store unconditional.
Aside of addressing the build warning this makes sense anyway because it removes the conditional from the fastpath. In the error case the stored value is uninteresting and the extra store does not matter at all.
--- arch/arm/include/asm/futex.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/include/asm/futex.h +7 -2
@@ -165,8 +165,13 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)preempt_enable ();#endif -if (!ret) - *oval = oldval; +/* +* Store unconditionally. If ret != 0 the extra store is the least +* of the worries but GCC cannot figure out that __futex_atomic_op() +* is either setting ret to -EFAULT or storing the old value in +* oldval which results in a uninitialized warning at the call site. +*/ + *oval = oldval;return ret; }