All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2] Unable to boot very old Linux kernels
@ 2014-04-15 11:58 Piotr Krysiuk
  2014-04-20 13:59 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 2+ messages in thread
From: Piotr Krysiuk @ 2014-04-15 11:58 UTC (permalink / raw)
  To: grub-devel; +Cc: Piotr Krysiuk

GRUB cannot determine end of BSS section of compressed image when loading
very old Linux kernels.  Booting these kernels, grub_relocator32_start and
new Global Descriptor Table are placed in the area overlapping with the BSS
section of loaded image.  When Linux executes, it initializes BSS also
wiping Global Descriptor Table that is still active.  This leads to failure
on segment reload that follows.

Current HEAD of GRUB repository is affected, with "Clear BSS" code from
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/arch/x86_64/boot/compressed/head.S?h=linux-2.6.17.y#n57
wiping GDT.

Old versions of GRUB, from before relocator was introduced, placed GDT close
to end of physical memory avoiding this issue.  This patch fixes regression
by moving GDT into conventional memory.

	* grub-core/lib/i386/relocator.c: Move GDT into conventional memory
	to avoid collision with BSS section of compressed Linux image for
	very old kernels.
---
 grub-core/lib/i386/relocator.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/relocator.c
index d2a1b27..ffaf25f 100644
--- a/grub-core/lib/i386/relocator.c
+++ b/grub-core/lib/i386/relocator.c
@@ -81,10 +81,13 @@ grub_relocator32_boot (struct grub_relocator *rel,
   void *relst;
   grub_relocator_chunk_t ch;
 
-  err = grub_relocator_alloc_chunk_align (rel, &ch, 0,
-					  (0xffffffff - RELOCATOR_SIZEOF (32))
-					  + 1, RELOCATOR_SIZEOF (32), 16,
-					  GRUB_RELOCATOR_PREFERENCE_NONE,
+  /* Specific memory range due to Global Descriptor Table for use by payload
+     that we will store in returned chunk.  The address range and preference
+     are based on "THE LINUX/x86 BOOT PROTOCOL" specification.  */
+  err = grub_relocator_alloc_chunk_align (rel, &ch, 0x1000,
+					  0x9a000 - RELOCATOR_SIZEOF (32),
+					  RELOCATOR_SIZEOF (32), 16,
+					  GRUB_RELOCATOR_PREFERENCE_LOW,
 					  avoid_efi_bootservices);
   if (err)
     return err;
-- 
1.7.9.5



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

* Re: [PATCHv2] Unable to boot very old Linux kernels
  2014-04-15 11:58 [PATCHv2] Unable to boot very old Linux kernels Piotr Krysiuk
@ 2014-04-20 13:59 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2014-04-20 13:59 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 2222 bytes --]

Committed, thanks.

On 15.04.2014 13:58, Piotr Krysiuk wrote:
> GRUB cannot determine end of BSS section of compressed image when loading
> very old Linux kernels.  Booting these kernels, grub_relocator32_start and
> new Global Descriptor Table are placed in the area overlapping with the BSS
> section of loaded image.  When Linux executes, it initializes BSS also
> wiping Global Descriptor Table that is still active.  This leads to failure
> on segment reload that follows.
> 
> Current HEAD of GRUB repository is affected, with "Clear BSS" code from
> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/arch/x86_64/boot/compressed/head.S?h=linux-2.6.17.y#n57
> wiping GDT.
> 
> Old versions of GRUB, from before relocator was introduced, placed GDT close
> to end of physical memory avoiding this issue.  This patch fixes regression
> by moving GDT into conventional memory.
> 
> 	* grub-core/lib/i386/relocator.c: Move GDT into conventional memory
> 	to avoid collision with BSS section of compressed Linux image for
> 	very old kernels.
> ---
>  grub-core/lib/i386/relocator.c |   11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/relocator.c
> index d2a1b27..ffaf25f 100644
> --- a/grub-core/lib/i386/relocator.c
> +++ b/grub-core/lib/i386/relocator.c
> @@ -81,10 +81,13 @@ grub_relocator32_boot (struct grub_relocator *rel,
>    void *relst;
>    grub_relocator_chunk_t ch;
>  
> -  err = grub_relocator_alloc_chunk_align (rel, &ch, 0,
> -					  (0xffffffff - RELOCATOR_SIZEOF (32))
> -					  + 1, RELOCATOR_SIZEOF (32), 16,
> -					  GRUB_RELOCATOR_PREFERENCE_NONE,
> +  /* Specific memory range due to Global Descriptor Table for use by payload
> +     that we will store in returned chunk.  The address range and preference
> +     are based on "THE LINUX/x86 BOOT PROTOCOL" specification.  */
> +  err = grub_relocator_alloc_chunk_align (rel, &ch, 0x1000,
> +					  0x9a000 - RELOCATOR_SIZEOF (32),
> +					  RELOCATOR_SIZEOF (32), 16,
> +					  GRUB_RELOCATOR_PREFERENCE_LOW,
>  					  avoid_efi_bootservices);
>    if (err)
>      return err;
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 274 bytes --]

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

end of thread, other threads:[~2014-04-20 14:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-15 11:58 [PATCHv2] Unable to boot very old Linux kernels Piotr Krysiuk
2014-04-20 13:59 ` Vladimir 'φ-coder/phcoder' Serbinenko

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.