Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Cristian Marussi <cristian.marussi@arm.com>
To: Fayssal Benmlih <Fayssal.Benmlih@arm.com>
Cc: Cristian Marussi <Cristian.Marussi@arm.com>,
	"arm-scmi@vger.kernel.org" <arm-scmi@vger.kernel.org>,
	"d-gole@ti.com" <d-gole@ti.com>,
	"david@kernel.org" <david@kernel.org>,
	Elif Topuz <Elif.Topuz@arm.com>,
	"etienne.carriere@st.com" <etienne.carriere@st.com>,
	"f.fainelli@gmail.com" <f.fainelli@gmail.com>,
	"james.quinlan@broadcom.com" <james.quinlan@broadcom.com>,
	"jic23@kernel.org" <jic23@kernel.org>,
	"kas@kernel.org" <kas@kernel.org>,
	"kernel-team@meta.com" <kernel-team@meta.com>,
	"leitao@kernel.org" <leitao@kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Lukasz Luba <Lukasz.Luba@arm.com>,
	"michal.simek@amd.com" <michal.simek@amd.com>,
	"peng.fan@oss.nxp.com" <peng.fan@oss.nxp.com>,
	Philip Radford <Philip.Radford@arm.com>,
	"puranjay@kernel.org" <puranjay@kernel.org>,
	Souvik Chakravarty <Souvik.Chakravarty@arm.com>,
	"sudeep.holla@kernel.org" <sudeep.holla@kernel.org>,
	"usama.arif@linux.dev" <usama.arif@linux.dev>,
	"vincent.guittot@linaro.org" <vincent.guittot@linaro.org>
Subject: Re: [PATCH v7 07/23] firmware: arm_scmi: Add support to parse SHMTIs areas
Date: Mon, 10 Aug 2026 15:06:27 +0100	[thread overview]
Message-ID: <anna43kYrUld7J-r@pluto> (raw)
In-Reply-To: <A88E25CA-4474-4937-9CCE-DAA62D481E92@contoso.com>

On Mon, Aug 03, 2026 at 11:53:45PM +0100, Fayssal Benmlih wrote:
> Hi Cristian,
> 

Hi,

