Skip to contentSkip to conversation

GRUB2 for UEFI crashes at startup when we got 8 gigabyte of memory

DISCUSSION [email protected] 4 participants 8 messages Apr 21, 2010 – Jan 4, 2011

lore
Share & tools
lore
#0 lore raw

In Febryary I was testing GRUB for UEFI and noticed that it was simply crashing.

See topic
http://lists.gnu.org/archive/html/grub-devel/2010-02/msg00000.html

At that time I blamed incorrect UEFI implementation on that computer (cause it worked fine on another one), but now I noticed that when I took off one memory stick, everything is working fine on that special computer!!!!

So, it seems that GRUB2 is crashing on computers with 8 gb of memory (or more?)

Is it known bug? Are there workarounds?

--
This message was sent on behalf of [email protected] at openSubscriber.com
http://www.opensubscriber.com/messages/[email protected]/topic.html

#1 lore raw
Quoted 12 lines · [email protected] wrote:

In Febryary I was testing GRUB for UEFI and noticed that it was simply crashing.

See topic
http://lists.gnu.org/archive/html/grub-devel/2010-02/msg00000.html

At that time I blamed incorrect UEFI implementation on that computer (cause it worked fine on another one), but now I noticed that when I took off one memory stick, everything is working fine on that special computer!!!!

So, it seems that GRUB2 is crashing on computers with 8 gb of memory (or more?)

Is it known bug? Are there workarounds?

