andikleen / linux-misc

Various Linux kernel changes
http://halobates.de
Other
64 stars 12 forks source link

5.12.0 w/ lto-5.12.0-3 patchset applied bootloops when built with gcc 11.1 on x86_64 musl host #36

Closed gottaeat closed 3 years ago

gottaeat commented 3 years ago

during the LTO stage i am getting these warnings with gcc 11.1.0, which i did not get with 10.3.0:

  LTO     vmlinux.o
In function 'ilk_setup_wm_latency',
    inlined from 'intel_init_pm' at drivers/gpu/drm/i915/intel_pm.c:7628:3:
drivers/gpu/drm/i915/intel_pm.c:3093:9: warning: 'intel_read_wm_latency' accessing 16 bytes in a region of size 10 [-Wstringop-overflow=]
 3093 |         intel_read_wm_latency(dev_priv, dev_priv->wm.pri_latency);
      |         ^
drivers/gpu/drm/i915/intel_pm.c: In function 'intel_init_pm':
drivers/gpu/drm/i915/intel_pm.c:3093:9: note: referencing argument 2 of type 'u16 *'
drivers/gpu/drm/i915/intel_pm.c:2849:13: note: in a call to function 'intel_read_wm_latency'
 2849 | static void intel_read_wm_latency(struct drm_i915_private *dev_priv,
      |             ^
In function 'snb_wm_latency_quirk',
    inlined from 'ilk_setup_wm_latency' at drivers/gpu/drm/i915/intel_pm.c:3108:3,
    inlined from 'intel_init_pm' at drivers/gpu/drm/i915/intel_pm.c:7628:3:
drivers/gpu/drm/i915/intel_pm.c:3057:9: warning: 'intel_print_wm_latency' reading 16 bytes from a region of size 10 [-Wstringop-overread]
 3057 |         intel_print_wm_latency(dev_priv, "Primary", dev_priv->wm.pri_latency);
      |         ^
drivers/gpu/drm/i915/intel_pm.c: In function 'intel_init_pm':
drivers/gpu/drm/i915/intel_pm.c:3057:9: note: referencing argument 3 of type 'const u16 *'
drivers/gpu/drm/i915/intel_pm.c:2994:13: note: in a call to function 'intel_print_wm_latency'
 2994 | static void intel_print_wm_latency(struct drm_i915_private *dev_priv,
      |             ^
In function 'snb_wm_latency_quirk',
    inlined from 'ilk_setup_wm_latency' at drivers/gpu/drm/i915/intel_pm.c:3108:3,
    inlined from 'intel_init_pm' at drivers/gpu/drm/i915/intel_pm.c:7628:3:
drivers/gpu/drm/i915/intel_pm.c:3058:9: warning: 'intel_print_wm_latency' reading 16 bytes from a region of size 10 [-Wstringop-overread]
 3058 |         intel_print_wm_latency(dev_priv, "Sprite", dev_priv->wm.spr_latency);
      |         ^
drivers/gpu/drm/i915/intel_pm.c: In function 'intel_init_pm':
drivers/gpu/drm/i915/intel_pm.c:3058:9: note: referencing argument 3 of type 'const u16 *'
drivers/gpu/drm/i915/intel_pm.c:2994:13: note: in a call to function 'intel_print_wm_latency'
 2994 | static void intel_print_wm_latency(struct drm_i915_private *dev_priv,
      |             ^
In function 'snb_wm_latency_quirk',
    inlined from 'ilk_setup_wm_latency' at drivers/gpu/drm/i915/intel_pm.c:3108:3,
    inlined from 'intel_init_pm' at drivers/gpu/drm/i915/intel_pm.c:7628:3:
drivers/gpu/drm/i915/intel_pm.c:3059:9: warning: 'intel_print_wm_latency' reading 16 bytes from a region of size 10 [-Wstringop-overread]
 3059 |         intel_print_wm_latency(dev_priv, "Cursor", dev_priv->wm.cur_latency);
      |         ^
drivers/gpu/drm/i915/intel_pm.c: In function 'intel_init_pm':
drivers/gpu/drm/i915/intel_pm.c:3059:9: note: referencing argument 3 of type 'const u16 *'
drivers/gpu/drm/i915/intel_pm.c:2994:13: note: in a call to function 'intel_print_wm_latency'
 2994 | static void intel_print_wm_latency(struct drm_i915_private *dev_priv,
      |             ^
In function 'snb_wm_lp3_irq_quirk',
    inlined from 'ilk_setup_wm_latency' at drivers/gpu/drm/i915/intel_pm.c:3109:3,
    inlined from 'intel_init_pm' at drivers/gpu/drm/i915/intel_pm.c:7628:3:
drivers/gpu/drm/i915/intel_pm.c:3086:9: warning: 'intel_print_wm_latency' reading 16 bytes from a region of size 10 [-Wstringop-overread]
 3086 |         intel_print_wm_latency(dev_priv, "Primary", dev_priv->wm.pri_latency);
      |         ^
drivers/gpu/drm/i915/intel_pm.c: In function 'intel_init_pm':
drivers/gpu/drm/i915/intel_pm.c:3086:9: note: referencing argument 3 of type 'const u16 *'
drivers/gpu/drm/i915/intel_pm.c:2994:13: note: in a call to function 'intel_print_wm_latency'
 2994 | static void intel_print_wm_latency(struct drm_i915_private *dev_priv,
      |             ^
In function 'snb_wm_lp3_irq_quirk',
    inlined from 'ilk_setup_wm_latency' at drivers/gpu/drm/i915/intel_pm.c:3109:3,
    inlined from 'intel_init_pm' at drivers/gpu/drm/i915/intel_pm.c:7628:3:
drivers/gpu/drm/i915/intel_pm.c:3087:9: warning: 'intel_print_wm_latency' reading 16 bytes from a region of size 10 [-Wstringop-overread]
 3087 |         intel_print_wm_latency(dev_priv, "Sprite", dev_priv->wm.spr_latency);
      |         ^
drivers/gpu/drm/i915/intel_pm.c: In function 'intel_init_pm':
drivers/gpu/drm/i915/intel_pm.c:3087:9: note: referencing argument 3 of type 'const u16 *'
drivers/gpu/drm/i915/intel_pm.c:2994:13: note: in a call to function 'intel_print_wm_latency'
 2994 | static void intel_print_wm_latency(struct drm_i915_private *dev_priv,
      |             ^
In function 'snb_wm_lp3_irq_quirk',
    inlined from 'ilk_setup_wm_latency' at drivers/gpu/drm/i915/intel_pm.c:3109:3,
    inlined from 'intel_init_pm' at drivers/gpu/drm/i915/intel_pm.c:7628:3:
drivers/gpu/drm/i915/intel_pm.c:3088:9: warning: 'intel_print_wm_latency' reading 16 bytes from a region of size 10 [-Wstringop-overread]
 3088 |         intel_print_wm_latency(dev_priv, "Cursor", dev_priv->wm.cur_latency);
      |         ^
drivers/gpu/drm/i915/intel_pm.c: In function 'intel_init_pm':
drivers/gpu/drm/i915/intel_pm.c:3088:9: note: referencing argument 3 of type 'const u16 *'
drivers/gpu/drm/i915/intel_pm.c:2994:13: note: in a call to function 'intel_print_wm_latency'
 2994 | static void intel_print_wm_latency(struct drm_i915_private *dev_priv,
      |             ^
In function 'ilk_setup_wm_latency',
    inlined from 'intel_init_pm' at drivers/gpu/drm/i915/intel_pm.c:7628:3:
drivers/gpu/drm/i915/intel_pm.c:3103:9: warning: 'intel_print_wm_latency' reading 16 bytes from a region of size 10 [-Wstringop-overread]
 3103 |         intel_print_wm_latency(dev_priv, "Primary", dev_priv->wm.pri_latency);
      |         ^
drivers/gpu/drm/i915/intel_pm.c: In function 'intel_init_pm':
drivers/gpu/drm/i915/intel_pm.c:3103:9: note: referencing argument 3 of type 'const u16 *'
drivers/gpu/drm/i915/intel_pm.c:2994:13: note: in a call to function 'intel_print_wm_latency'
 2994 | static void intel_print_wm_latency(struct drm_i915_private *dev_priv,
      |             ^
In function 'ilk_setup_wm_latency',
    inlined from 'intel_init_pm' at drivers/gpu/drm/i915/intel_pm.c:7628:3:
drivers/gpu/drm/i915/intel_pm.c:3104:9: warning: 'intel_print_wm_latency' reading 16 bytes from a region of size 10 [-Wstringop-overread]
 3104 |         intel_print_wm_latency(dev_priv, "Sprite", dev_priv->wm.spr_latency);
      |         ^
drivers/gpu/drm/i915/intel_pm.c: In function 'intel_init_pm':
drivers/gpu/drm/i915/intel_pm.c:3104:9: note: referencing argument 3 of type 'const u16 *'
drivers/gpu/drm/i915/intel_pm.c:2994:13: note: in a call to function 'intel_print_wm_latency'
 2994 | static void intel_print_wm_latency(struct drm_i915_private *dev_priv,
      |             ^
In function 'ilk_setup_wm_latency',
    inlined from 'intel_init_pm' at drivers/gpu/drm/i915/intel_pm.c:7628:3:
drivers/gpu/drm/i915/intel_pm.c:3105:9: warning: 'intel_print_wm_latency' reading 16 bytes from a region of size 10 [-Wstringop-overread]
 3105 |         intel_print_wm_latency(dev_priv, "Cursor", dev_priv->wm.cur_latency);
      |         ^
drivers/gpu/drm/i915/intel_pm.c: In function 'intel_init_pm':
drivers/gpu/drm/i915/intel_pm.c:3105:9: note: referencing argument 3 of type 'const u16 *'
drivers/gpu/drm/i915/intel_pm.c:2994:13: note: in a call to function 'intel_print_wm_latency'
 2994 | static void intel_print_wm_latency(struct drm_i915_private *dev_priv,
      |             ^
arch/x86/mm/pgtable.c: In function 'pgd_alloc':
arch/x86/mm/pgtable.c:437:13: warning: 'preallocate_pmds.constprop' accessing 8 bytes in a region of size 0 [-Wstringop-overflow=]
  437 |         if (preallocate_pmds(mm, pmds, PREALLOCATED_PMDS) != 0)
      |             ^
arch/x86/mm/pgtable.c:437:13: note: referencing argument 2 of type 'struct pmd_t * *'
arch/x86/mm/pgtable.c:225:12: note: in a call to function 'preallocate_pmds.constprop'
  225 | static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[], int count)
      |            ^
arch/x86/mm/pgtable.c:440:13: warning: 'preallocate_pmds.constprop' accessing 8 bytes in a region of size 0 [-Wstringop-overflow=]
  440 |         if (preallocate_pmds(mm, u_pmds, PREALLOCATED_USER_PMDS) != 0)
      |             ^
arch/x86/mm/pgtable.c:440:13: note: referencing argument 2 of type 'struct pmd_t * *'
arch/x86/mm/pgtable.c:225:12: note: in a call to function 'preallocate_pmds.constprop'
  225 | static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[], int count)
      |            ^
arch/x86/mm/pgtable.c:464:9: warning: 'free_pmds.constprop' accessing 8 bytes in a region of size 0 [-Wstringop-overflow=]
  464 |         free_pmds(mm, pmds, PREALLOCATED_PMDS);
      |         ^
arch/x86/mm/pgtable.c:464:9: note: referencing argument 2 of type 'struct pmd_t * *'
arch/x86/mm/pgtable.c:213:13: note: in a call to function 'free_pmds.constprop'
  213 | static void free_pmds(struct mm_struct *mm, pmd_t *pmds[], int count)
      |             ^

and seeing this warning on the ZSTD22 stage:

  ZSTD22  arch/x86/boot/compressed/vmlinux.bin.zst
In file included from arch/x86/boot/compressed/misc.c:18:
In function 'parse_elf',
    inlined from 'extract_kernel' at arch/x86/boot/compressed/misc.c:442:2:
arch/x86/boot/compressed/../string.h:15:23: warning: '__builtin_memcpy' reading 64 bytes from a region of size 0 [-Wstringop-overread]
   15 | #define memcpy(d,s,l) __builtin_memcpy(d,s,l)
      |                       ^~~~~~~~~~~~~~~~~~~~~~~
arch/x86/boot/compressed/misc.c:283:9: note: in expansion of macro 'memcpy'
  283 |         memcpy(&ehdr, output, sizeof(ehdr));
      |         ^~~~~~

once the kernel that got built above is installed, the machine keeps on rebooting after the Booting the kernel stage.

gottaeat commented 3 years ago

i am deeply sorry, while the bootlooping issue is still there when the lto patchset is applied, the warnings above are not caused by it, a vanilla 5.12.0 + gcc 11.1 build has them as well.

andikleen commented 3 years ago

On Wed, Apr 28, 2021 at 02:49:32PM -0700, mss wrote:

during the LTO stage i am getting these warnings with gcc 11.1.0, which i did not get with 10.3.0:

LTO vmlinux.o In function 'ilk_setup_wm_latency', inlined from 'intel_init_pm' at drivers/gpu/drm/i915/intel_pm.c:7628:3:

I looked at some of them and I think at least those were false positives. At some point need to fix them, but it's not urgent.

ZSTD22 arch/x86/boot/compressed/vmlinux.bin.zst In file included from arch/x86/boot/compressed/misc.c:18: In function 'parse_elf', inlined from 'extract_kernel' at arch/x86/boot/compressed/misc.c:442:2: arch/x86/boot/compressed/../string.h:15:23: warning: '__builtin_memcpy' reading 64 bytes from a region of size 0 [-Wstringop-overread] 15 | #define memcpy(d,s,l) __builtin_memcpy(d,s,l) | ^~~~~~~ arch/x86/boot/compressed/misc.c:283:9: note: in expansion of macro 'memcpy' 283 | memcpy(&ehdr, output, sizeof(ehdr)); | ^~

once the kernel that got built above is installed, the machine keeps on rebooting after the Booting the kernel stage.

That's bad. Do you see any output with earlyprintk=vga?

(or better earlyprintk=serial if you have a serial console)

Also can you please attach your .config?

andikleen commented 3 years ago

Never mind, I was able to reproduce. Working on it.

osevan commented 3 years ago

Never mind, I was able to reproduce. Working on it.

Andikleen,when you want, you can join to telegram group, where some ppl can help you with compile reports and many guys want as fast as possible GCC lto compiled kernel ready .

Here is group of lots of kernel compilers :

Im inviting you to most active compilers group

t.me/cacule_sched

gottaeat commented 3 years ago

@andikleen

I looked at some of them and I think at least those were false positives. At some point need to fix them, but it's not urgent.

apologies if i were not clear previously, all of the warnings are there without the lto-5.12-3 changes applied, a quick search shows up other instances of multiple people getting hit with them: gcc bugzilla bug 99578

Do you see any output with earlyprintk=vga?

machine reboots silently after this stage: image

Also can you please attach your .config?

of course.

andikleen commented 3 years ago

Fixed now with

23dd0face96b sched: Work around undefined behavior in sched class checking

gcc was exploiting some ISO-C undefined behavior in the scheduler initialization. Please let me know if this fixes your problem.

gottaeat commented 3 years ago

23dd0fa does fix the issue, thank you immensely for your work, have a safe and smooth day.