linux/init
Stafford Horne d0b7213f89 init: Align init_task to avoid conflict with MUTEX_FLAGS
When booting on 32-bit machines (seen on OpenRISC) I saw this warning
with CONFIG_DEBUG_MUTEXES turned on.

    ------------[ cut here ]------------
    WARNING: CPU: 0 PID: 0 at kernel/locking/mutex.c:1242 __mutex_unlock_slowpath+0x328/0x3ec
    DEBUG_LOCKS_WARN_ON(__owner_task(owner) != current)
    Modules linked in:
    CPU: 0 PID: 0 Comm: swapper Not tainted 5.8.0-rc1-simple-smp-00005-g2864e2171db4-dirty #179
    Call trace:
    [<(ptrval)>] dump_stack+0x34/0x48
    [<(ptrval)>] __warn+0x104/0x158
    [<(ptrval)>] ? __mutex_unlock_slowpath+0x328/0x3ec
    [<(ptrval)>] warn_slowpath_fmt+0x7c/0x94
    [<(ptrval)>] __mutex_unlock_slowpath+0x328/0x3ec
    [<(ptrval)>] mutex_unlock+0x18/0x28
    [<(ptrval)>] __cpuhp_setup_state_cpuslocked.part.0+0x29c/0x2f4
    [<(ptrval)>] ? page_alloc_cpu_dead+0x0/0x30
    [<(ptrval)>] ? start_kernel+0x0/0x684
    [<(ptrval)>] __cpuhp_setup_state+0x4c/0x5c
    [<(ptrval)>] page_alloc_init+0x34/0x68
    [<(ptrval)>] ? start_kernel+0x1a0/0x684
    [<(ptrval)>] ? early_init_dt_scan_nodes+0x60/0x70
    irq event stamp: 0

I traced this to kernel/locking/mutex.c storing 3 bits of MUTEX_FLAGS in
the task_struct pointer (mutex.owner).  There is a comment saying that
task_structs are always aligned to L1_CACHE_BYTES.  This is not true for
the init_task.

On 64-bit machines this is not a problem because symbol addresses are
naturally aligned to 64-bits providing 3 bits for MUTEX_FLAGS.  Howerver,
for 32-bit machines the symbol address only has 2 bits available.

Fix this by setting init_task alignment to at least L1_CACHE_BYTES.

Signed-off-by: Stafford Horne <shorne@gmail.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
2020-08-04 10:59:45 +09:00
..
calibrate.c
do_mounts.c block: remove __bdevname 2020-03-24 07:57:07 -06:00
do_mounts.h fs: add do_mknodat() helper and ksys_mknod() wrapper; remove in-kernel calls to syscall 2018-04-02 20:15:56 +02:00
do_mounts_initrd.c x86/setup: Add an initrdmem= option to specify initrd physical address 2020-04-27 09:28:16 +02:00
do_mounts_md.c init/: remove ineffective sparse disabling 2018-08-22 10:52:49 -07:00
do_mounts_rd.c init/: remove ineffective sparse disabling 2018-08-22 10:52:49 -07:00
init_task.c init: Align init_task to avoid conflict with MUTEX_FLAGS 2020-08-04 10:59:45 +09:00
initramfs.c gcc-10: mark more functions __init to avoid section mismatch warnings 2020-05-09 17:50:03 -07:00
Kconfig kbuild: fix CONFIG_CC_CAN_LINK(_STATIC) for cross-compilation with Clang 2020-07-02 00:57:45 +09:00
main.c Rebase locking/kcsan to locking/urgent 2020-06-11 20:02:46 +02:00
Makefile kbuild: use CONFIG_CC_VERSION_TEXT to construct LINUX_COMPILER macro 2020-05-12 13:28:33 +09:00
noinitramfs.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 167 2019-05-30 11:26:39 -07:00
version.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00