Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1124366pxx; Tue, 27 Oct 2020 08:48:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwv3EG8Wglx9OZYFFochag1p0gMnl1daN9OOxOUYIW+Yoca2qDbOhWdK5g8SWtpTK1sxD/d X-Received: by 2002:a17:906:c78a:: with SMTP id cw10mr3133464ejb.478.1603813716851; Tue, 27 Oct 2020 08:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603813716; cv=none; d=google.com; s=arc-20160816; b=MfXzXEZ1un40kHI0hiuUPqRwrCWlDe5MvZlr/8+18JPHXLU/RYmEhxD9oW5COQb7kC MF8yEYNhHZ8dkClN/V3Ll/So6HnsOtBBJO45mlwR2hTnZwWA5ULwJxAzc3EanGjsb2gj rKJZ6WTzaHt7tl9vmp2c4qeOLBvKmh6aujH7NpLA00XoRp89W3IkSL/4yq+kUZmj8IXh mmCwBKcfoUlANMTDh3sWNrsI3NtunaGZ4xFHeVdYBvA68wDtVfYwdql/kDOPcVb+5TSK Lmlhn/4A4K3r2MFsP1hjJszj0C+MCFVNuVYQ8AtqdTLgTggpP/AK1HqLkGaqtWlrtOSj e3Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ilfY13N/mMi1wm7C7hDZ5na9EOoQtCNjAoxhZc9t2Vg=; b=vnuR2cvU57eqOzK6da5Q/sDbeQPdA6BLrFAVvcC+wxXkOEVVosMyC5Fe6T/lT7woMK xz5CHZlAE4BUvNiUar5pF3WPjRSLnKkahtpo7BHTsvak05jEBpos7BDEsiz6dZpuQxHk mLZjkf5FU9pXIh6jqFDvLorIQQVsXn0yQHQapEKhV6hocXwlgmTOI0ZmSFHqoAqr+nLr ac8tg+prkpKqqp3ieao+DrwGKyuFVy4r6URp45nXeCktlfrtpjzU9+XfuTWzvHHZfQra 2zR66HjoYAf4sgumjTuC/U1Gyp+ShNGHIpwZUws8RRZf1i0FJbPUJVPWyqszUPuwFvom i7vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d2UfpCJk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m6si1058008edb.517.2020.10.27.08.48.14; Tue, 27 Oct 2020 08:48:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d2UfpCJk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1782162AbgJ0O4o (ORCPT + 99 others); Tue, 27 Oct 2020 10:56:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:46126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1764078AbgJ0OqN (ORCPT ); Tue, 27 Oct 2020 10:46:13 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 45C122225E; Tue, 27 Oct 2020 14:46:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809972; bh=MkgMDcccSHwun46vYipogs2oopYDY7nk+d6mYmDSuyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d2UfpCJkCNnsau9rB/L/bjyrrwjqYVFR0TdCrrfX5YssiBwBJw9XXUp9CKcTpKBO+ lbnUX6Dr9B/RFhs72b8knchakJEQetkLYdY9WF5bQz1GnVL/uMr5JNnIvP+aaPLXc6 ZOa+nQJVWbop0G5Io+g+W99QtsJDk/rGVtpWJVEw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sherry Sun , Joakim Zhang , Sasha Levin Subject: [PATCH 5.4 354/408] mic: vop: copy data to kernel space then write to io memory Date: Tue, 27 Oct 2020 14:54:52 +0100 Message-Id: <20201027135511.440525496@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sherry Sun [ Upstream commit 675f0ad4046946e80412896436164d172cd92238 ] 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 Signed-off-by: Joakim Zhang Link: https://lore.kernel.org/r/20200929091106.24624-5-sherry.sun@nxp.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/misc/mic/vop/vop_vringh.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/misc/mic/vop/vop_vringh.c b/drivers/misc/mic/vop/vop_vringh.c index 30eac172f0170..d069947b09345 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; + size_t offset = 0; if (dma) { dma_alignment = 1 << vi->dma_ch->device->copy_align; @@ -655,13 +656,20 @@ 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)) { - err = -EFAULT; - dev_err(vop_dev(vdev), "%s %d err %d\n", - __func__, __LINE__, err); - goto err; + while (len) { + partlen = min_t(size_t, len, VOP_INT_DMA_BUF_SIZE); + + if (copy_from_user(vvr->buf, ubuf + offset, partlen)) { + err = -EFAULT; + dev_err(vop_dev(vdev), "%s %d err %d\n", + __func__, __LINE__, err); + goto err; + } + memcpy_toio(dbuf + offset, vvr->buf, partlen); + offset += partlen; + vdev->out_bytes += partlen; + len -= partlen; } - vdev->out_bytes += len; err = 0; err: vpdev->hw_ops->unmap(vpdev, dbuf); -- 2.25.1