Re: [GIT pull] locking/urgent for v5.12-rc3

From: Peter Zijlstra
Date: Mon Mar 15 2021 - 07:11:20 EST


On Mon, Mar 15, 2021 at 09:33:45AM +0100, Peter Zijlstra wrote:
> On Sun, Mar 14, 2021 at 01:15:25PM -0700, Linus Torvalds wrote:
> > On Sun, Mar 14, 2021 at 8:40 AM Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
> > >
> > > - A fix for the static_call mechanism so it handles unaligned
> > > addresses correctly.
> >
> > I'm not disputing the fix in any way, but why weren't the relocation
> > info and function start addresses mutually aligned?
> >
> > Are we perhaps missing some .align directive somewhere?
> >
> > Or am I missing something?
>
> So I considered looking into that, but since carrying the flag on the
> absolute address is always correct I figured it was the more robust fix.
>
> I suppose I can try and figure out where alignment went wobbly.

include/asm-generic/vmlinux.lds.h:

#define STATIC_CALL_DATA \
. = ALIGN(8); \
__start_static_call_sites = .; \
KEEP(*(.static_call_sites)) \
__stop_static_call_sites = .; \
__start_static_call_tramp_key = .; \
KEEP(*(.static_call_tramp_key)) \
__stop_static_call_tramp_key = .;

#ifndef RO_AFTER_INIT_DATA
#define RO_AFTER_INIT_DATA \
. = ALIGN(8); \
__start_ro_after_init = .; \
*(.data..ro_after_init) \
JUMP_TABLE_DATA \
STATIC_CALL_DATA \
__end_ro_after_init = .;
#endif

.rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
__start_rodata = .; \
*(.rodata) *(.rodata.*) \
SCHED_DATA \
RO_AFTER_INIT_DATA /* Read only after init */ \
. = ALIGN(8); \
__start___tracepoints_ptrs = .; \
KEEP(*(__tracepoints_ptrs)) /* Tracepoints: pointer array */ \
__stop___tracepoints_ptrs = .; \
*(__tracepoints_strings)/* Tracepoints: strings */ \
} \


$ nm defconfig-build/vmlinux | grep static_call_sites
ffffffff82916dc0 D __start_static_call_sites
ffffffff8291aaf0 D __stop_static_call_sites


Which all reads to me like it *SHOULD* work. Howver when I was debugging
the crash as reported by Steve (using his .config), I definitely saw
non-aligned base offsets causing mayhem.