Re: [Patch v5 13/19] perf/x86: Enable SSP sampling using sample_regs_* fields

From: Ravi Bangoria
Date: Wed Dec 24 2025 - 00:45:55 EST


Hi Dapeng,

> This patch enables sampling of CET SSP register via the sample_regs_*
> fields.
>
> To sample SSP, the sample_simd_regs_enabled field must be set. This
> allows the spare space (reclaimed from the original XMM space) in the
> sample_regs_* fields to be used for representing SSP.
>
> Similar with eGPRs sampling, the perf_reg_value() function needs to
> check if the PERF_SAMPLE_REGS_ABI_SIMD flag is set first, and then
> determine whether to output SSP or legacy XMM registers to userspace.

1. The userspace SSP is saved in REGS_INTR even though interrupt regs
are of kernel context. Would it be better to pass 0 instead (see the
_untested_ patch below).

--- a/arch/x86/kernel/perf_regs.c
+++ b/arch/x86/kernel/perf_regs.c
@@ -71,7 +71,7 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)
return perf_regs->egpr_regs[idx - PERF_REG_X86_R16];
}
if (idx == PERF_REG_X86_SSP) {
- if (!perf_regs->cet)
+ if (!perf_regs->cet || !user_mode(regs))
return 0;
return perf_regs->cet->user_ssp;
}

2. Could a simple "--user-regs=ssp / --intr-regs=ssp" (without SIMD/eGPR
regs) fallback to an RDMSR instead of XSAVE? Possibly as a future
enhancement if the current patches are already upstream ready.

Thanks,
Ravi