All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dapeng Mi" <dapeng1.mi@linux.intel.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [Patch v11 04/10] perf headers: Sync perf_event.h/perf_regs.h with the kernel headers
Date: Mon, 14 Sep 2026 02:01:44 +0000	[thread overview]
Message-ID: <20260914020145.4DEE91F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260914014049.2061519-5-dapeng1.mi@linux.intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Sample parser in ASLR tool fails to consume the new SIMD register payload when PERF_SAMPLE_REGS_ABI_SIMD is set, leading to stream desynchronization.
- [Low] perf_event_attr__fprintf() prints the newly added SIMD fields out of struct layout order.
--

commit 2a8ebff44960ffb0cedfa7b327d5de5cc826d750
Author: Dapeng Mi <dapeng1.mi@linux.intel.com>

perf headers: Sync perf_event.h/perf_regs.h with the kernel headers

Sync the UAPI header changes of supporting SIMD/eGPRs/SSP sampling into
corresponding tools UAPI headers. Additionally, support the newly introduced
perf_event_attr fields in the perf_event_attr__fprintf and
perf_event__attr_swap() helpers.

> diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
> index fd10aa8d697f2..c49fc76292f79 100644
> --- a/tools/include/uapi/linux/perf_event.h
> +++ b/tools/include/uapi/linux/perf_event.h

[ ... ]

> @@ -1020,7 +1045,15 @@ enum perf_event_type {
>  	 *      } && PERF_SAMPLE_BRANCH_STACK
>  	 *
>  	 *	{ u64			abi; # enum perf_sample_regs_abi
> -	 *	  u64			regs[weight(mask)]; } && PERF_SAMPLE_REGS_USER
> +	 *	  u64			regs[weight(mask)];
> +	 *	  struct {
> +	 *		u64 nr_vectors;		# 0 ... weight(sample_simd_vec_reg_user)
> +	 *		u64 vector_qwords;	# 0 ... sample_simd_vec_reg_qwords
> +	 *		u64 nr_pred;		# 0 ... weight(sample_simd_pred_reg_user)
> +	 *		u64 pred_qwords;	# 0 ... sample_simd_pred_reg_qwords
> +	 *		u64 data[nr_vectors * vector_qwords + nr_pred * pred_qwords];
> +	 *	  } && (abi & PERF_SAMPLE_REGS_ABI_SIMD)
> +	 *	} && PERF_SAMPLE_REGS_USER
>  	 *

[Severity: High]
Does this new ABI payload cause stream desynchronization in
tools/perf/util/aslr.c?

When PERF_SAMPLE_REGS_ABI_SIMD is set, aslr_tool__process_sample() fails to 
advance the payload pointer over the extended SIMD struct:

tools/perf/util/aslr.c:aslr_tool__process_sample() {
	...
	if (orig_sample_type & PERF_SAMPLE_REGS_USER) {
		u64 abi;

		if (CHECK_BOUNDS(1, 0)) {
			ret = -EFAULT;
			goto out_put;
		}
		abi = in_array[i++];
		if (abi != PERF_SAMPLE_REGS_ABI_NONE) {
			u64 nr = hweight64(orig_regs_user);

			if (nr > max_i - i) {
				ret = -EFAULT;
				goto out_put;
			}
			i += nr;
		}
	}
	...
}

It appears the function skips standard registers by adding
hweight64(orig_regs_user) to the parser index, but misses parsing or skipping
the dynamically sized SIMD payload that follows. Can this leave unparsed
SIMD data in the stream, potentially corrupting subsequent fields?

A similar regression is present in the PERF_SAMPLE_REGS_INTR handling within
the same function.

Note that while other parsers like evsel.c were fixed in subsequent patches,
aslr.c appears to remain broken at the end of the series.

[ ... ]

