From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: "Suzuki K. Poulose" <suzuki@in.ibm.com>
Cc: mat@brain-dump.org, horms@verge.net.au,
kexec@lists.infradead.org, lethal@linux-sh.org
Subject: Re: [PATCH 1/3] kexec/uImage: Return the image type for uImage_probe
Date: Wed, 16 Jan 2013 18:20:36 +0100 [thread overview]
Message-ID: <20130116172036.GA20369@linutronix.de> (raw)
In-Reply-To: <20130111064131.11490.22173.stgit@suzukikp.in.ibm.com>
* Suzuki K. Poulose | 2013-01-11 12:11:36 [+0530]:
>From: Suzuki K. Poulose <suzuki@in.ibm.com>
>
>uImage supports different types of payloads, including kernel,
>ramdisks etc. uImage_probe() as of now checks whether the supplied
>payload is of type KERNEL ( i.e, IH_TYPE_KERNEL or IH_TYPE_KERNEL_NOLOAD ).
>
>Change this behaviour to return the image type, if it is one of the supported
>payloads. This change is in prepartion to support ramdisks in uImage format.
>
>Also, I have changed the code to check for the OS type only for the kernel images.
>
>Is this check really needed ? We shouldn't bother what OS is being loaded. Isn't it ?
We should bother because mostly linux is supported. Other operating
systems like NetBSD might have other ABI for the enter point or some
special requirements. The entry ABI for linux comapared to WindowsCE is
different for ARM just to name one example.
>This change would allow the user to decide if the image is of their interest.
>
>Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com>
>---
> kexec/arch/arm/kexec-uImage-arm.c | 8 +++++++-
> kexec/arch/ppc/kexec-uImage-ppc.c | 8 +++++++-
> kexec/arch/sh/kexec-uImage-sh.c | 9 ++++++++-
> kexec/kexec-uImage.c | 16 ++++++++++------
> 4 files changed, 32 insertions(+), 9 deletions(-)
>
>diff --git a/kexec/arch/arm/kexec-uImage-arm.c b/kexec/arch/arm/kexec-uImage-arm.c
>index 4875185..dc1bcb8 100644
>--- a/kexec/arch/arm/kexec-uImage-arm.c
>+++ b/kexec/arch/arm/kexec-uImage-arm.c
>@@ -11,7 +11,13 @@
>
> int uImage_arm_probe(const char *buf, off_t len)
> {
>- return uImage_probe(buf, len, IH_ARCH_ARM);
>+ int type;
>+ int rc = -1;
>+
>+ type = uImage_probe(buf, len, IH_ARCH_ARM);
>+ if (type == IH_TYPE_KERNEL || type == IH_TYPE_KERNEL_NOLOAD)
>+ rc = 0;
>+ return rc;
> }
>
> int uImage_arm_load(int argc, char **argv, const char *buf, off_t len,
>diff --git a/kexec/arch/ppc/kexec-uImage-ppc.c b/kexec/arch/ppc/kexec-uImage-ppc.c
>index e55bf94..eaea3c1 100644
>--- a/kexec/arch/ppc/kexec-uImage-ppc.c
>+++ b/kexec/arch/ppc/kexec-uImage-ppc.c
>@@ -48,7 +48,13 @@ void uImage_ppc_usage(void)
>
> int uImage_ppc_probe(const char *buf, off_t len)
> {
>- return uImage_probe(buf, len, IH_ARCH_PPC);
>+ int type;
>+ int rc = -1;
>+
>+ type = uImage_probe(buf, len, IH_ARCH_PPC);
>+ if (type == IH_TYPE_KERNEL || type == IH_TYPE_KERNEL_NOLOAD)
>+ rc = 0;
>+ return rc;
> }
>
> static int ppc_load_bare_bits(int argc, char **argv, const char *buf,
>diff --git a/kexec/arch/sh/kexec-uImage-sh.c b/kexec/arch/sh/kexec-uImage-sh.c
>index e983165..54bb073 100644
>--- a/kexec/arch/sh/kexec-uImage-sh.c
>+++ b/kexec/arch/sh/kexec-uImage-sh.c
>@@ -13,7 +13,14 @@
>
> int uImage_sh_probe(const char *buf, off_t len)
> {
>- return uImage_probe(buf, len, IH_ARCH_SH);
>+ int type;
>+ int rc = -1;
>+
>+ type = uImage_probe(buf, len, IH_ARCH_SH);
>+ if (type == IH_TYPE_KERNEL || type == IH_TYPE_KERNEL_NOLOAD)
>+ rc = uImage_probe(buf, len, IH_ARCH_SH);
This looks like a typo compared to ppc/arm above. If so you could create
uImage_probe_kernel() which has the type == check.
>+
>+ return rc;
> }
>
> int uImage_sh_load(int argc, char **argv, const char *buf, off_t len,
>diff --git a/kexec/kexec-uImage.c b/kexec/kexec-uImage.c
>index 3bc85c5..dcbd635 100644
>--- a/kexec/kexec-uImage.c
>+++ b/kexec/kexec-uImage.c
>@@ -16,6 +16,10 @@
> * Basic uImage loader. Not rocket science.
> */
>
>+/*
>+ * Returns the image type if everything goes well. This would
>+ * allow the user to decide if the image is of their interest.
>+ */
> int uImage_probe(const unsigned char *buf, off_t len, unsigned int arch)
> {
> struct image_header header;
>@@ -42,17 +46,17 @@ int uImage_probe(const unsigned char *buf, off_t len, unsigned int arch)
> switch (header.ih_type) {
> case IH_TYPE_KERNEL:
> case IH_TYPE_KERNEL_NOLOAD:
>+ /* XXX: Should we really check this ? */
Yes.
>+ if (header.ih_os != IH_OS_LINUX) {
>+ printf("uImage os %d unsupported\n", header.ih_os);
>+ return -1;
>+ }
Why did move this piece. Is it because ramdisk does not have an OS
selected?
> break;
> default:
> printf("uImage type %d unsupported\n", header.ih_type);
> return -1;
> }
>
>- if (header.ih_os != IH_OS_LINUX) {
>- printf("uImage os %d unsupported\n", header.ih_os);
>- return -1;
>- }
>-
> if (header.ih_arch != arch) {
> printf("uImage arch %d unsupported\n", header.ih_arch);
> return -1;
>@@ -84,7 +88,7 @@ int uImage_probe(const unsigned char *buf, off_t len, unsigned int arch)
> return -1;
> }
> #endif
>- return 0;
>+ return (int)header.ih_type;
Why do you return type here?
> }
>
> #ifdef HAVE_LIBZ
>
Sebastian
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2013-01-16 17:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-11 6:41 [PATCH 0/3] kexec: Support for uImage RAMDisks Suzuki K. Poulose
2013-01-11 6:41 ` [PATCH 1/3] kexec/uImage: Return the image type for uImage_probe Suzuki K. Poulose
2013-01-16 17:20 ` Sebastian Andrzej Siewior [this message]
2013-01-17 3:10 ` Suzuki K. Poulose
2013-01-11 6:41 ` [PATCH 2/3] kexec/uImage: Recognize uImage RAM Disks Suzuki K. Poulose
2013-01-11 6:42 ` [PATCH 3/3] ppc/uImage: Add support for " Suzuki K. Poulose
2013-01-11 7:11 ` McClintock Matthew-B29882
2013-01-14 5:14 ` Suzuki K. Poulose
2013-01-14 15:14 ` McClintock Matthew-B29882
2013-01-16 17:30 ` Sebastian Andrzej Siewior
2013-01-16 17:37 ` McClintock Matthew-B29882
2013-01-16 17:26 ` Sebastian Andrzej Siewior
2013-01-17 9:47 ` Suzuki K. Poulose
2013-01-27 16:39 ` Sebastian Andrzej Siewior
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=20130116172036.GA20369@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=horms@verge.net.au \
--cc=kexec@lists.infradead.org \
--cc=lethal@linux-sh.org \
--cc=mat@brain-dump.org \
--cc=suzuki@in.ibm.com \
/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