It may be a recent regression because we have a reports of successful boot in such configuration
(http://lists.gnu.org/archive/html/grub-devel/2009-05/msg00179.html and neighbour threads).
Be sure that grub is compiled with -mcmodel=large. You can also try disable usage of >4GiB memory by adding
#define MCMODEL_SMALL
to kern/efi/mm.c

Quoted 11 lines

--
This message was sent on behalf of [email protected] at openSubscriber.com
http://www.opensubscriber.com/messages/[email protected]/topic.html

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#4 lore raw
In reply to [email protected]

Hi,

Quoting [email protected], who wrote the following on Wed, 21 Apr 2010:

Quoted 10 lines

In Febryary I was testing GRUB for UEFI and noticed that it was simply crashing.

See topic
http://lists.gnu.org/archive/html/grub-devel/2010-02/msg00000.html

At that time I blamed incorrect UEFI implementation on that computer (cause it worked fine on another one), but now I noticed that when I took off one memory stick, everything is working fine on that special computer!!!!

So, it seems that GRUB2 is crashing on computers with 8 gb of memory (or more?)

Is it known bug? Are there workarounds?

Have you tried the latest GRUB2 from the Bazaar repository? If it still
fails there, and phcoder doesn't already have a fix for this in his newreloc branch, then I would consider it a bug.

--S

#5 lore raw
In reply to [email protected]
Quoted 10 lines · On Wed, Apr 21, 2010 at 3:53 PM, <[email protected]> wrote:

In Febryary I was testing GRUB for UEFI and noticed that it was simply crashing.

See topic
http://lists.gnu.org/archive/html/grub-devel/2010-02/msg00000.html

At that time I blamed incorrect UEFI implementation on that computer (cause it worked fine on another one), but now I noticed that when I took off one memory stick, everything is working fine on that special computer!!!!

So, it seems that GRUB2 is crashing on computers with  8 gb of memory (or more?)

Is it known bug? Are there workarounds?

Hi,

You could try BURG and see if it has the same problem, binary package for EFI is available for download at:

http://code.google.com/p/burg/downloads/list

Signature · 1 line
Bean
#6 lore raw
Quoted 11 lines · Bean
Quoted 9 lines · On Wed, Apr 21, 2010 at 3:53 PM, <[email protected]> wrote:

In Febryary I was testing GRUB for UEFI and noticed that it was simply crashing.

See topic
http://lists.gnu.org/archive/html/grub-devel/2010-02/msg00000.html

At that time I blamed incorrect UEFI implementation on that computer (cause it worked fine on another one), but now I noticed that when I took off one memory stick, everything is working fine on that special computer!!!!

So, it seems that GRUB2 is crashing on computers with 8 gb of memory (or more?)

Quoted 9 lines
Quoted 2 lines

Is it known bug? Are there workarounds?

Hi,

You could try BURG and see if it has the same problem, binary package for EFI is available for download at:

As I already told you before the bugs which are reported for GRUB2 must be fixed in GRUB2, not in any kind of fork. Moreover any discussion of BURG is off-topic here. And advertisement of it is not unlike spam.

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#2 lore raw
In reply to Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 8 lines

It may be a recent regression because we have a reports of successful boot in such configuration
(http://lists.gnu.org/archive/html/grub-devel/2009-05/msg00179.html and neighbour threads).
Be sure that grub is compiled with -mcmodel=large. You can also try disable usage of >4GiB memory by adding
#define MCMODEL_SMALL
to kern/efi/mm.c

Hm, as far as I can understand, the grub is always compiled with mcmodel=large for UEFI

if test "$target_cpu"-"$platform" = x86_64-efi; then
# Use large model to support 4G memory
{ echo "$as_me:$LINENO: checking whether option -mcmodel=large works" >&5
echo $ECHO_N "checking whether option -mcmodel=large works... $ECHO_C" >&6; } if test "${grub_cv_cc_mcmodel+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else

SAVED_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -m64 -mcmodel=large"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */

--
This message was sent on behalf of [email protected] at openSubscriber.com
http://www.opensubscriber.com/message/[email protected]/13789927.html

#3 lore raw
Quoted 10 lines · [email protected] wrote:
Quoted 9 lines

It may be a recent regression because we have a reports of successful boot in such configuration
(http://lists.gnu.org/archive/html/grub-devel/2009-05/msg00179.html and neighbour threads).
Be sure that grub is compiled with -mcmodel=large. You can also try disable usage of >4GiB memory by adding
#define MCMODEL_SMALL
to kern/efi/mm.c

Quoted 3 lines

Hm, as far as I can understand, the grub is always compiled with mcmodel=large for UEFI

It's checked that gcc supports -mcmodel=large and if it doesn't it defaults to smaller models and modifes module loader in order to satisfy the necessary placement requirements. However grub.efi itself is loaded by EFI and there is no way of informing it where grub should be loaded. I guess I should remove this hack and just refuse to compile to 64-bit efi if -mcmodel=large doesn't work.
Also it's possible that flags aren't propagated correctly so please check that -mcmodel=large is really passed to gcc

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#7 lore raw
In reply to [email protected]
Quoted 10 lines · On 04/21/2010 09:53 AM, [email protected] wrote:

In Febryary I was testing GRUB for UEFI and noticed that it was simply crashing.

See topic
http://lists.gnu.org/archive/html/grub-devel/2010-02/msg00000.html

At that time I blamed incorrect UEFI implementation on that computer (cause it worked fine on another one), but now I noticed that when I took off one memory stick, everything is working fine on that special computer!!!!

So, it seems that GRUB2 is crashing on computers with 8 gb of memory (or more?)

It has been discovered that some EFI implementations contrary to the
following sentence from the spec " any memory
space defined by the UEFI memory map is identity
mapped (virtual address equals physical address).
"
do not map the post-4G memory. Attached is a possible workaround. Can you test it?

Quoted 14 lines

Is it known bug? Are there workarounds?

--
This message was sent on behalf of [email protected] at openSubscriber.com
http://www.opensubscriber.com/messages/[email protected]/topic.html

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko

=== modified file 'grub-core/kern/efi/mm.c'

kern/efi/mm.c +4 -4
@@ -52,13 +52,13 @@
   grub_efi_status_t status;
   grub_efi_boot_services_t *b;
 
-#if GRUB_TARGET_SIZEOF_VOID_P < 8
+#if 1
   /* Limit the memory access to less than 4GB for 32-bit platforms.  */
   if (address > 0xffffffff)
     return 0;
 #endif
 
-#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL)
+#if 1
   if (address == 0)
     {
       type = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
@@ -251,7 +251,7 @@
        desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
     {
       if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY
-#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL)
+#if 1
 	  && desc->physical_start <= 0xffffffff
 #endif
 	  && desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000
@@ -267,7 +267,7 @@
 	      desc->physical_start = 0x100000;
 	    }
 
-#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL)
+#if 1
 	  if (BYTES_TO_PAGES (filtered_desc->physical_start)
 	      + filtered_desc->num_pages
 	      > BYTES_TO_PAGES (0x100000000LL))

=== modified file 'grub-core/lib/efi/relocator.c'

lib/efi/relocator.c +17 -2
@@ -62,13 +62,25 @@
        (char *) desc < ((char *) descs + mmapsize);
        desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
     {
+      grub_uint64_t start = desc->physical_start;
+      grub_uint64_t end = desc->physical_start + (desc->num_pages << 12);
+
+      /* post-4G addresses are never supported on 32-bit EFI. 
+	 Moreover it has been reported that some 64-bit EFI contrary to the
+	 spec don't map post-4G pages. So if you enable post-4G allocations,
+	 map pages manually or check that they are mapped.
+       */
+      if (end >= 0x100000000ULL)
+	end = 0x100000000ULL;
+      if (end <= start)
+	continue;
       if (desc->type != GRUB_EFI_CONVENTIONAL_MEMORY)
 	continue;
       events[counter].type = REG_FIRMWARE_START;
-      events[counter].pos = desc->physical_start;
+      events[counter].pos = start;
       counter++;
       events[counter].type = REG_FIRMWARE_END;
-      events[counter].pos = desc->physical_start + (desc->num_pages << 12);
+      events[counter].pos = end;
       counter++;      
     }
 
@@ -85,6 +97,9 @@
   if (grub_efi_is_finished)
     return 1;
 
+  grub_dprintf ("relocator", "EFI alloc: %llx, %llx\n",
+		(unsigned long long) start, (unsigned long long) size);
+
   b = grub_efi_system_table->boot_services;
   status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ADDRESS,
 		       GRUB_EFI_LOADER_DATA, size >> 12, &address);