From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-x229.google.com (mail-io0-x229.google.com [IPv6:2607:f8b0:4001:c06::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9D07381D6A for ; Fri, 20 Jan 2017 08:42:22 -0800 (PST) Received: by mail-io0-x229.google.com with SMTP id j18so65526892ioe.2 for ; Fri, 20 Jan 2017 08:42:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=I/25hP1c0Rv/1ZMhaWZ8SL1i4O/glv9Qfi95NdHaedw=; b=d6sQCZjQ/jJOFA8XuBr6punAUZF1FQ7nJEwFDJv93lQB7Ew50aYcJYKWHWE5sFAQ1Z pLDs3sbhqyiZnlj5z+jls1NAxbZLOe+u9dLCvYZIR6/yom46j9rUnFNt55fOYr+pPlru u+SXscekzgynl0IJ+UZrWvrUbALxqjmj7mDbU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=I/25hP1c0Rv/1ZMhaWZ8SL1i4O/glv9Qfi95NdHaedw=; b=UnPrWgmSHiI5za+NnrPeShSM1bJOLOSMWeqyHoW9XieI5Rm2m1/Td4CVyF3rDR2PF+ gXC31eMzv/aBhyncJGSdkj8As5XIsTBLYQDL3nsypSPliDHh6k5FIO4rdiGGguETycaH tHGqQMDvazP7a7olDe2/L8PaHaosaqgQcRdOX5e6Jbpi/7XTl6AYrpRjqasoAopiU00A ifYXMGWHwvR/h/NZYSH+Tje8PjLfZySq6GhzAR19XFUSANZXhz8IfSwPCdJEJwvh7NH0 KqpMPPPzyvnFdFm4KcnzAdyKam3UGsBYVlVVfm9F4/L0BTIKPH66POIPOsMube96y8hr Xn6Q== X-Gm-Message-State: AIkVDXLdlQvr4H4hLjoJaViJ8aTwQzAiF3Dvbt/6yIAKiBekggep/ty90F7yfb6LOHEi4RMQXoTJ1p3MIh2Sf0nK X-Received: by 10.107.18.230 with SMTP id 99mr13196483ios.45.1484930541819; Fri, 20 Jan 2017 08:42:21 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.144.135 with HTTP; Fri, 20 Jan 2017 08:42:21 -0800 (PST) In-Reply-To: <9fdd45fb-710c-cd62-d65e-fe541037a069@redhat.com> References: <9fdd45fb-710c-cd62-d65e-fe541037a069@redhat.com> From: Ard Biesheuvel Date: Fri, 20 Jan 2017 16:42:21 +0000 Message-ID: To: Laszlo Ersek Cc: edk2-devel-01 Subject: Re: [QUESTION] reservation of pool allocations performed during PEI X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jan 2017 16:42:22 -0000 Content-Type: text/plain; charset=UTF-8 On 20 January 2017 at 16:38, Laszlo Ersek wrote: > On 01/20/17 17:05, Ard Biesheuvel wrote: >> After a recent change to the AArch64 page table code, the root table >> of the page tables is allocated using AllocatePool() rather than >> AllocatePages() if its size is much smaller than a page. E.g., when >> using 40 bits of translation, the root table only takes up 16 bytes >> >> However, what I have noticed is that pool allocations made during PEI >> are listed as available memory in the EFI memory map (using memmap in >> the UEFI Shell). Is this expected? Is it part of the contract that >> AllocatePool() allocations are lost when entering DXE? > > Pool allocations in PEI are satisfied with HOBs (and therefore the pool > allocation sizes are limited to ~64KB). > > In addition, soon after permanent PEI RAM is installed, objects from the > temporary SEC/PEI heap are moved there (this is called "temporary RAM > migration"). This includes the migration of the full HOB list, including > those that were used to satisfy pool allocations prior to RAM migration. > So how is this supposed to work for code that holds a pointer to such a pool allocation? > If you want to allocate memory in PEI that is to survive in-place into > DXE and later, I can think of two ways: > > - Call AllocatePages. This will only work after permanent PEI RAM has > been installed (so you might want to make the PEIM performing the call > dependent on gEfiPeiMemoryDiscoveredPpiGuid, with a DEPEX). The > allocation will be carved out of the permanent PEI RAM. > The same code calls AllocatePages for the subsequent translation levels, i.e., when using 40 bits of translation, there are 4 levels, where all but the top level are full pages. So I could simply replace AllocatePool with AllocaPages in this case, which would effectively revert my 'improvement' to this code to use a pool allocation for the root level. > - Allocate a region (a whole multiple of pages) outside of the permanent > PEI RAM, but in a spot that will later on be backed by system memory > (due to a system memory resource descriptor HOB produced in PEI, or due > to a GCD memory space addition during DXE). The way to perform this kind > of allocation is simply to produce a memory allocation HOB, covering the > range in question. This works even before the installation of permanent > PEI RAM. > > ... I hope I remembered most of this stuff right. > Thanks for the lesson :-)