From patchwork Sun Oct 13 10:55:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835079 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1536950wrd; Sun, 13 Oct 2024 03:57:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVIlC1R9CedFTNyEDUMR9Wh8ZNMRxxHe4ZKDyyBsYsBuGOij9Guw87lcYWjzB7TFJizptETtQ==@linaro.org X-Google-Smtp-Source: AGHT+IFGq5mqcr0xUqRo5/RgAtZHex607yfiUqTrAGdKOV9FafKtx16E2jc8hbRU/xwZ1WiDwz0U X-Received: by 2002:a05:6e02:2163:b0:3a3:b143:98 with SMTP id e9e14a558f8ab-3a3b5faabf5mr52630905ab.15.1728817076919; Sun, 13 Oct 2024 03:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728817076; cv=none; d=google.com; s=arc-20240605; b=OvXhr85D3m8sjSAVOLj//OelKx6EsOfQr0KwX0+w50eLFXt72GMu4pEa73IeYa7vOi LdiOGXl76BxtSnM5GtNoXxXKwuk65ZFwNmGX+CAmRBX7/le/UqijfWqGi7ZZsbkm+X0V tgO+JQr1NjQNAoMER/zJT5LkllL31YaTUYBw/6yi2bU+nr3uZPc4vbvv0Z135BW05NCY KoNbf2SIU3ik9yWpSluBGvmKCcgEqXxrI6OMo4ecTTlPAPW6VG2WIB2v9cwQyt6X18km ibnge7Dq/ZlI2CxAMQMoXtYNvP0zJyHabbEEoyBM+oVqMbLiuWrH6ZF7t87ozF8NtWdK ee0Q== 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=A2JD8iRvCXOGGOgX+t4+2GDvXO2KWhDkNu8VyU2Z9Js=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=hewnd/LnNbcFt7Ax5rCNjyMBiQwsYwJRvngkWtm87IclSKHU5PG6PjdVKh7pRzSsPC Y49eDDyncvNLrxykKTyv4VhQoJeQtnq2yFks9ri01I/AuZ095kzRLAbEK+Ykztt8UEFa 8qKq/G+sURsELEpg4MvahlPaDO0Xi8zyNGk8Vw3Pq1bL4tlohBDljkAQYKkHqV9DdHip exzTJU39a70zTfcBkeggtJTewUYMrtcDJKITEl/TYdfi15/3D2kbkpyIOBLa0sj0yJ1I W+o1XPZB0yZkm6O0QGNJws30odNa8PBolGavs1I9eHLG8nyNmh7vi65Znc4luhVTWl/y iLiQ==; 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 e9e14a558f8ab-3a3afdc7173si33021315ab.38.2024.10.13.03.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:57:56 -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 D388888F3F; Sun, 13 Oct 2024 12:56:26 +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 79D0B88F3F; Sun, 13 Oct 2024 12:56:26 +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_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_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 4D28E88F5B for ; Sun, 13 Oct 2024 12:56:22 +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 604501007; Sun, 13 Oct 2024 03:56:51 -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 396B63F71E; Sun, 13 Oct 2024 03:56:18 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 13/15] efi_memory: do not add RAM memory to the memory map Date: Sun, 13 Oct 2024 16:25:20 +0530 Message-Id: <20241013105522.391414-14-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-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 EFI_CONVENTIONAL_MEMORY type, which is the usable RAM memory is now being managed by the LMB module. Remove the addition of this memory type to the EFI memory map. This memory now gets added to the EFI memory map as part of the LMB memory map update event handler. Signed-off-by: Sughosh Ganu Reviewed-by: Simon Glass Reviewed-by: Ilias Apalodimas --- Changes since V2: * Fix the wording of some comments in efi_add_known_memory() as suggested by Ilias. include/efi_loader.h | 13 ++++--- lib/efi_loader/efi_memory.c | 77 +++---------------------------------- 2 files changed, 13 insertions(+), 77 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index ac20395718..6b9a66a06c 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -798,10 +798,6 @@ efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, int memory_type, bool overlap_only_ram); -/* Adds a conventional range into the EFI memory map */ -efi_status_t efi_add_conventional_memory_map(u64 ram_start, u64 ram_end, - u64 ram_top); - /* Called by board init to initialize the EFI drivers */ efi_status_t efi_driver_init(void); /* Called when a block device is added */ @@ -1186,9 +1182,14 @@ efi_status_t efi_console_get_u16_string efi_status_t efi_disk_get_device_name(const efi_handle_t handle, char *buf, int size); /** - * efi_add_known_memory() - add memory banks to EFI memory map + * efi_add_known_memory() - add memory types to the EFI memory map + * + * This function is to be used to add different memory types other + * than EFI_CONVENTIONAL_MEMORY to the EFI memory map. The conventional + * memory is handled by the LMB module and gets added to the memory + * map through the LMB module. * - * This weak function may be overridden for specific architectures. + * This function may be overridden for architectures specific purposes. */ void efi_add_known_memory(void); diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 16e64987af..f59f7780e9 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -783,82 +783,17 @@ efi_status_t efi_get_memory_map_alloc(efi_uintn_t *map_size, } /** - * efi_add_conventional_memory_map() - add a RAM memory area to the map + * efi_add_known_memory() - add memory types to the EFI memory map * - * @ram_start: start address of a RAM memory area - * @ram_end: end address of a RAM memory area - * @ram_top: max address to be used as conventional memory - * Return: status code - */ -efi_status_t efi_add_conventional_memory_map(u64 ram_start, u64 ram_end, - u64 ram_top) -{ - u64 pages; - - /* Remove partial pages */ - ram_end &= ~EFI_PAGE_MASK; - ram_start = (ram_start + EFI_PAGE_MASK) & ~EFI_PAGE_MASK; - - if (ram_end <= ram_start) { - /* Invalid mapping */ - return EFI_INVALID_PARAMETER; - } - - pages = (ram_end - ram_start) >> EFI_PAGE_SHIFT; - - efi_add_memory_map_pg(ram_start, pages, - EFI_CONVENTIONAL_MEMORY, false); - - /* - * Boards may indicate to the U-Boot memory core that they - * can not support memory above ram_top. Let's honor this - * in the efi_loader subsystem too by declaring any memory - * above ram_top as "already occupied by firmware". - */ - if (ram_top < ram_start) { - /* ram_top is before this region, reserve all */ - efi_add_memory_map_pg(ram_start, pages, - EFI_BOOT_SERVICES_DATA, true); - } else if (ram_top < ram_end) { - /* ram_top is inside this region, reserve parts */ - pages = (ram_end - ram_top) >> EFI_PAGE_SHIFT; - - efi_add_memory_map_pg(ram_top, pages, - EFI_BOOT_SERVICES_DATA, true); - } - - return EFI_SUCCESS; -} - -/** - * efi_add_known_memory() - add memory banks to map + * This function is to be used to add different memory types other + * than EFI_CONVENTIONAL_MEMORY to the EFI memory map. The conventional + * memory is handled by the LMB module and gets added to the memory + * map through the LMB module. * - * This function may be overridden for specific architectures. + * This function may be overridden for architectures specific purposes. */ __weak void efi_add_known_memory(void) { - u64 ram_top = gd->ram_top & ~EFI_PAGE_MASK; - int i; - - /* - * ram_top is just outside mapped memory. So use an offset of one for - * mapping the sandbox address. - */ - ram_top = (uintptr_t)map_sysmem(ram_top - 1, 0) + 1; - - /* Fix for 32bit targets with ram_top at 4G */ - if (!ram_top) - ram_top = 0x100000000ULL; - - /* Add RAM */ - for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { - u64 ram_end, ram_start; - - ram_start = (uintptr_t)map_sysmem(gd->bd->bi_dram[i].start, 0); - ram_end = ram_start + gd->bd->bi_dram[i].size; - - efi_add_conventional_memory_map(ram_start, ram_end, ram_top); - } } /**