All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/i386/pc: run the multiboot loader before the PVH loader
@ 2019-02-14 18:02 Stefano Garzarella
  2019-02-14 19:09 ` Michael S. Tsirkin
  2019-03-01 17:59 ` Alex Bennée
  0 siblings, 2 replies; 4+ messages in thread
From: Stefano Garzarella @ 2019-02-14 18:02 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Liam Merwick, Eduardo Habkost,
	Marcel Apfelbaum, Michael S. Tsirkin, George Kennedy,
	Paolo Bonzini

Some multiboot images could be in the ELF format. In the current
implementation QEMU fails because we try to load these images
as a PVH image.

In order to fix this issue, we should try multiboot first (we
already check the multiboot magic header before to load it).
If it is not a multiboot image, we can try the PVH loader.

Fixes: ab969087da6 ("pvh: Boot uncompressed kernel using direct boot ABI", 2019-01-15)
Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
 hw/i386/pc.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 3889eccdc3..207c267093 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1209,6 +1209,17 @@ static void load_linux(PCMachineState *pcms,
     if (ldl_p(header+0x202) == 0x53726448) {
         protocol = lduw_p(header+0x206);
     } else {
+        /*
+         * This could be a multiboot kernel. If it is, let's stop treating it
+         * like a Linux kernel.
+         * Note: some multiboot images could be in the ELF format (the same of
+         * PVH), so we try multiboot first since we check the multiboot magic
+         * header before to load it.
+         */
+        if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename,
+                           kernel_cmdline, kernel_size, header)) {
+            return;
+        }
         /*
          * Check if the file is an uncompressed kernel file (ELF) and load it,
          * saving the PVH entry point used by the x86/HVM direct boot ABI.
@@ -1262,12 +1273,6 @@ static void load_linux(PCMachineState *pcms,
 
             return;
         }
-        /* This looks like a multiboot kernel. If it is, let's stop
-           treating it like a Linux kernel. */
-        if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename,
-                           kernel_cmdline, kernel_size, header)) {
-            return;
-        }
         protocol = 0;
     }
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/i386/pc: run the multiboot loader before the PVH loader
  2019-02-14 18:02 [Qemu-devel] [PATCH] hw/i386/pc: run the multiboot loader before the PVH loader Stefano Garzarella
@ 2019-02-14 19:09 ` Michael S. Tsirkin
  2019-02-14 20:33   ` Paolo Bonzini
  2019-03-01 17:59 ` Alex Bennée
  1 sibling, 1 reply; 4+ messages in thread
From: Michael S. Tsirkin @ 2019-02-14 19:09 UTC (permalink / raw)
  To: Stefano Garzarella
  Cc: qemu-devel, Richard Henderson, Liam Merwick, Eduardo Habkost,
	Marcel Apfelbaum, George Kennedy, Paolo Bonzini

On Thu, Feb 14, 2019 at 07:02:16PM +0100, Stefano Garzarella wrote:
> Some multiboot images could be in the ELF format. In the current
> implementation QEMU fails because we try to load these images
> as a PVH image.
> 
> In order to fix this issue, we should try multiboot first (we
> already check the multiboot magic header before to load it).
> If it is not a multiboot image, we can try the PVH loader.
> 
> Fixes: ab969087da6 ("pvh: Boot uncompressed kernel using direct boot ABI", 2019-01-15)
> Reported-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

Paolo can you pls merge since you did the pvh things?

> ---
>  hw/i386/pc.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 3889eccdc3..207c267093 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -1209,6 +1209,17 @@ static void load_linux(PCMachineState *pcms,
>      if (ldl_p(header+0x202) == 0x53726448) {
>          protocol = lduw_p(header+0x206);
>      } else {
> +        /*
> +         * This could be a multiboot kernel. If it is, let's stop treating it
> +         * like a Linux kernel.
> +         * Note: some multiboot images could be in the ELF format (the same of
> +         * PVH), so we try multiboot first since we check the multiboot magic
> +         * header before to load it.
> +         */
> +        if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename,
> +                           kernel_cmdline, kernel_size, header)) {
> +            return;
> +        }
>          /*
>           * Check if the file is an uncompressed kernel file (ELF) and load it,
>           * saving the PVH entry point used by the x86/HVM direct boot ABI.
> @@ -1262,12 +1273,6 @@ static void load_linux(PCMachineState *pcms,
>  
>              return;
>          }
> -        /* This looks like a multiboot kernel. If it is, let's stop
> -           treating it like a Linux kernel. */
> -        if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename,
> -                           kernel_cmdline, kernel_size, header)) {
> -            return;
> -        }
>          protocol = 0;
>      }
>  
> -- 
> 2.20.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/i386/pc: run the multiboot loader before the PVH loader
  2019-02-14 19:09 ` Michael S. Tsirkin
@ 2019-02-14 20:33   ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2019-02-14 20:33 UTC (permalink / raw)
  To: Michael S. Tsirkin, Stefano Garzarella
  Cc: qemu-devel, Richard Henderson, Liam Merwick, Eduardo Habkost,
	Marcel Apfelbaum, George Kennedy

