From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E8CDC3402A for ; Mon, 17 Feb 2020 21:26:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6581520836 for ; Mon, 17 Feb 2020 21:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581974761; bh=l0dOy2UpBtryST2iZLUusaGeXO0CcQ2p8oMEQoFeVKI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=moTxgPF9wzTGpXaaV97c66Zg2qMVOWuApkSQVxtZbrfmTOp7p1jKK3zQY4TVm5hYJ fRxRrRF0DORsg4pOk8toqyNiUZJdd1HI7UHQDqPya6rWQWS9ziOpVn+4OC9Uu0pWN3 NOg2VuGYQMwBWiNAYOpNmFBotQCDcbgN+IRKy0vw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729906AbgBQV0A (ORCPT ); Mon, 17 Feb 2020 16:26:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:39408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729676AbgBQVZ7 (ORCPT ); Mon, 17 Feb 2020 16:25:59 -0500 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 27EB2207FD for ; Mon, 17 Feb 2020 21:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581974759; bh=l0dOy2UpBtryST2iZLUusaGeXO0CcQ2p8oMEQoFeVKI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Vbp6SrXM29IkGlb9ZpFUPS1enfgo1NxT11uUwLYyeA5OEpR0Yok7iQMZ3bqVdAgM7 5p4mtShysT/cSued0BEY/WS1s3g4Wtm42pe0JX4B1cUrXwYIHsd101fKfpJCgRlftn /kmykk0mexaqiIT0i87kZ5hiGSPwy9Oq/ge17KQM= Received: by mail-wm1-f47.google.com with SMTP id q9so718103wmj.5 for ; Mon, 17 Feb 2020 13:25:59 -0800 (PST) X-Gm-Message-State: APjAAAW4RN7rEaU5peAlHSWsZrcZnLInjsNx6dooAhEpjsX1C+GoQQaR luDc1jwdHTghiK4B6zPfoEN6W6o8EkoplYIjtTqy6A== X-Google-Smtp-Source: APXvYqz4ckzSLSn80+EGpOONKPp+2jjUqj+eeWcBoPgxAti+TmJLW8eu5TALGjuu2ktF7TcJP3e4JE/+OlwHGNPCWbM= X-Received: by 2002:a1c:b603:: with SMTP id g3mr927700wmf.133.1581974757521; Mon, 17 Feb 2020 13:25:57 -0800 (PST) MIME-Version: 1.0 References: <20200217211323.4878-1-xypron.glpk@gmx.de> In-Reply-To: <20200217211323.4878-1-xypron.glpk@gmx.de> From: Ard Biesheuvel Date: Mon, 17 Feb 2020 22:25:46 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/1] efi/libstub: describe memory functions To: Heinrich Schuchardt Cc: linux-efi , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 17 Feb 2020 at 22:14, Heinrich Schuchardt wrote: > > Provide descriptions of: > > * efi_get_memory_map() > * efi_low_alloc_above() > * efi_free() > > Signed-off-by: Heinrich Schuchardt Thanks Heinrich. One comment below. > --- > drivers/firmware/efi/libstub/mem.c | 31 ++++++++++++++++++++++++++++-- > 1 file changed, 29 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/efi/libstub/mem.c b/drivers/firmware/efi/libstub/mem.c > index c25fd9174b74..be24c062115f 100644 > --- a/drivers/firmware/efi/libstub/mem.c > +++ b/drivers/firmware/efi/libstub/mem.c > @@ -16,6 +16,15 @@ static inline bool mmap_has_headroom(unsigned long buff_size, > return slack / desc_size >= EFI_MMAP_NR_SLACK_SLOTS; > } > > +/** > + * efi_get_memory_map() - get memory map > + * @map on return pointer to memory map > + * > + * Retrieve the UEFI memory map. The allocated memory leaves room for > + * up to EFI_MMAP_NR_SLACK_SLOTS additional memory map entries. > + * > + * Return: status code > + */ > efi_status_t efi_get_memory_map(struct efi_boot_memmap *map) > { > efi_memory_desc_t *m = NULL; > @@ -109,8 +118,20 @@ efi_status_t efi_allocate_pages(unsigned long size, unsigned long *addr, > } > return EFI_SUCCESS; > } > -/* > - * Allocate at the lowest possible address that is not below 'min'. > +/** > + * efi_low_alloc_above() - allocate pages at or above given address > + * @size: size of the memory area to allocate > + * @align: minimum alignment of the allocated memory area. It should > + * a power of two. > + * @addr: on exit the address of the allocated memory > + * @min: minimum address to used for the memory allocation > + * > + * Allocate at the lowest possible address that is not below 'min' as > + * EFI_LOADER_DATA. The allocated pages are aligned according to 'align' but at > + * least EFI_ALLOC_ALIGN. The first allocated page will not below the address > + * given by 'min'. > + * > + * Return: status code > */ > efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align, > unsigned long *addr, unsigned long min) > @@ -187,6 +208,12 @@ efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align, > return status; > } > > +/** > + * efi_free() - free memory pages > + * @size size of the memory area to free in bytes > + * @addr start of the memory area to free (must be EFI_PAGE_SIZE > + * aligned) > + */ It may be good to mention here that the allocation is rounded up to EFI_ALLOC_ALIGN again, so it should only be used for allocation that were made using efi_allocate_pages() or efi_low_alloc_above(). > void efi_free(unsigned long size, unsigned long addr) > { > unsigned long nr_pages; > -- > 2.25.0 >