Re: [PATCH v6 3/4] atomic: Add alignment check to instrumented atomic operations
From: Finn Thain
Date: Mon Jan 05 2026 - 16:26:21 EST
On Mon, 5 Jan 2026, Peter Zijlstra wrote:
> On Wed, Dec 31, 2025 at 07:25:42PM +1100, Finn Thain wrote:
> > From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> >
> > Add a Kconfig option for debug builds which logs a warning when an
> > instrumented atomic operation takes place that's misaligned.
> > Some platforms don't trap for this.
> >
> > [fthain: added __DISABLE_BUG_TABLE macro.]
> >
> > Cc: Sasha Levin <sashal@xxxxxxxxxx>
> > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> > Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> > Cc: Borislav Petkov <bp@xxxxxxxxx>
> > Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> > Cc: x86@xxxxxxxxxx
> > Cc: Ard Biesheuvel <ardb@xxxxxxxxxx>
> > Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
> > Link: https://lore.kernel.org/lkml/20250901093600.GF4067720@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
> > Link: https://lore.kernel.org/linux-next/df9fbd22-a648-ada4-fee0-68fe4325ff82@xxxxxxxxxxxxxx/
> > Signed-off-by: Finn Thain <fthain@xxxxxxxxxxxxxx>
> > ---
> > Checkpatch.pl says...
> > ERROR: Missing Signed-off-by: line by nominal patch author 'Peter Ziljstra <peterz@xxxxxxxxxxxxx>'
> > ---
> > Changed since v5:
> > - Add new __DISABLE_BUG_TABLE macro to prevent a build failure on those
> > architectures which use atomics in pre-boot code like the EFI stub loader:
> >
> > x86_64-linux-gnu-ld: error: unplaced orphan section `__bug_table' from `arch/x86/boot/compressed/sev-handle-vc.o'
>
> Urgh, so why not simply use __DISABLE_EXPORTS, that's typically (ab)used
> for these things?
>
OK, I'll change it back to __DISABLE_EXPORTS.
> Also, unless __DISABLE_BUG_TABLE goes live inside asm/bug.h and kills
> all __bug_table emissions, its a misnomer.
>
Yes, __DISABLE_BUG_TABLE is certainly a misnomer, since what it actually
does is to elide code that would emit bug table entries. I would argue
that this distinction is splitting hairs but it's moot.
> Furthermore, that SEV thing is broken and needs to be fixed anyway, this
> isn't helping it much. noinstr code should not be using instrumented
> things to begin with.
>
The problem is not confined to x86. I needed something that would work for
loongarch, arm, riscv etc.
Anyway, thanks for your review. I will make the necessary changes.