From patchwork Wed Aug 20 11:23:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 61 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755689051; bh=MTIQmhHQbgnXC1NHV9dxxvsEDD9FP8BPCi9hJtGrmsc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Dy4Wsb60QNZI5UDZFxPWk6UOS0I/a4igphdW2dS/cD3Lrc80E1BCCbRq3zkj/p8Rp 9OCEUcSrjue5o80qJzhtbnyjd4faKrRs9PZT4NkktbuSuPzKjqIyDkpgq9sjA224q8 rGHLPFyrp3o4puAc901p4GIunPCt3mL6MVvF3sTLKHbRJWpoWhk/2fpkibODRSGb7g /zvRym3fqb0E6kBVxK6f/SiMnk40+jxAC9O+Vcpm6AdGisqg+XTeAMoGAPyR8HJFak 64BD2ugqMjbB/N1x3VBvPVQ3dL5XmWfOhQC+pbAkCf0pacx6nzDPaFhsDI8T7HA3jK jaDga4Gp4iYBg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CAF4E67680 for ; Wed, 20 Aug 2025 05:24:11 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id BDOC2uJvlIbR for ; Wed, 20 Aug 2025 05:24:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755689051; bh=MTIQmhHQbgnXC1NHV9dxxvsEDD9FP8BPCi9hJtGrmsc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Dy4Wsb60QNZI5UDZFxPWk6UOS0I/a4igphdW2dS/cD3Lrc80E1BCCbRq3zkj/p8Rp 9OCEUcSrjue5o80qJzhtbnyjd4faKrRs9PZT4NkktbuSuPzKjqIyDkpgq9sjA224q8 rGHLPFyrp3o4puAc901p4GIunPCt3mL6MVvF3sTLKHbRJWpoWhk/2fpkibODRSGb7g /zvRym3fqb0E6kBVxK6f/SiMnk40+jxAC9O+Vcpm6AdGisqg+XTeAMoGAPyR8HJFak 64BD2ugqMjbB/N1x3VBvPVQ3dL5XmWfOhQC+pbAkCf0pacx6nzDPaFhsDI8T7HA3jK jaDga4Gp4iYBg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 06E1967685 for ; Wed, 20 Aug 2025 05:24:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755689049; bh=18DHpggzn7N2R8vNk5zms/N8G23hLUtP7zR/SlrrJy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uasQxcE8Nz/JfhuABlw6Ol/fRYlil0MExKx7jXOV1vaUPZkYmMm417p5NoIVzkZWu jw8eQRdhPXOz8f3dkULu20EhqzT1Vn66fpTnUTa8nwFdAAqsTYb8B1QF4l4mLAAP7Z rzNmIhrP/N2O/D0fL7xN0wlSBCbZ9Ay9mONw/y/rU1Kj+uV/jc3/xOAvRXvQ+r3ea5 6XIGgjrUCWwMcn3DQybW98jz5jAYFTu2M0iJYdz3myE1L+Jt2YL8TqFUKOoux/5eV2 VnliUrMt8cV5P9Kgpd2REF+YTTOndX+N53rEquMRY+oLiKcTydFqT5m1fY0itesUIC yrai3t3A7U7JA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 708F5674AF; Wed, 20 Aug 2025 05:24:09 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id SG3HGPJnBMdy; Wed, 20 Aug 2025 05:24:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755689049; bh=z9Qwoarp0iJqrSvaT3cA40YPEEq0WPijVbEShKzzNEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZnAQLQVxsa8OME0bfq+e++0/a10AHwD2ahVfNs+YFPc4k+z9I6QqFm/hIUZ3RvXzD h2dQb4n5eCpxHG+fLcSpsCSEodookIFtMDByx4E7dkIw48SkK+upz20jHT7lLbIDi6 KdKNPtVwuztN1P1Bt9AaoCplQ9rVOrAL5dBwq4wjY2g/viviDxXSibhX8UEf88uW5r o/A/O5Biqfhkl36OfdNhlYOtoTxTxPJIOfUVS+TlRGfhAefTnYN5IcZI0xc/GLrbCT 9U4W69W4MW5eYZYCbhjcZVr4wQtWxTuMg+ESoZaU72dOxdzvWwVZLqrDZg2qZW8NPD yzKtmdP7FJxJg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AEEC7674B4; Wed, 20 Aug 2025 05:24:08 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 20 Aug 2025 05:23:17 -0600 Message-ID: <20250820112340.147082-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250820112340.147082-1-sjg@u-boot.org> References: <20250820112340.147082-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: UA6THOQF3LWPH4G27DHZ3MUT7VFFNOXW X-Message-ID-Hash: UA6THOQF3LWPH4G27DHZ3MUT7VFFNOXW X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 05/18] efi: app: Support efidebug memmap List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass It is helpful to see the memory map in some cases, so enable this subcommand in the app. Unfortunately we cannot assume that desc_size is the same in the underlying EFI implementation, so use a variable for that. Signed-off-by: Simon Glass --- (no changes since v1) cmd/efidebug.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 2e156fef525..d93fa43b779 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -659,15 +659,24 @@ static int do_efi_show_memmap(struct cmd_tbl *cmdtp, int flag, struct efi_mem_desc *memmap, *map; efi_uintn_t map_size; const char *type; - int i; - efi_status_t ret; + int desc_size, i; + efi_status_t eret; + int ret; - if (app_not_supported("memmap")) - return CMD_RET_FAILURE; + if (IS_ENABLED(CONFIG_EFI_APP)) { + uint key, version; + int size; - ret = efi_get_memory_map_alloc(&map_size, &memmap); - if (ret != EFI_SUCCESS) - return CMD_RET_FAILURE; + ret = efi_get_mmap(&memmap, &size, &key, &desc_size, &version); + if (ret) + return CMD_RET_FAILURE; + map_size = size; + } else { + eret = efi_get_memory_map_alloc(&map_size, &memmap); + if (eret) + return CMD_RET_FAILURE; + desc_size = sizeof(*map); + } printf("Type Start%.*s End%.*s Attributes\n", EFI_PHYS_ADDR_WIDTH - 5, spc, EFI_PHYS_ADDR_WIDTH - 3, spc); @@ -678,7 +687,8 @@ static int do_efi_show_memmap(struct cmd_tbl *cmdtp, int flag, * This is a false positive as memmap will always be * populated by allocate_pool() above. */ - for (i = 0, map = memmap; i < map_size / sizeof(*map); map++, i++) { + for (i = 0, map = memmap; i < map_size / desc_size; + map = (void *)map + desc_size, i++) { if (map->type < ARRAY_SIZE(efi_mem_type_string)) type = efi_mem_type_string[map->type]; else