[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a331eceb-ec49-4396-a61d-78a75789b090@oss.qualcomm.com>
Date: Wed, 17 Sep 2025 09:35:55 +0800
From: Jie Gan <jie.gan@....qualcomm.com>
To: Carl Worth <carl@...amperecomputing.com>,
Suzuki K Poulose <suzuki.poulose@....com>,
Mike Leach
<mike.leach@...aro.org>,
James Clark <james.clark@...aro.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Sabrina Dubroca <sd@...asysnail.net>
Cc: coresight@...ts.linaro.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] coresight: Fix data argument to coresight_enable_helpers
On 9/17/2025 6:44 AM, Carl Worth wrote:
> In the commit being fixed, coresight_enable_path() was changed to call
> coresight_enable_helpers() with a final argument of 'path' rather than
> 'sink_data'. This was invalid, resulting in derefencing a pointer to
> a 'struct coresight_path' as if it were a 'struct perf_output_handle'.
>
> The compiler could not flag the error since there are several layers
> of function calls treating the pointer as void*.
>
> Fix to correctly pass the sink_data pointer as the final argument to
> coresight_enable_helpers(), exactly as it was before the buggy commit.
>
> Bug can be reproduced with:
>
> $ perf record -e cs_etm//k -C 0-9 dd if=/dev/zero of=/dev/null
>
> Showing an oops as follows:
>
> [ 88.696535] Unable to handle kernel paging request at virtual address 000f6e84934ed19e
> ...
> [ 88.911293] Call trace:
> [ 88.913728] tmc_etr_get_buffer+0x30/0x80 [coresight_tmc] (P)
> [ 88.919463] catu_enable_hw+0xbc/0x3d0 [coresight_catu]
> [ 88.924677] catu_enable+0x70/0xe0 [coresight_catu]
> [ 88.929542] coresight_enable_path+0xb0/0x258 [coresight]
>
> Fixes: 080ee83cc361 ("Coresight: Change functions to accept the coresight_path")
> Signed-off-by: Carl Worth <carl@...amperecomputing.com>
> ---
> drivers/hwtracing/coresight/coresight-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
> index fa758cc21827..b1077d73c988 100644
> --- a/drivers/hwtracing/coresight/coresight-core.c
> +++ b/drivers/hwtracing/coresight/coresight-core.c
> @@ -510,7 +510,7 @@ int coresight_enable_path(struct coresight_path *path, enum cs_mode mode,
> type = csdev->type;
>
> /* Enable all helpers adjacent to the path first */
> - ret = coresight_enable_helpers(csdev, mode, path);
> + ret = coresight_enable_helpers(csdev, mode, sink_data);
I dont think we can change back to sink_data since we introduced
coresight_path to wrap 'data' which is needed by the path.
I suggest you to add the struct perf_output_handle to the
coresight_path, then retrieving it with data->perf_handle in
tmc_etr_get_buffer.
before:
struct perf_output_handle *handle = data;
after:
struct coresight_path *path = data;
struct perf_output_handle *handle = path->perf_handle;
We can assign the perf_output_handle to the coresight_path after we
constructed the coresight_path in perf mode.
Thanks,
Jie
> if (ret)
> goto err_disable_path;
> /*
Powered by blists - more mailing lists