Thread (26 messages) flat view 26 messages, 1 author, 2d ago
WARM2d

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

From: Leo Yan <leo.yan@arm.com>
Date: 2026-09-15 15:49:52
Also in: linux-doc, linux-perf-users, lkml
Subsystem: arm/coresight framework and drivers, hardware tracing facilities, the rest · Maintainers: Suzuki K Poulose, Alexander Shishkin, Linus Torvalds

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@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;
 	}
-- 
2.34.1

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help