All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eddie James <eajames@linux.ibm.com>
To: openbmc@lists.ozlabs.org
Cc: joel@jms.id.au, Eddie James <eajames@linux.ibm.com>
Subject: [PATCH linux dev-5.4] soc: aspeed: xdma: Fix command buffer overrun
Date: Tue, 31 Mar 2020 16:56:00 -0500	[thread overview]
Message-ID: <20200331215600.5507-1-eajames@linux.ibm.com> (raw)

In the case of an operation requiring two commands, it was possible to
copy the second command into the user's memory space, which also
prevents the command from completing since the first doesn't trigger an
interrupt. Test for this special case and prevent it.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
 drivers/soc/aspeed/aspeed-xdma.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/soc/aspeed/aspeed-xdma.c b/drivers/soc/aspeed/aspeed-xdma.c
index 5d97919d38cf..d0a56a5a81ae 100644
--- a/drivers/soc/aspeed/aspeed-xdma.c
+++ b/drivers/soc/aspeed/aspeed-xdma.c
@@ -436,6 +436,13 @@ static void aspeed_xdma_start(struct aspeed_xdma *ctx,
 
 	mutex_lock(&ctx->start_lock);
 
+	if ((rc == 2) && (ctx->cmd_idx == (XDMA_NUM_CMDS - 1))) {
+		aspeed_xdma_writel(ctx, ctx->chip->regs.bmc_cmdq_readp,
+				   XDMA_BMC_CMDQ_READP_RESET);
+		aspeed_xdma_writel(ctx, ctx->chip->regs.bmc_cmdq_writep, 0);
+		ctx->cmd_idx = 0;
+	}
+
 	memcpy(&ctx->cmdq[ctx->cmd_idx], cmds,
 	       rc * sizeof(struct aspeed_xdma_cmd));
 	ctx->cmd_idx = (ctx->cmd_idx + rc) % XDMA_NUM_CMDS;
-- 
2.24.0

             reply	other threads:[~2020-03-31 21:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31 21:56 Eddie James [this message]
2020-04-01  8:40 ` [PATCH linux dev-5.4] soc: aspeed: xdma: Fix command buffer overrun Joel Stanley
2020-04-01 16:28   ` Eddie James

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=20200331215600.5507-1-eajames@linux.ibm.com \
    --to=eajames@linux.ibm.com \
    --cc=joel@jms.id.au \
    --cc=openbmc@lists.ozlabs.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 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.