public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] coresight: tpdm: fix invalid MMIO access issue
@ 2026-04-07  4:47 Jie Gan
  2026-04-07  8:10 ` Leo Yan
  0 siblings, 1 reply; 5+ messages in thread
From: Jie Gan @ 2026-04-07  4:47 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Leo Yan,
	Alexander Shishkin, Tingwei Zhang
  Cc: coresight, linux-arm-kernel, linux-kernel, Jie Gan

Create the csdev_access struct only when a valid MMIO resource is
available. In tpdm_probe(), base is uninitialized for static TPDM
instances that lack an MMIO resource, causing csdev_access to be
created with a garbage address and potentially leading to
unexpected issues.

Fixes: 14ae052f7947 ("coresight: tpdm: add static tpdm support")
Signed-off-by: Jie Gan <jie.gan@oss.qualcomm.com>
---
 drivers/hwtracing/coresight/coresight-tpdm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c
index 9b16f368a58b..eaf7210af648 100644
--- a/drivers/hwtracing/coresight/coresight-tpdm.c
+++ b/drivers/hwtracing/coresight/coresight-tpdm.c
@@ -1430,6 +1430,7 @@ static int tpdm_probe(struct device *dev, struct resource *res)
 		if (ret)
 			return ret;
 
+		desc.access = CSDEV_ACCESS_IOMEM(base);
 		if (tpdm_has_dsb_dataset(drvdata))
 			of_property_read_u32(drvdata->dev->of_node,
 					     "qcom,dsb-msrs-num", &drvdata->dsb_msr_num);
@@ -1452,7 +1453,6 @@ static int tpdm_probe(struct device *dev, struct resource *res)
 	desc.ops = &tpdm_cs_ops;
 	desc.pdata = dev->platform_data;
 	desc.dev = dev;
-	desc.access = CSDEV_ACCESS_IOMEM(base);
 	if (res)
 		desc.groups = tpdm_attr_grps;
 	else

---
base-commit: 816f193dd0d95246f208590924dd962b192def78
change-id: 20260407-fix-potential-issue-in-tpdm-b07b44416051

Best regards,
-- 
Jie Gan <jie.gan@oss.qualcomm.com>



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] coresight: tpdm: fix invalid MMIO access issue
  2026-04-07  4:47 [PATCH] coresight: tpdm: fix invalid MMIO access issue Jie Gan
@ 2026-04-07  8:10 ` Leo Yan
  2026-04-07  8:33   ` Jie Gan
  0 siblings, 1 reply; 5+ messages in thread
From: Leo Yan @ 2026-04-07  8:10 UTC (permalink / raw)
  To: Jie Gan
  Cc: Suzuki K Poulose, Mike Leach, James Clark, Alexander Shishkin,
	Tingwei Zhang, coresight, linux-arm-kernel, linux-kernel

On Tue, Apr 07, 2026 at 12:47:11PM +0800, Jie Gan wrote:
> Create the csdev_access struct only when a valid MMIO resource is
> available. In tpdm_probe(), base is uninitialized for static TPDM
> instances that lack an MMIO resource, causing csdev_access to be
> created with a garbage address and potentially leading to
> unexpected issues.

This patch itself is fine for me.  However, I am wandering if this
is sufficient.

As mentioned "potentially leading to unexpected issues", can I
understand some code pieces access register with uninitialized base?
If so, you would also explictly add coresight_is_static_tpdm() to
prevent register access.

Thanks,
Leo

> Fixes: 14ae052f7947 ("coresight: tpdm: add static tpdm support")
> Signed-off-by: Jie Gan <jie.gan@oss.qualcomm.com>
> ---
>  drivers/hwtracing/coresight/coresight-tpdm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c
> index 9b16f368a58b..eaf7210af648 100644
> --- a/drivers/hwtracing/coresight/coresight-tpdm.c
> +++ b/drivers/hwtracing/coresight/coresight-tpdm.c
> @@ -1430,6 +1430,7 @@ static int tpdm_probe(struct device *dev, struct resource *res)
>  		if (ret)
>  			return ret;
>  
> +		desc.access = CSDEV_ACCESS_IOMEM(base);
>  		if (tpdm_has_dsb_dataset(drvdata))
>  			of_property_read_u32(drvdata->dev->of_node,
>  					     "qcom,dsb-msrs-num", &drvdata->dsb_msr_num);
> @@ -1452,7 +1453,6 @@ static int tpdm_probe(struct device *dev, struct resource *res)
>  	desc.ops = &tpdm_cs_ops;
>  	desc.pdata = dev->platform_data;
>  	desc.dev = dev;
> -	desc.access = CSDEV_ACCESS_IOMEM(base);
>  	if (res)
>  		desc.groups = tpdm_attr_grps;
>  	else
> 
> ---
> base-commit: 816f193dd0d95246f208590924dd962b192def78
> change-id: 20260407-fix-potential-issue-in-tpdm-b07b44416051
> 
> Best regards,
> -- 
> Jie Gan <jie.gan@oss.qualcomm.com>
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] coresight: tpdm: fix invalid MMIO access issue
  2026-04-07  8:10 ` Leo Yan
