[PATCH 00/24] alpha: catch up on architecture Kconfig options

Matt Turner posted 24 patches 3 weeks, 3 days ago
There is a newer version of this series
arch/alpha/Kconfig                      | 21 ++++++
arch/alpha/include/asm/irqflags.h       |  2 +-
arch/alpha/include/asm/perf_regs.h      |  7 ++
arch/alpha/include/asm/pgtable.h        | 21 +++++-
arch/alpha/include/asm/processor.h      |  7 ++
arch/alpha/include/uapi/asm/perf_regs.h | 34 ++++++++++
arch/alpha/kernel/Makefile              |  1 +
arch/alpha/kernel/entry.S               | 54 +++++++++++++---
arch/alpha/kernel/irq.c                 |  9 ++-
arch/alpha/kernel/irq_alpha.c           | 13 ++++
arch/alpha/kernel/perf_regs.c           | 86 +++++++++++++++++++++++++
arch/alpha/kernel/vmlinux.lds.S         | 11 ++++
arch/alpha/mm/fault.c                   | 29 +++++++++
arch/alpha/mm/init.c                    |  5 ++
14 files changed, 287 insertions(+), 13 deletions(-)
create mode 100644 arch/alpha/include/asm/perf_regs.h
create mode 100644 arch/alpha/include/uapi/asm/perf_regs.h
create mode 100644 arch/alpha/kernel/perf_regs.c
[PATCH 00/24] alpha: catch up on architecture Kconfig options
Posted by Matt Turner 3 weeks, 3 days ago
Alpha is missing a long list of Kconfig options that other architectures
have picked up over the years, some of them for no better reason than
nobody having gone through the list.  I diffed the select statements in
every other arch/*/Kconfig against arch/alpha/Kconfig and worked through
what turned up.  This series is the result: two fixes it depends on, and
the options that are either free or close to it.

The patches are ordered from least to most contentious, so the front of
the series can be applied on its own if the tail needs discussion.

Patches 1-2 are fixes.  arch_irqs_disabled_flags() only reported
interrupts as disabled at IPL_MAX, but PALcode enters handlers at the
IPL of the interrupt being delivered, so a device or timer handler
answered that interrupts were enabled.  handle_irq() also called
irq_to_desc() before irq_enter(), running generic code with the preempt
count still saying task context and RCU not yet watching.  Both matter on
their own; patches 23 and 24 are what made them visible.

Patches 3-11 are one-line selects with no Alpha code behind them:
instrumentation (UBSAN, gcov, kmemleak), EDAC, and four properties Alpha
has always had but never declared (LL/SC atomics, hardware multiply,
__int128, the existing asm/compiler.h, and the non-overlapping user and
kernel address spaces).

Patches 12-17 add a small amount of code: an empty thread_struct
whitelist, _PAGE_SPECIAL on a free PTE bit, the page table check helpers,
and then the three things that follow from those - the page table helper
self test, lockless GUP, and the early memtest.  Note that early_memtest()
is called from arch_mm_preinit() rather than paging_init(), because Alpha
calls paging_init() from setup_arch(), before parse_early_param() has seen
the memtest= option.

Patches 18-20 change something visible.  Unhandled user faults now print
the usual message under the debug.exception-trace sysctl.  .eh_frame is
discarded: gcc emits it for Alpha regardless of
-fno-asynchronous-unwind-tables, it was allocated in the loaded image, and
nothing consumes it, since the stack trace code scans for text addresses
rather than unwinding DWARF.  That is worth about 1.1MB.  With that and
the relocation sections placed explicitly, the kernel links with no
orphans left, so the last of the three asks the linker to say so.

Patches 21-24 are the ones I expect to draw comment.  Patch 22 adds a
uapi header, so the perf register numbering is an ABI decision.  Patch 23
is SPARSE_IRQ: without it Marvel carries a 12.6MB static irq_desc[] in
.data for 32768 possible interrupts, of which a real ES47 uses 87, and
the kernel links at a fixed address just above the console reservation
where that 12.6MB is the difference between fitting and not.  Patch 24
instruments the entry assembly for lockdep hardirq tracking.

Tested with gcc 17 under QEMU (-M clipper -smp 2, an ALPHA_GENERIC build)
with PROVE_LOCKING enabled: no splats, early_memtest passes all four
patterns over the free memblock ranges with nothing reserved,
debug_vm_pgtable validates with no warning, a vmsplice() of an anonymous
mapping through pin_user_pages_fast() returns the right data, and an
unhandled SIGSEGV prints the new trace line.  Patch 23 was tested on an
AlphaServer ES47.

Not included, and worth mentioning: ARCH_HAS_KCOV.  A kernel with
KCOV_INSTRUMENT_ALL boots and runs, but CONFIG_KCOV_SELFTEST panics.  The
self test deliberately arms kcov with no coverage area so that any
instrumented function reached from interrupt context faults, checking
that nothing escapes the window before the preempt count says hardirq.
On Alpha something does.  Patch 2 fixes one such site; the panic survives
it, so the entry paths need an audit first.

Also available at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mattst88/alpha.git arch-kconfig-options

Matt Turner (24):
  alpha: fix arch_irqs_disabled_flags() to treat any raised IPL as
    disabled
  alpha: enter hardirq context before looking up the irq descriptor
  alpha: select ARCH_HAS_UBSAN
  alpha: select ARCH_HAS_GCOV_PROFILE_ALL
  alpha: select HAVE_DEBUG_KMEMLEAK
  alpha: select EDAC_SUPPORT
  alpha: select ARCH_SUPPORTS_ATOMIC_RMW
  alpha: select ARCH_HAS_FAST_MULTIPLIER
  alpha: select ARCH_SUPPORTS_INT128
  alpha: select HAVE_ARCH_COMPILER_H
  alpha: select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
  alpha: add HAVE_ARCH_THREAD_STRUCT_WHITELIST support
  alpha: add ARCH_HAS_PTE_SPECIAL support
  alpha: add ARCH_SUPPORTS_PAGE_TABLE_CHECK support
  alpha: select ARCH_HAS_DEBUG_VM_PGTABLE
  alpha: select HAVE_GUP_FAST
  alpha: select ARCH_USE_MEMTEST
  alpha: select SYSCTL_EXCEPTION_TRACE
  alpha: discard .eh_frame and the relocation sections
  alpha: select ARCH_WANT_LD_ORPHAN_WARN
  alpha: select ARCH_WANT_IRQS_OFF_ACTIVATE_MM
  alpha: add HAVE_PERF_REGS and HAVE_PERF_USER_STACK_DUMP support
  alpha: select SPARSE_IRQ
  alpha: add TRACE_IRQFLAGS_SUPPORT

 arch/alpha/Kconfig                      | 21 ++++++
 arch/alpha/include/asm/irqflags.h       |  2 +-
 arch/alpha/include/asm/perf_regs.h      |  7 ++
 arch/alpha/include/asm/pgtable.h        | 21 +++++-
 arch/alpha/include/asm/processor.h      |  7 ++
 arch/alpha/include/uapi/asm/perf_regs.h | 34 ++++++++++
 arch/alpha/kernel/Makefile              |  1 +
 arch/alpha/kernel/entry.S               | 54 +++++++++++++Matt Turner (24):
  alpha: fix arch_irqs_disabled_flags() to treat any raised IPL as
    disabled
  alpha: enter hardirq context before looking up the irq descriptor
  alpha: select ARCH_HAS_UBSAN
  alpha: select ARCH_HAS_GCOV_PROFILE_ALL
  alpha: select HAVE_DEBUG_KMEMLEAK
  alpha: select EDAC_SUPPORT
  alpha: select ARCH_SUPPORTS_ATOMIC_RMW
  alpha: select ARCH_HAS_FAST_MULTIPLIER
  alpha: select ARCH_SUPPORTS_INT128
  alpha: select HAVE_ARCH_COMPILER_H
  alpha: select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
  alpha: add HAVE_ARCH_THREAD_STRUCT_WHITELIST support
  alpha: add ARCH_HAS_PTE_SPECIAL support
  alpha: add ARCH_SUPPORTS_PAGE_TABLE_CHECK support
  alpha: select ARCH_HAS_DEBUG_VM_PGTABLE
  alpha: select HAVE_GUP_FAST
  alpha: select ARCH_USE_MEMTEST
  alpha: select SYSCTL_EXCEPTION_TRACE
  alpha: discard .eh_frame and the relocation sections
  alpha: select ARCH_WANT_LD_ORPHAN_WARN
  alpha: select ARCH_WANT_IRQS_OFF_ACTIVATE_MM
  alpha: add HAVE_PERF_REGS and HAVE_PERF_USER_STACK_DUMP support
  alpha: select SPARSE_IRQ
  alpha: add TRACE_IRQFLAGS_SUPPORT

 arch/alpha/Kconfig                      | 21 ++++++
 arch/alpha/include/asm/irqflags.h       |  2 +-
 arch/alpha/include/asm/perf_regs.h      |  7 ++
 arch/alpha/include/asm/pgtable.h        | 21 +++++-
 arch/alpha/include/asm/processor.h      |  7 ++
 arch/alpha/include/uapi/asm/perf_regs.h | 34 ++++++++++
 arch/alpha/kernel/Makefile              |  1 +
 arch/alpha/kernel/entry.S               | 54 +++++++++++++---
 arch/alpha/kernel/irq.c                 |  9 ++-
 arch/alpha/kernel/irq_alpha.c           | 13 ++++
 arch/alpha/kernel/perf_regs.c           | 86 +++++++++++++++++++++++++
 arch/alpha/kernel/vmlinux.lds.S         | 11 ++++
 arch/alpha/mm/fault.c                   | 29 +++++++++
 arch/alpha/mm/init.c                    |  5 ++
 14 files changed, 287 insertions(+), 13 deletions(-)
 create mode 100644 arch/alpha/include/asm/perf_regs.h
 create mode 100644 arch/alpha/include/uapi/asm/perf_regs.h
 create mode 100644 arch/alpha/kernel/perf_regs.c

-- 
2.54.0
Re: [PATCH 00/24] alpha: catch up on architecture Kconfig options
Posted by Magnus Lindholm 3 weeks, 2 days ago
Hi Matt,

On Tue, Sep 1, 2026 at 5:50 PM Matt Turner <mattst88@gmail.com> wrote:
>
> Alpha is missing a long list of Kconfig options that other architectures
> have picked up over the years, some of them for no better reason than
> nobody having gone through the list.  I diffed the select statements in
> every other arch/*/Kconfig against arch/alpha/Kconfig and worked through
> what turned up.  This series is the result: two fixes it depends on, and
> the options that are either free or close to it.
>
> The patches are ordered from least to most contentious, so the front of
> the series can be applied on its own if the tail needs discussion.
>
> Patches 1-2 are fixes.  arch_irqs_disabled_flags() only reported
> interrupts as disabled at IPL_MAX, but PALcode enters handlers at the
> IPL of the interrupt being delivered, so a device or timer handler
> answered that interrupts were enabled.  handle_irq() also called
> irq_to_desc() before irq_enter(), running generic code with the preempt
> count still saying task context and RCU not yet watching.  Both matter on
> their own; patches 23 and 24 are what made them visible.
>
> Patches 3-11 are one-line selects with no Alpha code behind them:
> instrumentation (UBSAN, gcov, kmemleak), EDAC, and four properties Alpha
> has always had but never declared (LL/SC atomics, hardware multiply,
> __int128, the existing asm/compiler.h, and the non-overlapping user and
> kernel address spaces).
>
> Patches 12-17 add a small amount of code: an empty thread_struct
> whitelist, _PAGE_SPECIAL on a free PTE bit, the page table check helpers,
> and then the three things that follow from those - the page table helper
> self test, lockless GUP, and the early memtest.  Note that early_memtest()
> is called from arch_mm_preinit() rather than paging_init(), because Alpha
> calls paging_init() from setup_arch(), before parse_early_param() has seen
> the memtest= option.
>
> Patches 18-20 change something visible.  Unhandled user faults now print
> the usual message under the debug.exception-trace sysctl.  .eh_frame is
> discarded: gcc emits it for Alpha regardless of
> -fno-asynchronous-unwind-tables, it was allocated in the loaded image, and
> nothing consumes it, since the stack trace code scans for text addresses
> rather than unwinding DWARF.  That is worth about 1.1MB.  With that and
> the relocation sections placed explicitly, the kernel links with no
> orphans left, so the last of the three asks the linker to say so.
>
> Patches 21-24 are the ones I expect to draw comment.  Patch 22 adds a
> uapi header, so the perf register numbering is an ABI decision.  Patch 23
> is SPARSE_IRQ: without it Marvel carries a 12.6MB static irq_desc[] in
> .data for 32768 possible interrupts, of which a real ES47 uses 87, and
> the kernel links at a fixed address just above the console reservation
> where that 12.6MB is the difference between fitting and not.  Patch 24
> instruments the entry assembly for lockdep hardirq tracking.
>
> Tested with gcc 17 under QEMU (-M clipper -smp 2, an ALPHA_GENERIC build)
> with PROVE_LOCKING enabled: no splats, early_memtest passes all four
> patterns over the free memblock ranges with nothing reserved,
> debug_vm_pgtable validates with no warning, a vmsplice() of an anonymous
> mapping through pin_user_pages_fast() returns the right data, and an
> unhandled SIGSEGV prints the new trace line.  Patch 23 was tested on an
> AlphaServer ES47.
>
> Not included, and worth mentioning: ARCH_HAS_KCOV.  A kernel with
> KCOV_INSTRUMENT_ALL boots and runs, but CONFIG_KCOV_SELFTEST panics.  The
> self test deliberately arms kcov with no coverage area so that any
> instrumented function reached from interrupt context faults, checking
> that nothing escapes the window before the preempt count says hardirq.
> On Alpha something does.  Patch 2 fixes one such site; the panic survives
> it, so the entry paths need an audit first.
>

