Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp297986pxx; Wed, 28 Oct 2020 05:18:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkRVNQCeC+Wy+h3QZk2AvMRLlFUe6lqCm5ABGdDhv5uZ5MHmiJGChStTINo/wiMqelWqBR X-Received: by 2002:a05:6402:1686:: with SMTP id a6mr7260524edv.106.1603887524064; Wed, 28 Oct 2020 05:18:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603887524; cv=none; d=google.com; s=arc-20160816; b=cXqSbjl50jxNChyly+dN8f3aiIZheRIUn9fuE5PKEk7ZldCgeAAOYV9z4Vs2nO0n7g 8Upx7ZWkfTTvVQSfH42gM9rpAFN5ep4DT4/3gyD0iYv/6lUmGKaeMrCW3l/3/aeXLseF OqTPSHFk0PlPbMYRbvCUhW0AQA6jeGUG6LBFAjbkJGlARO0KMWJDYGyaxSHhKPpX3Ht2 EOPDrVaIXocZaCFv0bzIjORmkoq2Auk4/ggkg6ufIquRnYqDSRpmbNTWZedNaxsjev01 HUMqNnGIFdEgGGYIsM078DxmloCsn8KooXRO7IxN+H9nipG2iNUd1I8YJzDLKcZaBU3t SmrQ== 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=pA/RR4OEqjT612q3GFcoDLtKnd4k21kmNDcdGW44LXYLX91/k6HkvkpBueFuFPEfA9 mNjQFIt19ZoC1LqSzP976075WfealtbzxzpvtTCVzbiUipvzUr0PPVQlgYwtvKdfM7r6 6xwQPRqdHzyKTFHdmCjEXwUdbMHJjYIyr6FuiFVcg3azO1t6Un3CiAPq0kQY0W2hGC0+ gPOL+WfM9yAOCrU2/kzTmi/4S4TyGU/0UQX6zY4mYk3pfBmIUTxp1AjlM45cHxSSbsTR GS7bX+6nd/0+z/w3RbgfF0UGqEVEUtKbkx2+WHkEY2lKxA0xWW+sZtfgK26HAbrSBwNx m3Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qPnc7k9y; 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 d2si2953320edn.245.2020.10.28.05.18.20; Wed, 28 Oct 2020 05:18:44 -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=qPnc7k9y; 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 S1796408AbgJ0PSU (ORCPT + 99 others); Tue, 27 Oct 2020 11:18:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:51086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1794874AbgJ0POF (ORCPT ); Tue, 27 Oct 2020 11:14:05 -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 077F220728; Tue, 27 Oct 2020 15:14:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811644; bh=MkgMDcccSHwun46vYipogs2oopYDY7nk+d6mYmDSuyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qPnc7k9yDUaG/xhN/bcmri4qs0T15DOgf15AVqUQf1XB18xU6p04tt/PBXI8IRil6 SykzCIU/4o8wt8dsfbI8ATdp+/88bqJQepj/QuAwior1vrj0pQwPLdkNtWmjnHraxU TI7eMIXhK8N3G6xYebokk64u2efGh/FHIzfC65f4= 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.8 566/633] mic: vop: copy data to kernel space then write to io memory Date: Tue, 27 Oct 2020 14:55:09 +0100 Message-Id: <20201027135549.354705053@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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