Linux Perf Users
 help / color / mirror / Atom feed
From: Stian Halseth <stian@itx.no>
To: sashiko-reviews@lists.linux.dev
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [RFC PATCH v3 3/3] perf tools: Support sparc user register samples and dwarf unwinding
Date: Wed, 23 Sep 2026 11:42:43 +0200	[thread overview]
Message-ID: <32d5f620550bab0cffdeac83147ca0a28c9834ed.camel@itx.no> (raw)
In-Reply-To: <20260923091443.2C7971F000FF@smtp.kernel.org>

[-- Attachment #1: Type: text/plain, Size: 2589 bytes --]

On Wed, 2026-09-23 at 09:14 +0000, sashiko-bot@kernel.org wrote:
> 
> > +	case PERF_REG_SPARC_Y:
> > +		return "y";
> > +	default:
> > +		return NULL;
> > +	}
> > +
> > +	return NULL;
> 
> [Severity: Low]
> Does this rely on implicit header inclusion for NULL?
> 
> The NULL macro is used here, but neither <stddef.h> nor <stdlib.h> is
> explicitly included in this file. It appears to rely on the implicit
> inclusion
> of <stdlib.h> via the ../../arch/sparc/include/perf_regs.h header.
> 
> Should this explicitly include <stddef.h> or <stdlib.h>?

My take is: No.

perf_regs.h includes <stdlib.h>

It's done like this to maintain consistency with perf_regs_arm.c,
perf_regs_mips.c and perf_regs_loongarch.c.



> > +/*
> > + * The sampled window's %l and %i registers (DWARF 16-31) are not
> > in the
> > + * sample; the kernel flushed them to the register save area at
> > the start
> > + * of the dumped stack.
> > + */
> > +static void libdw_set_sparc_window_registers(struct unwind_info
> > *ui,
> > +					     struct regs_dump
> > *user_regs,
> > +					     Dwarf_Word
> > *dwarf_regs)
> > +{
> > +	struct stack_dump *stack = &ui->sample->user_stack;
> > +	u64 sp;
> > +
> > +	if (perf_reg_value(&sp, user_regs, perf_arch_reg_sp(ui-
> > >e_machine)))
> > +		return;
> > +	if (!(sp & 1) || 16 * sizeof(u64) > stack->size)
> > +		return;
> > +
> > +	memcpy(&dwarf_regs[16], stack->data, 16 * sizeof(u64));
> 
> [Severity: Medium]
> When analyzing a SPARC perf.data file on a little-endian host, will
> this
> memcpy() write raw big-endian bytes into the little-endian host
> variables?
> 
> The dwarf_regs array is composed of Dwarf_Word (uint64_t) elements
> and expects
> values in host endianness, while the stack dump (stack->data) retains
> the
> target's original memory layout and endianness (SPARC is strictly
> big-endian).
> 
> This can cause the 64-bit integer values read by libdw to be byte-
> swapped,
> breaking cross-architecture DWARF unwinding for SPARC as the stack
> unwinder
> relies on %i6 and %i7 (DWARF registers 30 and 31) to find the
> caller's frame.
> 
> Should this code perform conditional byte-swapping when copying from
> the stack
> dump?

No.

Checked by analyzing a sparc64 perf.data on x86 with this series.

unwinds leaf -> mid2 -> mid1 -> main -> __libc_start_main -> _start,
the same as on the SPARC T4.

The dump of a 64-bit sparc stack starts at %sp + 2047. It's 16-byte
aligned, so each saved register is one swap unit and is already in host
order.



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-09-23  9:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23  9:04 [RFC PATCH v3 0/3] perf: sparc64 user regs and stack dump, with arch hooks Stian Halseth
2026-09-23  9:04 ` [RFC PATCH v3 1/3] perf/core: Let an arch prepare and locate the user stack dump Stian Halseth
2026-09-23  9:16   ` sashiko-bot
2026-09-23  9:04 ` [RFC PATCH v3 2/3] sparc64: Support PERF_SAMPLE_REGS_USER and PERF_SAMPLE_STACK_USER Stian Halseth
2026-09-23  9:14   ` sashiko-bot
2026-09-23  9:04 ` [RFC PATCH v3 3/3] perf tools: Support sparc user register samples and dwarf unwinding Stian Halseth
2026-09-23  9:14   ` sashiko-bot
2026-09-23  9:42     ` Stian Halseth [this message]
2026-09-23 16:02       ` Ian Rogers
2026-09-23 19:36         ` Stian Halseth
2026-09-23 20:38 ` [RFC PATCH v3 0/3] perf: sparc64 user regs and stack dump, with arch hooks Ian Rogers
2026-09-23 20:56   ` Stian Halseth
2026-09-23 21:16     ` Ian Rogers
2026-09-24 17:09       ` Arnaldo Carvalho de Melo
2026-09-24 17:11         ` Arnaldo Carvalho de Melo
2026-09-25  7:33           ` Stian Halseth
2026-09-23 23:10 ` Magnus Lindholm
2026-09-24  8:20   ` Stian Halseth

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=32d5f620550bab0cffdeac83147ca0a28c9834ed.camel@itx.no \
    --to=stian@itx.no \
    --cc=linux-perf-users@vger.kernel.org \
    --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