From: sashiko-bot@kernel.org
To: "Shubham Patil" <shubhamsanjay.patil@amd.com>
Cc: robh@kernel.org, linux-i3c@lists.infradead.org,
Frank.Li@kernel.org, conor+dt@kernel.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
devicetree@vger.kernel.org
Subject: Re: [PATCH v4 2/3] i3c: master: amd: Add support for in-band interrupts
Date: Wed, 09 Sep 2026 07:30:21 +0000 [thread overview]
Message-ID: <20260909073021.CE2141F00A3F@smtp.kernel.org> (raw)
In-Reply-To: <20260909071340.3649271-3-shubhamsanjay.patil@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Critical] Polling the shared RX FIFO during a read transfer steals an in-flight IBI's payload data, causing data corruption.
Pre-existing issues:
- [High] Unaligned pointer dereference in FIFO I/O accessors causes undefined behavior.
--
commit b1cc4b97eb8d4b5fc534199add697a3f1a306c98
Author: Shubham Patil <shubhamsanjay.patil@amd.com>
i3c: master: amd: Add support for in-band interrupts
This commit adds support for receiving and dequeueing I3C in-band interrupts.
The ops are assembled at probe and callbacks registered when the appropriate
property is present. IBIs share the response and read FIFOs with normal
transfers and are tagged with TID 0x0F.
> diff --git a/drivers/i3c/master/amd-i3c-master.c b/drivers/i3c/master/amd-i3c-master.c
> index ef5ad5abb788c..a50445530a430 100644
> --- a/drivers/i3c/master/amd-i3c-master.c
> +++ b/drivers/i3c/master/amd-i3c-master.c
[ ... ]
> @@ -437,13 +606,19 @@ static int xi3c_master_read(struct xi3c_master *master, struct xi3c_cmd *cmd)
[ ... ]
> /* Read data from rx fifo */
> - while (cmd->rx_len > 0 && !xi3c_is_resp_available(master)) {
> + while (cmd->rx_len > 0 && !xi3c_xfer_resp_available(master)) {
> if (time_after(jiffies, timeout)) {
> dev_err(master->dev, "XI3C read timeout\n");
> return -EIO;
> }
> xi3c_master_rd_from_rx_fifo(master, cmd);
[Severity: Critical]
Does this code steal payload bytes from an in-flight IBI when polling the
shared RX FIFO during a read transfer?
If an IBI is ACKed just before a read transfer starts, its payload begins
filling the RX FIFO while the IBI is still on the bus. Because the IBI hasn't
completed, its response word is not yet in the RESP FIFO.
The read transfer's polling loop in xi3c_master_read() sees RD_FIFO_NOT_EMPTY
and eagerly drains the RX FIFO, taking the IBI payload into cmd->rx_buf.
When the IBI completes and its response finally appears,
xi3c_master_process_ibi() will expect the payload to still be in the RX FIFO,
but instead consumes the read transfer's data, permanently desynchronizing
the RX FIFO.
> usleep_range(XI3C_POLL_INTERVAL_US, 2 * XI3C_POLL_INTERVAL_US);
> }
[ ... ]
> @@ -1052,9 +1243,338 @@ static void xi3c_master_bus_cleanup(struct i3c_master_controller *m)
[ ... ]
> +static void xi3c_master_process_ibi(struct xi3c_master *master, u32 resp, u8 da)
> +{
[ ... ]
> + slot->len = 0;
> + if (len) {
> + xi3c_readl_fifo(master->membase + XI3C_RD_FIFO_OFFSET,
> + slot->data, len);
[Severity: High]
This is a pre-existing issue, but does passing slot->data to
xi3c_readl_fifo() cause an unaligned pointer dereference?
i3c_generic_ibi_alloc_pool() allocates a single contiguous buffer for all IBI
slots. If max_payload_len is not a multiple of 4, the slot->data pointers for
subsequent slots will not be 4-byte aligned.
When this unaligned slot->data pointer is passed to xi3c_readl_fifo(), it
eventually calls xi3c_readsl_be(). That accessor casts the void * buffer to
a u32 * and dereferences it directly without using put_unaligned():
drivers/i3c/master/amd-i3c-master.c:xi3c_readsl_be() {
u32 *buf = buffer;
while (count--)
*buf++ = ioread32be(addr);
}
This can cause a kernel crash due to an alignment fault on architectures that
strictly enforce alignment.
> + slot->len = len;
> + }
> +
> + i3c_master_queue_ibi(dev, slot);
> + spin_unlock_irqrestore(&master->ibi.lock, flags);
> +
> + return;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909071340.3649271-1-shubhamsanjay.patil@amd.com?part=2
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Shubham Patil" <shubhamsanjay.patil@amd.com>
Cc: robh@kernel.org, linux-i3c@lists.infradead.org,
Frank.Li@kernel.org, conor+dt@kernel.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
devicetree@vger.kernel.org
Subject: Re: [PATCH v4 2/3] i3c: master: amd: Add support for in-band interrupts
Date: Wed, 09 Sep 2026 07:30:21 +0000 [thread overview]
Message-ID: <20260909073021.CE2141F00A3F@smtp.kernel.org> (raw)
In-Reply-To: <20260909071340.3649271-3-shubhamsanjay.patil@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Critical] Polling the shared RX FIFO during a read transfer steals an in-flight IBI's payload data, causing data corruption.
Pre-existing issues:
- [High] Unaligned pointer dereference in FIFO I/O accessors causes undefined behavior.
--
commit b1cc4b97eb8d4b5fc534199add697a3f1a306c98
Author: Shubham Patil <shubhamsanjay.patil@amd.com>
i3c: master: amd: Add support for in-band interrupts
This commit adds support for receiving and dequeueing I3C in-band interrupts.
The ops are assembled at probe and callbacks registered when the appropriate
property is present. IBIs share the response and read FIFOs with normal
transfers and are tagged with TID 0x0F.
> diff --git a/drivers/i3c/master/amd-i3c-master.c b/drivers/i3c/master/amd-i3c-master.c
> index ef5ad5abb788c..a50445530a430 100644
> --- a/drivers/i3c/master/amd-i3c-master.c
> +++ b/drivers/i3c/master/amd-i3c-master.c
[ ... ]
> @@ -437,13 +606,19 @@ static int xi3c_master_read(struct xi3c_master *master, struct xi3c_cmd *cmd)
[ ... ]
> /* Read data from rx fifo */
> - while (cmd->rx_len > 0 && !xi3c_is_resp_available(master)) {
> + while (cmd->rx_len > 0 && !xi3c_xfer_resp_available(master)) {
> if (time_after(jiffies, timeout)) {
> dev_err(master->dev, "XI3C read timeout\n");
> return -EIO;
> }
> xi3c_master_rd_from_rx_fifo(master, cmd);
[Severity: Critical]
Does this code steal payload bytes from an in-flight IBI when polling the
shared RX FIFO during a read transfer?
If an IBI is ACKed just before a read transfer starts, its payload begins
filling the RX FIFO while the IBI is still on the bus. Because the IBI hasn't
completed, its response word is not yet in the RESP FIFO.
The read transfer's polling loop in xi3c_master_read() sees RD_FIFO_NOT_EMPTY
and eagerly drains the RX FIFO, taking the IBI payload into cmd->rx_buf.
When the IBI completes and its response finally appears,
xi3c_master_process_ibi() will expect the payload to still be in the RX FIFO,
but instead consumes the read transfer's data, permanently desynchronizing
the RX FIFO.
> usleep_range(XI3C_POLL_INTERVAL_US, 2 * XI3C_POLL_INTERVAL_US);
> }
[ ... ]
> @@ -1052,9 +1243,338 @@ static void xi3c_master_bus_cleanup(struct i3c_master_controller *m)
[ ... ]
> +static void xi3c_master_process_ibi(struct xi3c_master *master, u32 resp, u8 da)
> +{
[ ... ]
> + slot->len = 0;
> + if (len) {
> + xi3c_readl_fifo(master->membase + XI3C_RD_FIFO_OFFSET,
> + slot->data, len);
[Severity: High]
This is a pre-existing issue, but does passing slot->data to
xi3c_readl_fifo() cause an unaligned pointer dereference?
i3c_generic_ibi_alloc_pool() allocates a single contiguous buffer for all IBI
slots. If max_payload_len is not a multiple of 4, the slot->data pointers for
subsequent slots will not be 4-byte aligned.
When this unaligned slot->data pointer is passed to xi3c_readl_fifo(), it
eventually calls xi3c_readsl_be(). That accessor casts the void * buffer to
a u32 * and dereferences it directly without using put_unaligned():
drivers/i3c/master/amd-i3c-master.c:xi3c_readsl_be() {
u32 *buf = buffer;
while (count--)
*buf++ = ioread32be(addr);
}
This can cause a kernel crash due to an alignment fault on architectures that
strictly enforce alignment.
> + slot->len = len;
> + }
> +
> + i3c_master_queue_ibi(dev, slot);
> + spin_unlock_irqrestore(&master->ibi.lock, flags);
> +
> + return;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909071340.3649271-1-shubhamsanjay.patil@amd.com?part=2
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
next prev parent reply other threads:[~2026-09-09 7:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 7:13 [PATCH v4 0/3] i3c: master: amd: Add IBI and hot-join support Shubham Patil
2026-09-09 7:13 ` Shubham Patil
2026-09-09 7:13 ` [PATCH v4 1/3] dt-bindings: i3c: xlnx: Add IBI and hot-join capability properties Shubham Patil
2026-09-09 7:13 ` Shubham Patil
2026-09-09 15:34 ` Frank Li
2026-09-09 15:34 ` Frank Li
2026-09-09 7:13 ` [PATCH v4 2/3] i3c: master: amd: Add support for in-band interrupts Shubham Patil
2026-09-09 7:13 ` Shubham Patil
2026-09-09 7:30 ` sashiko-bot [this message]
2026-09-09 7:30 ` sashiko-bot
2026-09-09 7:13 ` [PATCH v4 3/3] i3c: master: amd: Add hot-join support Shubham Patil
2026-09-09 7:13 ` Shubham Patil
2026-09-09 7:29 ` sashiko-bot
2026-09-09 7:29 ` sashiko-bot
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=20260909073021.CE2141F00A3F@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-i3c@lists.infradead.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shubhamsanjay.patil@amd.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.