From: sashiko-bot@kernel.org
To: "Ryan Roberts" <ryan.roberts@arm.com>
Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org,
robh@kernel.org, conor+dt@kernel.org,
"Oliver Upton" <oupton@kernel.org>,
"Marc Zyngier" <maz@kernel.org>
Subject: Re: [RFC PATCH v2 02/15] misc/arm-cla: Add launch operation helpers
Date: Thu, 15 Oct 2026 14:42:14 +0000 [thread overview]
Message-ID: <sashiko-outbox-172973@kernel.org> (raw)
In-Reply-To: <20261015142552.4128028-3-ryan.roberts@arm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] misc/arm-cla: 1-second busy loop in atomic poll function stalls CPU
- [High] misc/arm-cla: 32-bit truncation of max_regidx breaks register access unconditionally
--
commit 3a9a1e5f334e803060b4eaff6708691a049dc197
Author: Jean-Philippe Brucker <jpb@kernel.org>
misc/arm-cla: Add launch operation helpers
This commit introduces helpers for CLA commands that execute sequences on the
local CPU, wait for hardware responses, and translate response codes into Linux
errors. It also implements accelerator reset and register read/write operations
built upon these helpers.
> diff --git a/drivers/misc/arm-cla/cla-ops.c b/drivers/misc/arm-cla/cla-ops.c
> new file mode 100644
> index 0000000000000..46026304a057a
> --- /dev/null
> +++ b/drivers/misc/arm-cla/cla-ops.c
[ ... ]
> +/**
> + * cla_op_wait_lresp - Wait for any LAUNCH op to complete.
> + * @dev: CLA device.
> + * @lresp: last LRESP value read.
> + *
> + * Return: 0 on success, -ETIMEDOUT in case of timeout.
> + */
> +int cla_op_wait_lresp(struct cla_dev *dev, u64 *lresp)
> +{
> + return readq_relaxed_poll_timeout_atomic(dev->regs + CLA_REG_LRESP,
> + *lresp, FIELD_GET(CLA_LRESP_PENDING, *lresp) == 0,
> + CLA_LRESP_DELAY_US, CLA_LRESP_TIMEOUT_US);
> +}
[Severity: High]
Does this atomic polling loop stall the CPU for up to 1 second?
The timeout here is CLA_LRESP_TIMEOUT_US (1,000,000 microseconds). Using the
_atomic variant of the poll macro will busy-wait without yielding the CPU.
Since the surrounding code in cla_wait_status_dmb() uses the sleepable
poll_timeout_us(), does this context permit sleeping? If so, using the
non-atomic readq_relaxed_poll_timeout() macro might prevent long scheduler
delays.
[ ... ]
> +/* regidx is unsigned long here to avoid overflow during calculations */
> +static int cla_op_access_reg(struct cla_dev *dev, u8 op,
> + enum cla_launch_data_mode data_mode,
> + unsigned int accid, unsigned long regidx,
> + size_t nregs, u64 *regs)
> +{
> + int ret = -EINVAL;
> + unsigned long max_regidx;
> + struct cla_launch launch = {
> + .op = op,
> + .accid = accid,
> + .data_mode = data_mode,
> + };
> +
> + switch (op) {
> + case CLA_LAUNCH_OP_REGREAD:
> + case CLA_LAUNCH_OP_REGWRITE:
> + max_regidx = 0x100000000;
[Severity: High]
Will this unconditionally fail register accesses on 32-bit architectures?
The constant 0x100000000 requires 33 bits. When assigned to an unsigned long
on 32-bit platforms, it is implicitly truncated to 0.
> + break;
> + default:
> + WARN_ON(1);
> + return -EINVAL;
> + }
> +
> + if (WARN_ON(regidx + nregs > max_regidx))
Since max_regidx becomes 0 on 32-bit platforms, this bounds check evaluates
to regidx + nregs > 0, which is always true when nregs is greater than zero.
Should max_regidx and regidx both be explicitly typed as u64 to prevent this
truncation and correctly handle overflow calculations?
> + return -EINVAL;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261015142552.4128028-1-ryan.roberts@arm.com?part=2
next prev parent reply other threads:[~2026-10-15 14:42 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 14:25 [RFC PATCH v2 00/15] Arm Core Local Accelerator Driver Ryan Roberts
2026-10-15 14:25 ` [RFC PATCH v2 01/15] misc/arm-cla: Add driver skeleton and documentation Ryan Roberts
2026-10-15 14:35 ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 02/15] misc/arm-cla: Add launch operation helpers Ryan Roberts
2026-10-15 14:42 ` sashiko-bot [this message]
2026-10-15 16:17 ` Greg Kroah-Hartman
2026-10-15 16:32 ` Ryan Roberts
2026-10-15 14:25 ` [RFC PATCH v2 03/15] dt-bindings: misc: Add Arm Core Local Accelerator Ryan Roberts
2026-10-15 14:25 ` [RFC PATCH v2 04/15] misc/arm-cla: Probe firmware-described devices Ryan Roberts
2026-10-15 14:37 ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 05/15] misc/arm-cla: Initialize devices on CPU bringup Ryan Roberts
2026-10-15 14:25 ` [RFC PATCH v2 06/15] misc/arm-cla: Accelerator context save and restore Ryan Roberts
2026-10-15 14:41 ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 07/15] misc/arm-cla: Set up memory translation context Ryan Roberts
2026-10-15 14:25 ` [RFC PATCH v2 08/15] misc/arm-cla: Manage domain contexts Ryan Roberts
2026-10-15 14:38 ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 09/15] misc/arm-cla: Add userspace interface Ryan Roberts
2026-10-15 14:47 ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 10/15] KVM: arm64: Introduce support to pin VMIDs Ryan Roberts
2026-10-15 14:38 ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 11/15] KVM: arm64: Export stage-2 MMU config Ryan Roberts
2026-10-15 14:43 ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 12/15] vfio: Support VFIO devices that access the CPU MMU Ryan Roberts
2026-10-15 14:44 ` sashiko-bot
2026-10-15 16:44 ` Jason Gunthorpe
2026-10-15 14:25 ` [RFC PATCH v2 13/15] misc/arm-cla: Add stage-2 MTC and VM context switch Ryan Roberts
2026-10-15 14:40 ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 14/15] misc/arm-cla: Support exclusive context assignment Ryan Roberts
2026-10-15 14:41 ` sashiko-bot
2026-10-15 14:25 ` [RFC PATCH v2 15/15] misc/arm-cla: Add vfio-mdev user interface Ryan Roberts
2026-10-15 14:49 ` sashiko-bot
2026-10-15 16:41 ` Jason Gunthorpe
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=sashiko-outbox-172973@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=robh@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=sashiko-reviews@lists.linux.dev \
/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