Subject: [RFC PATCH 00/19] Remove STACK_FRAME_OVERHEAD

From: Nicholas Piggin <[email-masked]>
Date: Mon, 31 Oct 2022 15:54:21 +1000

This is some quick hacking, hardly tested but might have potential.

I think we're not validating the perf kernel stack walker bounds
quite correctly, and not setting up decent stack frames for the child
in copy_thread. So at least those two things we could do. Maybe
patch 1 should go upstream as a fix.

Thanks,
Nick

Nicholas Piggin (19):
  powerpc/perf: callchain validate kernel stack pointer bounds
  powerpc: Rearrange copy_thread child stack creation
  powerpc/64: Remove asm interrupt tracing call helpers
  powerpc/pseries: hvcall stack frame overhead
  powerpc/32: Use load and store multiple in GPR save/restore macros
  powerpc: simplify ppc_save_regs
  powerpc: add definition for pt_regs offset within an interrupt frame
  powerpc: add a definition for the marker offset within the interrupt
    frame
  powerpc: Rename STACK_FRAME_MARKER and derive it from frame offset
  powerpc: add a define for the user interrupt frame size
  powerpc: add a define for the switch frame size and regs offset
  powerpc: copy_thread fill in interrupt frame marker and back chain
  powerpc: copy_thread add a back chain to the switch stack frame
  powerpc: split validate_sp into two functions
  powerpc: allow minimum sized kernel stack frames
  powerpc/64: ELFv2 use minimal stack frames in int and switch frame
    sizes
  powerpc: remove STACK_FRAME_OVERHEAD
  powerpc: change stack marker memory operations to 32-bit
  powerpc/64: ELFv2 use reserved word in the stack frame for the regs
    marker

 arch/powerpc/include/asm/irqflags.h           | 29 -------
 arch/powerpc/include/asm/ppc_asm.h            | 18 +++-
 arch/powerpc/include/asm/processor.h          | 15 +++-
 arch/powerpc/include/asm/ptrace.h             | 41 +++++++---
 arch/powerpc/kernel/asm-offsets.c             |  9 +-
 arch/powerpc/kernel/entry_32.S                | 14 ++--
 arch/powerpc/kernel/exceptions-64e.S          | 44 +++++-----
 arch/powerpc/kernel/exceptions-64s.S          | 82 +++++++++----------
 arch/powerpc/kernel/head_32.h                 |  4 +-
 arch/powerpc/kernel/head_40x.S                |  2 +-
 arch/powerpc/kernel/head_44x.S                |  6 +-
 arch/powerpc/kernel/head_64.S                 |  6 +-
 arch/powerpc/kernel/head_85xx.S               |  8 +-
 arch/powerpc/kernel/head_8xx.S                |  2 +-
 arch/powerpc/kernel/head_book3s_32.S          |  4 +-
 arch/powerpc/kernel/head_booke.h              |  4 +-
 arch/powerpc/kernel/interrupt_64.S            | 32 ++++----
 arch/powerpc/kernel/irq.c                     |  4 +-
 arch/powerpc/kernel/kgdb.c                    |  2 +-
 arch/powerpc/kernel/misc_32.S                 |  2 +-
 arch/powerpc/kernel/misc_64.S                 |  4 +-
 arch/powerpc/kernel/optprobes_head.S          |  4 +-
 arch/powerpc/kernel/ppc_save_regs.S           | 58 ++++---------
 arch/powerpc/kernel/process.c                 | 54 +++++++-----
 arch/powerpc/kernel/smp.c                     |  2 +-
 arch/powerpc/kernel/stacktrace.c              | 10 +--
 arch/powerpc/kernel/tm.S                      |  8 +-
 arch/powerpc/kernel/trace/ftrace_mprofile.S   |  2 +-
 arch/powerpc/kvm/book3s_hv_rmhandlers.S       |  2 +-
 .../lib/test_emulate_step_exec_instr.S        |  2 +-
 arch/powerpc/perf/callchain.c                 |  9 +-
 arch/powerpc/platforms/pseries/hvCall.S       | 38 +++++----
 arch/powerpc/xmon/xmon.c                      | 10 +--
 33 files changed, 263 insertions(+), 268 deletions(-)

-- 
2.37.2