@ 2026-04-07  8:33   ` Jie Gan
  2026-04-07 10:35     ` Leo Yan
  0 siblings, 1 reply; 5+ messages in thread
From: Jie Gan @ 2026-04-07  8:33 UTC (permalink / raw)
  To: Leo Yan
  Cc: Suzuki K Poulose, Mike Leach, James Clark, Alexander Shishkin,
	Tingwei Zhang, coresight, linux-arm-kernel, linux-kernel


Hi Leo

On 4/7/2026 4:10 PM, Leo Yan wrote:
> On Tue, Apr 07, 2026 at 12:47:11PM +0800, Jie Gan wrote:
>> Create the csdev_access struct only when a valid MMIO resource is
>> available. In tpdm_probe(), base is uninitialized for static TPDM
>> instances that lack an MMIO resource, causing csdev_access to be
>> created with a garbage address and potentially leading to
>> unexpected issues.
> 
> This patch itself is fine for me.  However, I am wandering if this
> is sufficient.
> 
> As mentioned "potentially leading to unexpected issues", can I
> understand some code pieces access register with uninitialized base?
> If so, you would also explictly add coresight_is_static_tpdm() to
> prevent register access.
> 

Actually, we havent MMIO access for the static TPDM device, So no issues 
are observed. The commit message here may be misleading. do I need 
rephrase the commit message?

Thanks,
Jie

