Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Matt Turner" <mattst88@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v3 4/7] alpha/perf: do not report user registers from the entry code
Date: Sun, 01 Nov 2026 19:48:44 +0000	[thread overview]
Message-ID: <sashiko-outbox-192633@kernel.org> (raw)
In-Reply-To: <20261101-alpha-profileme-v3-4-92d511b5a044@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] alpha/perf: __entry_save_end precedes r16-r18 save in entSys
--

commit ce97475b8e0171fa2ccbfec6b4cebc978a8757a6
Author: Matt Turner <mattst88@gmail.com>

alpha/perf: do not report user registers from the entry code

This commit prevents perf_get_regs_user() from returning an incomplete user
pt_regs frame when a perf sample interrupts kernel exception or syscall
entry before the user registers have finished being saved.

> diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S
> index 790389a15c3ce..2de7cdd3a8725 100644
> --- a/arch/alpha/kernel/entry.S
> +++ b/arch/alpha/kernel/entry.S

[ ... ]

> @@ -473,6 +479,8 @@ CFI_END_OSF_FRAME entDbg
>  	.cfi_rel_offset	$gp, 16
>  entSys:
>  	SAVE_ALL
> +	.globl	__entry_save_end
> +__entry_save_end:
>  	ldq	$1, 0($sp)	/* syscall nr from saved r0 */
>  	stq	$1, 8($sp)	/* regs->r1 = shadow syscall nr */

[Severity: Medium]
Should __entry_save_end be placed after $16, $17, and $18 are stored into
SP_OFF+24..40($sp) in entSys?

Unlike non-syscall PALcode entries, PAL_callsys does not save user $16..$18
into the PALcode stack frame, and SAVE_ALL only stores them into
trap_a0..trap_a2 at 160..176($sp). In entSys, pt_regs->r16..r18 are
populated a few instructions after SAVE_ALL while interrupts are still
enabled:

arch/alpha/kernel/entry.S:
entSys:
	SAVE_ALL
	.globl	__entry_save_end
__entry_save_end:
	ldq	$1, 0($sp)	/* syscall nr from saved r0 */
	stq	$1, 8($sp)	/* regs->r1 = shadow syscall nr */

	lda	$8, 0x3fff
	bic	$sp, $8, $8

	stq	$16, SP_OFF+24($sp)
	stq	$17, SP_OFF+32($sp)
	stq	$18, SP_OFF+40($sp)

Since pt_regs_offset[] in arch/alpha/kernel/perf_regs.c maps
PERF_REG_ALPHA_R16..R18 to offsetof(struct pt_regs, r16..r18) rather than
trap_a0..trap_a2, if a perf interrupt lands between __entry_save_end and
stq $18, SP_OFF+40($sp), in_entry_save_code(regs->pc) will return false and
perf_get_regs_user() will expose task_pt_regs(current) before r16, r17, and
r18 have been saved.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261101-alpha-profileme-v3-0-92d511b5a044@gmail.com?part=4

  reply	other threads:[~2026-11-01 19:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01 19:28 [PATCH v3 0/7] alpha/perf: add ProfileMe sampling Matt Turner
2026-11-01 19:28 ` [PATCH v3 1/7] alpha/perf: pass PERFMON_CMD_LOGGING_ALL to the logging options call Matt Turner
2026-11-01 19:31   ` sashiko-bot
2026-11-01 19:28 ` [PATCH v3 2/7] alpha/perf: add sysfs format and event attributes Matt Turner
2026-11-01 19:33   ` sashiko-bot
2026-11-01 19:28 ` [PATCH v3 3/7] alpha/perf: clear PERF_HES_UPTODATE when an event starts counting Matt Turner
2026-11-01 19:39   ` sashiko-bot
2026-11-01 19:28 ` [PATCH v3 4/7] alpha/perf: do not report user registers from the entry code Matt Turner
2026-11-01 19:48   ` sashiko-bot [this message]
2026-11-01 19:28 ` [PATCH v3 5/7] alpha/perf: implement ProfileMe sampling Matt Turner
2026-11-01 20:12   ` sashiko-bot
2026-11-01 19:28 ` [PATCH v3 6/7] alpha/perf: attach ProfileMe status as PERF_SAMPLE_RAW data Matt Turner
2026-11-01 20:17   ` sashiko-bot
2026-11-01 19:28 ` [PATCH v3 7/7] alpha/perf: optionally randomize the ProfileMe sampling interval Matt Turner
2026-11-01 20:25   ` sashiko-bot

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=sashiko-outbox-192633@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mattst88@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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