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]
Message-ID: <20241126091042.918144-6-arnaud.pouliquen@foss.st.com>
Date: Tue, 26 Nov 2024 10:10:36 +0100
From: Arnaud Pouliquen <arnaud.pouliquen@...s.st.com>
To: Bjorn Andersson <andersson@...nel.org>,
        Mathieu Poirier
	<mathieu.poirier@...aro.org>
CC: Arnaud Pouliquen <arnaud.pouliquen@...s.st.com>,
        <linux-remoteproc@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH v14 5/8] remoteproc: Make load_segments and load_fw ops exclusive and optional

The two methods to load the firmware to memory should be exclusive.

- make load_segments optional returning 0 if not set in
  rproc_load_segments(),
- ensure that load_segments() and load_fw() are not both set,
- do not set default rproc::ops fields if load_fw() is set.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@...s.st.com>
---
 drivers/remoteproc/remoteproc_core.c     | 4 ++++
 drivers/remoteproc/remoteproc_internal.h | 2 +-
 include/linux/remoteproc.h               | 7 +++++--
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index e4ad024efcda..deadec0f3474 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -2477,6 +2477,10 @@ static int rproc_alloc_firmware(struct rproc *rproc,
 
 static int rproc_alloc_ops(struct rproc *rproc, const struct rproc_ops *ops)
 {
+	/* A processor with a load_segments() and a load_fw() functions makes no sense. */
+	if (ops->load_segments && ops->load_fw)
+		return -EINVAL;
+
 	rproc->ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL);
 	if (!rproc->ops)
 		return -ENOMEM;
diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h
index b898494600cf..3a4161eaf291 100644
--- a/drivers/remoteproc/remoteproc_internal.h
+++ b/drivers/remoteproc/remoteproc_internal.h
@@ -170,7 +170,7 @@ int rproc_load_segments(struct rproc *rproc, const struct firmware *fw)
 	if (rproc->ops->load_segments)
 		return rproc->ops->load_segments(rproc, fw);
 
-	return -EINVAL;
+	return 0;
 }
 
 static inline int rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 55c20424a99f..4f4c65ce74af 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -374,8 +374,9 @@ enum rsc_handling_status {
  * @find_loaded_rsc_table: find the loaded resource table from firmware image
  * @get_loaded_rsc_table: get resource table installed in memory
  *			  by external entity
- * @load_segments:	load firmware ELF segment to memory, where the remote processor
- *			expects to find it
+ * @load_segments:	optional load firmware ELF segments to memory, where the remote processor
+ *			expects to find it.
+ *			This operation is exclusive with the load_fw()
  * @sanity_check:	sanity check the fw image
  * @get_boot_addr:	get boot address to entry point specified in firmware
  * @panic:	optional callback to react to system panic, core will delay
@@ -383,8 +384,10 @@ enum rsc_handling_status {
  * @coredump:	  collect firmware dump after the subsystem is shutdown
  * @load_fw:	optional function to load non-ELF firmware image to memory, where the remote
  *		processor expects to find it.
+ *		This operation is exclusive with the load_segments()
  * @release_fw:	optional function to release the firmware image from memories.
  *		This function is called after stopping the remote processor or in case of error
+ *
  */
 struct rproc_ops {
 	int (*prepare)(struct rproc *rproc);
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