Re: [RFC][PATCH 4/4] x86_32: Provide consistent pt_regs

From: Josh Poimboeuf
Date: Wed May 08 2019 - 07:59:10 EST


On Wed, May 08, 2019 at 09:49:05AM +0200, Peter Zijlstra wrote:
> Currently pt_regs on x86_32 has an oddity in that kernel regs
> (!user_mode(regs)) are short two entries (esp/ss). This means that any
> code trying to use them (typically: regs->sp) needs to jump through
> some unfortunate hoops.
>
> Change the entry code to fix this up and create a full pt_regs frame.
>
> This then simplifies:
>
> - ftrace
> - kprobes
> - stack unwinder
> - ptrace
> - kdump
> - kgdb
>
> Hated-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> ---
> arch/x86/entry/entry_32.S | 105 ++++++++++++++++++++++++++++++++++----
> arch/x86/include/asm/kexec.h | 17 ------
> arch/x86/include/asm/ptrace.h | 17 ------
> arch/x86/include/asm/stacktrace.h | 2
> arch/x86/kernel/crash.c | 8 --
> arch/x86/kernel/ftrace_32.S | 81 ++++++++++++++++-------------
> arch/x86/kernel/kgdb.c | 8 --
> arch/x86/kernel/kprobes/common.h | 4 -
> arch/x86/kernel/kprobes/core.c | 29 ++++------
> arch/x86/kernel/kprobes/opt.c | 20 ++++---
> arch/x86/kernel/process_32.c | 16 +----
> arch/x86/kernel/ptrace.c | 29 ----------
> arch/x86/kernel/time.c | 3 -
> arch/x86/kernel/unwind_frame.c | 32 +----------
> arch/x86/kernel/unwind_orc.c | 2
> 15 files changed, 181 insertions(+), 192 deletions(-)

Very nice diffstat. This moves all the pain to the 32-bit entry code
where it belongs.

--
Josh