From patchwork Thu Oct 20 02:40:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 78383 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp560533qge; Wed, 19 Oct 2016 19:40:59 -0700 (PDT) X-Received: by 10.98.29.131 with SMTP id d125mr16938012pfd.111.1476931259563; Wed, 19 Oct 2016 19:40:59 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si39636407pgc.26.2016.10.19.19.40.59; Wed, 19 Oct 2016 19:40:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933864AbcJTCkw (ORCPT + 10 others); Wed, 19 Oct 2016 22:40:52 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:32777 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933992AbcJTCkj (ORCPT ); Wed, 19 Oct 2016 22:40:39 -0400 Received: by mail-pf0-f170.google.com with SMTP id 128so26595979pfz.0 for ; Wed, 19 Oct 2016 19:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1YnsdbQTjJSBGWZBakiUl9Gmj8Qe7EIM688J2xaHjsE=; b=kxyqMzeyid5jWLCtywj0eI/Aa4qjZKpa8ab0QoCcrjt7b1CIJK4uOHkIHjkz3CCXw3 TTFt+Nj54hyDXtywJpkOwquNNtbgbT84C6zSM0+3GNHPAEBY8DGhgqwKMJI7XgQvv1AD mICRGvPZhzgKjgrSW41hyNeVQiHCDt1n1NHEs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1YnsdbQTjJSBGWZBakiUl9Gmj8Qe7EIM688J2xaHjsE=; b=C/dTmITQ8IgRA21lqr1A5HSshvbl1rzEwVjXuast2FNHf+px/TQ65pE15nI3DUNDZy s0LyZttsVBEn/Kch7O50U78qFqZ92Hneam5QJbjZz8FaqA5UCHyZbyXxNCV/22nKWNFH rUPv6uyBwgVNsrcbSilzziNCgfjiLKplAvWP82et0YwZsHCgAUhcbZKM6wCtQpAtC/Hx EEFZS457zZ5mTlBYPII68F93eQlgUMXaylRy2JQyZHxhdPvUhW6ScDluMADo6+RzRs3z UeKIeg4Tsr8hLAz0ya2RDUcNgdn+fK5xl3++1egBbyTuhUPDkwelv4dMuwVYUzN1RQyU wAng== X-Gm-Message-State: AA6/9Rmo2zFl+CSipMRA/oJvnYXMIFUPRgq0mBnXbIsz472EecHRb9vzwL29ynzpu3UlG5ip X-Received: by 10.99.112.72 with SMTP id a8mr13872467pgn.43.1476931233304; Wed, 19 Oct 2016 19:40:33 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id s85sm66780616pfi.17.2016.10.19.19.40.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Oct 2016 19:40:32 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 11/11] remoteproc: Merge table_ptr and cached_table pointers Date: Wed, 19 Oct 2016 19:40:12 -0700 Message-Id: <1476931212-1806-12-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1476931212-1806-1-git-send-email-bjorn.andersson@linaro.org> References: <1476931212-1806-1-git-send-email-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org As all vdev resources are allocated before we boot the remote processor we no longer need to support modifying the resource table while the remote is running. This saves us from the table_ptr dance, but more importantly allow the remote processor to enable security lock down of the loaded table memory region. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 26 ++++++++++---------------- include/linux/remoteproc.h | 4 +--- 2 files changed, 11 insertions(+), 19 deletions(-) -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index f31783d27196..46078c959a9c 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -889,15 +889,13 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) /* * Create a copy of the resource table. When a virtio device starts * and calls vring_new_virtqueue() the address of the allocated vring - * will be stored in the cached_table. Before the device is started, - * cached_table will be copied into device memory. + * will be stored in the table_ptr. Before the device is started, + * table_ptr will be copied into device memory. */ - rproc->cached_table = kmemdup(table, tablesz, GFP_KERNEL); - if (!rproc->cached_table) + rproc->table_ptr = kmemdup(table, tablesz, GFP_KERNEL); + if (!rproc->table_ptr) goto clean_up; - rproc->table_ptr = rproc->cached_table; - /* reset max_notifyid */ rproc->max_notifyid = -1; @@ -916,18 +914,16 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) } /* - * The starting device has been given the rproc->cached_table as the + * The starting device has been given the rproc->table_ptr as the * resource table. The address of the vring along with the other - * allocated resources (carveouts etc) is stored in cached_table. + * allocated resources (carveouts etc) is stored in table_ptr. * In order to pass this information to the remote device we must copy * this information to device memory. We also update the table_ptr so * that any subsequent changes will be applied to the loaded version. */ loaded_table = rproc_find_loaded_rsc_table(rproc, fw); - if (loaded_table) { - memcpy(loaded_table, rproc->cached_table, tablesz); - rproc->table_ptr = loaded_table; - } + if (loaded_table) + memcpy(loaded_table, rproc->table_ptr, tablesz); /* power up the remote processor */ ret = rproc->ops->start(rproc); @@ -955,8 +951,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) clean_up_resources: rproc_resource_cleanup(rproc); clean_up: - kfree(rproc->cached_table); - rproc->cached_table = NULL; + kfree(rproc->table_ptr); rproc->table_ptr = NULL; rproc_disable_iommu(rproc); @@ -1206,8 +1201,7 @@ void rproc_shutdown(struct rproc *rproc) rproc_disable_iommu(rproc); /* Free the copy of the resource table */ - kfree(rproc->cached_table); - rproc->cached_table = NULL; + kfree(rproc->table_ptr); rproc->table_ptr = NULL; /* if in crash state, unlock crash handler */ diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index ff05b88730ad..51662ee7d032 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -408,8 +408,7 @@ enum rproc_crash_type { * @crash_comp: completion used to sync crash handler and the rproc reload * @recovery_disabled: flag that state if recovery was disabled * @max_notifyid: largest allocated notify id. - * @table_ptr: pointer to the resource table in effect - * @cached_table: copy of the resource table + * @table_ptr: our copy of the resource table * @has_iommu: flag to indicate if remote processor is behind an MMU */ struct rproc { @@ -441,7 +440,6 @@ struct rproc { bool recovery_disabled; int max_notifyid; struct resource_table *table_ptr; - struct resource_table *cached_table; bool has_iommu; bool auto_boot; };