diff mbox series

hw/arm/boot: Load the Non Linux initrd to the memory

Message ID 1566898915-3129-1-git-send-email-gengdongjiu@huawei.com (mailing list archive)
State New, archived
Headers show
Series hw/arm/boot: Load the Non Linux initrd to the memory | expand

Commit Message

Dongjiu Geng Aug. 27, 2019, 9:41 a.m. UTC
Except support linux operation system, qemu also supports other
operation system which is non linux, such as microkernel system.

But now Qemu only load linux initrd, so change it to load both
linux and Non-linux initrd Image.

Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com> 
---
 hw/arm/boot.c | 45 +++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

Comments

Peter Maydell Aug. 27, 2019, 9:47 a.m. UTC | #1
On Tue, 27 Aug 2019 at 10:42, Dongjiu Geng <gengdongjiu@huawei.com> wrote:
>
> Except support linux operation system, qemu also supports other
> operation system which is non linux, such as microkernel system.
>
> But now Qemu only load linux initrd, so change it to load both
> linux and Non-linux initrd Image.

We currently support two methods of booting:
 (1) using the boot protocol defined by the Linux kernel
     (which includes how to find the DTB, initrd, what the
     secondary CPUs do, and so on)
 (2) you're a 'bare-metal' image, in which case you get
     complete control of all the CPUs at once in the same
     way the hardware does. Raw hardware doesn't provide
     initrd files, and nor does QEMU.

This patch seems to be trying to introduce a third hybrid
thing. Is there a specification for whatever this boot
protocol is? How many guest OSes use it? Are they common?

If you want an initrd, you can always wrap your guest OS in
a shim which complies with the Linux kernel boot protocol.
I think that would be a better approach than this patch.

thanks
-- PMM
Dongjiu Geng Aug. 28, 2019, 10:50 a.m. UTC | #2
On 2019/8/27 17:47, Peter Maydell wrote:
> On Tue, 27 Aug 2019 at 10:42, Dongjiu Geng <gengdongjiu@huawei.com> wrote:
>>
>> Except support linux operation system, qemu also supports other
>> operation system which is non linux, such as microkernel system.
>>
>> But now Qemu only load linux initrd, so change it to load both
>> linux and Non-linux initrd Image.
> 
> We currently support two methods of booting:
>  (1) using the boot protocol defined by the Linux kernel
>      (which includes how to find the DTB, initrd, what the
>      secondary CPUs do, and so on)
>  (2) you're a 'bare-metal' image, in which case you get
>      complete control of all the CPUs at once in the same
>      way the hardware does. Raw hardware doesn't provide
>      initrd files, and nor does QEMU.
> 
> This patch seems to be trying to introduce a third hybrid
> thing. Is there a specification for whatever this boot
> protocol is? How many guest OSes use it? Are they common?
> 
> If you want an initrd, you can always wrap your guest OS in
> a shim which complies with the Linux kernel boot protocol.
> I think that would be a better approach than this patch.

OK, thanks for the suggestion, I will use your suggested method.

> 
> thanks
> -- PMM
> .
>
diff mbox series

Patch

diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index a830655e1a..2e6c17975a 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -1056,30 +1056,31 @@  static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
         exit(1);
     }
     info->entry = entry;
-    if (is_linux) {
-        uint32_t fixupcontext[FIXUP_MAX];
 
-        if (info->initrd_filename) {
-            initrd_size = load_ramdisk_as(info->initrd_filename,
-                                          info->initrd_start,
-                                          info->ram_size - info->initrd_start,
-                                          as);
-            if (initrd_size < 0) {
-                initrd_size = load_image_targphys_as(info->initrd_filename,
-                                                     info->initrd_start,
-                                                     info->ram_size -
-                                                     info->initrd_start,
-                                                     as);
-            }
-            if (initrd_size < 0) {
-                error_report("could not load initrd '%s'",
-                             info->initrd_filename);
-                exit(1);
-            }
-        } else {
-            initrd_size = 0;
+    if (info->initrd_filename) {
+        initrd_size = load_ramdisk_as(info->initrd_filename,
+                                      info->initrd_start,
+                                      info->ram_size - info->initrd_start,
+                                      as);
+        if (initrd_size < 0) {
+            initrd_size = load_image_targphys_as(info->initrd_filename,
+                                                 info->initrd_start,
+                                                 info->ram_size -
+                                                 info->initrd_start,
+                                                 as);
         }
-        info->initrd_size = initrd_size;
+        if (initrd_size < 0) {
+            error_report("could not load initrd '%s'",
+                         info->initrd_filename);
+            exit(1);
+        }
+    } else {
+        initrd_size = 0;
+    }
+    info->initrd_size = initrd_size;
+
+    if (is_linux) {
+        uint32_t fixupcontext[FIXUP_MAX];
 
         fixupcontext[FIXUP_BOARDID] = info->board_id;
         fixupcontext[FIXUP_BOARD_SETUP] = info->board_setup_addr;