grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Leif Lindholm <leif.lindholm@linaro.org>
To: grub-devel@gnu.org
Cc: Daniel Kiper <daniel.kiper@oracle.com>
Subject: [PATCH 2/3] loader/ia64/linux: use central copy of grub_efi_find_mmap_size
Date: Fri, 13 Jul 2018 17:34:44 +0100	[thread overview]
Message-ID: <20180713163445.29478-3-leif.lindholm@linaro.org> (raw)
In-Reply-To: <20180713163445.29478-1-leif.lindholm@linaro.org>

Delete local copy of function to determine required buffer size for the
UEFI memory map, use helper in kern/efi/mm.c.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/loader/ia64/efi/linux.c | 46 ++-------------------------------------
 1 file changed, 2 insertions(+), 44 deletions(-)

diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c
index 750330d45..96fce713a 100644
--- a/grub-core/loader/ia64/efi/linux.c
+++ b/grub-core/loader/ia64/efi/linux.c
@@ -133,48 +133,6 @@ query_fpswa (void)
     } 
 }
 
-/* Find the optimal number of pages for the memory map. Is it better to
-   move this code to efi/mm.c?  */
-static grub_efi_uintn_t
-find_mmap_size (void)
-{
-  static grub_efi_uintn_t mmap_size = 0;
-
-  if (mmap_size != 0)
-    return mmap_size;
-  
-  mmap_size = (1 << 12);
-  while (1)
-    {
-      int ret;
-      grub_efi_memory_descriptor_t *mmap;
-      grub_efi_uintn_t desc_size;
-      
-      mmap = grub_malloc (mmap_size);
-      if (! mmap)
-	return 0;
-
-      ret = grub_efi_get_memory_map (&mmap_size, mmap, 0, &desc_size, 0);
-      grub_free (mmap);
-      
-      if (ret < 0)
-	{
-	  grub_error (GRUB_ERR_IO, "cannot get memory map");
-	  return 0;
-	}
-      else if (ret > 0)
-	break;
-
-      mmap_size += (1 << 12);
-    }
-
-  /* Increase the size a bit for safety, because GRUB allocates more on
-     later, and EFI itself may allocate more.  */
-  mmap_size += (1 << 12);
-
-  return page_align (mmap_size);
-}
-
 static void
 free_pages (void)
 {
@@ -212,7 +170,7 @@ allocate_pages (grub_uint64_t align, grub_uint64_t size_pages,
 
   size = size_pages << 12;
 
-  mmap_size = find_mmap_size ();
+  mmap_size = grub_efi_find_mmap_size ();
   if (!mmap_size)
     return 0;
 
@@ -323,7 +281,7 @@ grub_linux_boot (void)
   /* MDT.
      Must be done after grub_machine_fini because map_key is used by
      exit_boot_services.  */
-  mmap_size = find_mmap_size ();
+  mmap_size = grub_efi_find_mmap_size ();
   if (! mmap_size)
     return grub_errno;
   mmap_buf = grub_efi_allocate_any_pages (page_align (mmap_size) >> 12);
-- 
2.11.0



  parent reply	other threads:[~2018-07-13 16:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 16:34 [PATCH 0/3] use central copy of grub_efi_find_mmap_size Leif Lindholm
2018-07-13 16:34 ` [PATCH 1/3] loader/i386/linux: " Leif Lindholm
2018-07-13 16:34 ` Leif Lindholm [this message]
2018-07-13 16:34 ` [PATCH 3/3] loader/multiboot_mbi2: " Leif Lindholm
2018-09-06 13:46 ` [PATCH 0/3] " Daniel Kiper

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=20180713163445.29478-3-leif.lindholm@linaro.org \
    --to=leif.lindholm@linaro.org \
    --cc=daniel.kiper@oracle.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).