grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Cc: gburanov@gmail.com
Subject: Re: GRUB2 for UEFI crashes at startup when we got 8 gigabyte of memory
Date: Tue, 04 Jan 2011 13:59:11 +0100	[thread overview]
Message-ID: <4D23199F.6050506@gmail.com> (raw)
In-Reply-To: <22824150.11271836407741.JavaMail.root@wombat>


[-- Attachment #1.1: Type: text/plain, Size: 1309 bytes --]

On 04/21/2010 09:53 AM, gburanov@gmail.com 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?
> Is it known bug? Are there workarounds?
>
>
> --
> This message was sent on behalf of gburanov@gmail.com at openSubscriber.com
> http://www.opensubscriber.com/messages/grub-devel@gnu.org/topic.html
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
>   


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: efi_l4.diff --]
[-- Type: text/x-diff; name="efi_l4.diff", Size: 1188 bytes --]

=== modified file 'grub-core/kern/efi/mm.c'
--- grub-core/kern/efi/mm.c	2010-10-16 15:50:48 +0000
+++ grub-core/kern/efi/mm.c	2011-01-04 12:56:14 +0000
@@ -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))


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: efi4G.diff --]
[-- Type: text/x-diff; name="efi4G.diff", Size: 1608 bytes --]

=== modified file 'grub-core/lib/efi/relocator.c'
--- grub-core/lib/efi/relocator.c	2010-04-20 16:08:26 +0000
+++ grub-core/lib/efi/relocator.c	2011-01-04 11:02:37 +0000
@@ -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);


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

      parent reply	other threads:[~2011-01-04 12:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-21  7:53 GRUB2 for UEFI crashes at startup when we got 8 gigabyte of memory gburanov
2010-04-21  8:31 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-04-21 12:06   ` gburanov
2010-04-21 18:58     ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-04-21  8:34 ` Seth Goldberg
2010-04-21  9:12 ` Bean
2010-04-21  9:40   ` Vladimir 'φ-coder/phcoder' Serbinenko
2011-01-04 12:59 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D23199F.6050506@gmail.com \
    --to=phcoder@gmail.com \
    --cc=gburanov@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).