From: sashiko-bot@kernel.org
To: "Dapeng Mi" <dapeng1.mi@linux.intel.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [Patch v10 06/10] perf regs: Support x86 SIMD registers sampling
Date: Tue, 21 Jul 2026 07:50:12 +0000 [thread overview]
Message-ID: <20260721075012.961481F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260721072707.3787848-7-dapeng1.mi@linux.intel.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The sample parser fails to skip the SIMD register data payload, corrupting subsequent sample fields.
- [Medium] Silently synchronizing SIMD register masks between intr and user modes bypasses architectural capability checks.
- [Medium] Bypassing hardware event check for SIMD register sampling enables it for unsupported software events.
--
--- Patch [6]: [Patch v10 06/10] perf regs: Support x86 SIMD registers sampling ---
commit 511dc4506d241eccda5990483afe081741ffbdb5
Author: Dapeng Mi <dapeng1.mi@linux.intel.com>
perf regs: Support x86 SIMD registers sampling
This commit adds support for the SIMD register sampling format on x86 platforms.
It introduces functions to retrieve register class masks, names, and lengths for
both interrupt and user registers, and updates command-line parsing to handle
groups like XMM, YMM, ZMM, and OPMASK.
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index da0ad06446091..52249316709d7 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
[ ... ]
> @@ -1669,6 +1670,16 @@ void evsel__config(struct evsel *evsel, const struct record_opts *opts,
> evsel__set_sample_bit(evsel, REGS_INTR);
> }
>
> + if ((opts->sample_intr_vec_regs || opts->sample_intr_pred_regs) &&
> + !evsel->no_aux_samples && !evsel__is_dummy_event(evsel)) {
> + attr->sample_simd_regs_enabled = !!opts->sample_simd_regs_enabled;
[Severity: Medium]
When SIMD registers are enabled here, should there be a check to verify it is a
hardware event?
For regular registers, this is guarded with evsel__is_hardware_event(evsel),
but here it seems to unconditionally enable SIMD registers for software events.
Could this cause the kernel to reject the event with -EINVAL?
> + attr->sample_simd_vec_reg_intr = opts->sample_intr_vec_regs;
> + attr->sample_simd_vec_reg_qwords = opts->sample_vec_reg_qwords;
> + attr->sample_simd_pred_reg_intr = opts->sample_intr_pred_regs;
> + attr->sample_simd_pred_reg_qwords = opts->sample_pred_reg_qwords;
> + evsel__set_sample_bit(evsel, REGS_INTR);
> + }
[Severity: High]
If SIMD sampling is enabled, does the parser in __evsel__parse_sample() properly
skip the SIMD data payload?
It appears that __evsel__parse_sample() only skips the 4 header elements but
misses the variable-length SIMD data array that follows:
__evsel__parse_sample() {
...
if (regs->abi & PERF_SAMPLE_REGS_ABI_SIMD) {
/* Skip SIMD-regs header. */
sz = 4 * sizeof(u64);
OVERFLOW_CHECK(array, sz, max_size);
array = (void *)array + sz;
}
...
}
Will this leave the array pointer pointing at register data instead of the next
field (like PERF_SAMPLE_STACK_USER), potentially corrupting subsequent fields
and failing to parse the event?
> +
> if (opts->sample_user_regs && !evsel->no_aux_samples &&
> !evsel__is_dummy_event(evsel)) {
> attr->sample_regs_user |= opts->sample_user_regs;
> @@ -1677,6 +1688,16 @@ void evsel__config(struct evsel *evsel, const struct record_opts *opts,
> evsel__set_sample_bit(evsel, REGS_USER);
> }
>
> + if ((opts->sample_user_vec_regs || opts->sample_user_pred_regs) &&
> + !evsel->no_aux_samples && !evsel__is_dummy_event(evsel)) {
> + attr->sample_simd_regs_enabled = !!opts->sample_simd_regs_enabled;
> + attr->sample_simd_vec_reg_user = opts->sample_user_vec_regs;
> + attr->sample_simd_vec_reg_qwords = opts->sample_vec_reg_qwords;
> + attr->sample_simd_pred_reg_user = opts->sample_user_pred_regs;
> + attr->sample_simd_pred_reg_qwords = opts->sample_pred_reg_qwords;
> + evsel__set_sample_bit(evsel, REGS_USER);
> + }
> +
> if (target__has_cpu(&opts->target) || opts->sample_cpu)
> evsel__set_sample_bit(evsel, CPU);
>
> diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c
> index 70a1cc90b2c13..709fcfb077a2b 100644
> --- a/tools/perf/util/parse-regs-options.c
> +++ b/tools/perf/util/parse-regs-options.c
[ ... ]
> @@ -53,26 +106,116 @@ name_to_perf_reg_mask(const char *to_match, uint64_t mask, int abi)
> return reg_mask;
> }
>
> +static bool
> +name_to_simd_reg_mask(struct record_opts *opts, const char *to_match,
> + uint64_t mask, bool intr, bool pred)
> +{
[ ... ]
> + /*
> + * sample_intr_pred_regs and sample_user_pred_regs share
> + * sample_pred_reg_qwords. If both are set, keep their bitmaps identical.
> + */
> + if (opts->sample_intr_pred_regs && opts->sample_user_pred_regs) {
> + uint64_t max_pred_regs = MAX(opts->sample_intr_pred_regs,
> + opts->sample_user_pred_regs);
> +
> + opts->sample_intr_pred_regs = max_pred_regs;
> + opts->sample_user_pred_regs = max_pred_regs;
> + }
> + } else {
> + opts->sample_vec_reg_qwords =
> + MAX(qwords, opts->sample_vec_reg_qwords);
[ ... ]
> + /*
> + * sample_intr_vec_regs and sample_user_vec_regs share
> + * sample_vec_reg_qwords. If both are set, keep their bitmaps identical.
> + */
> + if (opts->sample_intr_vec_regs && opts->sample_user_vec_regs) {
> + uint64_t max_vec_regs = MAX(opts->sample_intr_vec_regs,
> + opts->sample_user_vec_regs);
> +
> + opts->sample_intr_vec_regs = max_vec_regs;
> + opts->sample_user_vec_regs = max_vec_regs;
> + }
> + }
[Severity: Medium]
Does synchronizing the SIMD register masks between intr and user modes bypass
architectural capability checks?
If a user specifies different sets for INTR and USER mode SIMD registers
(e.g., -I XMM --user-regs ZMM), forcing both masks to the maximum might
violate the capability check retrieved by
perf_intr_simd_reg_class_bitmap_qwords().
Will this cause perf record to pass an unsupported register bitmask and fail
with -EINVAL from the kernel?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260721072707.3787848-1-dapeng1.mi@linux.intel.com?part=6
next prev parent reply other threads:[~2026-07-21 7:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 7:26 [Patch v10 00/10] Perf tools: Support eGPRs/SSP/SIMD registers sampling Dapeng Mi
2026-07-21 7:26 ` [Patch v10 01/10] perf dwarf-regs: Fix DWARF register index bounds check Dapeng Mi
2026-07-21 7:26 ` [Patch v10 02/10] perf util: Add missed fields in _attr__fprintf() and __attr_swap() Dapeng Mi
2026-07-21 7:27 ` [Patch v10 03/10] tools headers: Sync x86 headers with kernel sources Dapeng Mi
2026-07-21 7:39 ` sashiko-bot
2026-07-21 7:27 ` [Patch v10 04/10] perf headers: Sync perf_event.h/perf_regs.h with the kernel headers Dapeng Mi
2026-07-21 7:47 ` sashiko-bot
2026-07-21 7:27 ` [Patch v10 05/10] perf regs: Support x86 eGPRs/SSP sampling Dapeng Mi
2026-07-21 7:52 ` sashiko-bot
2026-07-21 7:27 ` [Patch v10 06/10] perf regs: Support x86 SIMD registers sampling Dapeng Mi
2026-07-21 7:50 ` sashiko-bot [this message]
2026-07-21 7:27 ` [Patch v10 07/10] perf regs: Enable dumping of SIMD registers Dapeng Mi
2026-07-21 7:27 ` [Patch v10 08/10] perf dwarf-regs: Add SIMD/eGPRs support for x86 DWARF registers Dapeng Mi
2026-07-21 7:27 ` [Patch v10 09/10] perf tests: Add x86 eGPRs/SSP registers sampling test Dapeng Mi
2026-07-21 7:42 ` sashiko-bot
2026-07-21 7:27 ` [Patch v10 10/10] perf tests: Add SIMD " Dapeng Mi
2026-07-21 7:48 ` 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=20260721075012.961481F00A3D@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox