All of lore.kernel.org
 help / color / mirror / Atom feed
* Grub xen_pvh platform does not seem to support uncompressed kernels
@ 2020-11-02  6:22 Andy Smith
  2020-11-02  7:43 ` Jürgen Groß
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Smith @ 2020-11-02  6:22 UTC (permalink / raw)
  To: grub-devel; +Cc: xen-users

Hi,

[ xen-users in CC as I know a few there are using a decompressed
  kernel workaround for LZ4 and might be hit by this too ]

I'm currently evaluating switching from booting Xen guests with grub
Xen PV (grub-mkimage -O x86_64-xen) to Xen PVH (grub-mkimage -O
i386-xen_pvh). I've noticed that a decompressed guest kernel refuses
to boot under PVH with the following error:

Loading Linux 5.4.0-52-generic ...
error: invalid magic number.

That same kernel boots with PV.

If I use the LZ4-compressed version of that kernel as supplied by
the distribution (Ubuntu 20.04), it works PVH. I therefore can only
conclude that PVH grub doesn't like kernels with no compression. Is
that expected?

I suppose it is possible that the method I use to decompress the
kernel could be wrong, though as I say, it does work with PV grub. I
basically use the extract-vmlinux script from the upstream kernel
source¹.

When decompressed:

$ sudo file /boot/vmlinuz-5.4.0-52-generic
/boot/vmlinuz-5.4.0-52-generic: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=d435b2b7b13b7e1904dddeee22bff30225d2bd04, stripped
$ ls -lah /boot/vmlinuz-5.4.0-52-generic
-rw------- 1 root root 43M Nov  1 20:00 /boot/vmlinuz-5.4.0-52-generic

When leaving it LZ4 compressed as it comes from the distributor:

$ sudo file /boot/vmlinuz-5.4.0-52-generic
/boot/vmlinuz-5.4.0-52-generic: Linux kernel x86 boot executable bzImage, version 5.4.0-52-generic (buildd@lgw01-amd64-060) #57-Ubuntu SMP Thu Oct 15 10:57:00 UTC 2020, RO-rootFS, swap_dev 0xB, Normal VGA
$ ls -lah /boot/vmlinuz-5.4.0-52-generic
-rw------- 1 root root 12M Oct 15 11:33 /boot/vmlinuz-5.4.0-52-generic

The reason why I am decompressing these guest kernels is because
PV grub does not understand LZ4 compression and as I currently do
boot guests this way, they would be unbootable otherwise.

For new installs I can skip installing my hack that decompresses the
kernel image, but if PVH grub won't support uncompressed kernel
images then this is inconvenient for the installed base who will
need to make extra changes.

Is not supporting decompressed kernel images a bug in PVH grub?

This was tested with a git clone just now, following these
instructions:

    https://wiki.xenproject.org/wiki/Xen_4.12_RC_test_instructions#PVH_domU_boot_via_grub2

Thanks,
Andy

¹ https://raw.githubusercontent.com/torvalds/linux/master/scripts/extract-vmlinux


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

* Re: Grub xen_pvh platform does not seem to support uncompressed kernels
  2020-11-02  6:22 Grub xen_pvh platform does not seem to support uncompressed kernels Andy Smith
@ 2020-11-02  7:43 ` Jürgen Groß
  2020-11-02  8:27   ` Andy Smith
  0 siblings, 1 reply; 6+ messages in thread
From: Jürgen Groß @ 2020-11-02  7:43 UTC (permalink / raw)
  To: The development of GNU GRUB, Andy Smith; +Cc: xen-users

On 02.11.20 07:22, Andy Smith wrote:
> Hi,
> 
> [ xen-users in CC as I know a few there are using a decompressed
>    kernel workaround for LZ4 and might be hit by this too ]
> 
> I'm currently evaluating switching from booting Xen guests with grub
> Xen PV (grub-mkimage -O x86_64-xen) to Xen PVH (grub-mkimage -O
> i386-xen_pvh). I've noticed that a decompressed guest kernel refuses
> to boot under PVH with the following error:
> 
> Loading Linux 5.4.0-52-generic ...
> error: invalid magic number.
> 
> That same kernel boots with PV.
> 
> If I use the LZ4-compressed version of that kernel as supplied by
> the distribution (Ubuntu 20.04), it works PVH. I therefore can only
> conclude that PVH grub doesn't like kernels with no compression. Is
> that expected?

Can you boot the decompressed kernel on bare metal or in an HVM
domain using grub?

I'm asking because PVH grub is using the standard i386 kernel loading
functions, so I wouldn't expect any differences here compared to bare
metal.

It might still be that PVH grub is missing some code due to wrong
configure parameters, of course.


Juergen


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

* Re: Grub xen_pvh platform does not seem to support uncompressed kernels
  2020-11-02  7:43 ` Jürgen Groß
@ 2020-11-02  8:27   ` Andy Smith
  2020-11-02  8:43     ` Jürgen Groß
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Smith @ 2020-11-02  8:27 UTC (permalink / raw)
  To: Jürgen Groß; +Cc: The development of GNU GRUB, xen-users

Hi Jürgen,

On Mon, Nov 02, 2020 at 08:43:24AM +0100, Jürgen Groß wrote:
> On 02.11.20 07:22, Andy Smith wrote:
> >I therefore can only conclude that PVH grub doesn't like kernels
> >with no compression. Is that expected?
> 
> Can you boot the decompressed kernel on bare metal or in an HVM
> domain using grub?

Oh that's interesting. The decompressed kernel doesn't boot bare
metal either (same message).

The decompressed kernel is generated like this:

# extract-vmlinux /boot/vmlinuz-5.4.0-52-generic > /boot/vmlinuz-5.4.0-52-generic-decompressed