Thanks for taking the time to do this! This is a nice collection of patches.
I've started on the review and testing, I will keep at it.
As general feedback for the series, I noticed that several of the
corresponding architecture feature matrices still list Alpha as TODO.
The Alpha entries should be changed to "ok" for:

  ARCH_HAS_GCOV_PROFILE_ALL
  HAVE_DEBUG_KMEMLEAK
  ARCH_HAS_PTE_SPECIAL
  ARCH_HAS_DEBUG_VM_PGTABLE
  HAVE_PERF_REGS
  HAVE_PERF_USER_STACK_DUMP

These correspond to patches 4, 5, 13, 15, and 22.  It would probably be
best to include each documentation update in the patch which enables the
corresponding feature.

It would also be helpful if the next revision were rebased onto
v7.3-rc1 and applied cleanly on top of my Alpha GENERIC_ENTRY v5 series.
I am currently testing only the patches which applied successfully.

Alpha GENERIC_ENTRY v5 series is available here:
https://lore.kernel.org/linux-alpha/20260902184058.198679-1-linmag7@gmail.com/T/#t

Regards,
Magnus
Re: [PATCH 00/24] alpha: catch up on architecture Kconfig options
Posted by Matt Turner 3 weeks, 2 days ago
On Wed, Sep 2, 2026 at 2:54 PM Magnus Lindholm <linmag7@gmail.com> wrote:
>
> Hi Matt,
>
> On Tue, Sep 1, 2026 at 5:50 PM Matt Turner <mattst88@gmail.com> wrote:
> >
> > Alpha is missing a long list of Kconfig options that other architectures
> > have picked up over the years, some of them for no better reason than
> > nobody having gone through the list.  I diffed the select statements in
> > every other arch/*/Kconfig against arch/alpha/Kconfig and worked through
> > what turned up.  This series is the result: two fixes it depends on, and
> > the options that are either free or close to it.
> >
> > The patches are ordered from least to most contentious, so the front of
> > the series can be applied on its own if the tail needs discussion.
> >
> > Patches 1-2 are fixes.  arch_irqs_disabled_flags() only reported
> > interrupts as disabled at IPL_MAX, but PALcode enters handlers at the
> > IPL of the interrupt being delivered, so a device or timer handler
> > answered that interrupts were enabled.  handle_irq() also called
> > irq_to_desc() before irq_enter(), running generic code with the preempt
> > count still saying task context and RCU not yet watching.  Both matter on
> > their own; patches 23 and 24 are what made them visible.
> >
> > Patches 3-11 are one-line selects with no Alpha code behind them:
> > instrumentation (UBSAN, gcov, kmemleak), EDAC, and four properties Alpha
> > has always had but never declared (LL/SC atomics, hardware multiply,
> > __int128, the existing asm/compiler.h, and the non-overlapping user and
> > kernel address spaces).
> >
> > Patches 12-17 add a small amount of code: an empty thread_struct
> > whitelist, _PAGE_SPECIAL on a free PTE bit, the page table check helpers,
> > and then the three things that follow from those - the page table helper
> > self test, lockless GUP, and the early memtest.  Note that early_memtest()
> > is called from arch_mm_preinit() rather than paging_init(), because Alpha
> > calls paging_init() from setup_arch(), before parse_early_param() has seen
> > the memtest= option.
> >
> > Patches 18-20 change something visible.  Unhandled user faults now print
> > the usual message under the debug.exception-trace sysctl.  .eh_frame is
> > discarded: gcc emits it for Alpha regardless of
> > -fno-asynchronous-unwind-tables, it was allocated in the loaded image, and
> > nothing consumes it, since the stack trace code scans for text addresses
> > rather than unwinding DWARF.  That is worth about 1.1MB.  With that and
> > the relocation sections placed explicitly, the kernel links with no
> > orphans left, so the last of the three asks the linker to say so.
> >
> > Patches 21-24 are the ones I expect to draw comment.  Patch 22 adds a
> > uapi header, so the perf register numbering is an ABI decision.  Patch 23
> > is SPARSE_IRQ: without it Marvel carries a 12.6MB static irq_desc[] in
> > .data for 32768 possible interrupts, of which a real ES47 uses 87, and
> > the kernel links at a fixed address just above the console reservation
> > where that 12.6MB is the difference between fitting and not.  Patch 24
> > instruments the entry assembly for lockdep hardirq tracking.
> >
> > Tested with gcc 17 under QEMU (-M clipper -smp 2, an ALPHA_GENERIC build)
> > with PROVE_LOCKING enabled: no splats, early_memtest passes all four
> > patterns over the free memblock ranges with nothing reserved,
> > debug_vm_pgtable validates with no warning, a vmsplice() of an anonymous
> > mapping through pin_user_pages_fast() returns the right data, and an
> > unhandled SIGSEGV prints the new trace line.  Patch 23 was tested on an
> > AlphaServer ES47.
> >
> > Not included, and worth mentioning: ARCH_HAS_KCOV.  A kernel with
> > KCOV_INSTRUMENT_ALL boots and runs, but CONFIG_KCOV_SELFTEST panics.  The
> > self test deliberately arms kcov with no coverage area so that any
> > instrumented function reached from interrupt context faults, checking
> > that nothing escapes the window before the preempt count says hardirq.
> > On Alpha something does.  Patch 2 fixes one such site; the panic survives
> > it, so the entry paths need an audit first.
> >
>
> Thanks for taking the time to do this! This is a nice collection of patches.
> I've started on the review and testing, I will keep at it.
> As general feedback for the series, I noticed that several of the
> corresponding architecture feature matrices still list Alpha as TODO.
> The Alpha entries should be changed to "ok" for:
>
>   ARCH_HAS_GCOV_PROFILE_ALL
>   HAVE_DEBUG_KMEMLEAK
>   ARCH_HAS_PTE_SPECIAL
>   ARCH_HAS_DEBUG_VM_PGTABLE
>   HAVE_PERF_REGS
>   HAVE_PERF_USER_STACK_DUMP
>
> These correspond to patches 4, 5, 13, 15, and 22.  It would probably be
> best to include each documentation update in the patch which enables the
> corresponding feature.

Oh, definitely. Thanks for catching that.

> It would also be helpful if the next revision were rebased onto
> v7.3-rc1 and applied cleanly on top of my Alpha GENERIC_ENTRY v5 series.
> I am currently testing only the patches which applied successfully.
>
> Alpha GENERIC_ENTRY v5 series is available here:
> https://lore.kernel.org/linux-alpha/20260902184058.198679-1-linmag7@gmail.com/T/#t

Perfect, I will do it!