linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] remoteproc: bail out if firmware has different endianess
@ 2012-01-31 16:52 Ohad Ben-Cohen
  2012-01-31 16:52 ` [PATCH 2/2] remoteproc: s/big switch/lookup table/ Ohad Ben-Cohen
  2012-01-31 20:09 ` [PATCH 1/2] remoteproc: bail out if firmware has different endianess Grant Likely
  0 siblings, 2 replies; 7+ messages in thread
From: Ohad Ben-Cohen @ 2012-01-31 16:52 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: Grant Likely, Mark Grosen, Ohad Ben-Cohen

At this point we don't support remote processors that have
a different endianess than the host.

Look out for these unsupported scenarios, and bail out if
encountered.

Reported-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Cc: Mark Grosen <mgrosen@ti.com>
---
 drivers/remoteproc/remoteproc_core.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 6212b82..567a3c5 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -39,6 +39,7 @@
 #include <linux/elf.h>
 #include <linux/virtio_ids.h>
 #include <linux/virtio_ring.h>
+#include <asm/byteorder.h>
 
 #include "remoteproc_internal.h"
 
@@ -851,6 +852,16 @@ static int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)
 
 	ehdr = (struct elf32_hdr *)fw->data;
 
+	/* We assume the firmware has the same endianess as the host */
+# ifdef __LITTLE_ENDIAN
+	if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) {
+# else /* BIG ENDIAN */
+	if (ehdr->e_ident[EI_DATA] != ELFDATA2MSB) {
+# endif
+		dev_err(dev, "Unsupported firmware endianess\n");
+		return -EINVAL;
+	}
+
 	if (fw->size < ehdr->e_shoff + sizeof(struct elf32_shdr)) {
 		dev_err(dev, "Image is too small\n");
 		return -EINVAL;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-02-08 21:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-31 16:52 [PATCH 1/2] remoteproc: bail out if firmware has different endianess Ohad Ben-Cohen
2012-01-31 16:52 ` [PATCH 2/2] remoteproc: s/big switch/lookup table/ Ohad Ben-Cohen
2012-01-31 17:58   ` Jack Stone
2012-01-31 20:08     ` Grant Likely
2012-01-31 20:21       ` Ohad Ben-Cohen
2012-01-31 20:09 ` [PATCH 1/2] remoteproc: bail out if firmware has different endianess Grant Likely
2012-02-08 21:01   ` Ohad Ben-Cohen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).