Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1324240

Re: CONFIG_UBSAN_ALIGNMENT breaks x86-64 kernel with lockdep enabled

From Andrey Ryabinin <aryabinin@virtuozzo.com>
Newsgroups linux.kernel
Subject Re: CONFIG_UBSAN_ALIGNMENT breaks x86-64 kernel with lockdep enabled
Date 2016-02-02 17:20 +0100
Message-ID <qXLQm-5Be-19@gated-at.bofh.it> (permalink)
References <qWrK2-2Ro-11@gated-at.bofh.it> <qXoh4-4Gm-25@gated-at.bofh.it> <qXv8S-14l-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 02/02/2016 01:21 AM, Andrew Morton wrote:
> On Mon, 1 Feb 2016 18:10:38 +0300 Andrey Ryabinin <aryabinin@virtuozzo.com> wrote:
> 
>> On 01/30/2016 03:36 AM, Mike Krinkin wrote:
>>> Hi,
>>>
>>> option CONFIG_UBSAN_ALIGNMENT breaks x86-64 kernel with lockdep enabled,
>>> i. e kernel with CONFIG_UBSAN_ALIGNMENT fails to load without even any
>>> error message.
>>>
>>> The problem is that ubsan callbacks use spinlocks and might be called
>>> before lockdep is initialized. Particularly this line in the
>>> reserve_ebda_region function causes problem:
>>>
>>> lowmem = *(unsigned short *)__va(BIOS_LOWMEM_KILOBYTES);
>>>
>>> If i put lockdep_init() before reserve_ebda_region call in
>>> x86_64_start_reservations kernel loads well. Since CONFIG_UBSAN_ALIGNMENT
>>> isn't useful for x86 anyway it might be better to disable this option for
>>> x86 arch?
>>>
>>
>>
>> Alignment checks could be useful even on x86, because there are unaligned accesses in generic code.
>> I think we can disable alignment instrumentation for arch/x86 directory only.
> 
> It looks pretty simple to make lockdep self-initialize on demand.  I
> don't think it'll affect performance much at all and it takes away all
> these "has lockdep initialized yet" concerns?
> 

Yes, this seems a better choice. 
It also should protect us from possible undefined behavior that someday may appear in early code.
Your patch works for me.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

CONFIG_UBSAN_ALIGNMENT breaks x86-64 kernel with lockdep enabled Mike Krinkin <krinkin.m.u@gmail.com> - 2016-01-30 01:40 +0100
  Re: CONFIG_UBSAN_ALIGNMENT breaks x86-64 kernel with lockdep enabled Andrey Ryabinin <aryabinin@virtuozzo.com> - 2016-02-01 16:10 +0100
    Re: CONFIG_UBSAN_ALIGNMENT breaks x86-64 kernel with lockdep  enabled Andrew Morton <akpm@linux-foundation.org> - 2016-02-01 23:30 +0100
      Re: CONFIG_UBSAN_ALIGNMENT breaks x86-64 kernel with lockdep enabled Andrey Ryabinin <aryabinin@virtuozzo.com> - 2016-02-02 17:20 +0100
        Re: CONFIG_UBSAN_ALIGNMENT breaks x86-64 kernel with lockdep  enabled Andrew Morton <akpm@linux-foundation.org> - 2016-02-02 22:20 +0100

csiph-web