From: Jens Remus <jremus@linux.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>,
jpoimboe@kernel.org, rostedt@kernel.org,
Josh Poimboeuf <jpoimboe@kernel.org>,
Indu Bhagat <indu.bhagat@oracle.com>
Cc: linux-kernel@vger.kernel.org, Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>
Subject: Re: [PATCH 11/12] unwind: Implement compat fp unwind
Date: Fri, 17 Oct 2025 17:47:26 +0200 [thread overview]
Message-ID: <bd9bac99-208c-426d-b828-e23188d93226@linux.ibm.com> (raw)
In-Reply-To: <20250924080119.613695709@infradead.org>
Hello Peter, Steve, Josh, and Indu,
while rebasing the unwind user sframe series on top of this series and
https://lore.kernel.org/linux-trace-kernel/20251007214008.080852573@kernel.org/
I ran into the following issue:
On 9/24/2025 9:59 AM, Peter Zijlstra wrote:
> --- a/include/linux/unwind_user_types.h
> +++ b/include/linux/unwind_user_types.h
> @@ -36,6 +36,7 @@ struct unwind_user_state {
> unsigned long ip;
> unsigned long sp;
> unsigned long fp;
> + unsigned int ws;
Factoring out the word size (ws) from the CFA, FP, and RA offsets is
clever. Wondering though whether that would be an issue for unwind user
sframe. Do all architectures guarantee that those offsets are aligned
to the native word size?
> enum unwind_user_type current_type;
> unsigned int available_types;
> bool done;
> --- a/kernel/unwind/user.c
> +++ b/kernel/unwind/user.c
> @@ -29,21 +44,21 @@ static int unwind_user_next_fp(struct un
> }
>
> /* Get the Canonical Frame Address (CFA) */
> - cfa += frame->cfa_off;
> + cfa += state->ws * frame->cfa_off;
In SFrame the CFA, FP, and RA offsets are unscaled. Would it be ok, if
unwind user sframe would factor state->ws from those offset values? What
if they were not aligned? unwind user sframe would then have to fail.
@Indu: Thought from a SFrame perspective?
>
> /* stack going in wrong direction? */
> if (cfa <= state->sp)
> return -EINVAL;
>
> /* Make sure that the address is word aligned */
> - if (cfa & (sizeof(long) - 1))
> + if (cfa & (state->ws - 1))
> return -EINVAL;
Alternatively using a state->ws of 1 in uwind user sframe would defeat
this alignment check.
>
> /* Find the Return Address (RA) */
> - if (get_user(ra, (unsigned long *)(cfa + frame->ra_off)))
> + if (get_user_word(&ra, cfa, frame->ra_off, state->ws))
> return -EINVAL;
>
> - if (frame->fp_off && get_user(fp, (unsigned long __user *)(cfa + frame->fp_off)))
> + if (frame->fp_off && get_user_word(&fp, cfa, frame->fp_off, state->ws))
> return -EINVAL;
>
> state->ip = ra;
> @@ -100,6 +115,7 @@ static int unwind_user_start(struct unwi
> state->ip = instruction_pointer(regs);
> state->sp = user_stack_pointer(regs);
> state->fp = frame_pointer(regs);
> + state->ws = compat_user_mode(regs) ? sizeof(int) : sizeof(long);
>
> return 0;
> }
Thanks and regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
+49-7031-16-1128 Office
jremus@de.ibm.com
IBM
IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
next prev parent reply other threads:[~2025-10-17 15:48 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-24 7:59 [PATCH 00/12] Various fixes and x86 support Peter Zijlstra
2025-09-24 7:59 ` [PATCH 01/12] task_work: Fix NMI race condition Peter Zijlstra
2025-10-01 15:31 ` Steven Rostedt
2025-10-29 9:36 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-09-24 7:59 ` [PATCH 02/12] unwind: Shorten lines Peter Zijlstra
2025-10-01 15:32 ` Steven Rostedt
2025-10-29 9:36 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-09-24 7:59 ` [PATCH 03/12] unwind: Add required include files Peter Zijlstra
2025-10-01 15:32 ` Steven Rostedt
2025-10-29 9:36 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-09-24 7:59 ` [PATCH 04/12] unwind: Simplify unwind_reset_info() Peter Zijlstra
2025-10-01 15:33 ` Steven Rostedt
2025-10-29 9:36 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-09-24 7:59 ` [PATCH 05/12] unwind: Add comment to unwind_deferred_task_exit() Peter Zijlstra
2025-10-01 15:35 ` Steven Rostedt
2025-10-20 10:16 ` Peter Zijlstra
2025-10-22 15:16 ` Steven Rostedt
2025-10-29 9:36 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-09-24 7:59 ` [PATCH 06/12] unwind: Fix unwind_deferred_request() vs NMI Peter Zijlstra
2025-10-01 15:37 ` Steven Rostedt
2025-10-29 9:36 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-09-24 7:59 ` [PATCH 07/12] unwind: Clarify calling context Peter Zijlstra
2025-10-01 15:38 ` Steven Rostedt
2025-10-29 9:36 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-09-24 7:59 ` [PATCH 08/12] unwind: Simplify unwind_user_faultable() Peter Zijlstra
2025-10-01 15:40 ` Steven Rostedt
2025-10-20 10:17 ` Peter Zijlstra
2025-10-29 9:36 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-09-24 7:59 ` [PATCH 09/12] unwind: Make unwind_task_info::unwind_mask consistent Peter Zijlstra
2025-10-01 15:47 ` Steven Rostedt
2025-10-20 10:20 ` Peter Zijlstra
2025-10-29 9:36 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-09-24 7:59 ` [PATCH 10/12] unwind: Simplify unwind_user_next_fp() alignment check Peter Zijlstra
2025-10-01 15:55 ` Steven Rostedt
2025-10-20 10:28 ` Peter Zijlstra
2025-10-22 15:20 ` Steven Rostedt
2025-10-23 9:53 ` Peter Zijlstra
2025-10-29 9:36 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-09-24 7:59 ` [PATCH 11/12] unwind: Implement compat fp unwind Peter Zijlstra
2025-10-17 15:47 ` Jens Remus [this message]
2025-10-20 9:16 ` Jens Remus
2025-10-20 10:39 ` Peter Zijlstra
2025-10-20 10:48 ` Peter Zijlstra
2025-10-22 15:23 ` Steven Rostedt
2025-10-24 13:45 ` Peter Zijlstra
2025-10-22 14:55 ` Jens Remus
2025-10-24 13:40 ` Peter Zijlstra
2025-10-20 10:38 ` Peter Zijlstra
2025-10-22 18:31 ` Steven Rostedt
2025-10-24 14:10 ` Peter Zijlstra
2025-10-24 14:16 ` Peter Zijlstra
2025-10-29 9:36 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-09-24 8:00 ` [PATCH 12/12] unwind_user/x86: Enable frame pointer unwinding on x86 Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bd9bac99-208c-426d-b828-e23188d93226@linux.ibm.com \
--to=jremus@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=indu.bhagat@oracle.com \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®