> Thanks,
> Leo
> 
>> Fixes: 14ae052f7947 ("coresight: tpdm: add static tpdm support")
>> Signed-off-by: Jie Gan <jie.gan@oss.qualcomm.com>
>> ---
>>   drivers/hwtracing/coresight/coresight-tpdm.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c
>> index 9b16f368a58b..eaf7210af648 100644
>> --- a/drivers/hwtracing/coresight/coresight-tpdm.c
>> +++ b/drivers/hwtracing/coresight/coresight-tpdm.c
>> @@ -1430,6 +1430,7 @@ static int tpdm_probe(struct device *dev, struct resource *res)
>>   		if (ret)
>>   			return ret;
>>   
>> +		desc.access = CSDEV_ACCESS_IOMEM(base);
>>   		if (tpdm_has_dsb_dataset(drvdata))
>>   			of_property_read_u32(drvdata->dev->of_node,
>>   					     "qcom,dsb-msrs-num", &drvdata->dsb_msr_num);
>> @@ -1452,7 +1453,6 @@ static int tpdm_probe(struct device *dev, struct resource *res)
>>   	desc.ops = &tpdm_cs_ops;
>>   	desc.pdata = dev->platform_data;
>>   	desc.dev = dev;
>> -	desc.access = CSDEV_ACCESS_IOMEM(base);
>>   	if (res)
>>   		desc.groups = tpdm_attr_grps;
>>   	else
>>
>> ---
>> base-commit: 816f193dd0d95246f208590924dd962b192def78
>> change-id: 20260407-fix-potential-issue-in-tpdm-b07b44416051
>>
>> Best regards,
>> -- 
>> Jie Gan <jie.gan@oss.qualcomm.com>
>>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] coresight: tpdm: fix invalid MMIO access issue
  2026-04-07  8:33   ` Jie Gan
@ 2026-04-07 10:35     ` Leo Yan
  2026-04-07 10:59       ` Jie Gan
  0 siblings, 1 reply; 5+ messages in thread
From: Leo Yan @ 2026-04-07 10:35 UTC (permalink / raw)
  To: Jie Gan
  Cc: Suzuki K Poulose, Mike Leach, James Clark, Alexander Shishkin,
	Tingwei Zhang, coresight, linux-arm-kernel, linux-kernel

Hi Jie,

On Tue, Apr 07, 2026 at 04:33:22PM +0800, Jie Gan wrote:
> On 4/7/2026 4:10 PM, Leo Yan wrote:
> > On Tue, Apr 07, 2026 at 12:47:11PM +0800, Jie Gan wrote:
> > > Create the csdev_access struct only when a valid MMIO resource is
> > > available. In tpdm_probe(), base is uninitialized for static TPDM
> > > instances that lack an MMIO resource, causing csdev_access to be
> > > created with a garbage address and potentially leading to
> > > unexpected issues.
> > 
> > This patch itself is fine for me.  However, I am wandering if this
> > is sufficient.
> > 
> > As mentioned "potentially leading to unexpected issues", can I
> > understand some code pieces access register with uninitialized base?
> > If so, you would also explictly add coresight_is_static_tpdm() to
> > prevent register access.
> > 
> 
> Actually, we havent MMIO access for the static TPDM device, So no issues are
> observed. The commit message here may be misleading. do I need rephrase the
> commit message?

Yes, good to clarify a bit in commit log:

  "So far there has no register access for static instance, but this
   change helps mitigate potential risks in the future."

With this:

Reviewed-by: Leo Yan <leo.yan@arm.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] coresight: tpdm: fix invalid MMIO access issue
  2026-04-07 10:35     ` Leo Yan
@ 2026-04-07 10:59       ` Jie Gan
  0 siblings, 0 replies; 5+ messages in thread
From: Jie Gan @ 2026-04-07 10:59 UTC (permalink / raw)
  To: Leo Yan
  Cc: Suzuki K Poulose, Mike Leach, James Clark, Alexander Shishkin,
	Tingwei Zhang, coresight, linux-arm-kernel, linux-kernel


Hi Leo,

On 4/7/2026 6:35 PM, Leo Yan wrote:
> Hi Jie,
> 
> On Tue, Apr 07, 2026 at 04:33:22PM +0800, Jie Gan wrote:
>> On 4/7/2026 4:10 PM, Leo Yan wrote:
>>> On Tue, Apr 07, 2026 at 12:47:11PM +0800, Jie Gan wrote:
>>>> Create the csdev_access struct only when a valid MMIO resource is
>>>> available. In tpdm_probe(), base is uninitialized for static TPDM
>>>> instances that lack an MMIO resource, causing csdev_access to be
>>>> created with a garbage address and potentially leading to
>>>> unexpected issues.
>>>
>>> This patch itself is fine for me.  However, I am wandering if this
>>> is sufficient.
>>>
>>> As mentioned "potentially leading to unexpected issues", can I
>>> understand some code pieces access register with uninitialized base?
>>> If so, you would also explictly add coresight_is_static_tpdm() to
>>> prevent register access.
>>>
>>
>> Actually, we havent MMIO access for the static TPDM device, So no issues are
>> observed. The commit message here may be misleading. do I need rephrase the
>> commit message?
> 
> Yes, good to clarify a bit in commit log:
> 
>    "So far there has no register access for static instance, but this
>     change helps mitigate potential risks in the future."
> 
> With this:
> 
> Reviewed-by: Leo Yan <leo.yan@arm.com>

Well noted.

Thanks,
Jie




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-04-07 10:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-07  4:47 [PATCH] coresight: tpdm: fix invalid MMIO access issue Jie Gan
2026-04-07  8:10 ` Leo Yan
2026-04-07  8:33   ` Jie Gan
2026-04-07 10:35     ` Leo Yan
2026-04-07 10:59       ` Jie Gan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox