From: grant.likely@secretlab.ca (Grant Likely)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] remoteproc: bail out if firmware has different endianess
Date: Tue, 31 Jan 2012 13:09:45 -0700 [thread overview]
Message-ID: <20120131200945.GD22611@ponder.secretlab.ca> (raw)
In-Reply-To: <1328028762-28352-1-git-send-email-ohad@wizery.com>
On Tue, Jan 31, 2012 at 06:52:41PM +0200, Ohad Ben-Cohen wrote:
> 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>
> ---
> 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
>
next prev parent reply other threads:[~2012-01-31 20:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Grant Likely [this message]
2012-02-08 21:01 ` [PATCH 1/2] remoteproc: bail out if firmware has different endianess Ohad Ben-Cohen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120131200945.GD22611@ponder.secretlab.ca \
--to=grant.likely@secretlab.ca \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).