Re: [PATCH] perf: Fix oops when kthread execs user process

From: Will Deacon
Date: Mon Jun 03 2019 - 07:27:52 EST


On Fri, May 31, 2019 at 04:37:15PM +0100, Will Deacon wrote:
> Oh, nice! I think this happens because Power doesn't actually initialise
> the regs after a kthread execs() until late in start_thread(). But the plot
> thickens somewhat, since current_pt_regs() is different to
> task_pt_regs(current) on Power (the former cannot return NULL).
>
> So a really hideous hack on top of Peter's patch might be:
>
> diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c
> index 0bbac612146e..5bde866024b6 100644
> --- a/arch/arm64/kernel/perf_regs.c
> +++ b/arch/arm64/kernel/perf_regs.c
> @@ -57,6 +57,6 @@ void perf_get_regs_user(struct perf_regs *regs_user,
> struct pt_regs *regs,
> struct pt_regs *regs_user_copy)
> {
> - regs_user->regs = task_pt_regs(current);
> + regs_user->regs = current_pt_regs();
> regs_user->abi = perf_reg_abi(current);

^^^ Bah, this was clearly supposed to be a change in the powerpc code, but
you get the idea.

Will