> I found two UUID database issues that appear to be blockers.
> 
> > 	if (ti->info.num_uuids + SCMI_UUID_DB_THRESH >= ti->uuids_len) {
> > 		uuid_t **uuids, **old_uuids;
> >
> > 		uuids = kcalloc(ti->uuids_len * 2, sizeof(*uuids),
> > 				GFP_KERNEL);
> > 		if (!uuids)
> > 			return -ENOMEM;
> >
> > 		/* Copy/move old allocated UUIDs */
> > 		for (int i = 0; i < ti->info.num_uuids; i++)
> > 			uuid_copy(uuids[i], ti->info.uuids[i]);
> 
> uuids is a newly allocated and zeroed array of uuid_t pointers, so
> uuids[i] is NULL here. uuid_copy() therefore copies into a NULL
> destination when the database grows with existing entries.
> 
> The database stores pointers to UUIDs owned by telemetry_uuid objects, so
> should this instead copy the pointers themselves, for example:
> 
> 	uuids[i] = ti->info.uuids[i];
>

Exactly...my bad .. fixed in V8.

> or use an appropriately sized memcpy() of the pointer array?
> 
> > 	ti->uuids_len = ti->num_shmti * 2;
> > 	ti->info.uuids = kcalloc(ti->uuids_len,
> > 				 sizeof(*ti->info.uuids),
> > 				 GFP_KERNEL);
> 
> A valid implementation can have zero SHMTIs while exposing fast-channel or
> notification-only DEs. In that case uuids_len is zero.
> 
> Primary UUID creation then enters the resize path, doubles zero to zero,
> and eventually writes the primary UUID pointer through a zero-size
> allocation.
> 
> Please give the UUID database a nonzero minimum initial capacity and use
> checked growth so that zero cannot remain zero.
> 

Done in V8, since Primary is always present AND also we'd like to avoid
to immediately resize the Array so initial len is set to at least
SCMI_UUID_DB_THRESH + 1

> > static void scmi_telemetry_line_put(struct telemetry_line *line,
> > 				    void *blob)
> > {
> > 	if (refcount_dec_and_test(&line->users)) {
> > 		xa_erase(line->xa_lines,
> > 			 (unsigned long)line->payld);
> > 		kfree(blob);
> > 	}
> > }
> 
> Lookups and refcount increments are serialized using lines_mtx, but this
> final decrement, XArray erase and free are not performed under the same
> lock.
> 
> A concurrent get-or-create operation can load the entry while another
> thread decrements the refcount to zero and frees it. Please serialize the
> final put with lookup/creation, or use a lifetime scheme such as
> refcount_inc_not_zero() with appropriate XArray/RCU protection.
> 

I have reviewed/reworked all of the lines internal and external mutexing
in V8 due to also a ton of Sashiko reports...

Thanks,
Cristian


  reply	other threads:[~2026-08-10 14:06 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<20260802145618.1952804-8-cristian.marussi@arm.com>
2026-08-03 22:53 ` [PATCH v7 07/23] firmware: arm_scmi: Add support to parse SHMTIs areas Fayssal Benmlih
2026-08-10 14:06   ` Cristian Marussi [this message]
     [not found] <<20260802145618.1952804-9-cristian.marussi@arm.com>
2026-08-03 22:54 ` [PATCH v7 08/23] firmware: arm_scmi: Add Telemetry configuration operations Fayssal Benmlih
2026-08-10 14:13   ` Cristian Marussi
     [not found] <<20260802145618.1952804-7-cristian.marussi@arm.com>
2026-08-03 22:53 ` [PATCH v7 06/23] firmware: arm_scmi: Add basic Telemetry support Fayssal Benmlih
2026-08-10 13:39   ` Cristian Marussi
     [not found] <<20260802145618.1952804-4-cristian.marussi@arm.com>
2026-08-03 22:52 ` [PATCH v7 03/23] firmware: arm_scmi: Introduce protocol instance notifiers Fayssal Benmlih
2026-08-10 13:35   ` Cristian Marussi
     [not found] <<20260802145618.1952804-20-cristian.marussi@arm.com>
2026-08-03 22:25 ` [PATCH v7 19/23] uapi: Add ARM SCMI Telemetry definitions Fayssal Benmlih
2026-08-04 10:39   ` Cristian Marussi
2026-08-02 14:55 [PATCH v7 00/23] Introduce SCMI Telemetry support Cristian Marussi
2026-08-02 14:55 ` [PATCH v7 01/23] firmware: arm_scmi: Add new SCMIv4.0 error codes definitions Cristian Marussi
2026-08-02 14:55 ` [PATCH v7 02/23] firmware: arm_scmi: Allow registration of unknown-size events/reports Cristian Marussi
2026-08-02 14:55 ` [PATCH v7 03/23] firmware: arm_scmi: Introduce protocol instance notifiers Cristian Marussi
2026-08-02 14:55 ` [PATCH v7 04/23] dt-bindings: firmware: arm,scmi: Add support for telemetry protocol Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 05/23] include: trace: Add Telemetry trace events Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 06/23] firmware: arm_scmi: Add basic Telemetry support Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 07/23] firmware: arm_scmi: Add support to parse SHMTIs areas Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 08/23] firmware: arm_scmi: Add Telemetry configuration operations Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 09/23] firmware: arm_scmi: Add Telemetry DataEvent read capabilities Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 10/23] firmware: arm_scmi: Add support for Telemetry reset Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 11/23] firmware: arm_scmi: Add Telemetry notification support Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 12/23] firmware: arm_scmi: Add support for boot-on Telemetry Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 13/23] firmware: arm-scmi: Add telemetry generic event support Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 14/23] firmware: arm_scmi: Add Telemetry generation counter event Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 15/23] firmware: arm_scmi: Add common per-protocol debugfs support Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 16/23] firmware: arm_scmi: Add Telemetry debugfs SHMTI dump support Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 17/23] firmware: arm_scmi: Add Telemetry debugfs ABI documentation Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 18/23] firmware: arm_scmi: Expose per-instance identifier Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 19/23] uapi: Add ARM SCMI Telemetry definitions Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 20/23] firmware: arm_scmi: Add System Telemetry driver Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 21/23] docs: ioctl-number: Add SCMI Ioctls Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 22/23] [RFC] Documentation: Add SCMI System Telemetry documentation Cristian Marussi
2026-08-02 14:56 ` [PATCH v7 23/23] [RFC] tools/scmi: Add SCMI Telemetry testing tool Cristian Marussi
2026-08-05  5:21 ` [PATCH v7 00/23] Introduce SCMI Telemetry support Subrahmanya Lingappa
2026-08-05  6:14   ` David Hildenbrand (Arm)
2026-08-05 11:06     ` Subrahmanya Lingappa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=anna43kYrUld7J-r@pluto \
    --to=cristian.marussi@arm.com \
    --cc=Elif.Topuz@arm.com \
    --cc=Fayssal.Benmlih@arm.com \
    --cc=Lukasz.Luba@arm.com \
    --cc=Philip.Radford@arm.com \
    --cc=Souvik.Chakravarty@arm.com \
    --cc=arm-scmi@vger.kernel.org \
    --cc=d-gole@ti.com \
    --cc=david@kernel.org \
    --cc=etienne.carriere@st.com \
    --cc=f.fainelli@gmail.com \
    --cc=james.quinlan@broadcom.com \
    --cc=jic23@kernel.org \
    --cc=kas@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=leitao@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=puranjay@kernel.org \
    --cc=sudeep.holla@kernel.org \
    --cc=usama.arif@linux.dev \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox