lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 24 Mar 2017 12:22:24 -0700
From:   Wendy Liang <wendy.liang@...inx.com>
To:     <bjorn.andersson@...aro.org>
CC:     <linux-remoteproc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        "Wendy Liang" <wendy.liang@...inx.com>,
        Wendy Liang <jliang@...inx.com>,
        Michal Simek <michal.simek@...inx.com>
Subject: [RFC LINUX PATCH 08/19] remoteproc: add a function to set fw checksum rsc

From: Wendy Liang <wendy.liang@...inx.com>

Add a function to set the firmware checksum resource.
The function will call the firmware loader to calculate
the firmware checksum and set it to the resource table.

Signed-off-by: Wendy Liang <jliang@...inx.com>
Signed-off-by: Michal Simek <michal.simek@...inx.com>
---
 drivers/remoteproc/remoteproc_core.c | 54 ++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index f13f56d..447c28b 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -897,6 +897,60 @@ static bool rproc_is_running(struct rproc *rproc)
 	return (rproc->state == RPROC_RUNNING) ? true : false;
 }
 
+/**
+ * rproc_handle_fw_chksum() - handle firmware checksum resource
+ * @rproc: rproc handle
+ * @fw: firmware
+ * @offset: returns fw_chksum resource offset.
+ *
+ * This function will handle request to set the firmware checksum.
+ */
+static
+struct fw_rsc_fw_chksum *rproc_handle_fw_chksum(struct rproc *rproc,
+				const struct firmware *fw, int *offset)
+{
+	struct fw_rsc_fw_chksum *rsc = NULL;
+	int i, tablesz;
+	struct device *dev = &rproc->dev;
+	struct resource_table *table;
+
+	/* look for the resource table */
+	table = rproc_find_rsc_table(rproc, fw, &tablesz);
+	if (!table) {
+		dev_err(dev, "Failed to find resource table\n");
+		return NULL;
+	}
+
+	for (i = 0; i < rproc->table_ptr->num; i++) {
+		int ret = 0;
+		int tmpoffset = rproc->table_ptr->offset[i];
+		struct fw_rsc_hdr *hdr = (void *)rproc->table_ptr + tmpoffset;
+		int avail = tablesz - tmpoffset - sizeof(*hdr);
+
+		if (hdr->type != RSC_FW_CHKSUM)
+			continue;
+
+		rsc = (struct fw_rsc_fw_chksum *)((void *)hdr + sizeof(*hdr));
+		if (sizeof(*rsc) > avail) {
+			dev_err(dev, "firmware checksum rsc is truncated\n");
+			return NULL;
+		}
+		if (rproc->fw_ops->get_chksum) {
+			ret = rproc->fw_ops->get_chksum(rproc, fw,
+				rsc->algo, rsc->chksum, sizeof(rsc->chksum));
+			if (ret) {
+				dev_err(dev,
+					"failed to get firmware chksum.\n");
+				return NULL;
+			}
+		}
+		*offset = tmpoffset + sizeof(*hdr);
+		return rsc;
+	}
+
+	return NULL;
+}
+
 /*
  * check if the remote needs start.
  */
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