From patchwork Tue Oct 8 18:14:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 833599 Delivered-To: patch@linaro.org Received: by 2002:adf:a1d9:0:b0:367:895a:4699 with SMTP id v25csp436426wrv; Tue, 8 Oct 2024 11:17:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVrp18lFz7R0yo04OGlP6/lSMBrMHCRXIQL5AKBA21pP+ssj6PSB13vzmMe5S9RPX29nXOkiA==@linaro.org X-Google-Smtp-Source: AGHT+IHnoWJl8MczQl6PR+VTPAnNZYeMtJdvGAv+AKK1KUx3ZwWRmKzgoCV2mVmOMIQobe9SFeg1 X-Received: by 2002:a5d:59a1:0:b0:371:88b9:256d with SMTP id ffacd0b85a97d-37d0e6cae5emr13032367f8f.6.1728411437685; Tue, 08 Oct 2024 11:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728411437; cv=none; d=google.com; s=arc-20240605; b=OMtjyrgYD3Ii4anxwmXdbYx3CU+1RfJ4ve+Gv7sOIdALtvd3fa5P5xAa5kMQAccFS2 n8lQRXBIea+D/ytQwgYVAWKj6sSsQI8DP6mx5Ar7+sLY2nUGrZu+j75++iVe1CmeTu9D tAkEzrlHdyTO9PkibM/hPOX34JwvLTmimyPeghS90UaOUVlJeYZgABPXuyw3AIxVNZqk xvcxJKiBDFqz3LzHnkypPXt/t5zwv5VU38mETu0k9fhp6uACmD3qlA47RpatqwBtmitO cs+8ANWH5IUI6dM/s4b6rE8+MzhPZ1ohtbOt9ws6sIgqxvEajRfklonO8OFVV5DazdOE qFWg== 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=52eZV0NzoU+nj51sRT0CdkvDxxSdAfMEin2wNu8EBX0=; fh=EURqIhM9Cs9+QDCQ9Vm6IsJQ8gNya1VBDuunKFxPiA8=; b=fwuZRIu0VwqwwjnT/Cade27ac7MUZVL6aRXq+lrDpXofW2n5x14WBtXukZXTLh3rJV 1ABfpaUtC9+FGcSNt+XRn8+1srvaYRfX5Hna0XQ2GTApTwbFx7Si7LvcqLEtDUUsoBZR 20FojoTiOww1GkHK+I5euQdSW+v2X0/MNEYi4h8TUQutJVi/ZWNJ3DQ3Hj9BkidBU0Vk cuc26B51GOfw3nyh+9TlIYkoCg1Uk3SnD71dgRCo3gzR1JTorISv40xdHaszJxzgU8EO 4sVaFKVnFruyN9uxQJZ+pehRr7aVELLwuhUFRhvWEAH7jA0oL2u1vufFFc6DpGVbZ8OK UCxg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 5b1f17b1804b1-42f86b52312si50515885e9.230.2024.10.08.11.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 11:17:17 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 C97A288F67; Tue, 8 Oct 2024 20:15:37 +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 D5B6C88F67; Tue, 8 Oct 2024 20:15:36 +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 9E94288E26 for ; Tue, 8 Oct 2024 20:15:34 +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 A9E47113E; Tue, 8 Oct 2024 11:16:03 -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 40CBA3F64C; Tue, 8 Oct 2024 11:15:31 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v2 14/14] efi_memory: rename variable to highlight overlap with free memory Date: Tue, 8 Oct 2024 23:44:35 +0530 Message-Id: <20241008181435.1753814-15-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241008181435.1753814-1-sughosh.ganu@linaro.org> References: <20241008181435.1753814-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 functions to add a memory region to the EFI memory map have a variable, overlap_only_ram, which is used to indicate if a new memory region needs to be carved out from the free, or conventional memory. The name overlap_only_ram is a bit confusing, as other allocated memory regions, like boot-services code and data are also part of the RAM memory. Rename the variable to highlight the fact that it is the free/conventional memory that is being referred to in this context. Signed-off-by: Sughosh Ganu --- Changes since V1: New patch 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 0d5555c7597..c3512c63a50 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_only_freemem: 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_only_freemem); /* 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 0f25094dbf8..97b89a97a2e 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_only_freemem: 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_only_freemem 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_only_freemem) { 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_only_freemem && (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_only_freemem: 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_only_freemem) { 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_only_freemem ? + "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_only_freemem); 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_only_freemem && (carved_pages != pages)) { /* * The payload wanted to have RAM overlaps, but we overlapped * with an unallocated region. Error out.