Skip to contentSkip to conversation

Make -kernel flag optional on ARM.

PATCH In review Grant Likely 3 participants 5 messages Jul 10, 2013 – Aug 30, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Make -kernel flag optional on ARM.

Sometimes we want to boot the system via firmware instead of loading a kernel into ram with the -kernel parameter. This patch makes the -kernel parameter optional so that a bios image provided by the -pflash flag will be executed.

For example:
qemu-system-arm -M vexpress-a15 -pflash <filename>

Note: Currently the file must be at least the size of the emulated flash device (ie 64M for VExpress) otherwise QEMU will silently not use the data. This will be fixed in a separate patch

v2: just return if the kernel filename isn't provided

---
 hw/arm/boot.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
hw/arm/boot.c +2 -5
index 7c0090f..e702fd7 100644
@@ -361,11 +361,8 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
     int big_endian;
     QemuOpts *machine_opts;
 
-    /* Load the kernel.  */
-    if (!info->kernel_filename) {
-        fprintf(stderr, "Kernel image must be specified\n");
-        exit(1);
-    }
+    if (!info->kernel_filename)
+        return;
 
     machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
     if (machine_opts) {
Signature · 1 line
1.8.1.2
#1 lore raw

Hi Peter,

What's the status on this patch? Is it able to be merged?

g.

Quoted 42 lines · Grant Likely

Sometimes we want to boot the system via firmware instead of loading a kernel into ram with the -kernel parameter. This patch makes the -kernel parameter optional so that a bios image provided by the -pflash flag will be executed.

For example:
qemu-system-arm -M vexpress-a15 -pflash <filename>

Note: Currently the file must be at least the size of the emulated flash device (ie 64M for VExpress) otherwise QEMU will silently not use the data. This will be fixed in a separate patch

v2: just return if the kernel filename isn't provided

---
 hw/arm/boot.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
hw/arm/boot.c +2 -6
index 7c0090f..e702fd7 100644
@@ -361,11 +361,8 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
     int big_endian;
     QemuOpts *machine_opts;
 
-    /* Load the kernel.  */
-    if (!info->kernel_filename) {
-        fprintf(stderr, "Kernel image must be specified\n");
-        exit(1);
-    }
+    if (!info->kernel_filename)
+        return;
 
     machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
     if (machine_opts) {
--

1.8.1.2

#2 lore raw

Hi,

Am 30.08.2013 12:58, schrieb Grant Likely:

Quoted 3 lines

Hi Peter,

What's the status on this patch? Is it able to be merged?

I had posted a slightly different patch earlier that just returned immediately when qtest_enabled(). If we go with yours, we might be able to drop mine, have you checked on that?

As for your patch I wonder, isn't there anything else to do in the kernel_filename==NULL case?

Andreas

Quoted 42 lines · Grant Likely
Quoted 41 lines

Sometimes we want to boot the system via firmware instead of loading a kernel into ram with the -kernel parameter. This patch makes the -kernel parameter optional so that a bios image provided by the -pflash flag will be executed.

For example:
qemu-system-arm -M vexpress-a15 -pflash <filename>

Note: Currently the file must be at least the size of the emulated flash device (ie 64M for VExpress) otherwise QEMU will silently not use the data. This will be fixed in a separate patch

v2: just return if the kernel filename isn't provided

---
 hw/arm/boot.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
hw/arm/boot.c +2 -6
index 7c0090f..e702fd7 100644
@@ -361,11 +361,8 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
     int big_endian;
     QemuOpts *machine_opts;
 
-    /* Load the kernel.  */
-    if (!info->kernel_filename) {
-        fprintf(stderr, "Kernel image must be specified\n");
-        exit(1);
-    }
+    if (!info->kernel_filename)
+        return;
 
     machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
     if (machine_opts) {
--

1.8.1.2

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#3 lore raw
Quoted 5 lines · Andreas Färber

Hi,

Am 30.08.2013 12:58, schrieb Grant Likely:

Quoted 2 lines

Hi Peter,

Quoted 8 lines
Quoted 1 line

What's the status on this patch? Is it able to be merged?

I had posted a slightly different patch earlier that just returned immediately when qtest_enabled(). If we go with yours, we might be able to drop mine, have you checked on that?

As for your patch I wonder, isn't there anything else to do in the kernel_filename==NULL case?

Not that I've been able to find, although it would be nice to have a warning if neither a kernel or NOR image is provided.

g.

Quoted 49 lines

Andreas

Quoted 38 lines · Grant Likely
Quoted 37 lines

Sometimes we want to boot the system via firmware instead of loading a kernel into ram with the -kernel parameter. This patch makes the -kernel parameter optional so that a bios image provided by the -pflash flag will be executed.

For example:
qemu-system-arm -M vexpress-a15 -pflash <filename>

Note: Currently the file must be at least the size of the emulated flash device (ie 64M for VExpress) otherwise QEMU will silently not use the data. This will be fixed in a separate patch

v2: just return if the kernel filename isn't provided

---
 hw/arm/boot.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
hw/arm/boot.c +2 -5
index 7c0090f..e702fd7 100644
@@ -361,11 +361,8 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
     int big_endian;
     QemuOpts *machine_opts;
 
-    /* Load the kernel.  */
-    if (!info->kernel_filename) {
-        fprintf(stderr, "Kernel image must be specified\n");
-        exit(1);
-    }
+    if (!info->kernel_filename)
+        return;
 
Quoted 4 lines
Quoted 4 lines
hw/arm/boot.c +0 -1
     machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
     if (machine_opts) {
--

1.8.1.2

--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

#4 lore raw
In reply to Andreas Färber
Quoted 6 lines · Andreas Färber

Hi,

Am 30.08.2013 12:58, schrieb Grant Likely:

Quoted 3 lines

Hi Peter,

What's the status on this patch? Is it able to be merged?

I had a variant on it I'd already written, plus a second patch that cleans up some places that no longer need to make calls to arm_load_kernel() be conditional on kernel_filename not being NULL, but I'm afraid I didn't get to sending it out before 1.6 freeze and I forgot about it in the interim.

Also I couldn't decide what I thought about the way that boards end up with not warning if the user doesn't specify -kernel or provide a boot rom image somehow. I'd like to be user friendly but it doesn't seem right that every board init function ends up having to have similar boilerplate either.

Quoted 6 lines

I had posted a slightly different patch earlier that just returned immediately when qtest_enabled(). If we go with yours, we might be able to drop mine, have you checked on that?

As for your patch I wonder, isn't there anything else to do in the kernel_filename==NULL case?

Nope, that's it. In that case we'll just do what the hardware does, ie all CPUs start executing at the reset vector address (zero). The assumption is the boot firmware deals with that, as it has to for h/w.

-- PMM