Subject: Re: linux-next: build problems (Was: [PATCH v3 1/2] Provide READ_ONCE_NOCHECK())

From: Andrey Ryabinin <[email-masked]>
Date: Thu, 15 Oct 2015 13:03:11 +0300

On 10/15/2015 12:18 PM, Stephen Rothwell wrote:
> Hi Andrey,
> 
> On Tue, 13 Oct 2015 18:28:07 +0300 Andrey Ryabinin <[email-masked]> wrote:
>>
>> Some code may perform racy by design memory reads. This could be harmless,
>> yet such code may produce KASAN warnings.
>>
>> To hide such accesses from KASAN this patch introduces READ_ONCE_NOCHECK()
>> macro. KASAN will not check the memory accessed by READ_ONCE_NOCHECK().
>>
>> This patch creates __read_once_size_nocheck() a clone of
>> __read_once_size_check() (renamed __read_once_size()).
>> The only difference between them is 'no_sanitized_address' attribute
>> appended to '*_nocheck' function. This attribute tells the compiler that
>> instrumentation of memory accesses should not be applied to that function.
>> We declare it as static '__maybe_unsed' because GCC is not capable to
>> inline such function: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368
>>
>> With KASAN=n READ_ONCE_NOCHECK() is just a clone of READ_ONCE().
>>
>> Signed-off-by: Andrey Ryabinin <[email-masked]>
>> ---
>>  include/linux/compiler-gcc.h | 13 ++++++++++
>>  include/linux/compiler.h     | 60 ++++++++++++++++++++++++++++++++++----------
>>  2 files changed, 60 insertions(+), 13 deletions(-)
> 
> I am pretty sure that this patch is causing quite a bit of compile
> breakage in linux-next today.  During the day I compile with gcc 4.9.0
> and did not see any problems with c86_64 allmodconfig, or i386
> defconfig etc, but overnight we compile with older compilers (gcc 4.6.3
> in particular) and are getting quite a few errors:
> 

Looks like that older GCC doesn't like __alias (or combination of static __always_inline __alias).
It creates outline and unused copy of __read_once_size_check() function in the object file.
Should be easy to work around this.

> From an i386 allnoconfig build:
> 
> arch/x86/entry/vdso/vdso32.so.dbg: undefined symbols found
> /home/kisskb/slave/src/arch/x86/entry/vdso/Makefile:154: recipe for target 'arch/x86/entry/vdso/vdso32.so.dbg' failed
> 
> From an x86_64 allnoconfig build:
> 
> arch/x86/entry/vdso/vclock_gettime.o: In function `__read_once_size_check':
> vclock_gettime.c:(.text+0x5f): undefined reference to `memcpy'
> arch/x86/entry/vdso/vgetcpu.o: In function `__read_once_size_check':
> vgetcpu.c:(.text+0x2f): undefined reference to `memcpy'
> 
> and several others ...
>