mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sherry Sun <sherry.sun@nxp.com>
To: sudeep.dutt@intel.com, ashutosh.dixit@intel.com, arnd@arndb.de,
	gregkh@linuxfoundation.org, rikard.falkeborn@gmail.com,
	lee.jones@linaro.org, mst@redhat.com
Cc: linux-kernel@vger.kernel.org, linux-imx@nxp.com
Subject: [PATCH 4/4] mic: vop: copy data to kernel space then write to io memory
Date: Fri, 25 Sep 2020 15:18:31 +0800	[thread overview]
Message-ID: <20200925071831.8025-5-sherry.sun@nxp.com> (raw)
In-Reply-To: <20200925071831.8025-1-sherry.sun@nxp.com>

Read and write io memory should address align on ARCH ARM. Change to use
memcpy_toio to avoid kernel panic caused by the address un-align issue.

Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 drivers/misc/mic/vop/vop_vringh.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/mic/vop/vop_vringh.c b/drivers/misc/mic/vop/vop_vringh.c
index 45fdb394de11..f344209ac386 100644
--- a/drivers/misc/mic/vop/vop_vringh.c
+++ b/drivers/misc/mic/vop/vop_vringh.c
@@ -602,6 +602,7 @@ static int vop_virtio_copy_from_user(struct vop_vdev *vdev, void __user *ubuf,
 	size_t partlen;
 	bool dma = VOP_USE_DMA && vi->dma_ch;
 	int err = 0;
+	void *temp = NULL;
 
 	if (dma) {
 		dma_alignment = 1 << vi->dma_ch->device->copy_align;
@@ -655,12 +656,15 @@ static int vop_virtio_copy_from_user(struct vop_vdev *vdev, void __user *ubuf,
 	 * We are copying to IO below and should ideally use something
 	 * like copy_from_user_toio(..) if it existed.
 	 */
-	if (copy_from_user((void __force *)dbuf, ubuf, len)) {
+	temp = kmalloc(len, GFP_KERNEL);
+	if (copy_from_user(temp, ubuf, len)) {
 		err = -EFAULT;
 		dev_err(vop_dev(vdev), "%s %d err %d\n",
 			__func__, __LINE__, err);
 		goto err;
 	}
+	memcpy_toio((void __force *)dbuf, temp, len);
+	kfree(temp);
 	vdev->out_bytes += len;
 	err = 0;
 err:
-- 
2.17.1


  parent reply	other threads:[~2020-09-25  7:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25  7:18 [PATCH 0/4] Fix some bugs of the vop driver and mpssd user space tool Sherry Sun
2020-09-25  7:18 ` [PATCH 1/4] samples: mpssd: fix the build errors when enable DEBUG in mpssd.c Sherry Sun
2020-09-25  7:18 ` [PATCH 2/4] misc: vop: build VOP based on CONFIG_VOP Sherry Sun
2020-09-25  7:18 ` [PATCH 3/4] misc: vop: add round_up(x,4) for vring_size to avoid kernel panic Sherry Sun
2020-09-25  7:18 ` Sherry Sun [this message]
2020-09-25  7:32   ` [PATCH 4/4] mic: vop: copy data to kernel space then write to io memory Arnd Bergmann
2020-09-25  7:50     ` Sherry Sun
2020-09-25 10:55   ` kernel test robot
2020-09-25 11:03   ` kernel test robot

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=20200925071831.8025-5-sherry.sun@nxp.com \
    --to=sherry.sun@nxp.com \
    --cc=arnd@arndb.de \
    --cc=ashutosh.dixit@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=rikard.falkeborn@gmail.com \
    --cc=sudeep.dutt@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®