[PATCH 08/25] coresight: perf: Validate context before resuming trace

James Clark james.clark at linaro.org
Mon Oct 19 02:27:47 PDT 2026



On 15/09/2026 16:48, Leo Yan wrote:
> An AUX pause ends the current AUX output before trying to begin a new
> one. That new beginning can fail, leaving the CoreSight path published
> after the perf handle has become inactive. AUX resume may also overlap
> a normal stop which clears the per-CPU context.
> 
> Pass the per-CPU ETM context to etm_event_resume() and centralize both
> lifetime checks there. Use perf_get_aux() to confirm that the AUX output
> handle is active and path to confirm that the context is still live.
> Resume the source only when both checks succeed.
> 
> Assisted-by: Codex:gpt-6
> Signed-off-by: Leo Yan <leo.yan at arm.com>
> ---
>   drivers/hwtracing/coresight/coresight-etm-perf.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
> index c7454da5c881c4a8eea5cc77902c9113c297096e..e3c9d3cf84c502f357a430bc3bfa854a776618f1 100644
> --- a/drivers/hwtracing/coresight/coresight-etm-perf.c
> +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
> @@ -517,11 +517,17 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
>   	goto out;
>   }
>   
> -static int etm_event_resume(struct coresight_path *path)
> +static int etm_event_resume(struct etm_ctxt *ctxt)
>   {
> +	struct perf_output_handle *handle = &ctxt->handle;
>   	struct coresight_device *source;
> +	struct coresight_path *path;
>   	int ret;
>   
> +	if (!perf_get_aux(handle))
> +		return 0;
> +
> +	path = etm_event_get_ctxt_path(ctxt);
>   	if (!path)
>   		return 0;
>   
> @@ -547,8 +553,7 @@ static void etm_event_start(struct perf_event *event, int flags)
>   	u64 hw_id;
>   
>   	if (flags & PERF_EF_RESUME) {
> -		path = etm_event_get_ctxt_path(ctxt);
> -		if (etm_event_resume(path) < 0)
> +		if (etm_event_resume(ctxt) < 0)
>   			goto fail;
>   		return;
>   	}
> 

Reviewed-by: James Clark <james.clark at linaro.org>



More information about the linux-arm-kernel mailing list