mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 19:29:37 +00:00
![Arnd Bergmann](/assets/img/avatar_default.png)
Moving the qrwlock struct definition into a header file introduced
a subtle bug on all little-endian machines, where some files in some
configurations would see the fields in an incorrect order. This was
found by building with an LTO enabled compiler that warns every time we
try to link together files with incompatible data structures.
A second patch changes linux/kconfig.h to always define the symbols,
but this seems to be the root cause of most of the issues, so I'd suggest
we do both.
On a current linux-next kernel, I verified that this header is
responsible for all type mismatches as a result from the endianess
confusion.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Babu Moger <babu.moger@oracle.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nicolas Pitre <nico@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Fixes: e0d02285f1
("locking/qrwlock: Use 'struct qrwlock' instead of 'struct __qrwlock'")
Link: http://lkml.kernel.org/r/20180202154104.1522809-1-arnd@arndb.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
34 lines
682 B
C
34 lines
682 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __ASM_GENERIC_QRWLOCK_TYPES_H
|
|
#define __ASM_GENERIC_QRWLOCK_TYPES_H
|
|
|
|
#include <linux/types.h>
|
|
#include <asm/byteorder.h>
|
|
#include <asm/spinlock_types.h>
|
|
|
|
/*
|
|
* The queue read/write lock data structure
|
|
*/
|
|
|
|
typedef struct qrwlock {
|
|
union {
|
|
atomic_t cnts;
|
|
struct {
|
|
#ifdef __LITTLE_ENDIAN
|
|
u8 wlocked; /* Locked for write? */
|
|
u8 __lstate[3];
|
|
#else
|
|
u8 __lstate[3];
|
|
u8 wlocked; /* Locked for write? */
|
|
#endif
|
|
};
|
|
};
|
|
arch_spinlock_t wait_lock;
|
|
} arch_rwlock_t;
|
|
|
|
#define __ARCH_RW_LOCK_UNLOCKED { \
|
|
{ .cnts = ATOMIC_INIT(0), }, \
|
|
.wait_lock = __ARCH_SPIN_LOCK_UNLOCKED, \
|
|
}
|
|
|
|
#endif /* __ASM_GENERIC_QRWLOCK_TYPES_H */
|