From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GSwQw-0004bF-Hd for mharc-grub-devel@gnu.org; Thu, 28 Sep 2006 10:00:14 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GSwQu-0004ab-WD for grub-devel@gnu.org; Thu, 28 Sep 2006 10:00:13 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GSwQs-0004ZC-AC for grub-devel@gnu.org; Thu, 28 Sep 2006 10:00:12 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GSwQs-0004Z9-5y for grub-devel@gnu.org; Thu, 28 Sep 2006 10:00:10 -0400 Received: from [195.54.107.76] (helo=mxfep03.bredband.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GSwVx-0007wP-PV for grub-devel@gnu.org; Thu, 28 Sep 2006 10:05:26 -0400 Received: from ironport2.bredband.com ([195.54.107.84] [195.54.107.84]) by mxfep03.bredband.com with ESMTP id <20060928140008.HJXY14075.mxfep03.bredband.com@ironport2.bredband.com> for ; Thu, 28 Sep 2006 16:00:08 +0200 Received: from c-e5df71d5.029-19-73746f13.cust.bredbandsbolaget.se (HELO localhost.localdomain) ([213.113.223.229]) by ironport2.bredband.com with ESMTP; 28 Sep 2006 16:00:08 +0200 From: Johan Rydberg To: The development of GRUB 2 References: <1159444090.451bb67a38fba@imp6-g19.free.fr> <87d59g9jku.fsf@night.trouble.net> <87irj814kp.fsf@xs4all.nl> Date: Thu, 28 Sep 2006 16:24:24 +0200 In-Reply-To: <87irj814kp.fsf@xs4all.nl> (Marco Gerards's message of "Thu, 28 Sep 2006 15:52:22 +0200") Message-ID: <874pus9ihz.fsf@night.trouble.net> User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Cc: Subject: Re: patch for kern/efi/mm.c (big memmap) X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Sep 2006 14:00:13 -0000 --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Marco Gerards writes: >> + memory_map = grub_efi_allocate_pages >> + (0, 2 * BYTES_TO_PAGES (memory_map_size + 0x1000)); >> >> I suppose you add 0x1000 to round it up. Maybe we should change >> the BYTES_TO_PAGES macro to do roundup. > > Agreed. Can you make this change as well? Done. See attached patch. >> Even through this patch is quite trivial and small, I believe we >> need you to sign over the copyright for it to FSF. Okuji, Marco, >> what are your opinions? > > This patch is trivial enough to apply without the paperwork, I > think. OK. I'll commit it after I get a few minutes over to test it. ~j --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=grub.efi-mm.2.patch Content-Transfer-Encoding: quoted-printable Index: kern/efi/mm.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/grub/grub2/kern/efi/mm.c,v retrieving revision 1.3 diff -u -p -r1.3 mm.c =2D-- kern/efi/mm.c 28 May 2006 23:01:43 -0000 1.3 +++ kern/efi/mm.c 28 Sep 2006 13:57:30 -0000 @@ -27,13 +27,9 @@ #define NEXT_MEMORY_DESCRIPTOR(desc, size) \ ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size))) =20 =2D#define BYTES_TO_PAGES(bytes) ((bytes) >> 12) +#define BYTES_TO_PAGES(bytes) (((bytes) + 4095) >> 12) #define PAGES_TO_BYTES(pages) ((pages) << 12) =20 =2D/* The size of a memory map obtained from the firmware. This must be =2D a multiplier of 4KB. */ =2D#define MEMORY_MAP_SIZE 0x1000 =2D /* Maintain the list of allocated pages. */ struct allocated_page { @@ -346,6 +342,8 @@ grub_efi_mm_init (void) grub_efi_uintn_t desc_size; grub_efi_uint64_t total_pages; grub_efi_uint64_t required_pages; + grub_efi_uintn_t memory_map_size; + int res; =20 /* First of all, allocate pages to maintain allocations. */ allocated_pages @@ -355,16 +353,23 @@ grub_efi_mm_init (void) =20 grub_memset (allocated_pages, 0, ALLOCATED_PAGES_SIZE); =20=20=20 =2D /* Prepare a memory region to store two memory maps. */ =2D memory_map =3D grub_efi_allocate_pages (0, =2D 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); + /* Prepare a memory region to store two memory maps. Obtain size of + memory map by passing a NULL buffer and a buffer size of + zero. */ + memory_map_size =3D 0; + res =3D grub_efi_get_memory_map (&memory_map_size, NULL, 0, &desc_size, = 0); + if (res !=3D 0) + grub_fatal ("cannot get memory map size"); + + memory_map =3D grub_efi_allocate_pages + (0, 2 * BYTES_TO_PAGES (memory_map_size)); if (! memory_map) grub_fatal ("cannot allocate memory"); =20 =2D filtered_memory_map =3D NEXT_MEMORY_DESCRIPTOR (memory_map, MEMORY_MAP= _SIZE); + filtered_memory_map =3D NEXT_MEMORY_DESCRIPTOR (memory_map, memory_map_s= ize); =20 /* Obtain descriptors for available memory. */ =2D map_size =3D MEMORY_MAP_SIZE; + map_size =3D memory_map_size; =20 if (grub_efi_get_memory_map (&map_size, memory_map, 0, &desc_size, 0) < = 0) grub_fatal ("cannot get memory map"); @@ -393,7 +398,7 @@ grub_efi_mm_init (void) =20 #if 0 /* For debug. */ =2D map_size =3D MEMORY_MAP_SIZE; + map_size =3D memory_map_size; =20 if (grub_efi_get_memory_map (&map_size, memory_map, 0, &desc_size, 0) < = 0) grub_fatal ("cannot get memory map"); @@ -406,7 +411,7 @@ grub_efi_mm_init (void) =20=20=20 /* Release the memory maps. */ grub_efi_free_pages ((grub_addr_t) memory_map, =2D 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); + 2 * BYTES_TO_PAGES (memory_map_size)); } =20 void --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQBFG9sb3CqIy3K3X2ERAoNMAKCzbp1cVmb5KELEJ0JFTkrczmSBWwCfd2s0 6OJqUboumzTFvB90+v7C28w= =Jss6 -----END PGP SIGNATURE----- --==-=-=--