From patchwork Fri Jul 6 07:46:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 141259 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2815830ljj; Fri, 6 Jul 2018 00:47:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeORY7zqD+FhQqK6E6zztwBFAO+iUalpxodHOBQ4s/Afl8CXHRmPypok0ACr3SE9H0Qiuxr X-Received: by 2002:a63:af14:: with SMTP id w20-v6mr2648523pge.47.1530863278215; Fri, 06 Jul 2018 00:47:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530863278; cv=none; d=google.com; s=arc-20160816; b=h4GQ77+2OZIiKtjy2GEUw99iijTwtXViDILekBoWlN+4SvIjkISpVUk9ig8xztmACr L7RBOx5l8kfD06+zpsN9PFo6bxA4tlJ9cHrQv3gmoWtMln1IZVpEZE7piTPmI/kHpLyk rdzwxHiBvKFafLFxFct33CQo25Wid6++x1XC37di57ATRgHXzMi1ZE00hQRYr13YBzuZ JUTtbCbCfkvsZ+Ss5WSFG7I4eyVJlQevVSvMpvoHeYlbX/Txt8BAQqiMZOYfNxfgMCOz 44/Ddp61vKGLukg6MAqMAeG+CjDNYEEadjRtanCmSIgtVhj6Q3TENR+qGo4+04jbBXDk CzLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=+ZIgYvt1cuosEAkbEAEQAayYXmxcBqfFF3orUaiJhJI=; b=BKBwxWi14wYfeWeBHyCu+TTEpAOMBD6m0j5EtmUbwzxEYsTo5M7H+k/iOdafkV3pi9 gUJ9tG6pNbLEcfRLoleoKprGus4nrpbn7KLeunWamQ96AVJvzmWCdjCa0ePWSon0rHM7 1R9WG1vH4mPfKXedS4ramV7xhSQLaJJD1InfBaBgP41APp35EOBwpFvj5P5p1Zr/Fu09 oqUyETeoqbKBfKeoucKpjkdVDzTSHXWtq3kE7rZYhw9cYuPZD5aPO7GH8hK6jkY+Z3fH wxYbxw57MYGbtK7YRTVeyjSkASVjOiKnuJXzDSnQQz5Aby59Go4V1F24YeLBbih6aYL1 79fQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f14-v6si7366679plr.365.2018.07.06.00.47.57; Fri, 06 Jul 2018 00:47:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932205AbeGFHr4 (ORCPT + 30 others); Fri, 6 Jul 2018 03:47:56 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:39971 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752077AbeGFHry (ORCPT ); Fri, 6 Jul 2018 03:47:54 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w667hZnx031922; Fri, 6 Jul 2018 09:47:52 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2k0dnx539w-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 06 Jul 2018 09:47:52 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9D83131; Fri, 6 Jul 2018 07:47:51 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag7node2.st.com [10.75.127.20]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 509161D84; Fri, 6 Jul 2018 07:47:51 +0000 (GMT) Received: from localhost (10.75.127.47) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 6 Jul 2018 09:47:50 +0200 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 1/1] remoteproc: correct rproc_free_vring() to avoid invalid kernel paging Date: Fri, 6 Jul 2018 09:46:52 +0200 Message-ID: <1530863212-16584-1-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG3NODE3.st.com (10.75.127.9) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-06_02:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If rproc_start() failed, rproc_resource_cleanup() is called to clean debugfs entries, then associated iommu mappings, carveouts and vdev. Issue occurs when rproc_free_vring() is trying to reset vring resource table entry. At this time, table_ptr is pointing on loaded resource table and carveouts already released, so access to loaded resource table is generating a kernel paging error: [ 12.696535] Unable to handle kernel paging request at virtual address f0f357cc [ 12.696540] pgd = (ptrval) [ 12.696542] [f0f357cc] *pgd=6d2d0811, *pte=00000000, *ppte=00000000 [ 12.696558] Internal error: Oops: 807 [#1] SMP ARM [ 12.696563] Modules linked in: rpmsg_core v4l2_mem2mem videobuf2_dma_contig sti_drm v4l2_common vida [ 12.696598] CPU: 1 PID: 48 Comm: kworker/1:1 Tainted: G W 4.18.0-rc2-00018-g3170fdd-8 [ 12.696602] Hardware name: STi SoC with Flattened Device Tree [ 12.696625] Workqueue: events request_firmware_work_func [ 12.696659] PC is at rproc_free_vring+0x84/0xbc [remoteproc] [ 12.696667] LR is at rproc_free_vring+0x70/0xbc [remoteproc] This patch proposes to simply remove reset of resource table vring entries, as firmware and resource table are reloaded at each rproc boot. rproc_trigger_recovery() not impacted as resources not touched during recovery procedure. Signed-off-by: Loic Pallardy --- Changes from V1: typo fixes in commit message drivers/remoteproc/remoteproc_core.c | 6 ------ 1 file changed, 6 deletions(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index a9609d9..9a8b47c 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -289,16 +289,10 @@ void rproc_free_vring(struct rproc_vring *rvring) { int size = PAGE_ALIGN(vring_size(rvring->len, rvring->align)); struct rproc *rproc = rvring->rvdev->rproc; - int idx = rvring->rvdev->vring - rvring; - struct fw_rsc_vdev *rsc; dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma); idr_remove(&rproc->notifyids, rvring->notifyid); - /* reset resource entry info */ - rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset; - rsc->vring[idx].da = 0; - rsc->vring[idx].notifyid = -1; } static int rproc_vdev_do_probe(struct rproc_subdev *subdev)