Re: [PATCH v2 1/2] livepatch: introduce shadow variable API

From: Joe Lawrence
Date: Fri Jul 07 2017 - 14:05:52 EST


On Fri, Jun 30, 2017 at 09:49:46PM +0800, kbuild test robot wrote:
> Date: Fri, 30 Jun 2017 21:49:46 +0800
> From: kbuild test robot <lkp@xxxxxxxxx>
> To: Joe Lawrence <joe.lawrence@xxxxxxxxxx>
> Cc: kbuild-all@xxxxxx, live-patching@xxxxxxxxxxxxxxx,
> linux-kernel@xxxxxxxxxxxxxxx, Josh Poimboeuf <jpoimboe@xxxxxxxxxx>,
> Jessica Yu <jeyu@xxxxxxxxxx>, Jiri Kosina <jikos@xxxxxxxxxx>, Miroslav
> Benes <mbenes@xxxxxxx>, Petr Mladek <pmladek@xxxxxxxx>
> Subject: Re: [PATCH v2 1/2] livepatch: introduce shadow variable API
> User-Agent: Mutt/1.5.23 (2014-03-12)
>
> Hi Joe,
>
> [auto build test WARNING on jikos-livepatching/for-next]
> [also build test WARNING on v4.12-rc7 next-20170630]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url: https://github.com/0day-ci/linux/commits/Joe-Lawrence/livepatch-introduce-shadow-variable-API/20170630-061942
> base: https://git.kernel.org/pub/scm/linux/kernel/git/jikos/livepatching.git for-next
> config: s390-performance_defconfig (attached as .config)
> compiler: s390x-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
> reproduce:
> wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=s390
>
> Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
> http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
>
> All warnings (new ones prefixed by >>):
>
> In file included from include/linux/irqflags.h:15:0,
> from arch/s390/include/asm/processor.h:35,
> from arch/s390/include/asm/thread_info.h:24,
> from include/linux/thread_info.h:37,
> from arch/s390/include/asm/preempt.h:5,
> from include/linux/preempt.h:80,
> from include/linux/spinlock.h:50,
> from include/linux/rcupdate.h:38,
> from include/linux/rculist.h:10,
> from include/linux/hashtable.h:13,
> from kernel/livepatch/shadow.c:49:
> kernel/livepatch/shadow.c: In function '_klp_shadow_attach':
> >> arch/s390/include/asm/irqflags.h:63:12: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized]
> if (flags & ARCH_IRQ_ENABLED)
> ^
> kernel/livepatch/shadow.c:135:16: note: 'flags' was declared here
> unsigned long flags;
> ^~~~~
> --
> In file included from include/linux/irqflags.h:15:0,
> from arch/s390/include/asm/processor.h:35,
> from arch/s390/include/asm/thread_info.h:24,
> from include/linux/thread_info.h:37,
> from arch/s390/include/asm/preempt.h:5,
> from include/linux/preempt.h:80,
> from include/linux/spinlock.h:50,
> from include/linux/rcupdate.h:38,
> from include/linux/rculist.h:10,
> from include/linux/hashtable.h:13,
> from kernel//livepatch/shadow.c:49:
> kernel//livepatch/shadow.c: In function '_klp_shadow_attach':
> >> arch/s390/include/asm/irqflags.h:63:12: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized]
> if (flags & ARCH_IRQ_ENABLED)
> ^
> kernel//livepatch/shadow.c:135:16: note: 'flags' was declared here
> unsigned long flags;
> ^~~~~
>
> vim +/flags +63 arch/s390/include/asm/irqflags.h
>
> 94c12cc7d include/asm-s390/irqflags.h Martin Schwidefsky 2006-09-28 47 }
> 94c12cc7d include/asm-s390/irqflags.h Martin Schwidefsky 2006-09-28 48
> f433c4aec arch/s390/include/asm/irqflags.h Steven Rostedt 2011-07-24 49 static inline notrace void arch_local_irq_disable(void)
> df9ee2927 arch/s390/include/asm/irqflags.h David Howells 2010-10-07 50 {
> df9ee2927 arch/s390/include/asm/irqflags.h David Howells 2010-10-07 51 arch_local_irq_save();
> df9ee2927 arch/s390/include/asm/irqflags.h David Howells 2010-10-07 52 }
> 1f194a4c3 include/asm-s390/irqflags.h Heiko Carstens 2006-07-03 53
> f433c4aec arch/s390/include/asm/irqflags.h Steven Rostedt 2011-07-24 54 static inline notrace void arch_local_irq_enable(void)
> 94c12cc7d include/asm-s390/irqflags.h Martin Schwidefsky 2006-09-28 55 {
> df9ee2927 arch/s390/include/asm/irqflags.h David Howells 2010-10-07 56 __arch_local_irq_stosm(0x03);
> 94c12cc7d include/asm-s390/irqflags.h Martin Schwidefsky 2006-09-28 57 }
> 1f194a4c3 include/asm-s390/irqflags.h Heiko Carstens 2006-07-03 58
> 204ee2c56 arch/s390/include/asm/irqflags.h Christian Borntraeger 2016-01-11 59 /* This only restores external and I/O interrupt state */
> f433c4aec arch/s390/include/asm/irqflags.h Steven Rostedt 2011-07-24 60 static inline notrace void arch_local_irq_restore(unsigned long flags)
> df9ee2927 arch/s390/include/asm/irqflags.h David Howells 2010-10-07 61 {
> 204ee2c56 arch/s390/include/asm/irqflags.h Christian Borntraeger 2016-01-11 62 /* only disabled->disabled and disabled->enabled is valid */
> 204ee2c56 arch/s390/include/asm/irqflags.h Christian Borntraeger 2016-01-11 @63 if (flags & ARCH_IRQ_ENABLED)
> 204ee2c56 arch/s390/include/asm/irqflags.h Christian Borntraeger 2016-01-11 64 arch_local_irq_enable();
> df9ee2927 arch/s390/include/asm/irqflags.h David Howells 2010-10-07 65 }
> df9ee2927 arch/s390/include/asm/irqflags.h David Howells 2010-10-07 66
> f433c4aec arch/s390/include/asm/irqflags.h Steven Rostedt 2011-07-24 67 static inline notrace bool arch_irqs_disabled_flags(unsigned long flags)
> 1f194a4c3 include/asm-s390/irqflags.h Heiko Carstens 2006-07-03 68 {
> 204ee2c56 arch/s390/include/asm/irqflags.h Christian Borntraeger 2016-01-11 69 return !(flags & ARCH_IRQ_ENABLED);
> 1f194a4c3 include/asm-s390/irqflags.h Heiko Carstens 2006-07-03 70 }
> 1f194a4c3 include/asm-s390/irqflags.h Heiko Carstens 2006-07-03 71
>
> :::::: The code at line 63 was first introduced by commit
> :::::: 204ee2c5643199a25181ec04ea645d00709c2a5a s390/irqflags: optimize irq restore
>
> :::::: TO: Christian Borntraeger <borntraeger@xxxxxxxxxx>
> :::::: CC: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation

Presumably the 0-day built bot doesn't like this construct:

static void *_klp_shadow_attach(void *obj, unsigned long num, void *new_data,
size_t new_size, gfp_t gfp_flags,
bool lock)
{
unsigned long flags;
...
if (lock)
spin_lock_irqsave(&klp_shadow_lock, flags);
hash_add_rcu(klp_shadow_hash, &shadow->node, (unsigned long)obj);
if (lock)
spin_unlock_irqrestore(&klp_shadow_lock, flags);

Perhaps explicitly initializing flags to 0, or combining the conditional
will appease it?

-- Joe