From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Laszlo Ersek <lersek@redhat.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
Leif Lindholm <leif.lindholm@linaro.org>
Subject: Re: [PATCH 10/15] ArmVirtPkg: introduce ArmVirtMemInfoLib library class
Date: Tue, 21 Nov 2017 16:32:22 +0000 [thread overview]
Message-ID: <CAKv+Gu-fKEqZSsO3ALuH+V2XtWMOsOOUbvwrwObnWVugD=qBgQ@mail.gmail.com> (raw)
In-Reply-To: <428456f8-237a-89aa-2531-18ce18bb4c97@redhat.com>
On 21 November 2017 at 16:27, Laszlo Ersek <lersek@redhat.com> wrote:
> On 11/21/17 17:23, Laszlo Ersek wrote:
>> On 11/17/17 17:09, Ard Biesheuvel wrote:
>>> As part of the effort to get rid of ArmPlatformLib (which incorporates
>>> far too many duties in a single library), introduce ArmVirtMemInfoLib
>>> which will be invoked by our ArmVirtMemoryInitPeiLib implementation to
>>> get a description of the virtual address space. This will allow us to
>>> remove this functionality from ArmPlatformLib later, or, in the case of
>>> ArmVirtXen and ArmVirtQemuKernel, drop ArmPlatformLib altogether.
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.1
>>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>>> ---
>>> ArmVirtPkg/ArmVirtPkg.dec | 3 ++
>>> ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h | 39 ++++++++++++++++++++
>>> 2 files changed, 42 insertions(+)
>>>
>>> diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
>>> index a8603e1b80e5..8f656fd2739d 100644
>>> --- a/ArmVirtPkg/ArmVirtPkg.dec
>>> +++ b/ArmVirtPkg/ArmVirtPkg.dec
>>> @@ -30,6 +30,9 @@ [Defines]
>>> [Includes.common]
>>> Include # Root include for the package
>>>
>>> +[LibraryClasses]
>>> + ArmVirtMemInfoLib|Include/Library/ArmVirtMemInfoLib.h
>>> +
>>> [Guids.common]
>>> gArmVirtTokenSpaceGuid = { 0x0B6F5CA7, 0x4F53, 0x445A, { 0xB7, 0x6E, 0x2E, 0x36, 0x5B, 0x80, 0x63, 0x66 } }
>>> gEarlyPL011BaseAddressGuid = { 0xB199DEA9, 0xFD5C, 0x4A84, { 0x80, 0x82, 0x2F, 0x41, 0x70, 0x78, 0x03, 0x05 } }
>>> diff --git a/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h b/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h
>>> new file mode 100644
>>> index 000000000000..65be2cbd8082
>>> --- /dev/null
>>> +++ b/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h
>>> @@ -0,0 +1,39 @@
>>> +/** @file
>>> +
>>> + Copyright (c) 2011-2013, ARM Limited. All rights reserved.
>>> + Copyright (c) 2017, Linaro, Ltd. All rights reserved.
>>> +
>>> + This program and the accompanying materials are licensed and made available
>>> + under the terms and conditions of the BSD License which accompanies this
>>> + distribution. The full text of the license may be found at
>>> + http://opensource.org/licenses/bsd-license.php
>>> +
>>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
>>> +
>>> +**/
>>> +
>>> +#ifndef _ARM_VIRT_MEMINFO_LIB_H_
>>> +#define _ARM_VIRT_MEMINFO_LIB_H_
>>> +
>>> +#include <Base.h>
>>> +#include <Library/ArmLib.h>
>>> +
>>> +/**
>>> + Return the Virtual Memory Map of your platform
>>> +
>>> + This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
>>> + on your platform.
>>> +
>>> + @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
>>> + describing a Physical-to-Virtual Memory
>>> + mapping. This array must be ended by a
>>> + zero-filled entry
>>> +
>>> +**/
>>> +VOID
>>> +ArmVirtGetMemoryMap (
>>> + OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
>>> + );
>>> +
>>> +#endif
>>>
>>
>> (1) Since this is a library API, please add EFIAPI to the declaration.
>>
>> (This will affect the instance(s) too.)
>>
>>
>> (2) If it's not overly restrictive, then please mention in the
>> "VirtualMemoryMap" param comment that the map is supposed to be
>> allocated dynamically within the function, using the phase-matching
>> MemoryAllocationLib instance.
>>
>> (Judged from the AllocatePages() call in
>> "ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/QemuVirtMem.c".)
>
> Looking at the patch right after this one, dynamic memory allocation
> appears wrong to spell out in the library interface.
>
> Then I guess the right thing to say would be, "the returned array is
> never supposed to be freed; it is released at the latest when the OS
> takes control".
>
>> With those addressed,
>>
>> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
>
> My R-b stands, just please clarify the expected lifetime of the array
> returned, one way or another.
>
Thanks. Simply not freeing it is the current practice everywhere,
given that PrePi and PEI MemoryAllocationLib implementations don't do
FreePages() in the first place. But I agree it should be mentioned
explicitly.
next prev parent reply other threads:[~2017-11-21 16:28 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-17 16:08 [PATCH 00/15] ArmVirtPkg: get rid of ArmPlatformLib Ard Biesheuvel
2017-11-17 16:08 ` [PATCH 01/15] ArmPlatformPkg/ArmPlatformLibNull: remove bogus PCD dependencies Ard Biesheuvel
2017-11-17 16:20 ` Leif Lindholm
2017-11-17 16:23 ` Ard Biesheuvel
2017-11-17 16:28 ` Leif Lindholm
2017-11-17 19:10 ` Ard Biesheuvel
2017-11-17 16:09 ` [PATCH 02/15] ArmVirtPkg/PrePi: run all library constructors by hand Ard Biesheuvel
2017-11-21 15:32 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 03/15] ArmVirtPkg/PrePi: remove unused GetPlatformPpi() function Ard Biesheuvel
2017-11-21 15:36 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 04/15] ArmVirtPkg/PrePi: remove bogus primary core check Ard Biesheuvel
2017-11-21 15:40 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 05/15] ArmVirtPkg/PrePi: remove dependency on ArmPlatformLib Ard Biesheuvel
2017-11-21 15:46 ` Laszlo Ersek
2017-11-21 15:47 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 06/15] ArmVirtPkg/PrePi: move DRAM discovery code into PrePi Ard Biesheuvel
2017-11-21 15:48 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 07/15] ArmVirtPkg/PrePi: remove ArmPlatformStackLib dependency Ard Biesheuvel
2017-11-21 15:51 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 08/15] ArmVirtPkg/PrePi: remove bogus IntelFrameworkModulePkg.dec dependency Ard Biesheuvel
2017-11-21 15:52 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 09/15] ArmVirtPkg/ArmVirtPlatformLib: remove support for uncached mappings Ard Biesheuvel
2017-11-21 16:15 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 10/15] ArmVirtPkg: introduce ArmVirtMemInfoLib library class Ard Biesheuvel
2017-11-21 16:23 ` Laszlo Ersek
2017-11-21 16:27 ` Laszlo Ersek
2017-11-21 16:32 ` Ard Biesheuvel [this message]
2017-11-17 16:09 ` [PATCH 11/15] ArmVirtPkg/ArmVirtXen: add ArmVirtMemInfoLib implementation Ard Biesheuvel
2017-11-21 16:30 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 12/15] ArmVirtPkg/ArmVirtQemu: " Ard Biesheuvel
2017-11-21 16:47 ` Ard Biesheuvel
2017-11-21 16:56 ` Laszlo Ersek
2017-11-21 17:11 ` Ard Biesheuvel
2017-11-17 16:09 ` [PATCH 13/15] ArmVirtPkg: implement ArmVirtMemInfo PPI, PEIM and library Ard Biesheuvel
2017-11-21 17:49 ` Laszlo Ersek
2017-11-21 17:57 ` Ard Biesheuvel
2017-11-21 20:17 ` Laszlo Ersek
2017-11-21 20:32 ` Ard Biesheuvel
2017-11-22 8:45 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 14/15] ArmVirtPkg/ArmVirtMemoryInitPeiLib: move to ArmVirtMemInfoLib Ard Biesheuvel
2017-11-21 17:51 ` Laszlo Ersek
2017-11-17 16:09 ` [PATCH 15/15] ArmVirtPkg: remove ArmPlatformLib implementations Ard Biesheuvel
2017-11-21 17:52 ` Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKv+Gu-fKEqZSsO3ALuH+V2XtWMOsOOUbvwrwObnWVugD=qBgQ@mail.gmail.com' \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox