From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Vgrvc-00009v-Cy for mharc-grub-devel@gnu.org; Thu, 14 Nov 2013 03:05:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgrvV-00008Q-MG for grub-devel@gnu.org; Thu, 14 Nov 2013 03:05:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VgrvP-0001yu-V4 for grub-devel@gnu.org; Thu, 14 Nov 2013 03:05:21 -0500 Received: from mail-we0-x232.google.com ([2a00:1450:400c:c03::232]:56753) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgrvP-0001yn-JF for grub-devel@gnu.org; Thu, 14 Nov 2013 03:05:15 -0500 Received: by mail-we0-f178.google.com with SMTP id u57so1008899wes.23 for ; Thu, 14 Nov 2013 00:05:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=VFJ4IKJ3e0LBWG7FrWhkAuzni9LBMLb1lULl9bnfDBQ=; b=PuA4Rgx7ek9XrRiuVptPQyZgoKg1Sa3N5xxxxXA0r55LAoVSyVYKZ5Z/70Hxz/pijz KLdteW6VVQB8FRogZVzbxhABononZWCqEX1UHT5EAm5CeQai3rUApPrT6KcuPHqq/1Uo p/gp9sMeZRBJVtR485LgyaSS99EQz3peCw3Et9DVCs/x/E3xMsn2xNWiTxjjHjApvf8a 0FVqZFfNhuyD8n/air76do9pjJP0CWhiPajoQYB36dzEsELugM8cZO6ac9axljTO2ijn 0LqzCifQ09OrpVCMzkeH5whZ2thEAhdKL2N1UZeP00j9L83umKeJihUDrJjhgUITV9sG pBUg== X-Received: by 10.195.13.45 with SMTP id ev13mr228361wjd.20.1384416314794; Thu, 14 Nov 2013 00:05:14 -0800 (PST) Received: from [192.168.42.82] (8-237.197-178.cust.bluewin.ch. [178.197.237.8]) by mx.google.com with ESMTPSA id v45sm97130638eef.11.2013.11.14.00.05.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Nov 2013 00:05:13 -0800 (PST) Message-ID: <52848435.5060508@gmail.com> Date: Thu, 14 Nov 2013 09:05:09 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131005 Icedove/17.0.9 MIME-Version: 1.0 To: grub-devel@gnu.org Subject: Re: [PATCH 3/4] efi: Support GRUB_MMAP_MALLOC_LOW in the EFI firmware allocator References: In-Reply-To: X-Enigmail-Version: 1.5.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="----enig2QGVMSBQRWFOIBJSTJFDC" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::232 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Nov 2013 08:05:27 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2QGVMSBQRWFOIBJSTJFDC Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 13.11.2013 03:26, Josh Triplett wrote: > EFI supports allocating memory below a specified address; use that to > implement GRUB_MMAP_MALLOC_LOW by requesting memory below 1M. As discussed on the IRC, using mmap isn't right way to allocate transient low memory space. This would merit a separate functions (alloc_low_page and free_low_page) which uses EFI calls on EFI and returns the scratch address GRUB_MEMORY_MACHINE_SCRATCH_ADDR on other platforms. These would be subjected to following rules: - Always gives only 4k - Consumer has to ensure the transient nature of allocation since low memory is scarce. > --- >=20 > ChangeLog entry: >=20 > 2013-11-13 Josh Triplett >=20 > * include/grub/efi/memory.h (GRUB_MMAP_MALLOC_LOW): Define. > * grub-core/mmap/efi/mmap.c (grub_mmap_malign_and_register): Add > support for GRUB_MMAP_MALLOC_LOW, to allocate memory below 1M via th= e > EFI firmware. >=20 > grub-core/mmap/efi/mmap.c | 15 ++++++++++----- > include/grub/efi/memory.h | 2 ++ > 2 files changed, 12 insertions(+), 5 deletions(-) >=20 > diff --git a/grub-core/mmap/efi/mmap.c b/grub-core/mmap/efi/mmap.c > index e6cd185..64ad05c 100644 > --- a/grub-core/mmap/efi/mmap.c > +++ b/grub-core/mmap/efi/mmap.c > @@ -239,9 +239,9 @@ void * > grub_mmap_malign_and_register (grub_uint64_t align __attribute__ ((unu= sed)), > grub_uint64_t size, > int *handle, int type, > - int flags __attribute__ ((unused))) > + int flags) > { > - grub_efi_physical_address_t address; > + grub_efi_physical_address_t address, max_address; > grub_efi_boot_services_t *b; > grub_efi_uintn_t pages; > grub_efi_status_t status; > @@ -254,13 +254,18 @@ grub_mmap_malign_and_register (grub_uint64_t alig= n __attribute__ ((unused)), > =20 > b =3D grub_efi_system_table->boot_services; > =20 > - address =3D 0xffffffff; > + if (flags & GRUB_MMAP_MALLOC_LOW) > + max_address =3D 0xfffff; > + else > + max_address =3D 0xffffffff; > + address =3D max_address; > =20 > #if GRUB_TARGET_SIZEOF_VOID_P < 8 > /* Limit the memory access to less than 4GB for 32-bit platforms. *= / > atype =3D GRUB_EFI_ALLOCATE_MAX_ADDRESS; > #else > - atype =3D GRUB_EFI_ALLOCATE_ANY_PAGES; > + atype =3D (flags & GRUB_MMAP_MALLOC_LOW) ? GRUB_EFI_ALLOCATE_MAX_ADD= RESS > + : GRUB_EFI_ALLOCATE_ANY_PAGES= ; > #endif > =20 > pages =3D (size + 0xfff) >> 12; > @@ -276,7 +281,7 @@ grub_mmap_malign_and_register (grub_uint64_t align = __attribute__ ((unused)), > { > /* Uggh, the address 0 was allocated... This is too annoying, > so reallocate another one. */ > - address =3D 0xffffffff; > + address =3D max_address; > status =3D efi_call_4 (b->allocate_pages, atype, > make_efi_memtype (type), pages, &address); > grub_efi_free_pages (0, pages); > diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h > index 20526b1..b4940af 100644 > --- a/include/grub/efi/memory.h > +++ b/include/grub/efi/memory.h > @@ -24,6 +24,8 @@ > =20 > #define GRUB_MMAP_REGISTER_BY_FIRMWARE 1 > =20 > +#define GRUB_MMAP_MALLOC_LOW 1 > + > grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint6= 4_t size, > int type, int handle); > grub_err_t grub_machine_mmap_unregister (int handle); >=20 ------enig2QGVMSBQRWFOIBJSTJFDC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iF4EAREKAAYFAlKEhDUACgkQmBXlbbo5nOsJ7QD+MJchpP7J5dg5mViplvK3lf0P unoSXmu+ZRTfoJCn7q4BAJQ5tw9/fsr18wFCpDUWywB1h5GBsSjCoXD4kT0O6XdG =oWXy -----END PGP SIGNATURE----- ------enig2QGVMSBQRWFOIBJSTJFDC--