On 14/02/19 20:09, Michael S. Tsirkin wrote:
> On Thu, Feb 14, 2019 at 07:02:16PM +0100, Stefano Garzarella wrote:
>> Some multiboot images could be in the ELF format. In the current
>> implementation QEMU fails because we try to load these images
>> as a PVH image.
>>
>> In order to fix this issue, we should try multiboot first (we
>> already check the multiboot magic header before to load it).
>> If it is not a multiboot image, we can try the PVH loader.
>>
>> Fixes: ab969087da6 ("pvh: Boot uncompressed kernel using direct boot ABI", 2019-01-15)
>> Reported-by: Paolo Bonzini <pbonzini@redhat.com>
>> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> 
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> 
> Paolo can you pls merge since you did the pvh things?

Yes, queued.

Paolo

>> ---
>>  hw/i386/pc.c | 17 +++++++++++------
>>  1 file changed, 11 insertions(+), 6 deletions(-)
>>
>> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
>> index 3889eccdc3..207c267093 100644
>> --- a/hw/i386/pc.c
>> +++ b/hw/i386/pc.c
>> @@ -1209,6 +1209,17 @@ static void load_linux(PCMachineState *pcms,
>>      if (ldl_p(header+0x202) == 0x53726448) {
>>          protocol = lduw_p(header+0x206);
>>      } else {
>> +        /*
>> +         * This could be a multiboot kernel. If it is, let's stop treating it
>> +         * like a Linux kernel.
>> +         * Note: some multiboot images could be in the ELF format (the same of
>> +         * PVH), so we try multiboot first since we check the multiboot magic
>> +         * header before to load it.
>> +         */
>> +        if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename,
>> +                           kernel_cmdline, kernel_size, header)) {
>> +            return;
>> +        }
>>          /*
>>           * Check if the file is an uncompressed kernel file (ELF) and load it,
>>           * saving the PVH entry point used by the x86/HVM direct boot ABI.
>> @@ -1262,12 +1273,6 @@ static void load_linux(PCMachineState *pcms,
>>  
>>              return;
>>          }
>> -        /* This looks like a multiboot kernel. If it is, let's stop
>> -           treating it like a Linux kernel. */
>> -        if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename,
>> -                           kernel_cmdline, kernel_size, header)) {
>> -            return;
>> -        }
>>          protocol = 0;
>>      }
>>  
>> -- 
>> 2.20.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/i386/pc: run the multiboot loader before the PVH loader
  2019-02-14 18:02 [Qemu-devel] [PATCH] hw/i386/pc: run the multiboot loader before the PVH loader Stefano Garzarella
  2019-02-14 19:09 ` Michael S. Tsirkin
@ 2019-03-01 17:59 ` Alex Bennée
  1 sibling, 0 replies; 4+ messages in thread
From: Alex Bennée @ 2019-03-01 17:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Eduardo Habkost, Michael S. Tsirkin, George Kennedy,
	Paolo Bonzini, Richard Henderson


Stefano Garzarella <sgarzare@redhat.com> writes:

> Some multiboot images could be in the ELF format. In the current
> implementation QEMU fails because we try to load these images
> as a PVH image.
>
> In order to fix this issue, we should try multiboot first (we
> already check the multiboot magic header before to load it).
> If it is not a multiboot image, we can try the PVH loader.
>
> Fixes: ab969087da6 ("pvh: Boot uncompressed kernel using direct boot ABI", 2019-01-15)
> Reported-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  hw/i386/pc.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 3889eccdc3..207c267093 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -1209,6 +1209,17 @@ static void load_linux(PCMachineState *pcms,
>      if (ldl_p(header+0x202) == 0x53726448) {
>          protocol = lduw_p(header+0x206);
>      } else {
> +        /*
> +         * This could be a multiboot kernel. If it is, let's stop treating it
> +         * like a Linux kernel.
> +         * Note: some multiboot images could be in the ELF format (the same of
> +         * PVH), so we try multiboot first since we check the multiboot magic
> +         * header before to load it.
> +         */
> +        if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename,
> +                           kernel_cmdline, kernel_size, header)) {
> +            return;
> +        }
>          /*
>           * Check if the file is an uncompressed kernel file (ELF) and load it,
>           * saving the PVH entry point used by the x86/HVM direct boot ABI.
> @@ -1262,12 +1273,6 @@ static void load_linux(PCMachineState *pcms,
>
>              return;
>          }
> -        /* This looks like a multiboot kernel. If it is, let's stop
> -           treating it like a Linux kernel. */
> -        if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename,
> -                           kernel_cmdline, kernel_size, header)) {
> -            return;
> -        }
>          protocol = 0;
>      }


--
Alex Bennée

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-01 17:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-14 18:02 [Qemu-devel] [PATCH] hw/i386/pc: run the multiboot loader before the PVH loader Stefano Garzarella
2019-02-14 19:09 ` Michael S. Tsirkin
2019-02-14 20:33   ` Paolo Bonzini
2019-03-01 17:59 ` Alex Bennée

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.