Received: from list by lists.gnu.org with archive (Exim 4.71) id 1YbTpH-0004mV-DG for mharc-grub-devel@gnu.org; Fri, 27 Mar 2015 08:57:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbTpF-0004mO-8B for grub-devel@gnu.org; Fri, 27 Mar 2015 08:57:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YbTpA-0004CE-3R for grub-devel@gnu.org; Fri, 27 Mar 2015 08:57:25 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:51069) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbTp9-0004C8-U4 for grub-devel@gnu.org; Fri, 27 Mar 2015 08:57:20 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t2RCv9Kc030266 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 27 Mar 2015 12:57:09 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t2RCv8th015466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 27 Mar 2015 12:57:08 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t2RCv8sG031961; Fri, 27 Mar 2015 12:57:08 GMT Received: from olila.local.net-space.pl (/10.175.231.232) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 27 Mar 2015 05:57:07 -0700 Date: Fri, 27 Mar 2015 13:57:01 +0100 From: Daniel Kiper To: Jan Beulich Subject: Re: [PATCH 17/18] x86/efi: create new early memory allocator Message-ID: <20150327125701.GL8294@olila.local.net-space.pl> References: <1422640462-28103-1-git-send-email-daniel.kiper@oracle.com> <1422640462-28103-18-git-send-email-daniel.kiper@oracle.com> <54F4AAB502000078000654ED@mail.emea.novell.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54F4AAB502000078000654ED@mail.emea.novell.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userv0022.oracle.com [156.151.31.74] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 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: Fri, 27 Mar 2015 12:57:26 -0000 On Mon, Mar 02, 2015 at 05:23:49PM +0000, Jan Beulich wrote: > >>> 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) = phys >> 4; > > } > > > > +#define __MALLOC_SIZE 65536 > > + > > +static char __malloc_mem[__MALLOC_SIZE]; > > +static char *__malloc_free = 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 == NULL ) > > + __malloc_free = __malloc_mem; > > + > > + ptr = __malloc_free; > > + > > + __malloc_free += 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. I can understand why __malloc_mem should be let's say page aligned but I am not sure why we should care here about alignment inside of __malloc_mem array like... > > @@ -192,12 +218,7 @@ static void __init > > efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable, > > > > static void *__init efi_arch_allocate_mmap_buffer(UINTN *map_size) > > { > > - place_string(&mbi.mem_upper, NULL); > > - mbi.mem_upper -= *map_size; > > - mbi.mem_upper &= -__alignof__(EFI_MEMORY_DESCRIPTOR); ...here... > > - 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). So, go or no go this route? If not what do you suggest? Daniel