aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/remoteproc
diff options
context:
space:
mode:
authorOhad Ben-Cohen <ohad@wizery.com>2012-01-31 08:23:41 -0500
committerOhad Ben-Cohen <ohad@wizery.com>2012-02-22 11:28:49 -0500
commitcf59d3e9a715fd2b6ff96e4a3a130fceded09a64 (patch)
treeefc2040a4e7a60863589ee1b7415516dffbf7c90 /drivers/remoteproc
parentdd6da1c5e99a3b736b52370c504a2b8843cbfda6 (diff)
remoteproc: bail out if firmware has different endianess
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> Acked-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/remoteproc')
-rw-r--r--drivers/remoteproc/remoteproc_core.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 6212b82885d0..567a3c59b4af 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -39,6 +39,7 @@
39#include <linux/elf.h> 39#include <linux/elf.h>
40#include <linux/virtio_ids.h> 40#include <linux/virtio_ids.h>
41#include <linux/virtio_ring.h> 41#include <linux/virtio_ring.h>
42#include <asm/byteorder.h>
42 43
43#include "remoteproc_internal.h" 44#include "remoteproc_internal.h"
44 45
@@ -851,6 +852,16 @@ static int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)
851 852
852 ehdr = (struct elf32_hdr *)fw->data; 853 ehdr = (struct elf32_hdr *)fw->data;
853 854
855 /* We assume the firmware has the same endianess as the host */
856# ifdef __LITTLE_ENDIAN
857 if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) {
858# else /* BIG ENDIAN */
859 if (ehdr->e_ident[EI_DATA] != ELFDATA2MSB) {
860# endif
861 dev_err(dev, "Unsupported firmware endianess\n");
862 return -EINVAL;
863 }
864
854 if (fw->size < ehdr->e_shoff + sizeof(struct elf32_shdr)) { 865 if (fw->size < ehdr->e_shoff + sizeof(struct elf32_shdr)) {
855 dev_err(dev, "Image is too small\n"); 866 dev_err(dev, "Image is too small\n");
856 return -EINVAL; 867 return -EINVAL;