The decompressed kernel does boot when presented to the hypervisor
directly, i.e. no grub, directly listed in guest config file.

I don't have an HVM test setup right now so am unable to test that,
but I suppose we can assume it will fail as the problem is in the
standard grub loading functions.

So, is this a bug? Grub should be able to boot uncompressed kernels,
shouldn't it?

Thanks,
Andy


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

* Re: Grub xen_pvh platform does not seem to support uncompressed kernels
  2020-11-02  8:27   ` Andy Smith
@ 2020-11-02  8:43     ` Jürgen Groß
  2020-11-02  9:17       ` Andy Smith
  0 siblings, 1 reply; 6+ messages in thread
From: Jürgen Groß @ 2020-11-02  8:43 UTC (permalink / raw)
  To: Andy Smith; +Cc: The development of GNU GRUB, xen-users

On 02.11.20 09:27, Andy Smith wrote:
> Hi Jürgen,
> 
> On Mon, Nov 02, 2020 at 08:43:24AM +0100, Jürgen Groß wrote:
>> On 02.11.20 07:22, Andy Smith wrote:
>>> I therefore can only conclude that PVH grub doesn't like kernels
>>> with no compression. Is that expected?
>>
>> Can you boot the decompressed kernel on bare metal or in an HVM
>> domain using grub?
> 
> Oh that's interesting. The decompressed kernel doesn't boot bare
> metal either (same message).
> 
> The decompressed kernel is generated like this:
> 
> # extract-vmlinux /boot/vmlinuz-5.4.0-52-generic > /boot/vmlinuz-5.4.0-52-generic-decompressed
> 
> The decompressed kernel does boot when presented to the hypervisor
> directly, i.e. no grub, directly listed in guest config file.
> 
> I don't have an HVM test setup right now so am unable to test that,
> but I suppose we can assume it will fail as the problem is in the
> standard grub loading functions.
> 
> So, is this a bug? Grub should be able to boot uncompressed kernels,
> shouldn't it?

As long as the boot entry code is included in this kernel, yes.


Juergen


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

* Re: Grub xen_pvh platform does not seem to support uncompressed kernels
  2020-11-02  8:43     ` Jürgen Groß
@ 2020-11-02  9:17       ` Andy Smith
  2020-11-02  9:39         ` Jürgen Groß
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Smith @ 2020-11-02  9:17 UTC (permalink / raw)
  To: Jürgen Groß; +Cc: The development of GNU GRUB, xen-users

Hi,

On Mon, Nov 02, 2020 at 09:43:06AM +0100, Jürgen Groß wrote:
> On 02.11.20 09:27, Andy Smith wrote:
> >The decompressed kernel is generated like this:
> >
> ># extract-vmlinux /boot/vmlinuz-5.4.0-52-generic > /boot/vmlinuz-5.4.0-52-generic-decompressed
> >
> >The decompressed kernel does boot when presented to the hypervisor
> >directly, i.e. no grub, directly listed in guest config file.
> >
> >I don't have an HVM test setup right now so am unable to test that,
> >but I suppose we can assume it will fail as the problem is in the
> >standard grub loading functions.
> >
> >So, is this a bug? Grub should be able to boot uncompressed kernels,
> >shouldn't it?
> 
> As long as the boot entry code is included in this kernel, yes.

I actually think now that the output of extract-vmlinux lacks
something and I further suspect that if I would use a vmlinux file
from within a kernel build tree it would be fine.

In which case this is not an issue for grub or xen, and only for
those of us employing hacks based around extract-vmlinux.

Apologies for the distraction!

Thanks,
Andy


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

* Re: Grub xen_pvh platform does not seem to support uncompressed kernels
  2020-11-02  9:17       ` Andy Smith
@ 2020-11-02  9:39         ` Jürgen Groß
  0 siblings, 0 replies; 6+ messages in thread
From: Jürgen Groß @ 2020-11-02  9:39 UTC (permalink / raw)
  To: Andy Smith; +Cc: The development of GNU GRUB, xen-users

On 02.11.20 10:17, Andy Smith wrote:
> Hi,
> 
> On Mon, Nov 02, 2020 at 09:43:06AM +0100, Jürgen Groß wrote:
>> On 02.11.20 09:27, Andy Smith wrote:
>>> The decompressed kernel is generated like this:
>>>
>>> # extract-vmlinux /boot/vmlinuz-5.4.0-52-generic > /boot/vmlinuz-5.4.0-52-generic-decompressed
>>>
>>> The decompressed kernel does boot when presented to the hypervisor
>>> directly, i.e. no grub, directly listed in guest config file.
>>>
>>> I don't have an HVM test setup right now so am unable to test that,
>>> but I suppose we can assume it will fail as the problem is in the
>>> standard grub loading functions.
>>>
>>> So, is this a bug? Grub should be able to boot uncompressed kernels,
>>> shouldn't it?
>>
>> As long as the boot entry code is included in this kernel, yes.
> 
> I actually think now that the output of extract-vmlinux lacks
> something and I further suspect that if I would use a vmlinux file
> from within a kernel build tree it would be fine.
> 
> In which case this is not an issue for grub or xen, and only for
> those of us employing hacks based around extract-vmlinux.
> 
> Apologies for the distraction!

No need to apologize.

We should really think about adding lz4 decompression support to grub
for being able to use lz4 compressed kernels with pvgrub.


Juergen


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

end of thread, other threads:[~2020-11-02  9:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-02  6:22 Grub xen_pvh platform does not seem to support uncompressed kernels Andy Smith
2020-11-02  7:43 ` Jürgen Groß
2020-11-02  8:27   ` Andy Smith
2020-11-02  8:43     ` Jürgen Groß
2020-11-02  9:17       ` Andy Smith
2020-11-02  9:39         ` Jürgen Groß

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.