> diff --git a/tools/perf/util/perf_event_attr_fprintf.c b/tools/perf/util/perf_event_attr_fprintf.c
> index cc817294ad3d6..2e8be9a357dce 100644
> --- a/tools/perf/util/perf_event_attr_fprintf.c
> +++ b/tools/perf/util/perf_event_attr_fprintf.c
> @@ -407,8 +407,17 @@ int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr,
>  	}
>  	if (attr_size >= offsetof(struct perf_event_attr, config4))
>  		PRINT_ATTRf(config3, p_hex);
> -	if (attr_size > offsetof(struct perf_event_attr, config4))
> +	if (attr_size >= offsetof(struct perf_event_attr, sample_simd_regs_enabled))
>  		PRINT_ATTRf(config4, p_hex);
> +	if (attr_size > offsetof(struct perf_event_attr, sample_simd_vec_reg_user)) {
> +		PRINT_ATTRf(sample_simd_regs_enabled, p_unsigned);
> +		PRINT_ATTRf(sample_simd_pred_reg_qwords, p_unsigned);
> +		PRINT_ATTRf(sample_simd_pred_reg_intr, p_hex);
> +		PRINT_ATTRf(sample_simd_pred_reg_user, p_hex);
> +		PRINT_ATTRf(sample_simd_vec_reg_qwords, p_unsigned);
> +		PRINT_ATTRf(sample_simd_vec_reg_intr, p_hex);
> +		PRINT_ATTRf(sample_simd_vec_reg_user, p_hex);
> +	}

[Severity: Low]
Does this print the newly added SIMD fields out of struct layout order?

The UAPI struct definition in tools/include/uapi/linux/perf_event.h places
sample_simd_vec_reg_qwords before sample_simd_pred_reg_intr:

tools/include/uapi/linux/perf_event.h:struct perf_event_attr {
	...
	__u16	sample_simd_regs_enabled;
	__u16	sample_simd_pred_reg_qwords;
	__u16	sample_simd_vec_reg_qwords;
	__u16	__reserved_4;

	__u32	sample_simd_pred_reg_intr;
	__u32	sample_simd_pred_reg_user;
	...
}

However, the fprintf code above prints sample_simd_vec_reg_qwords after both
sample_simd_pred_reg_intr and sample_simd_pred_reg_user. Could this cause
minor confusion when debugging raw perf_event_attr fields?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260914014049.2061519-1-dapeng1.mi@linux.intel.com?part=4

  reply	other threads:[~2026-09-14  2:01 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14  1:40 [Patch v11 00/10] Perf tools: Support eGPRs/SSP/SIMD registers sampling Dapeng Mi
2026-09-14  1:40 ` [Patch v11 01/10] perf dwarf-regs: Fix DWARF register index bounds check Dapeng Mi
2026-09-14  1:55   ` sashiko-bot
2026-09-14  1:40 ` [Patch v11 02/10] perf util: Add missed fields in _attr__fprintf() and __attr_swap() Dapeng Mi
2026-09-14  1:53   ` sashiko-bot
2026-09-14  1:40 ` [Patch v11 03/10] tools headers: Sync x86 headers with kernel sources Dapeng Mi
2026-09-14  1:55   ` sashiko-bot
2026-09-14  3:06     ` Mi, Dapeng
2026-09-14  1:40 ` [Patch v11 04/10] perf headers: Sync perf_event.h/perf_regs.h with the kernel headers Dapeng Mi
2026-09-14  2:01   ` sashiko-bot [this message]
2026-09-14  3:23     ` Mi, Dapeng
2026-09-14  1:40 ` [Patch v11 05/10] perf regs: Support x86 eGPRs/SSP sampling Dapeng Mi
2026-09-14  2:06   ` sashiko-bot
2026-09-14  1:40 ` [Patch v11 06/10] perf regs: Support x86 SIMD registers sampling Dapeng Mi
2026-09-14  2:03   ` sashiko-bot
2026-09-14  5:14     ` Mi, Dapeng
2026-09-14  1:40 ` [Patch v11 07/10] perf regs: Enable dumping of SIMD registers Dapeng Mi
2026-09-14  2:04   ` sashiko-bot
2026-09-14  5:17     ` Mi, Dapeng
2026-09-14 18:29       ` Arnaldo Carvalho de Melo
2026-09-14 19:28         ` Arnaldo Carvalho de Melo
2026-09-14 23:56           ` Mi, Dapeng
2026-09-15  0:05             ` Arnaldo Carvalho de Melo
2026-09-14  1:40 ` [Patch v11 08/10] perf dwarf-regs: Add SIMD/eGPRs support for x86 DWARF registers Dapeng Mi
2026-09-14  1:56   ` sashiko-bot
2026-09-14  1:40 ` [Patch v11 09/10] perf tests: Add x86 eGPRs/SSP registers sampling test Dapeng Mi
2026-09-14  1:57   ` sashiko-bot
2026-09-14  1:40 ` [Patch v11 10/10] perf tests: Add SIMD " Dapeng Mi
2026-09-14  1:59   ` 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=20260914020145.4DEE91F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dapeng1.mi@linux.intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.