Commit cf59d3e9 authored by Ohad Ben-Cohen's avatar Ohad Ben-Cohen

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: default avatarGrant Likely <grant.likely@secretlab.ca>
Signed-off-by: default avatarOhad Ben-Cohen <ohad@wizery.com>
Cc: Mark Grosen <mgrosen@ti.com>
Acked-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent dd6da1c5
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <linux/elf.h> #include <linux/elf.h>
#include <linux/virtio_ids.h> #include <linux/virtio_ids.h>
#include <linux/virtio_ring.h> #include <linux/virtio_ring.h>
#include <asm/byteorder.h>
#include "remoteproc_internal.h" #include "remoteproc_internal.h"
...@@ -851,6 +852,16 @@ static int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) ...@@ -851,6 +852,16 @@ static int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)
ehdr = (struct elf32_hdr *)fw->data; 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)) { if (fw->size < ehdr->e_shoff + sizeof(struct elf32_shdr)) {
dev_err(dev, "Image is too small\n"); dev_err(dev, "Image is too small\n");
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment