Received: from list by lists.gnu.org with archive (Exim 4.71) id 1YSU4b-000236-2B for mharc-grub-devel@gnu.org; Mon, 02 Mar 2015 12:24:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSU4V-0001tn-46 for grub-devel@gnu.org; Mon, 02 Mar 2015 12:24:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YSU4Q-0000EG-IO for grub-devel@gnu.org; Mon, 02 Mar 2015 12:23:59 -0500 Received: from mail.emea.novell.com ([130.57.118.101]:56222) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSU4Q-0000E9-9w for grub-devel@gnu.org; Mon, 02 Mar 2015 12:23:54 -0500 Received: from EMEA1-MTA by mail.emea.novell.com with Novell_GroupWise; Mon, 02 Mar 2015 17:23:53 +0000 Message-Id: <54F4AAB502000078000654ED@mail.emea.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.0.1 Date: Mon, 02 Mar 2015 17:23:49 +0000 From: "Jan Beulich" To: "Daniel Kiper" Subject: Re: [PATCH 17/18] x86/efi: create new early memory allocator References: <1422640462-28103-1-git-send-email-daniel.kiper@oracle.com> <1422640462-28103-18-git-send-email-daniel.kiper@oracle.com> In-Reply-To: <1422640462-28103-18-git-send-email-daniel.kiper@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 130.57.118.101 Cc: Juergen Gross , grub-devel@gnu.org, keir@xen.org, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com, roy.franz@linaro.org, ning.sun@intel.com, david.vrabel@citrix.com, phcoder@gmail.com, xen-devel@lists.xenproject.org, qiaowei.ren@intel.com, richard.l.maliszewski@intel.com, gang.wei@intel.com, fu.wei@linaro.org 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: Mon, 02 Mar 2015 17:24:03 -0000 >>> On 30.01.15 at 18:54, wrote: > --- a/xen/arch/x86/efi/efi-boot.h > +++ b/xen/arch/x86/efi/efi-boot.h > @@ -103,9 +103,35 @@ static void __init relocate_trampoline(unsigned = long phys) > *(u16 *)(*trampoline_ptr + (long)trampoline_ptr) =3D phys >> 4; > } > =20 > +#define __MALLOC_SIZE 65536 > + > +static char __malloc_mem[__MALLOC_SIZE]; > +static char *__malloc_free =3D NULL; > + > +static void __init *__malloc(size_t size) Please do away with all these prefixing underscores. > +{ > + void *ptr; > + > + /* > + * Init __malloc_free on runtime. Static initialization > + * will not work because it puts virtual address there. > + */ > + if ( __malloc_free =3D=3D NULL ) > + __malloc_free =3D __malloc_mem; > + > + ptr =3D __malloc_free; > + > + __malloc_free +=3D size; > + > + if ( __malloc_free - __malloc_mem > sizeof(__malloc_mem) ) > + blexit(L"Out of static memory\r\n"); > + > + return ptr; > +} You're ignoring alignment requirements here altogether. > @@ -192,12 +218,7 @@ static void __init=20 > efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable, > =20 > static void *__init efi_arch_allocate_mmap_buffer(UINTN *map_size) > { > - place_string(&mbi.mem_upper, NULL); > - mbi.mem_upper -=3D *map_size; > - mbi.mem_upper &=3D -__alignof__(EFI_MEMORY_DESCRIPTOR); > - if ( mbi.mem_upper < xen_phys_start ) > - return NULL; > - return (void *)(long)mbi.mem_upper; > + return __malloc(*map_size); > } Which then even suggests that _if_ we go this route, this could be shared with ARM (and hence become common code again). Jan