From patchwork Tue Oct 15 15:37:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835458 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp301611wrs; Tue, 15 Oct 2024 08:40:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVFnE/CQDftNXD1sbR+aG1MxdcEwCGVj3BxexbEgrHYBwC+tIlGbpa2VDXO/Z3kCSaIzB5YIA==@linaro.org X-Google-Smtp-Source: AGHT+IFueqKMtmDANY8kVNo+xQdCsceTOnn6+214NS28376oUppaTwlVj6KjoPKH7ihiQnjwXM46 X-Received: by 2002:a05:6602:1342:b0:834:f6d2:bfca with SMTP id ca18e2360f4ac-837936cc6bfmr1703302139f.9.1729006808136; Tue, 15 Oct 2024 08:40:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006808; cv=none; d=google.com; s=arc-20240605; b=jY0U8WygBo3BUno9DS/Tt5PSgJmMoIOcymfkNl9XNUqWrDP0TeGIfnpUXWqfKlBdca JfTk0XEb7oH4eQj7S6kYtnxzRB7VOJm+bU+/4noDC7k3Qtq+JEtAAHpRShFtuk7cwIZ7 vTHfu+LDKbdcKtxWlGpTOCHlFCQk9Ja36w+jp9NpopoXwKGpj3OzKugtxHcX5olTd3pW wgcqMf2OyFtP6In0hys6Ow+j5oYzgY/E22MjQfYS3sFjXHHqHttSzO1LfdcVOCGZN7GS npl5MhoYcJw0OjNF7jFXTwinUBruQbRhE4t2VPxPvgx6CVRHLn523Uk35mA6mE/ZzJA3 SetA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=3wm7pKb5h6rLaLfq/oVVqIx3Ex0oAVocBcyOHqVahz4=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=BuEF7LRHFj62h/Hi3PYgwMIqVKUYIVrVia2c0mA4Yi96oiZpIQ7DjBC3YnKmrfqQlo ut/dcRSnlWhnxgaEcSsZv906AMFqdoP0I/TZG8SLiJIe+tWoRHpmIpY3emGUT0ftzQsJ FmZ3X+lxDR+JyQA3ukQ9DBhtLkx9hRv0mMLRfra2aCOfwsG7IRVFclYpe0drYjGHywud VJWuM3Al1yNi4iyfnROtV3dJBLHbS8TZUfqJGL3wFWJEF7clr3fq2idOQM9X3Fv0zUb6 PDJNvrfRYGf6Wrg7JUIz4gPW/yx6OAxeCECp+ai0OgO9ptaQNlTtCCAIEOCXETSiIY0f A1oQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 8926c6da1cb9f-4dbecb382casi807926173.28.2024.10.15.08.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:40:08 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C6C1488D56; Tue, 15 Oct 2024 17:38:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 3C89588730; Tue, 15 Oct 2024 17:38:29 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id BDE9688D39 for ; Tue, 15 Oct 2024 17:38:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AD2C01756; Tue, 15 Oct 2024 08:38:55 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1E8933F7A6; Tue, 15 Oct 2024 08:38:22 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 14/15] efi_memory: rename variable to highlight overlap with free memory Date: Tue, 15 Oct 2024 21:07:16 +0530 Message-Id: <20241015153717.401371-15-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The variable overlap_only_ram is used to specify that the new memory region that is being created needs to come from the free memory pool -- this is done by carving out the memory region from the free memory. The name is a bit confusing though, as other allocated memory regions, like boot-services code and data are also part of the RAM memory. Rename the variable to overlap_conventional to highlight the fact that it is the free/conventional memory that is being referred to in this context. Signed-off-by: Sughosh Ganu Reviewed-by: Ilias Apalodimas Reviewed-by: Simon Glass --- Changes since V3: None include/efi_loader.h | 16 +++++++----- lib/efi_loader/efi_memory.c | 51 ++++++++++++++++++++----------------- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 6b9a66a06c0..291eca5c077 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -788,15 +788,17 @@ efi_status_t efi_add_memory_map(u64 start, u64 size, int memory_type); /** * efi_add_memory_map_pg() - add pages to the memory map * - * @start: start address, must be a multiple of EFI_PAGE_SIZE - * @pages: number of pages to add - * @memory_type: type of memory added - * @overlap_only_ram: region may only overlap RAM - * Return: status code + * @start: start address, must be a multiple of + * EFI_PAGE_SIZE + * @pages: number of pages to add + * @memory_type: type of memory added + * @overlap_conventional: region may only overlap free(conventional) + * memory + * Return: status code */ efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, - int memory_type, - bool overlap_only_ram); + int memory_type, + bool overlap_conventional); /* Called by board init to initialize the EFI drivers */ efi_status_t efi_driver_init(void); diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index f59f7780e92..b63b5cca71e 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -173,17 +173,19 @@ static void efi_mem_sort(void) /** * efi_mem_carve_out() - unmap memory region * - * @map: memory map - * @carve_desc: memory region to unmap - * @overlap_only_ram: the carved out region may only overlap RAM - * Return: the number of overlapping pages which have been - * removed from the map, - * EFI_CARVE_NO_OVERLAP, if the regions don't overlap, - * EFI_CARVE_OVERLAPS_NONRAM, if the carve and map overlap, - * and the map contains anything but free ram - * (only when overlap_only_ram is true), - * EFI_CARVE_LOOP_AGAIN, if the mapping list should be - * traversed again, as it has been altered. + * @map: memory map + * @carve_desc: memory region to unmap + * @overlap_conventional: the carved out region may only overlap free, + * or conventional memory + * Return: the number of overlapping pages which have been + * removed from the map, + * EFI_CARVE_NO_OVERLAP, if the regions don't + * overlap, EFI_CARVE_OVERLAPS_NONRAM, if the carve + * and map overlap, and the map contains anything + * but free ram(only when overlap_conventional is + * true), + * EFI_CARVE_LOOP_AGAIN, if the mapping list should + * be traversed again, as it has been altered. * * Unmaps all memory occupied by the carve_desc region from the list entry * pointed to by map. @@ -193,7 +195,7 @@ static void efi_mem_sort(void) */ static s64 efi_mem_carve_out(struct efi_mem_list *map, struct efi_mem_desc *carve_desc, - bool overlap_only_ram) + bool overlap_conventional) { struct efi_mem_list *newmap; struct efi_mem_desc *map_desc = &map->desc; @@ -208,7 +210,7 @@ static s64 efi_mem_carve_out(struct efi_mem_list *map, return EFI_CARVE_NO_OVERLAP; /* We're overlapping with non-RAM, warn the caller if desired */ - if (overlap_only_ram && (map_desc->type != EFI_CONVENTIONAL_MEMORY)) + if (overlap_conventional && (map_desc->type != EFI_CONVENTIONAL_MEMORY)) return EFI_CARVE_OVERLAPS_NONRAM; /* Sanitize carve_start and carve_end to lie within our bounds */ @@ -258,15 +260,17 @@ static s64 efi_mem_carve_out(struct efi_mem_list *map, /** * efi_add_memory_map_pg() - add pages to the memory map * - * @start: start address, must be a multiple of EFI_PAGE_SIZE - * @pages: number of pages to add - * @memory_type: type of memory added - * @overlap_only_ram: region may only overlap RAM - * Return: status code + * @start: start address, must be a multiple of + * EFI_PAGE_SIZE + * @pages: number of pages to add + * @memory_type: type of memory added + * @overlap_conventional: region may only overlap free(conventional) + * memory + * Return: status code */ efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, - int memory_type, - bool overlap_only_ram) + int memory_type, + bool overlap_conventional) { struct efi_mem_list *lmem; struct efi_mem_list *newlist; @@ -275,7 +279,8 @@ efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, struct efi_event *evt; EFI_PRINT("%s: 0x%llx 0x%llx %d %s\n", __func__, - start, pages, memory_type, overlap_only_ram ? "yes" : "no"); + start, pages, memory_type, overlap_conventional ? + "yes" : "no"); if (memory_type >= EFI_MAX_MEMORY_TYPE) return EFI_INVALID_PARAMETER; @@ -312,7 +317,7 @@ efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, s64 r; r = efi_mem_carve_out(lmem, &newlist->desc, - overlap_only_ram); + overlap_conventional); switch (r) { case EFI_CARVE_OUT_OF_RESOURCES: free(newlist); @@ -348,7 +353,7 @@ efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, } } while (carve_again); - if (overlap_only_ram && (carved_pages != pages)) { + if (overlap_conventional && (carved_pages != pages)) { /* * The payload wanted to have RAM overlaps, but we overlapped * with an unallocated region. Error out.