Patchwork armv7m: Guard against no -kernel argument

login
register
mail settings
Submitter Peter A. G. Crosthwaite
Date Aug. 10, 2012, 1:27 a.m.
Message ID <1344562055-7347-1-git-send-email-peter.crosthwaite@petalogix.com>
Download mbox | patch
Permalink /patch/176306/
State New
Headers show

Comments

Peter A. G. Crosthwaite - Aug. 10, 2012, 1:27 a.m.
A -kernel argument must be specified for this machine. Gaurd against no -kernel
argument. Previously gave an unhelpful "bad address" error message.

Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
---
 hw/armv7m.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
Markus Armbruster - Aug. 10, 2012, 6:06 a.m.
"Peter A. G. Crosthwaite" <peter.crosthwaite@petalogix.com> writes:

> A -kernel argument must be specified for this machine. Gaurd against no -kernel
> argument. Previously gave an unhelpful "bad address" error message.
>
> Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>

Tested-by: Markus Armbruster <armbru@redhat.com>
Andreas Färber - Aug. 10, 2012, 8:53 a.m.
Am 10.08.2012 03:27, schrieb Peter A. G. Crosthwaite:
> A -kernel argument must be specified for this machine. Gaurd against no -kernel

"Guard"

> argument. Previously gave an unhelpful "bad address" error message.
> 
> Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>

Otherwise looks good - PMM, can you fix?

/-F

> ---
>  hw/armv7m.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/armv7m.c b/hw/armv7m.c
> index 8cec78d..9f66667 100644
> --- a/hw/armv7m.c
> +++ b/hw/armv7m.c
> @@ -227,6 +227,11 @@ qemu_irq *armv7m_init(MemoryRegion *address_space_mem,
>      big_endian = 0;
>  #endif
>  
> +    if (!kernel_filename) {
> +        fprintf(stderr, "Guest image must be specified (using -kernel)\n");
> +        exit(1);
> +    }
> +
>      image_size = load_elf(kernel_filename, NULL, NULL, &entry, &lowaddr,
>                            NULL, big_endian, ELF_MACHINE, 1);
>      if (image_size < 0) {
>
Peter Maydell - Aug. 10, 2012, 10:18 a.m.
On 10 August 2012 09:53, Andreas Färber <afaerber@suse.de> wrote:
> Am 10.08.2012 03:27, schrieb Peter A. G. Crosthwaite:
>> A -kernel argument must be specified for this machine. Gaurd against no -kernel
>
> "Guard"
>
>> argument. Previously gave an unhelpful "bad address" error message.
>>
>> Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
>
> Otherwise looks good - PMM, can you fix?

Yes, I have fixed the typo and put this patch into arm-devs.next.
I'm planning to put together a pullreq later today.

-- PMM

Patch

diff --git a/hw/armv7m.c b/hw/armv7m.c
index 8cec78d..9f66667 100644
--- a/hw/armv7m.c
+++ b/hw/armv7m.c
@@ -227,6 +227,11 @@  qemu_irq *armv7m_init(MemoryRegion *address_space_mem,
     big_endian = 0;
 #endif
 
+    if (!kernel_filename) {
+        fprintf(stderr, "Guest image must be specified (using -kernel)\n");
+        exit(1);
+    }
+
     image_size = load_elf(kernel_filename, NULL, NULL, &entry, &lowaddr,
                           NULL, big_endian, ELF_MACHINE, 1);
     if (image_size < 0) {