From patchwork Thu Aug 28 02:07:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 144 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=1756346872; bh=aRbLSOnksHDIhzrmn+875pgUY2Xqp4rMfEWrBT9o+kA=; 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=HeBUqjpAFaMVTWZMH1+Hmv7vwZ183L2OhV+WurkjnzxpjMLDyu6Siwr/t9Jc2klKw h1jxsk8GmzZ1io8FVsPncGhJp4CjBDxkS86EF/TZ6gIzO+f43pOqiXm7kHL5ywM7f6 Aw7ujIKRr2u3DfnStHfNDie0AzJcRGYrUSC6iOiybLyt79jmTZtAWLSgLeNhPV1a50 S3Bey3olklcr0mGqAdYfQxcnHknAK51PGK1ozLxR9VG6+CndaArsNaXe355TnYlBiE Pe/5HidPko8hH1AdFIVFFMeLBj1un6nZr4UBFiP8EsDOs1AL+RSefLCjEn5MVqWPhF pcVNyxZY3l0PQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 29A6C6780B for ; Wed, 27 Aug 2025 20:07:52 -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 24HtJynEjwWG for ; Wed, 27 Aug 2025 20:07:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346872; bh=aRbLSOnksHDIhzrmn+875pgUY2Xqp4rMfEWrBT9o+kA=; 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=HeBUqjpAFaMVTWZMH1+Hmv7vwZ183L2OhV+WurkjnzxpjMLDyu6Siwr/t9Jc2klKw h1jxsk8GmzZ1io8FVsPncGhJp4CjBDxkS86EF/TZ6gIzO+f43pOqiXm7kHL5ywM7f6 Aw7ujIKRr2u3DfnStHfNDie0AzJcRGYrUSC6iOiybLyt79jmTZtAWLSgLeNhPV1a50 S3Bey3olklcr0mGqAdYfQxcnHknAK51PGK1ozLxR9VG6+CndaArsNaXe355TnYlBiE Pe/5HidPko8hH1AdFIVFFMeLBj1un6nZr4UBFiP8EsDOs1AL+RSefLCjEn5MVqWPhF pcVNyxZY3l0PQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 17C7E6777E for ; Wed, 27 Aug 2025 20:07:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346869; bh=FOdozXc4rebyfwvEPg0mnPIVi7C37Ijwk5l6jPIGtD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jB1UnwgmLz+jSFsMPkd4BFRrtG3+HFFhyebanIA06KmVZ/A27aAvhJpJ/I3TJ5op8 xOQ56/2+PbJPxOfTvAkUapv+1EjQkUyw/XI/vop/hDiXOTqg/E3K3jfYg+WUpGh4w3 6n6fOo7uk2N0uEFD2/Hc3Jn3nV3Ef1fcmwhA1mcC1PHBDiy0qPhsG3yfiAR+mld0wz nm+e8QqQ1lIkKvchXd5NnWYJl/JKCXHcooPqPYuJNRNngrV5Dy0DEuOCY8WzN93Mbm 3lFonWhwJcSnq4ICfyrPct6YwBWVYrYiPKxxAmsgcT0/lzinFIRjgoIW9z/qqslxH7 rG5PR9+xPDEiA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CD1E86780A; Wed, 27 Aug 2025 20:07:49 -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 P13C07N57uMq; Wed, 27 Aug 2025 20:07:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346865; bh=VjEiWU1oPFgteenFvkLzz6Kp6AhG2/rQ4tGmYVi0Ryg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jgg2lz1yH6dF+IT10U7Qh5KWeAAjpdiOAHrVcOaRNzI2ghepQ4uVBzHqUJXaYbPGG Orz36AUozKNF0fGfHDqb2aD2muXX6wjmpOfuohyiMR3RA3WJwOdh/AXy3Z6P5HnCdt PpFEBC6reZsqw4V2P4aR0IA1FAlGM7fpMLlvZ6vSdVHc3koGVUISjwyvvMSIZvpj8o Ndubnu/ita0dgxmwunmv5VWW8/KGm28K/oq8ZouWmJZyF2pTuBkQ8Lm6FnyWsfxX/z Kv4DwqIY/tqh2xfk6YlxQcFgnDrXnhxnJyBGYck3l4+Zg7HDdor8Eo9rlfKqYMu/WH tL3whrSXpBthg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7A6776743E; Wed, 27 Aug 2025 20:07:45 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:04 -0600 Message-ID: <20250828020732.981415-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: U7SHMWPLIFPQB4LQB6RIJXVE2MVKAZ3B X-Message-ID-Hash: U7SHMWPLIFPQB4LQB6RIJXVE2MVKAZ3B 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 01/20] efi: Set the efi_media device name when binding 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 Binding a new efi_media device uses a placeholder name which is then changed after the device is bound. But binding the device immediately causes a child block device to be bound, which uses this placeholder name as its base, rather than the eventual name of the efi_media device. To fix, decide on the name earlier (based on the number of existing devices), then pass that name to device_bind() Signed-off-by: Simon Glass --- lib/efi_client/efi_app_init.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/efi_client/efi_app_init.c b/lib/efi_client/efi_app_init.c index 7d30e79528f..b5421dc5a91 100644 --- a/lib/efi_client/efi_app_init.c +++ b/lib/efi_client/efi_app_init.c @@ -50,7 +50,7 @@ int efi_bind_block(efi_handle_t handle, struct efi_block_io *blkio, { struct efi_media_plat *plat; struct udevice *dev; - char name[18]; + char name[18], *str; int ret; size_t device_path_len = device_path_length(device_path); @@ -63,13 +63,20 @@ int efi_bind_block(efi_handle_t handle, struct efi_block_io *blkio, if (!plat->device_path) return log_msg_ret("path", -ENOMEM); memcpy(plat->device_path, device_path, device_path_len); - ret = device_bind(dm_root(), DM_DRIVER_GET(efi_media), "efi_media", - plat, ofnode_null(), &dev); - if (ret) - return log_msg_ret("bind", ret); - snprintf(name, sizeof(name), "efi_media_%x", dev_seq(dev)); - device_set_name(dev, name); + snprintf(name, sizeof(name), "efi_media_%x", + uclass_id_count(UCLASS_EFI_MEDIA)); + str = strdup(name); + if (!str) + return -ENOMEM; + + ret = device_bind(dm_root(), DM_DRIVER_GET(efi_media), str, plat, + ofnode_null(), &dev); + if (ret) { + free(str); + return log_msg_ret("bind", ret); + } + device_set_name_alloced(dev); *devp = dev; return 0; From patchwork Thu Aug 28 02:07:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 145 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=1756346874; bh=CBzvv0IRD0gftzleHgag4HVNaUYIhgVtP/0MS0ve3rg=; 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=esKOPiOXF1xaOn4AKLomwnVhJKvQETHXk8xf+5zbc+HMeqHJC/tyNdNrFIgKGekrg nTsgVapY2xyT+uXOJyVNuiJYCUP07/NVjFZ+V23RzEaSuxfNFXdG0UPtRy9AbHHBKM BnP6UZBBcpcIr7sE4SNKRRA+YFrVwjqEBuHNGFqH9h7BFWJDrZCfcmL0Zd8AmXDREL 8hosuyLFvPITZrOsAmukdsu0AVfKcooJBAgJytnvjmxTJaHyGi1CPI0SRk7bm7RaRF DvJ6QH/7h5p5cs9Upwih7MGeOz3ZK4oI9f+tjTCMuaiQuzB336O9/ezMsv9vsxCgEl zjDcolsHnuTIQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 975C867821 for ; Wed, 27 Aug 2025 20:07:54 -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 BHcI8PWdAP-G for ; Wed, 27 Aug 2025 20:07:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346874; bh=CBzvv0IRD0gftzleHgag4HVNaUYIhgVtP/0MS0ve3rg=; 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=esKOPiOXF1xaOn4AKLomwnVhJKvQETHXk8xf+5zbc+HMeqHJC/tyNdNrFIgKGekrg nTsgVapY2xyT+uXOJyVNuiJYCUP07/NVjFZ+V23RzEaSuxfNFXdG0UPtRy9AbHHBKM BnP6UZBBcpcIr7sE4SNKRRA+YFrVwjqEBuHNGFqH9h7BFWJDrZCfcmL0Zd8AmXDREL 8hosuyLFvPITZrOsAmukdsu0AVfKcooJBAgJytnvjmxTJaHyGi1CPI0SRk7bm7RaRF DvJ6QH/7h5p5cs9Upwih7MGeOz3ZK4oI9f+tjTCMuaiQuzB336O9/ezMsv9vsxCgEl zjDcolsHnuTIQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 72BCE6780A for ; Wed, 27 Aug 2025 20:07:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346872; bh=6U+ToJHf+pYVr2nZ/+gDyZ+2s9meLhJTfdgkz4Wp4F4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TShhOz1hiUkK4vxHhioGXN53y1oFVg/cs0v0CRHssqvIVkZww9IypPU3InhYcJAZG 23H2/NTCq+8e2Chn7rcWWDICId+3JxGfVUaW9DMVa4PDWPUW6tiFNNJQjEJ4PkgZnD Wksi0lysZXT1D+IdSPzdQ1mzdKIH9hbnZNXHSl1VHHSRPB3Sc6VtPRN+yVkKn0TCzW RPkpgQJ/6/3J/J5h5woI1cTr9mJrKvYcwcdR1wVcFs0eUYFq/u4FzWxUElZ+WcWKdL QdGK8Bo3TQ14iGtNWPPwswGP1cqcZO4Z/O9bPLV8Hu6pAjRDjH/EB71xrPJlcf8bg2 MfOp+tGxy6GYg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 066986777F; Wed, 27 Aug 2025 20:07:52 -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 zxEE_HGTV9q3; Wed, 27 Aug 2025 20:07:51 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346870; bh=5goLnHlazoVD0fRtrevSFiYKDxBfNfXnTNjk19kujm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EZw6Zki/Ns0VVTQEbxWWQApWXLt2cBZlx9a6KG85UekjGmMt+LqZ/HxM5m5/VxxvY nQQHPT83+G1VHRQp9W3G03ZpjNEGoLhzxjLeTVSXeOMW7VYSEKWHhqGD0YseJ8H1B8 bGJGPmQcunCbvcULh8qI4lZvlqkkoBgAN4jiVJzLcSnMMwMw6XVgodl8EZpP5LgSNz ecKY/1n55sTwTsVuGWLVINR5kP28tPjZbO2RrjmlYAS4mZ20gvaoa+ImATAOO8R8jd LbIXuNn0sY7d8Qdb4x0b8TgXtXpPU0Oz7xkl2aCm3WyPCb+pPp6bJZrxsF2NQyj+3/ 0YmT3n/kD3ZfQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 17FC26777E; Wed, 27 Aug 2025 20:07:50 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:05 -0600 Message-ID: <20250828020732.981415-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: LCE5UCVQRPGW7FBUDYNSSEPH3NZD6PSC X-Message-ID-Hash: LCE5UCVQRPGW7FBUDYNSSEPH3NZD6PSC 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 02/20] efi: app: Avoid switching exception levels on ARM 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 The EFI app runs under the environment provided to it and is not allowed to change the exception level. Remove this call for the app. Signed-off-by: Simon Glass --- lib/efi_client/app_run.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/efi_client/app_run.c b/lib/efi_client/app_run.c index d2519985c87..03cc29778d8 100644 --- a/lib/efi_client/app_run.c +++ b/lib/efi_client/app_run.c @@ -31,7 +31,8 @@ static efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options) efi_status_t ret; /* On ARM switch from EL3 or secure mode to EL2 or non-secure mode */ - switch_to_non_secure_mode(); + if (!IS_ENABLED(CONFIG_EFI_APP)) + switch_to_non_secure_mode(); /* TODO(sjg@chromium.org): Set watchdog */ From patchwork Thu Aug 28 02:07:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 146 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=1756346877; bh=gazZlT59w9TUlc/e63heGqpvXnsEQiqGmoG1Gc3v7sk=; 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=ZszoR5mwMEn0ADGNkefbKR+NwiuX6wslQaZsnBsYFizjwN4GKQQA7KfiQT2NzYgRH NqC09WyBsz5Bz3HyFOUc8OYXhxSON6+B10izMcHO+17hpgvg+LtZ/FvSqk2Smmfuu/ 6xLYkbpbsdpDz8KTOaMYQXw5Th5N9anztqRn7uc1h6loCKa5d9k5L9UoUn73LOfZvg jTOvGOWsKpsg50OJdO9t5KJsn/T127vrbhg7J+cawJ+yg45YKI8Sq3TaeE22jqGJmP v+LCc6ryYBSdIA4Skk3sL4Z1k4u5UWR0FgJA0iMNXwehut1hEDdn70vqVZ4t56lZeZ j3nT4wHQEkv6g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F33FF6777F for ; Wed, 27 Aug 2025 20:07:56 -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 JVcGRtMITkLf for ; Wed, 27 Aug 2025 20:07:56 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346875; bh=gazZlT59w9TUlc/e63heGqpvXnsEQiqGmoG1Gc3v7sk=; 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=m+FmoleQ7FlnILL1w5SKyyFAUBcUkB8RrXadLbCYZtlxj+ZLLDU/WCwzD4bBMn0Mg 3IxHKw0VnMITQz066V9bupM4FVRsXxbjREn80onvAP3IyBe3jiXSegShKa9+hxlGAZ EttLj2pnvL6q8EJ/rOD4haKKtmHyVe5D7uozyS8aGVwTMEY7/RQAJjvKRqWeV+sBAx kTztRa/GOjUJTkYILjsI9Sn3Y2BTOVfaSJROPcZJiNJwKLAISR627rRrUJoPMRVMMM qZHDl0SXKHwnHyHYXa2BYJLrr5fTHzfDhAyI/pNMJfxqUBkJpycyLOZl3M8n7of6xS fXRpUayxGmnsA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C0B586780E for ; Wed, 27 Aug 2025 20:07:55 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346874; bh=6wm7rTvdm1708xRMhgllRqxp0h01WxKs4dll/yJEJZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XEpq1t/7ObTviMa7wb7RJLe6yyoVaqO8bcFkOpW4VsYXxJawyfwXdt1oSTEiPyVt+ ovKsieGugb0hIxmEuZaynXlFQY8rzzL+vrh+SORu+/8zRTvnVGf94jhot6llGXjpuC ZVSiLZMDTaRXEKb+d6JPfRjhRi2gemhkU9gvhtNoU7BrFkuRsWQQjYv1wdQn5EecTh 63hAaj6+l8FX3wQVRFn39RDXE3ZknMSBm6FV+I3mMXF45WRIQoc9T2mnMbnvQuV9pF gx900RdgbaUOAIDLCjW45248yD2v+melJHRD5ycC7cYD/k3ecYozPAD49xBsvY2khV rJ6Ew5d1DbUyA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6CC99677CE; Wed, 27 Aug 2025 20:07:54 -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 YERtc9wqbatl; Wed, 27 Aug 2025 20:07:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346872; bh=pMp0+oU2xnFH+Oco5Kwqki3N/uv1g44ehMjAwwerkwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QVDnV0Z4fN1rmvSAosfL+1kDfxoUXgYYEaE+F8Nfwv0qLElFrwEI5RSXxCKF1yVll k/uavqQBitxcW01sO9vc3ubvf0zgbUrpWeBgDxePytqtIlSxw9W4LZuhE29nikuJMh gxI6GISApQA2y6FewKJ5K9hdCy0ux1A9b9NHXfK2Fam+dFbIL+GJocJar7/PhENZe8 qUyxdjyHNZwUXSyponLvDERqr1FioZn2MNdYpz19CQNgMtdhrQfGTSSW3coXpRQ0Rr 4oSaztm8rQz3HKKEqUIsvvE0XaT5/Y54s3NMYl9wU9HFycQxUz/sCXrS9pIsEN1aqe lpo7ARdO2RqGA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1A26F6780A; Wed, 27 Aug 2025 20:07:52 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:06 -0600 Message-ID: <20250828020732.981415-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: U42P7H423KNRHM4HTICBVX7AXMRXJYLC X-Message-ID-Hash: U42P7H423KNRHM4HTICBVX7AXMRXJYLC 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 03/20] efi: app: Avoid freeing memory on exit 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 The private data is used to perform the exit, so freeing anything used by the app may cause a hang or crash. The underlying EFI system should be able to free any memory allocated by the app, so just skip the call to free_memory() Signed-off-by: Simon Glass --- lib/efi_client/efi_app.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index 7c9c156e006..f67973dbb85 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -245,7 +245,6 @@ static void efi_exit(void) struct efi_priv *priv = efi_get_priv(); printf("U-Boot EFI exiting\n"); - free_memory(priv); priv->boot->exit(priv->parent_image, EFI_SUCCESS, 0, NULL); } From patchwork Thu Aug 28 02:07:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 147 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=1756346877; bh=W1QJr7d/OTKMNABky2M+ApgIWjSVzhm2SUTl6a5Qvi4=; 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=s5kdbWFbAGEXROE0X9q/yZmP74Fveegj+xaQ/Ix428DW9xLst4CTaOpt847quB/X+ qy893yv3yDBoOkgL6DZREbV8qpS1t7dUVSORecAvKHi0ebY8iNGjGtDJ8yRRtVbPXk NMksdka1q2HHvjUsRjJ4FmpIp/UvSFy4rhtsZ9n0zN757I2ApK7qh9kQ6uXLVMpEPO HDSUqravAieMf9+7+jwEST7Z5J6F/XF/zKgOsU7CLeoitpBPQt+q2PFQ2QtZLuOWZv d3VSHxvNrGMFGqfMbWDLaakHOQYBlG6Bx2bEGOOceexPWpXYkRrC2xpcSEXziaSmmy CsR6hB4ezB6Fg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3D67D677CB for ; Wed, 27 Aug 2025 20:07:57 -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 ykifhaAK4H_A for ; Wed, 27 Aug 2025 20:07:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346876; bh=W1QJr7d/OTKMNABky2M+ApgIWjSVzhm2SUTl6a5Qvi4=; 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=YFYzXMVQDcNtBjqZh+0SaXtzj0qDni6q/VT2i5gTHMywL55QvIzYP25m4D/JcOQcz 9RB3P9EoaDM7QlAr9G8/vVpxl4+m75NoRqePFGpv5+25b/K9mrJjO1afUt2C131CxJ VRRB8TUWdWJuLcJjWCH5/M9X2rCg9PQghHPbQU2+zGp1VIdddun1zhiXyRKSmOQSZd SdSiyrmsYmd1FUtXtqS5V60mD6wXG0UNKhR9YKV+nn2E6AlJO9umLGZ8c6C/M67e3a YjL1B2gTX5yWTv/8yZG5EZh3buxP2Xx/kKaIMmnRAaSqJXm22S+DKhVx0e3Gi291e2 rDawtiKD7j8+Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0BFD567823 for ; Wed, 27 Aug 2025 20:07:56 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346874; bh=LVPVIBwQUqIs1vzQxro/iDIIuFSTUpHih7mHzrF6vEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PlNZh1xNm98rFY8CNwo60Dr4qaLPlHMulET7GjMis6Ij9mf7edueFYN+b+pQgJzXH eKOn40mn7uAVwgoHonGPMLdMMK/OPJdeG7a9L24qhP0za8EelMCjENp4S/f4Fo7Fw8 PQB/+jVSzHjbVxxGwl+VZ6ewVByMz9Cv1M2hEbSvxM56cX2zhzl8D1f2hDyBy03Sbj EcW2RSz5ri/vAd3BzKKu+QNMix+IpiW8r8ZXV0ZvHhZ7VMtjareUCIVsFAPGKTADTi ycRuBRsFuev8CmQ/gbS5enKljGdGkd7vBgsdmoBdscFlwvelO8F+zsrpnVpo0goVSX nTq+JCO5Ut7iw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 775956780C; Wed, 27 Aug 2025 20:07:54 -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 499y9MrE-VV3; Wed, 27 Aug 2025 20:07:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346873; bh=SavHrHsLUAuVBkbW+IJ6yfDTWpNDpU8uiHjYWPXrWsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FR5r265Gn48gRvUp8nT7uhpfI3oU6G8iHP9ecwBvR6bYmH2w8cJmDwF8sQVEqwo55 1V+fTHdsKuhZmhVr/ny3va+XwaPivlR6Q8VhTdyI2j+bnrwJsii9XOxeThmubqhwfF U204LE0IhY9lhb/fgnz5lfkovGQdeMwTwEMNyiSW1pOgPiYkyDtRhUnQtFzfl7wiG5 LLyMMYwLdWbuq98ACk8bFRfByfIPAdHcCrW+yR+BhWtRG30rV8KrMHTs8TF38F4DbR bJkHYKK+/DDTA9wd8Hu2CVwGL2KFsktXXYCKAHFdL0Z98X1so+JneItQc3YmutPzOq RYGsf7mIuZgSg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E216C6743E; Wed, 27 Aug 2025 20:07:52 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:07 -0600 Message-ID: <20250828020732.981415-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: KWHINNP3QYKNVCFBC2JBZIX2EHMJZ54R X-Message-ID-Hash: KWHINNP3QYKNVCFBC2JBZIX2EHMJZ54R 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 04/20] efi: Add a way to show media devices 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 Add a new 'efidebug media' subcommand to show media devices and their device-paths. Signed-off-by: Simon Glass --- cmd/efidebug.c | 43 ++++++++++++++++++++++++++++++++++++++ doc/usage/cmd/efidebug.rst | 21 ++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 1515a508e2d..1d943113054 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include #include @@ -1604,6 +1606,43 @@ static int do_efi_test(struct cmd_tbl *cmdtp, int flag, return cp->cmd(cmdtp, flag, argc, argv); } +/** + * do_efi_show_media() - show EFI media devices + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * Return: CMD_RET_SUCCESS on success, CMD_RET_FAILURE on failure + * + * Implement efidebug "media" sub-command. + * Show all EFI media devices and their device paths. + */ +static int do_efi_show_media(struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) +{ + struct udevice *dev; + struct uclass *uc; + int ret; + + ret = uclass_get(UCLASS_EFI_MEDIA, &uc); + if (ret) { + printf("Cannot get EFI media uclass: (err=%dE)\n", ret); + return CMD_RET_FAILURE; + } + + printf("Device Device Path\n"); + printf("------------------- -----------\n"); + + uclass_foreach_dev(dev, uc) { + struct efi_media_plat *plat = dev_get_plat(dev); + + printf("%-20s %pD\n", dev->name, plat->device_path); + } + + return CMD_RET_SUCCESS; +} + /** * do_efi_query_info() - QueryVariableInfo EFI service * @@ -1670,6 +1709,8 @@ static struct cmd_tbl cmd_efidebug_sub[] = { U_BOOT_CMD_MKENT(images, CONFIG_SYS_MAXARGS, 1, do_efi_show_images, "", ""), U_BOOT_CMD_MKENT(log, CONFIG_SYS_MAXARGS, 1, do_efi_show_log, "", ""), + U_BOOT_CMD_MKENT(media, CONFIG_SYS_MAXARGS, 1, do_efi_show_media, + "", ""), U_BOOT_CMD_MKENT(memmap, CONFIG_SYS_MAXARGS, 1, do_efi_show_memmap, "", ""), U_BOOT_CMD_MKENT(tables, CONFIG_SYS_MAXARGS, 1, do_efi_show_tables, @@ -1772,6 +1813,8 @@ U_BOOT_LONGHELP(efidebug, " - show loaded images\n" "efidebug log\n" " - show UEFI log\n" + "efidebug media\n" + " - show EFI media devices\n" "efidebug memmap\n" " - show UEFI memory map\n" "efidebug tables\n" diff --git a/doc/usage/cmd/efidebug.rst b/doc/usage/cmd/efidebug.rst index 5eca4079f82..90e0b9c4546 100644 --- a/doc/usage/cmd/efidebug.rst +++ b/doc/usage/cmd/efidebug.rst @@ -14,6 +14,7 @@ Synopsis :: efidebug log + efidebug media Description ----------- @@ -21,7 +22,7 @@ Description The *efidebug* command provides access to debugging features for the EFI-loader subsystem. -Only one of the subcommands are documented at present. +Only two of the subcommands are documented at present. efidebug log ~~~~~~~~~~~~ @@ -30,10 +31,28 @@ This shows a log of EFI boot-services calls which have been handled since U-Boot started. This can be useful to see what the app is doing, or even what U-Boot itself has called. +efidebug media +~~~~~~~~~~~~~~ + +This shows a list of all EFI media devices and their corresponding device paths. +Each EFI media device represents a block device that was discovered through EFI +boot services, such as hard drives, USB storage, or other bootable media. The +device path shows the EFI device path for each device, which can be useful for +debugging boot issues or understanding the system topology. + Example ------- +This shows checking the EFI media devices:: + + => efidebug media + Device Device Path + ------ ----------- + efi_media_1 PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x0,0xFFFF,0x0) + efi_media_2 PciRoot(0x0)/Pci(0x5,0x0) + + This shows checking the log, then using 'efidebug tables' to fully set up the EFI-loader subsystem, then checking the log again:: From patchwork Thu Aug 28 02:07:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 148 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=1756346877; bh=+vk+7tT40NYurP2TT3bqu+pXGHgwyBQlXHIHKb0czXI=; 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=a0G+MYeyzQfuAHF2PtaOXKf4NDoU/5MT+QQzYKm/4lExMAaWhgH4gvTId4yiCqLqK pK89Mvs9E8YZ2IPHf1XphkpAHfKREudS08N+7sxSiZz2Uz4aYEsYlUu13yShrMySdY cijQ0XaN1PAmDpxBKVPdX8M0ni5lcSftdqzqdBEkH1W3CvSn/QLs6/+FcfHjJGNZlz 4su8S2aF7WJ0T/uEjWhcVKq1z9mj62hEBCywmEjqXSHrOcYdtXOyktbpFk/tJ+ihN2 HisM84N6r2/gqMjZ/p0djjYKKQGLztZcxY/bfmqJhzz1qGg41dDuBj8y4DSWs30cb1 Fxcda+NcEeh/g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 943546780A for ; Wed, 27 Aug 2025 20:07:57 -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 DX4_9E_CLOEV for ; Wed, 27 Aug 2025 20:07:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346876; bh=+vk+7tT40NYurP2TT3bqu+pXGHgwyBQlXHIHKb0czXI=; 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=D/ew8oRwTbjt5sgryHM/ScwjaSih0KVP7ZzFCuzKxkAlIrGaKOlOcBrYezcZDRIRm WrRpxhrdAfEvtNCfi3MIsu+Z2NcXrnUcP5fIt84suZI3H2z3Ku6U8NiNSoXyBtHw5P RnnDztUOJFgHxaf65nuIUuE3bpkkXqpEeDbPEc5Ce+85xa7xauelvoW2MQo54sMSbj qrRTbgmoWpD0ROVzMx5tS70N3EtC0v5QHtwF2mk22Lj81Xj0FfBon958Qtp9uCbtEz XHqCBC49m4PchyfiT2OL58zbHJUFOhJH+nfnD/4OkN7LUmbAH+w3235InTi9pN6W+E 1KczqGtQXMmog== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BC37D6782A for ; Wed, 27 Aug 2025 20:07:56 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346874; bh=qG8szPDk6Y4JRCDUpvdv5svJSf+eFVKAyXKh/t8fUtM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VS5zw/opy/mGz0i5cgBZ2XcOGaiehiwj9O5JFU25W5mZQ+amQheEFbvP61Debb3LK M6PCEVTP687TLnpXCIvlqQP625uV6qA/wQfMA8kuPwpUJ8oS7DgPEhpKZ3IBoxFWq7 NZ50HbNgzZbjc2wZE49TXzuneeLWFY9QA2ygmErrXqlxjAlgwoOcqv0VSyB7a1m3cN lCA+jxklj9XPdDaaMtt/xETa+r93bify1TtvPWuzfuOgnV/Qo75JotpVJJuo3gEwUY 310MJPGqFGdOK8nNgxtJZWnKcJhSGyoNcRCykDRJJSgbVDNa6yCbQhumCVs3we4U7h rgUYjqR+6EUdg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8DF14677B6; Wed, 27 Aug 2025 20:07:54 -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 qjWFEGXMsY3L; Wed, 27 Aug 2025 20:07:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346874; bh=cF4D15QZ38DUGby8B/kNRZfDMg5HCqwUfP05Cm7+K9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XLLh7SiiQXP2rWFlW1zTMVjjYavRlHP8skBgu95wNaJ94S7443dTKsLMjPdtCDlRN 8KboePTQlFjwAo05Nn15I+4cpILYbyj5Reomj7ojhJTZ793JjYMPdsV0Ad9TlVEiX0 2+lwVX5dPzpuUCHhQziK3RQMPAPRO1p7q8lDhgWk3FB4W+BtRFUIQQ4AoMgUi+Q4UR bzos7SBQ0yjF8uCnLZw+NGGN03nXLnExsvvHXl2hxDfNORViIt/pcyi8Xpzf0uUaDG AtBVy/hT15x7SDg7zUwvxxnXgGyhieV7IlisKRp5gEqhXnVag8DsrWcje/Gxa0o3jy NO02iLaJNj30g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id CA6A96777F; Wed, 27 Aug 2025 20:07:53 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:08 -0600 Message-ID: <20250828020732.981415-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: TQU5Q7XARGQGAVJEJE24E32MQLB6THCK X-Message-ID-Hash: TQU5Q7XARGQGAVJEJE24E32MQLB6THCK 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/20] efi: Add all messaging types for device paths 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 Fill out the rest of these values from the spec, so that we can (later) provide a more useful summary for the user. Co-developed-by: Claude Signed-off-by: Simon Glass --- include/efi_api.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/include/efi_api.h b/include/efi_api.h index 876c1ac2bbe..b3f6172e97a 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -643,20 +643,34 @@ struct efi_device_path_acpi_path { u32 uid; } __packed; -#define DEVICE_PATH_TYPE_MESSAGING_DEVICE 0x03 +# define DEVICE_PATH_TYPE_MESSAGING_DEVICE 0x03 # define DEVICE_PATH_SUB_TYPE_MSG_ATAPI 0x01 # define DEVICE_PATH_SUB_TYPE_MSG_SCSI 0x02 +# define DEVICE_PATH_SUB_TYPE_MSG_FIREWIRE 0x03 +# define DEVICE_PATH_SUB_TYPE_MSG_1394 0x04 # define DEVICE_PATH_SUB_TYPE_MSG_USB 0x05 +# define DEVICE_PATH_SUB_TYPE_MSG_I2O 0x06 +# define DEVICE_PATH_SUB_TYPE_MSG_INFINIBAND 0x09 +# define DEVICE_PATH_SUB_TYPE_MSG_VENDOR 0x0a # define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR 0x0b # define DEVICE_PATH_SUB_TYPE_MSG_IPV4 0x0c +# define DEVICE_PATH_SUB_TYPE_MSG_IPV6 0x0d # define DEVICE_PATH_SUB_TYPE_MSG_UART 0x0e # define DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS 0x0f # define DEVICE_PATH_SUB_TYPE_MSG_USB_WWI 0x10 # define DEVICE_PATH_SUB_TYPE_MSG_SATA 0x12 +# define DEVICE_PATH_SUB_TYPE_MSG_ISCSI 0x13 +# define DEVICE_PATH_SUB_TYPE_MSG_VLAN 0x14 +# define DEVICE_PATH_SUB_TYPE_MSG_FIBRECHAN 0x15 +# define DEVICE_PATH_SUB_TYPE_MSG_FIBRECHAN_EX 0x16 # define DEVICE_PATH_SUB_TYPE_MSG_NVME 0x17 # define DEVICE_PATH_SUB_TYPE_MSG_URI 0x18 # define DEVICE_PATH_SUB_TYPE_MSG_SD 0x1a # define DEVICE_PATH_SUB_TYPE_MSG_MMC 0x1d +# define DEVICE_PATH_SUB_TYPE_MSG_SAS 0x22 +# define DEVICE_PATH_SUB_TYPE_MSG_SAS_EX 0x23 +# define DEVICE_PATH_SUB_TYPE_MSG_UFS 0x19 +# define DEVICE_PATH_SUB_TYPE_MSG_EMMC 0x1c struct efi_device_path_atapi { struct efi_device_path dp; From patchwork Thu Aug 28 02:07:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 149 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=1756346882; bh=YQl0v0nZ/93U8rgJ1V5gGCo1bF+HdF7XLmProrndCEU=; 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=fO5Ak7WikfWCUdOs0WoYubLW40w8sKKJu6b1yzhU/xrX6I+1Sj0ktqkpwq+vse10o suWUPtfUaLXryDWV8expmzSQL8qoLJBP91O7OkXkGijHt5+fhhR3lVbxnxnQtE5O0S 7M529fCWueZKkXJqXMZAzMP6GyuGjLcGaBwUVHR20oCMGoG3LJKOiNgZDV6RR8n1Tq JMpBrRPCZmw46vb+ZMn0icJWZ3z8ucfZn9Z9FgudhL1098F87mRSTFtnFkA4B9pUVM cUXznApbkRe+oSTEtYYEzcsOI3IEUCLbOT2IeRW6VZJHav+qmg1MkZ8bydWYQhfTR2 MuxK2QmkQnjfw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1867E6777F for ; Wed, 27 Aug 2025 20:08:02 -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 DSaCMHYo5mZU for ; Wed, 27 Aug 2025 20:08:02 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346878; bh=YQl0v0nZ/93U8rgJ1V5gGCo1bF+HdF7XLmProrndCEU=; 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=sEnau5vbrrFp+UCbISFC7zR4MLiHlxScnSAS+A/a9tQBHRznkxrLB3Nrt9F5e5+sp dCkrFh3o6BMyzmeyLvkWUZ2pCo+DCxLAg3bFvoHmLrmBXm/8gfDZe4DxEeXO39B92j 7rXkpbpbhqL6j5WNPbHxo0g7kl52bWyB+qKS1y7ZoyyU9ePRPsua1X0UkL5kviQQQQ 1jSfVW0BC1n1S6/ubkUnSu5OdIUvFy7Eo0u1OwVtrtiKVxpPDbp/9Ya3IMU76zvQLY KAMmmhupeYHglCMuz5seVbGXF3uFwcLqEYXer7lcJHUj6rie1kydCg1aE/d27liaAe PcTalrJiJtT3g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7B86E677CB for ; Wed, 27 Aug 2025 20:07:58 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346876; bh=WzqJOvLUjifWz/xpMyWDZfxTj2jZaBS6ZoON0grvcCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PZqGnaZ+PjeWQIOXoUxJSL+pPwYAzGO/MMHNA0ZB/AukPH7cH7epYD3vnDAPUAYXs bLM//8fTBS2VNX1FiSjQ0eUEMahaWk9vCSlFLESApirY9G4EVNdGk/liP4aVQ4sQyf EtIzHYrViOt3zdMRgazgHVBVfz7qtiaSggyc9DvEkWqDWV4vUF8JohCCFZYqfzRaHr XRecN0LEO4/1Sdz9rufZoGrRaxp6ABGoD3P6UgvpOthv3Fb5L3hfpmVyw8Q0oMOLpE LdVmHnsSY6ubx6NzONAF7w57/CFJPQyowX4fC3IF/Cpm1wk1lS82GJrMNSIEX3Y4A0 qpgKhOXxXuIrw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D44D06782C; Wed, 27 Aug 2025 20:07:56 -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 SBsX5mT-8gxs; Wed, 27 Aug 2025 20:07:56 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346875; bh=3Y59aaUIbE857StPd7jLtp9bTVi6UADBsxCvgjLvgG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vw7bwt5WBAjNNExGRIpOcvQHIPwpTQzPqYI/ng9UeC4l2ur2otcez0kTx6SDxU/P1 HVsGRHFZzzreFMeJPL0ulwwRY6NQIbnM1lIFCH6cdOjOAtRuzo5plzmyztJU1BGdFR 9QZHEdPz/tZLEBkpbp2BPAXwCe9/ArPChZDf8N6J5V5cDJePX6GkCAV6dv06qpDwKa yAPwJr5aAPlsg6WFuNF87TL7mkOpkgliNslFTx4Sa2K3SB0NgIOZOYHDBgLcDzZSah F9IW5HEElF7HjSdFkKUDdVwxbVTpiSev6ln32FZTNo5Ke5fII6TRLjjbjCgoWz/lb3 5hirxC1CR8nyA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B96F26777F; Wed, 27 Aug 2025 20:07:54 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:09 -0600 Message-ID: <20250828020732.981415-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: KUJ4HMYSD5BHVF247GL3FNZWL5DLXBCI X-Message-ID-Hash: KUJ4HMYSD5BHVF247GL3FNZWL5DLXBCI 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/20] efi: Convert a device-path to a uclass and name 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 Add a function which looks through a device path and tries to figure out the corresponding name (e.g. 'nvme' and uclass ID. This can be useful for showing a short summary of the device path. Co-developed-by: Claude Signed-off-by: Simon Glass --- include/efi_device_path.h | 11 +++++ lib/efi/device_path.c | 86 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) diff --git a/include/efi_device_path.h b/include/efi_device_path.h index 41b59367762..2e425a6d82b 100644 --- a/include/efi_device_path.h +++ b/include/efi_device_path.h @@ -10,6 +10,7 @@ #include +enum uclass_id; struct blk_desc; struct efi_load_option; struct udevice; @@ -418,4 +419,14 @@ struct efi_device_path *search_gpt_dp_node(struct efi_device_path *device_path); struct efi_device_path *efi_dp_from_http(const char *server, struct udevice *dev); +/** + * efi_dp_guess_uclass() - get the guessed name and uclass from EFI device path + * + * @device_path: EFI device path + * @guessp: Returns the U-Boot uclass ID + * Return: name string + */ +const char *efi_dp_guess_uclass(struct efi_device_path *device_path, + enum uclass_id *guessp); + #endif /* EFI_DEVICE_PATH_H */ diff --git a/lib/efi/device_path.c b/lib/efi/device_path.c index 1dc28f81146..191d58bbd2d 100644 --- a/lib/efi/device_path.c +++ b/lib/efi/device_path.c @@ -1290,3 +1290,89 @@ struct efi_device_path *search_gpt_dp_node(struct efi_device_path *device_path) return NULL; } + +const char *efi_dp_guess_uclass(struct efi_device_path *device_path, + enum uclass_id *guessp) +{ + struct efi_device_path *dp = device_path; + enum uclass_id best_guess = UCLASS_BLK; + const char *best_name = "blk"; + + while (dp) { + if (dp->type == DEVICE_PATH_TYPE_MESSAGING_DEVICE) { + switch (dp->sub_type) { + case DEVICE_PATH_SUB_TYPE_MSG_ATAPI: + *guessp = UCLASS_IDE; + return "ide"; + case DEVICE_PATH_SUB_TYPE_MSG_SCSI: + case DEVICE_PATH_SUB_TYPE_MSG_ISCSI: + *guessp = UCLASS_SCSI; + return "scsi"; + case DEVICE_PATH_SUB_TYPE_MSG_FIREWIRE: + case DEVICE_PATH_SUB_TYPE_MSG_1394: + *guessp = UCLASS_BLK; + return "firewire"; + case DEVICE_PATH_SUB_TYPE_MSG_USB: + case DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS: + case DEVICE_PATH_SUB_TYPE_MSG_USB_WWI: + *guessp = UCLASS_USB; + return "usb"; + case DEVICE_PATH_SUB_TYPE_MSG_I2O: + *guessp = UCLASS_BLK; + return "i2o"; + case DEVICE_PATH_SUB_TYPE_MSG_INFINIBAND: + *guessp = UCLASS_ETH; + return "infiniband"; + case DEVICE_PATH_SUB_TYPE_MSG_VENDOR: + *guessp = UCLASS_MISC; + return "vendor"; + case DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR: + case DEVICE_PATH_SUB_TYPE_MSG_IPV4: + case DEVICE_PATH_SUB_TYPE_MSG_IPV6: + case DEVICE_PATH_SUB_TYPE_MSG_VLAN: + *guessp = UCLASS_ETH; + return "eth"; + case DEVICE_PATH_SUB_TYPE_MSG_UART: + *guessp = UCLASS_SERIAL; + return "serial"; + case DEVICE_PATH_SUB_TYPE_MSG_SATA: + *guessp = UCLASS_AHCI; + return "ahci"; + case DEVICE_PATH_SUB_TYPE_MSG_FIBRECHAN: + case DEVICE_PATH_SUB_TYPE_MSG_FIBRECHAN_EX: + *guessp = UCLASS_SCSI; + return "fibrechan"; + case DEVICE_PATH_SUB_TYPE_MSG_SAS: + case DEVICE_PATH_SUB_TYPE_MSG_SAS_EX: + *guessp = UCLASS_SCSI; + return "sas"; + case DEVICE_PATH_SUB_TYPE_MSG_NVME: + *guessp = UCLASS_NVME; + return "nvme"; + case DEVICE_PATH_SUB_TYPE_MSG_URI: + *guessp = UCLASS_ETH; + return "uri"; + case DEVICE_PATH_SUB_TYPE_MSG_UFS: + *guessp = UCLASS_UFS; + return "ufs"; + case DEVICE_PATH_SUB_TYPE_MSG_SD: + case DEVICE_PATH_SUB_TYPE_MSG_MMC: + case DEVICE_PATH_SUB_TYPE_MSG_EMMC: + *guessp = UCLASS_MMC; + return "mmc"; + default: + break; + } + } else if (dp->type == DEVICE_PATH_TYPE_HARDWARE_DEVICE) { + /* PCI devices could be many things, keep as fallback */ + best_guess = UCLASS_PCI; + best_name = "pci"; + } + dp = efi_dp_next(dp); + } + + *guessp = best_guess; + + return best_name; +} + From patchwork Thu Aug 28 02:07:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 151 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=1756346882; bh=Ch2ze1OMr/sLQuWLv+NULcAs2cuRguOVO5OfpxxfRPo=; 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=RV+pvNLnkJPRLSLYXPMkaZpzL0JD2PSfRLgH66MLIhGAzqK7vTsVrGP49BOoUuVE2 fO/deTinurekzNkpVb+UVDNf2KhbDHt+i3KdamzsMI+aBCIbjaAP4IZjwz6gl8Hpew Rp03prEbrY+/5HkQ3Kpjup0XFO6QU6FU6wy/TntK5Tv0d+C/RGjIS1xokwLBxbKz/c G4DZEEe7hMza3tjyDC3ffmixHyIGyYt6hMDKC+xcsnNr289qsCNEB9JPW9SzVzWCur 0j48bn0SfiUOgmhftF62K2+5qXregjVzYTKcKIektCu/r9w5IuIzgIdPuWeL1iT8wf tXzydgZXnhxPA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D2BD167828 for ; Wed, 27 Aug 2025 20:08:02 -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 Tb5TY6cb1edQ for ; Wed, 27 Aug 2025 20:08:02 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346882; bh=Ch2ze1OMr/sLQuWLv+NULcAs2cuRguOVO5OfpxxfRPo=; 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=RV+pvNLnkJPRLSLYXPMkaZpzL0JD2PSfRLgH66MLIhGAzqK7vTsVrGP49BOoUuVE2 fO/deTinurekzNkpVb+UVDNf2KhbDHt+i3KdamzsMI+aBCIbjaAP4IZjwz6gl8Hpew Rp03prEbrY+/5HkQ3Kpjup0XFO6QU6FU6wy/TntK5Tv0d+C/RGjIS1xokwLBxbKz/c G4DZEEe7hMza3tjyDC3ffmixHyIGyYt6hMDKC+xcsnNr289qsCNEB9JPW9SzVzWCur 0j48bn0SfiUOgmhftF62K2+5qXregjVzYTKcKIektCu/r9w5IuIzgIdPuWeL1iT8wf tXzydgZXnhxPA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ACD896777E for ; Wed, 27 Aug 2025 20:08:02 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346879; bh=88Pp5usihZnlBJ44HFpLBQQ2LaKxhRq8OkYWlaEPWUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hO1zf7RIMZcZbG7EEksFPIVILAbvzTXNmmehpiuvzYt5h5d/gCm8l+HezW4ITbVN3 TfEG90GmNKncnjFxhSff5QNn3S3cQwwa+E9rOxVDj3z3b8onOst18MhGXgCnsWqLyq 4aCXrSWyIJ7g0g4Zo6migV3dgp2HGGmCpCx3EsNCb4SLk0pigDIZy4KEmKYRHHE18i /3hdeLF3ceQt5ebbQ8KobiFrn030F4XBVqinPZhLTAaerTIT2G9Wgpjo1OWmiNJajZ ltByJDI2GV6GolU3usiOXMZf149KGLadu2O0cEqXmEjbVlHnUqmkno2idQSuGY3A2w TZdS109QprkEQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CEC6A67810; Wed, 27 Aug 2025 20:07:59 -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 eA-q10Wqaiyn; Wed, 27 Aug 2025 20:07:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346876; bh=cldvo3RpPsOKljR74dbMxMv28Tgb20t14zwTc7uX5X0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dAtFH6dS7mDUbHABqtfEYTx9UVJ7xfaId8F9J8lWFOmuNK5FwfihrR65AvWmo5Uz5 1aYQ8C/BHYtKBH4bquuYRkTxS2YHxv/ATVcjy0PbK4BEb64dDgQamAcvp6VPWi6DDD yTh7GFV/1KGuT7lC0bD+FKki6M77dBDWeDV+0Jcleie+7uWyrVUOltsoQ95aHKLhyS DiiBsuFz+DpQTqFK14JTxduM8nAFKPhUV+uU5DoZo18tWrAhqMqYDokJbYE040P8ZX GCuC/NxQPTk9oMoldZNPn4XWnDjyzyCU3GTd0ejcwaaXGyEjL8/54PF+1ekl+6gjYi B+fJGwNm6F6Sg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A9B256777E; Wed, 27 Aug 2025 20:07:55 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:10 -0600 Message-ID: <20250828020732.981415-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 4VVESB3TWT7KADQJWHUPZN5DTTAZWIZX X-Message-ID-Hash: 4VVESB3TWT7KADQJWHUPZN5DTTAZWIZX 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 07/20] efi: Add a uclass column to efidebug media command 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 Add a new column to the 'efidebug media' command that shows the likely uclass for each EFI media device based on its device path. This uses the new efi_dp_guess_uclass() function which looks through an EFI device-path to determine the corresponding uclass. Co-developed-by: Claude Signed-off-by: Simon Glass --- cmd/efidebug.c | 10 +++++++--- doc/usage/cmd/efidebug.rst | 21 ++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 1d943113054..9c0b6b084cb 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -1606,6 +1606,7 @@ static int do_efi_test(struct cmd_tbl *cmdtp, int flag, return cp->cmd(cmdtp, flag, argc, argv); } + /** * do_efi_show_media() - show EFI media devices * @@ -1631,13 +1632,16 @@ static int do_efi_show_media(struct cmd_tbl *cmdtp, int flag, return CMD_RET_FAILURE; } - printf("Device Device Path\n"); - printf("------------------- -----------\n"); + printf("Device Media type Device Path\n"); + printf("------------------- --------------- -----------\n"); uclass_foreach_dev(dev, uc) { struct efi_media_plat *plat = dev_get_plat(dev); + enum uclass_id id; + const char *name = efi_dp_guess_uclass(plat->device_path, &id); - printf("%-20s %pD\n", dev->name, plat->device_path); + printf("%-20s %-15s %pD\n", dev->name, name, + plat->device_path); } return CMD_RET_SUCCESS; diff --git a/doc/usage/cmd/efidebug.rst b/doc/usage/cmd/efidebug.rst index 90e0b9c4546..903293ad3d8 100644 --- a/doc/usage/cmd/efidebug.rst +++ b/doc/usage/cmd/efidebug.rst @@ -34,11 +34,14 @@ itself has called. efidebug media ~~~~~~~~~~~~~~ -This shows a list of all EFI media devices and their corresponding device paths. -Each EFI media device represents a block device that was discovered through EFI -boot services, such as hard drives, USB storage, or other bootable media. The -device path shows the EFI device path for each device, which can be useful for -debugging boot issues or understanding the system topology. +This shows a list of all EFI media devices, their likely U-Boot uclass, and +their corresponding device paths. Each EFI media device represents a block +device that was discovered through EFI boot services, such as hard drives, USB +storage, or other bootable media. The U-Boot Class column shows which U-Boot +driver subsystem would likely handle the device (e.g., "ahci" for SATA drives, +"usb" for USB storage). The device path shows the EFI device path for each +device, which can be useful for debugging boot issues or understanding the +system topology. Example @@ -47,10 +50,10 @@ Example This shows checking the EFI media devices:: => efidebug media - Device Device Path - ------ ----------- - efi_media_1 PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x0,0xFFFF,0x0) - efi_media_2 PciRoot(0x0)/Pci(0x5,0x0) + Device U-Boot Class Device Path + ------------------- --------------- ----------- + efi_media_1 ahci PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x0,0xFFFF,0x0) + efi_media_2 pci PciRoot(0x0)/Pci(0x5,0x0) This shows checking the log, then using 'efidebug tables' to fully set up the From patchwork Thu Aug 28 02:07:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 150 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=1756346882; bh=0+1bUYbU4ECedm3fYYzMy4Sh/OO4a+KdpISucIrI7T4=; 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=wk/8rUVr8JO2SvWahudALCnvEcODIyTwCoORgCYcLh1H4bncC7eQfqkkDyck+Nego iUrKW0ybrCp02GR1zo/+UwPd0/ndvj8IDkpvhKPEftfJ09C/q9cC2yBWH3jsacfNdl mVQIJOC5JgfeLZ8K9iDOwphiFd/Gwd3CdLpynu3+RKNnnkcHoXDf0UWJZ+LpoLOG+u CkgIhBfHgZb+dD0A5ULvlzeLtcYDKV+RSD/FHaeeX/YKRQqyfIveicugFmb7iuWTdn T0xsKwfEkwl26FVxMgZekMwSoBW/64oVXPaKt3gDGwp8UiEiOf1KqsaWbliz+8o981 UhKKvvoWyxYKA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6287867823 for ; Wed, 27 Aug 2025 20:08:02 -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 L_s0yAkcbbkk for ; Wed, 27 Aug 2025 20:08:02 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346882; bh=0+1bUYbU4ECedm3fYYzMy4Sh/OO4a+KdpISucIrI7T4=; 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=wk/8rUVr8JO2SvWahudALCnvEcODIyTwCoORgCYcLh1H4bncC7eQfqkkDyck+Nego iUrKW0ybrCp02GR1zo/+UwPd0/ndvj8IDkpvhKPEftfJ09C/q9cC2yBWH3jsacfNdl mVQIJOC5JgfeLZ8K9iDOwphiFd/Gwd3CdLpynu3+RKNnnkcHoXDf0UWJZ+LpoLOG+u CkgIhBfHgZb+dD0A5ULvlzeLtcYDKV+RSD/FHaeeX/YKRQqyfIveicugFmb7iuWTdn T0xsKwfEkwl26FVxMgZekMwSoBW/64oVXPaKt3gDGwp8UiEiOf1KqsaWbliz+8o981 UhKKvvoWyxYKA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 46D32677CB for ; Wed, 27 Aug 2025 20:08:02 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346879; bh=UENNzyBI1NdVP2V+pIZf5H2m+pgNANidKXUlaBQ14Uw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RSez+pz5GnbZv5IdQMPMhXLwIDcin9ZESlKrrh7vSuLrqtx2R82LwFYtwpyLrFjtR lFLDJA4MtZhrf3pMoqISHEjyVLVT4Ctm4BhdbE4Px15wVilAd9iqHDvUBu8e/bjzQj MP5ezdZA3Nb7nG8YT70FbNwZAR/hDjEfEnnv1kc2Ik9JX9EkBPgv++JFjLWp0XiHKe sMoskQ4dIisKj1BItDncZunfvogP7H8DvmtwUKPNPSEiiCo8fim8gdcRPRb7qNVaxD KsS/Ti9ji39oRgA0pOIvlQFfkn/wBaxEBzQfNrIzE5uXbHDm5jP3DO6oyFeYrkA4ar OrrI2yJYvm2GA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CEC566780C; Wed, 27 Aug 2025 20:07:59 -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 aQ9iqxbNuyoo; Wed, 27 Aug 2025 20:07:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346876; bh=WOXsOV6STCKaXYQiPkS8oMgxlErU+wE6DgRGdDpstyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ekdiMDTVATKzq2/6DqU28JFVDxfS2cyjcqY6WOBceN6ZPZMvRxkYFLunlwkniotLT EO2yoQeHtE58MClBnNzcQ6Ivg/lV6ISToklcs325QuDbCL/AxaE/BUaFINt41uFtqK LQfM1BPJi9z/7oL0hPd+C2f+ZrQXiqUCuTe5ZHIbTDFi+xUGGDach/Iab9xlDRVc4Y w/evSdkLpcAsKoxQ1GW3Cpo7RLxM+iOKPbKOTPCGaCl7Y1LYdJ06+6Gp8KJ4wXLrPo m7QGQfXbvtk5VIp4V5EGcnqQEK1QpmyxBw531REKPzvGwK0j5IglX6dLqMCdimC2J3 vZttzyftrkFJA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9B7D767829; Wed, 27 Aug 2025 20:07:56 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:11 -0600 Message-ID: <20250828020732.981415-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 4IC72EU6OIHP5P5C4SQ4YZ4LLBBPKWEQ X-Message-ID-Hash: 4IC72EU6OIHP5P5C4SQ4YZ4LLBBPKWEQ 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 08/20] efi: Implement efidebug show drivers in the app 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 Adjust the code slightly to support the final subcommand in efidebug that is currently unavailable in the app: 'efidebug drivers'. Drop the now-unused app_not_supported() function. Signed-off-by: Simon Glass --- cmd/efidebug.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 9c0b6b084cb..f88da42c2c4 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -28,16 +28,6 @@ #include #include -static bool app_not_supported(const char *cmd) -{ - if (!IS_ENABLED(CONFIG_EFI_APP)) - return false; - - printf("Command '%s' is not yet supported in the app\n", cmd); - - return true; -} - #ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT /** * do_efi_capsule_update() - process a capsule update @@ -372,7 +362,7 @@ static const char sep[] = "================"; static int efi_get_driver_handle_info(efi_handle_t handle, u16 **driver_name, u16 **image_path) { - struct efi_handler *handler; + struct efi_boot_services *boot = efi_get_boot(); struct efi_loaded_image *image; efi_status_t ret; @@ -383,13 +373,13 @@ static int efi_get_driver_handle_info(efi_handle_t handle, u16 **driver_name, *driver_name = NULL; /* image name */ - ret = efi_search_protocol(handle, &efi_guid_loaded_image, &handler); + ret = boot->handle_protocol(handle, &efi_guid_loaded_image, + (void **)&image); if (ret != EFI_SUCCESS) { *image_path = NULL; return 0; } - image = handler->protocol_interface; *image_path = efi_dp_str(image->file_path); return 0; @@ -410,17 +400,15 @@ static int efi_get_driver_handle_info(efi_handle_t handle, u16 **driver_name, static int do_efi_show_drivers(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { + struct efi_boot_services *boot = efi_get_boot(); efi_handle_t *handles; efi_uintn_t num, i; u16 *driver_name, *image_path_text; efi_status_t ret; - if (app_not_supported("show_drivers")) - return CMD_RET_FAILURE; - - ret = EFI_CALL(efi_locate_handle_buffer( - BY_PROTOCOL, &efi_guid_driver_binding_protocol, - NULL, &num, &handles)); + ret = boot->locate_handle_buffer(BY_PROTOCOL, + &efi_guid_driver_binding_protocol, + NULL, &num, &handles); if (ret != EFI_SUCCESS) return CMD_RET_FAILURE; From patchwork Thu Aug 28 02:07:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 152 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=1756346883; bh=RlVxRo5VFxVyj2YMIkPLOVtYVyLqAIzOjPIdnJWBqY8=; 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=j/sZR+T7hXoAt6qdSghMGhkMsQajlFYwcm2P5t2aUEQcdmSW6YjZUZFr8T4uMomFi 3jeU1xYpatZwIsUjmAHgkKHOf6n8lYpJRN8/jv+UcAwI2pyadkSS0oUNtLR5zpcKr3 OF13d6kaaOz8MgiJlVLZcZNG2XQeJP6btC+T6ymE2myl3MAjiKouTNQNOcR7NoDT7e ISF15lGwOtcsBfZPHcEIBBiubf2qL5tykDojznCFR2D9BA/xNnPwD7PulpwHIgdzIi QpFyVLPF9U3hCtz1G6sVqW6+g61XqxAHbJptNb7UOHWBhI2aZNNtKpSDIqf0OpoY2e kAPKMWhT2om1g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 56C9A6777F for ; Wed, 27 Aug 2025 20:08:03 -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 MWaERCycPoZH for ; Wed, 27 Aug 2025 20:08:03 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346883; bh=RlVxRo5VFxVyj2YMIkPLOVtYVyLqAIzOjPIdnJWBqY8=; 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=j/sZR+T7hXoAt6qdSghMGhkMsQajlFYwcm2P5t2aUEQcdmSW6YjZUZFr8T4uMomFi 3jeU1xYpatZwIsUjmAHgkKHOf6n8lYpJRN8/jv+UcAwI2pyadkSS0oUNtLR5zpcKr3 OF13d6kaaOz8MgiJlVLZcZNG2XQeJP6btC+T6ymE2myl3MAjiKouTNQNOcR7NoDT7e ISF15lGwOtcsBfZPHcEIBBiubf2qL5tykDojznCFR2D9BA/xNnPwD7PulpwHIgdzIi QpFyVLPF9U3hCtz1G6sVqW6+g61XqxAHbJptNb7UOHWBhI2aZNNtKpSDIqf0OpoY2e kAPKMWhT2om1g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 105A1677CB for ; Wed, 27 Aug 2025 20:08:03 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346879; bh=jyt+eky56MoqReQoheAZtzb4elpeFnyrU8z7PKui6L4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZJoPId+cPqjBxDg50k0mFECR3WiJL2csQbWEUkk1sr+1k0zjXnXIF9pd4wE6gaTaa 8GOCWSRv2nxi79xEZz3s/bIi9ytm0z5fWnEKrd5LIvKQa4XepoAQk39LLg7W2O0zSk Z9KcEirqSkAMtfY4iciJB5VvqtnlHmP6RVk07+IoUUzscF7I5832JQbVGB36ndxWBD 3y4apqtFcmaEmXG+p+wQrO4FEoX08FthEDxY88qfI2S5ZSu9/Heme3Ur5HoUYEvsAY j6sLlX4fPnCgnn7yYAfNz2nt+ENuy2fV6sHFhjBo9Go/mu8/c9Pgn0HD8XhdDE8QMm iiwPbaKVxRFtw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E3F2B6777E; Wed, 27 Aug 2025 20:07:59 -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 IYqCVgu_MwXZ; Wed, 27 Aug 2025 20:07:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346877; bh=XIJnMo569q/5KH6EnMqtJyXl6QGB8vM8no3a5tciPwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PwCpD3GkEW/pplgUmP8QSI39N7lZXUSd++/oL4FA6LJ5xY9giF9gRMPr10dllEFXO oyLYAATz48Llm2u1C0Dcxlqi8xJIRTooGFq+4ZzqYl2LBl043oXAjtp89OlFnWsiCJ 9k5Pwk1ZlC7hP2isA8cijYqLksJzigTsmn8PMQRk8LFRL3uuFiPFfEt1zj8YJ7gwyP 2nim/+gUmcU4nFg6doany2YGFQgtonol7ta54QOjGnKYxdlQ3jMqwZOIcgU756wLxq OnZ/Qr0VwlagSnGOMOX4rJ/v/USGFoR//phJzbqQDyK85d4mF7EMhGjmCBDOSVY6Ta +KqVES4/+p6WQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9D56467823; Wed, 27 Aug 2025 20:07:57 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:12 -0600 Message-ID: <20250828020732.981415-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 7BZRNZDPDRKE4DMD6GBJKENQNXQZPLTO X-Message-ID-Hash: 7BZRNZDPDRKE4DMD6GBJKENQNXQZPLTO 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 09/20] boot: Correct filename in bootmeth_common_read_file() 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 This should add the filename provided to the image, not the original bootflow filename. Fix it. Signed-off-by: Simon Glass Fixes: 114dd14e38d ("bootmeth: Update the read_file() method to...") --- boot/bootmeth-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index 6c0eff7579d..8c191082cf3 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -437,7 +437,7 @@ int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow, return ret; *sizep = len_read; - if (!bootflow_img_add(bflow, bflow->fname, type, *addrp, size)) + if (!bootflow_img_add(bflow, file_path, type, *addrp, size)) return log_msg_ret("bci", -ENOMEM); return 0; From patchwork Thu Aug 28 02:07:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 153 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=1756346887; bh=H15k7AWv2SQgj/yFJZnIJjLsSvg9FT7x1JTl8GBN4uI=; 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=QFKPTt5xr295vYgIYy7lSOmUON5iBjrsluPKsE3jgtLEHCQGHaHE5pRNPhvhl2K4M HnkjkKJZfhYVU5nfe64vr48wGO0CQQ3FwwtwShyFn3mfaaFwBohbUCBb1tDg8yMgDu Ox2mZQ9tESV4rQsgxjxNYfyb+RjpPlVAR5aVJLYfN7jFGTXGY4iXcP8ZyRga+VI2yz Fqvg68v3ZknNd5Cpc+OD1yCF+iR0Ya7lrd3IeGvm/md2GXTn66YiRo4zRBV4qz6W/G yLwEtUjazidL9EwVvW33dF4ihxg1oSVK7JiA8HqalwNpCsrAqAsrofG3L1D/8oEX2t UIJP7cpm+VAgw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E3997677B6 for ; Wed, 27 Aug 2025 20:08:07 -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 T50dUAnZ3Sqo for ; Wed, 27 Aug 2025 20:08:07 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346887; bh=H15k7AWv2SQgj/yFJZnIJjLsSvg9FT7x1JTl8GBN4uI=; 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=QFKPTt5xr295vYgIYy7lSOmUON5iBjrsluPKsE3jgtLEHCQGHaHE5pRNPhvhl2K4M HnkjkKJZfhYVU5nfe64vr48wGO0CQQ3FwwtwShyFn3mfaaFwBohbUCBb1tDg8yMgDu Ox2mZQ9tESV4rQsgxjxNYfyb+RjpPlVAR5aVJLYfN7jFGTXGY4iXcP8ZyRga+VI2yz Fqvg68v3ZknNd5Cpc+OD1yCF+iR0Ya7lrd3IeGvm/md2GXTn66YiRo4zRBV4qz6W/G yLwEtUjazidL9EwVvW33dF4ihxg1oSVK7JiA8HqalwNpCsrAqAsrofG3L1D/8oEX2t UIJP7cpm+VAgw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D0DDC6777E for ; Wed, 27 Aug 2025 20:08:07 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346885; bh=wyswUlvWuQKbY864wSAiE9lgAZJKbp4wyEGLZW0JzQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WLMDbOyTaIOwpsjHGPghh29g4tU0fYUPU5E6D3WAA8PUz79mCQ5YMMK5CmknTufRh 7DfSlh6RJ4S31CiecXY2bsplJidH0W16Xj6dKXDCns3F4gTLczoJ9USIcoeIk7bYml 04IOWN9XdvMPyJNpqq8mQV6cqlQ0gzHGpEg3jYmmIY20VRt8/MlH07ZJFXjyjlx4dS QLLUasyc8VWVdhnLUD97iIykv6/9PaIAhHj3Nd2zPd5El2sw7pVtiWWD7MtnkPjjZF IOE4vVrpSRW8ue0qsav/WWp37ARCect5Yv40bW9biCJ8SpQ8QffOWOecWsskKK9qTy SKHBthAJN7bIA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A26EC6777F; Wed, 27 Aug 2025 20:08:05 -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 cv0d86qU7QHx; Wed, 27 Aug 2025 20:08:05 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346878; bh=yZkFoJGjMt59yO64C0kOUu/vKxpLHA77hfPyG/ZyMZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gBKnfYFLfy3InwbbM+27eSc8wx7DOKIsR+EBUe2AWQj8dwahIiZCzh+XrFRF8JJpK Vxg0TEkXFyDQyV1kWHbSYQtk7fZmUyck6KWThYNE4J1wqwvPz0M+/kInzIcg4LJOgb hdWOO2y32TuUbH0ecAo7fPsmtc9vZYr4QzbBiZ2MaNeMr04KBuIWvaY1tNYwCkRSZV MsWmJHgBWlhqAuNykNi9+Er0mO2BhTJcE1TzBZ3AkEFGsEZl5Yb6zsfwtMwAI8/wmJ iUb/ElxxJVD5H1TrMAxrHnvQhcKAXReu/44JczawNtN0oLSbDtO4x0XwYxq4dOt6fZ O4F9ch4mC3wnA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 70A10677B6; Wed, 27 Aug 2025 20:07:58 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:13 -0600 Message-ID: <20250828020732.981415-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: NUWOEOJLVM2I36UWHKLCZ3AVHOQQO6UM X-Message-ID-Hash: NUWOEOJLVM2I36UWHKLCZ3AVHOQQO6UM 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 10/20] boot: Show the device path for EFI bootflows 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 If the bootflow relates to the EFI bootmeth, show the device path along with the other info. Signed-off-by: Simon Glass --- cmd/bootflow.c | 17 +++++++++++++++++ include/efi.h | 15 +++++++++++++++ include/efi_device_path.h | 14 ++++++++++++++ lib/efi/device_path.c | 37 +++++++++++++++++++++++++++++++++++++ lib/efi_client/app_run.c | 18 ++++++++++++++++++ 5 files changed, 101 insertions(+) diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 464c3e40475..ae692cf521b 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -453,6 +454,22 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc, printf("FDT addr: %lx\n", bflow->fdt_addr); } printf("Error: %d\n", bflow->err); + if (IS_ENABLED(CONFIG_BOOTMETH_EFI) && + bflow->method->driver == DM_DRIVER_GET(bootmeth_4efi)) { + struct efi_device_path *dp; + bool alloced; + + ret = efi_dp_from_bootflow(bflow, &dp, &alloced); + printf("EFI path "); + if (!ret) { + printf("%pD\n", dp); + if (alloced) + efi_free_pool(dp); + } else { + printf("(err %dE)\n", ret); + } + } + if (dump && bflow->buf) { /* Set some sort of maximum on the size */ int size = min(bflow->size, 10 << 10); diff --git a/include/efi.h b/include/efi.h index 3558c03db23..c07717811da 100644 --- a/include/efi.h +++ b/include/efi.h @@ -23,6 +23,8 @@ #include #endif +struct udevice; + /* Type INTN in UEFI specification */ #define efi_intn_t ssize_t /* Type UINTN in UEFI specification*/ @@ -848,4 +850,17 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size, struct efi_device_path *dp_dev, struct efi_device_path *dp_img); +/** + * efi_dp_from_bootdev() - Get the device path from a bootdev + * + * This is only available in the app. It looks up the bootdev and returns the + * assocated device path (attached to its sibling block device) + * + * @dev: UCLASS_BOOTDEV device to check + * @dpp: Returns device path on success + * Returns: 0 if OK, -ve on error + */ +int efi_dp_from_bootdev(const struct udevice *dev, + const struct efi_device_path **dpp); + #endif /* _LINUX_EFI_H */ diff --git a/include/efi_device_path.h b/include/efi_device_path.h index 2e425a6d82b..d030674d6bd 100644 --- a/include/efi_device_path.h +++ b/include/efi_device_path.h @@ -12,6 +12,7 @@ enum uclass_id; struct blk_desc; +struct bootflow; struct efi_load_option; struct udevice; @@ -429,4 +430,17 @@ struct efi_device_path *efi_dp_from_http(const char *server, const char *efi_dp_guess_uclass(struct efi_device_path *device_path, enum uclass_id *guessp); +/** + * efi_dp_from_bootflow() - Get the device path for a bootflow + * + * @bflow: Bootflow to check + * @dpp: Returns the device path + * @allocedp: if NULL, no allocation is permitted, otherwise retrusn true if + * efi_free_pool() must be called to free the device path + * Return: 0 if OK, -EINVAL if @allocedp is NULL and allocation is needed, + * -ve on error + */ +int efi_dp_from_bootflow(const struct bootflow *bflow, + struct efi_device_path **dpp, bool *allocedp); + #endif /* EFI_DEVICE_PATH_H */ diff --git a/lib/efi/device_path.c b/lib/efi/device_path.c index 191d58bbd2d..bae9e5c537a 100644 --- a/lib/efi/device_path.c +++ b/lib/efi/device_path.c @@ -8,6 +8,7 @@ #define LOG_CATEGORY LOGC_EFI #include +#include #include #include #include @@ -1376,3 +1377,39 @@ const char *efi_dp_guess_uclass(struct efi_device_path *device_path, return best_name; } +int efi_dp_from_bootflow(const struct bootflow *bflow, + struct efi_device_path **dpp, bool *allocedp) +{ + struct udevice *bdev = bflow->dev; + struct blk_desc *desc; + struct udevice *blk; + int ret; + + if (IS_ENABLED(CONFIG_EFI_APP)) { + const struct efi_device_path *dpc; + + ret = efi_dp_from_bootdev(bflow->dev, &dpc); + if (ret) + return log_msg_ret("dfa", ret); + *dpp = (struct efi_device_path *)dpc; + if (allocedp) + *allocedp = false; + } else { + struct efi_device_path *dp; + + if (!allocedp) + return log_msg_ret("dfb", -EINVAL); + ret = bootdev_get_sibling_blk(bdev, &blk); + if (ret) + return log_msg_ret("dfc", ret); + + desc = dev_get_uclass_plat(blk); + dp = efi_dp_from_part(desc, bflow->part); + if (!dp) + return log_msg_ret("dfd", -ENOMEM); + *allocedp = true; + *dpp = dp; + } + + return 0; +} diff --git a/lib/efi_client/app_run.c b/lib/efi_client/app_run.c index 03cc29778d8..9fc753ceed8 100644 --- a/lib/efi_client/app_run.c +++ b/lib/efi_client/app_run.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -89,3 +90,20 @@ efi_status_t efi_binary_run_dp(void *image, size_t size, void *fdt, { return efi_run_image(image, size, dp_dev, dp_img); } + +int efi_dp_from_bootdev(const struct udevice *dev, + const struct efi_device_path **dpp) +{ + const struct udevice *media = dev_get_parent(dev); + const struct efi_media_plat *plat; + + log_debug("dev '%s': uclass ID %d\n", media->name, + device_get_uclass_id(media)); + if (device_get_uclass_id(media) != UCLASS_EFI_MEDIA) + return log_msg_ret("efb", -ENOTSUPP); + + plat = dev_get_plat(media); + *dpp = plat->device_path; + + return 0; +} From patchwork Thu Aug 28 02:07:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 154 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=1756346888; bh=zK2n6mvdpi9oRr/urGeozkVKPwBqfrybZpp6wKcuc7s=; 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=i6UBmUZV3goAlq/M0X2WxFQSxMqJVz7g3V7YsbAwRCCMWy08YVCQhe27+Dq4n+5sC Sv2ThNXMPyt8cFr7OzqcrIZGUCTED5KzDErGfvmNGU4CGPO+hksmCDAzygdd/GrUoM VWuEWZa3pgVzeCsIhPPnBaKBv0FilfmOleU3PX6ZJyvENLnOfx1YkXi+ySQM/V8ZYa rwma0GodcZYkZikl/JUrpHiqbUPJY0eZJ8Scxv9g+Zk7DK0qbIRlWPU7D8EqR5ONk6 U8kNvKjiBM9Ve8S+E2v+AXC7kxcPFLZ2lrH9f3XglFmzQaRmxDHgmjYS7MpWaW5BGB PEiQe3WgtfX3g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EB53C6780C for ; Wed, 27 Aug 2025 20:08:08 -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 DdGQ_SnBR68O for ; Wed, 27 Aug 2025 20:08:08 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346888; bh=zK2n6mvdpi9oRr/urGeozkVKPwBqfrybZpp6wKcuc7s=; 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=i6UBmUZV3goAlq/M0X2WxFQSxMqJVz7g3V7YsbAwRCCMWy08YVCQhe27+Dq4n+5sC Sv2ThNXMPyt8cFr7OzqcrIZGUCTED5KzDErGfvmNGU4CGPO+hksmCDAzygdd/GrUoM VWuEWZa3pgVzeCsIhPPnBaKBv0FilfmOleU3PX6ZJyvENLnOfx1YkXi+ySQM/V8ZYa rwma0GodcZYkZikl/JUrpHiqbUPJY0eZJ8Scxv9g+Zk7DK0qbIRlWPU7D8EqR5ONk6 U8kNvKjiBM9Ve8S+E2v+AXC7kxcPFLZ2lrH9f3XglFmzQaRmxDHgmjYS7MpWaW5BGB PEiQe3WgtfX3g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D2EDA677B6 for ; Wed, 27 Aug 2025 20:08:08 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346885; bh=H2c1zW5JBBcutlYadOrdzNU8ato/R/F+1h+wG+tk4fw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mBCV/drq8Eu0Db7b28zp0TqWh+ntNO862yy57vhK7XekT51aPty+0CxwThJNv6yrz RkIRV/U8XHFTx91s3XnoskWDepBflFBiMBKqVv4PWif2bQGQHt7G/eLxFePeGEAOmE G6ua0AluxM/cPj34cl0NYQlA3M6zNJOzl9enrJK1e0qv5Y3YIxNSPqSxXGmkGOC93I fq8MeYvxNknaVH13bsAzs8ZbJuO9Y7LbnhJ562pFP1fwfIg8S/Tiec8bE/UL011W9l YJJUJ8uOOfVQ7icTIjhVO9qxW7lk5xaRdSRCpyehVpE3KNgFOorjNytod6ttciSeiI jq7JJrb+wxTnA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AAC97677B6; Wed, 27 Aug 2025 20:08:05 -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 8De1oLUt1d94; Wed, 27 Aug 2025 20:08:05 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346879; bh=sqcjKa7EXZXhCgTruaMpc+MLnABYbjtjht8iFYLNtFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tHH2chpRA4VWFo8flM6Lu8lau03XD2fQxSEvJSt3bAEvkTE61unlWU10Mi1tTcg7y W6+bkhNQCQTalhN3bhW0xy/qhqklW3WfNhl1s9Ue0+2hF0Q6V80IX5mXFwWhdR90Qn /8c3o1wH3tQjeCghioYJd61H15hBi/dd3LmlFJT5uvggQ8lisB1Q/B3OFaeMM5Jkpd Z1mFAn0m3RvUENyK4Wp2EpqAxH85/GQ3MJn9ln1Sw2oXcIcukgShxAR15yLZcieAg/ ImBnlgRKAaY429YxEN5ojJ9Ezb0gN/2huD4EPVUTmejElZt2jl2ersxmkoXkOKssPf iZTzq1x3BTjKA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 509696743E; Wed, 27 Aug 2025 20:07:59 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:14 -0600 Message-ID: <20250828020732.981415-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: OXK5AYPLCDM4JOPEUWDS4PCYKOORBJLS X-Message-ID-Hash: OXK5AYPLCDM4JOPEUWDS4PCYKOORBJLS 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 11/20] boot: Show the underlying bootflow device in the app 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 Within the app all media devices are 'efi' so it isn't useful to show that as the media. Look up the media-type of the underlying device, e.g. 'usb' or 'nvme'. This is a lot more helpful, and can make it easy to see which bootflows relates to internal media and which to external, for example. Signed-off-by: Simon Glass --- cmd/bootflow.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cmd/bootflow.c b/cmd/bootflow.c index ae692cf521b..20fc04bdda3 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -70,11 +70,26 @@ static void report_bootflow_err(struct bootflow *bflow, int err) */ static void show_bootflow(int index, struct bootflow *bflow, bool errors) { + const char *name = NULL; + + if (IS_ENABLED(CONFIG_EFI_APP)) { + struct efi_device_path *dp; + enum uclass_id id; + int ret; + + ret = efi_dp_from_bootflow(bflow, &dp, NULL); + if (!ret) + name = efi_dp_guess_uclass(dp, &id); + } else if (bflow->dev) { + name = dev_get_uclass_name(dev_get_parent(bflow->dev)); + } + if (!name) + name = "(none)"; + printf("%3x %-11s %-6s %-9.9s %4x %-25.25s %s\n", index, bflow->method ? bflow->method->name : "(none)", - bootflow_state_get_name(bflow->state), - bflow->dev ? dev_get_uclass_name(dev_get_parent(bflow->dev)) : - "(none)", bflow->part, bflow->name, bflow->fname ?: ""); + bootflow_state_get_name(bflow->state), name, bflow->part, + bflow->name, bflow->fname ?: ""); if (errors) report_bootflow_err(bflow, bflow->err); } From patchwork Thu Aug 28 02:07:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 155 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=1756346891; bh=zz+nP41NTcwfVTCY/K3IigGuObtnpTmRfxAzsxQxC2E=; 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=Bsz3H0L6CZec/ekXsFP3MNiqLIfKbz7kcR4azkrVIQxcFHsKJO5abpgfCrTPuVebB qa+ZPF9eRScqMry3y8/IWtfAsdJHngtlBLh4N5wEvPfra/F+kYe0e52CSP+ALf5o8e yUVfL17XONu2Agep3LppEe7nehO+ZKigDaIepcUkLUY6CcKikQpORgmmtg/KgzRQRk rZH5LuXcQju2yJNGgmFOlpDpHE5RqDZ10unElK1ztbqcRBpX0I893Tlld6DJewKDn1 gb/yxQISgyfXYXjeVUcspyxrcWgndPIhJbnGuy2s5CSBK5cP64KcxKnr3DqXDfd+6u pH4KJBkloelDQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3A8DE6783B for ; Wed, 27 Aug 2025 20:08: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 0wFKRq10_0xj for ; Wed, 27 Aug 2025 20:08:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346889; bh=zz+nP41NTcwfVTCY/K3IigGuObtnpTmRfxAzsxQxC2E=; 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=NeNTEz5rbVlN56zJPNg7loun96/0aXuwMyJjfSMETxDj3p0b8mvJWzFRt8Goc/4ki vVpjmhIttdYsTmU2vNj703BSZmNoXq4f+yOeuQ4kGgMk8HQMaNp7C4kSuYgna1osY6 6hP7vMpgg4ffwcv5MRZlk0y3903AN2sZEgOAhjtsFjUMzL1/KpLYzMVSkILnwNbx+H rtJQGqh7T7ZvEpajhmORzi7H2t8zUs9gryjHzgs4zC9pgXZ8ToWG/GDI3vThmyd6vG B1SIin9v5Z/NXvi+eDs6vSCZtLnNgv+PZvwIbiYARJIIPxtUS0y9zyCL+As2n2Hnx9 cSEHoK8YyNhYw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3654367829 for ; Wed, 27 Aug 2025 20:08:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346885; bh=h6XaJqxEsfsFvsgl695GPlZGzLoord17ShoESiWe21Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FeZ9KMbPaw/yxEdKxdE2JmFQ8oVPIcMO8SrtFi8wecKeAONEj4RSJ5LUefQV/2gzB wYcXu4WqdRza1qLZ/zNSchM0m9vcsTK4MeQo98xLfrOENbiXQsQ2MBFJRHZ1y9ehvI P+SKKCuldSX/Hq6qY6jO4nRwnAJhlAKnZOz8CadUazcP1MEqewy2sxgDX/V3J80DE7 WIKNmqcvAy0i8WDSQViRl7cNhYZQceEUnq7F3nbVYJJSSECvlGkphiwqkiZbINM2wh 3aqNh9WKAO6oqIdCpH979aWLrwL7Hqf4xh9UtmRcw4IQzS6qBOxRWxM7dLFYSh3le0 B8TWchJLHvnHA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BF1A06743E; Wed, 27 Aug 2025 20:08:05 -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 rkW6O4U0SN2B; Wed, 27 Aug 2025 20:08:05 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346884; bh=zMZU542tShLwYlEnq0QIcJsWakJezkZob2oCC7WSrEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jShBV68LDA9T1O1eBbt+ab/UTrJvbHRhb6G5+/Iq80IA207n5Fzdj2sHQe4+0DKJh PlsVHdUPNBk0EjXeBjXZhE9VnYnUud+ABSWt/w0x8J+/Cc4YwSuQjf2Ojo36qbtRqu B9SHQY23UQDMNBNMgqk7LtDdaW7GT1SDVtrRTTDGq4Uc/qDK8BQiV/9dwfOVEpFS4R w7E9HB+k9vqaRQzOkbvzugnmG2lRM9Sc268P4RlcIMJZM7VvY8q1BmHmgAqF9iVtAO 06sN5krV3zi//uy+njHVETdI6z5hth9CA0HCIUAEssP+WQ6VDPtHt3VzVHc/Wjp9If 0nH1D72qLUWtA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id DC8D86777E; Wed, 27 Aug 2025 20:08:03 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:15 -0600 Message-ID: <20250828020732.981415-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: IDDEVB2IFSEF4FN7APFERYSEFBHGJKFA X-Message-ID-Hash: IDDEVB2IFSEF4FN7APFERYSEFBHGJKFA 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 12/20] efi: Use abuf when reading EFI variables 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 The abuf interface provides a nicer abstraction of the data and size of EFI variables. Create a new efi_read_var() function and export it so it can be used elsewhere. Adjust the existing efi_dump_single_var() to use it. Signed-off-by: Simon Glass --- cmd/nvedit_efi.c | 62 ++++++++++++++++++++++++++++++++---------------- include/efi.h | 15 ++++++++++++ 2 files changed, 56 insertions(+), 21 deletions(-) diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c index 5616e73bcfd..45d6a8ef67a 100644 --- a/cmd/nvedit_efi.c +++ b/cmd/nvedit_efi.c @@ -5,6 +5,7 @@ * Copyright (c) 2018 AKASHI Takahiro, Linaro Limited */ +#include #include #include #include @@ -50,6 +51,36 @@ struct var_info { efi_guid_t guid; }; +int efi_read_var(const u16 *name, const efi_guid_t *guid, u32 *attrp, + struct abuf *buf, u64 *timep) +{ + efi_uintn_t size; + efi_status_t eret; + u32 attr; + u64 time; + + abuf_init(buf); + size = 0; + eret = efi_get_variable_int(name, guid, &attr, &size, NULL, &time); + if (eret == EFI_BUFFER_TOO_SMALL) { + if (!abuf_realloc(buf, size)) + return -ENOMEM; + + eret = efi_get_variable_int(name, guid, &attr, &size, buf->data, + &time); + } + if (eret == EFI_NOT_FOUND) + return -ENOENT; + if (eret != EFI_SUCCESS) + return -EBADF; + if (attrp) + *attrp = attr; + if (timep) + *timep = time; + + return 0; +} + /** * efi_dump_single_var() - show information about a UEFI variable * @@ -63,30 +94,19 @@ struct var_info { static void efi_dump_single_var(u16 *name, const efi_guid_t *guid, bool verbose, bool nodump) { - u32 attributes; - u8 *data; - u64 time; struct rtc_time tm; - efi_uintn_t size; + u32 attributes; + struct abuf buf; int count, i; - efi_status_t ret; - - data = NULL; - size = 0; - ret = efi_get_variable_int(name, guid, &attributes, &size, data, &time); - if (ret == EFI_BUFFER_TOO_SMALL) { - data = malloc(size); - if (!data) - goto out; + u64 time; + int ret; - ret = efi_get_variable_int(name, guid, &attributes, &size, - data, &time); - } - if (ret == EFI_NOT_FOUND) { + ret = efi_read_var(name, guid, &attributes, &buf, &time); + if (ret == -ENOENT) { printf("Error: \"%ls\" not defined\n", name); goto out; } - if (ret != EFI_SUCCESS) + if (ret) goto out; if (verbose) { @@ -103,16 +123,16 @@ static void efi_dump_single_var(u16 *name, const efi_guid_t *guid, count++; puts(efi_var_attrs[i].text); } - printf(", DataSize = 0x%zx\n", size); + printf(", DataSize = 0x%zx\n", buf.size); if (!nodump) print_hex_dump(" ", DUMP_PREFIX_OFFSET, 16, 1, - data, size, true); + buf.data, buf.size, true); } else { printf("%ls\n", name); } out: - free(data); + abuf_uninit(&buf); } static bool match_name(int argc, char *const argv[], u16 *var_name16) diff --git a/include/efi.h b/include/efi.h index c07717811da..07d07050c01 100644 --- a/include/efi.h +++ b/include/efi.h @@ -23,6 +23,7 @@ #include #endif +struct abuf; struct udevice; /* Type INTN in UEFI specification */ @@ -863,4 +864,18 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size, int efi_dp_from_bootdev(const struct udevice *dev, const struct efi_device_path **dpp); +/** + * efi_read_var() - Read an EFI variable + * + * @name: Name of variable to read + * @guid: GUID for the variable + * @attrp: Returns variable attributes if non-NULL, on success + * @buf: Returns allocated buffer containing the value + * @timep: Returns the timestamp for the variable if non_NULL + * Return: 0 if OK, -ENOENT if the variable was not found, -EBADF if something + * went wrong when reading + */ +int efi_read_var(const u16 *name, const efi_guid_t *guid, u32 *attrp, + struct abuf *buf, u64 *timep); + #endif /* _LINUX_EFI_H */ From patchwork Thu Aug 28 02:07:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 156 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=1756346891; bh=EULpu+jY4LmC9tXfOHuWhTz2oUwl7ZL9Sy+jdvtZXXk=; 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=r3gveVsDvqiKeVOt8EiPIk6kxpHSjGciDKDHmM3CJ5Fh0F6hhJvZPVWTbLPyfDqGy Ewhp1FpUsSuZmfpWge/ZKDVv+drvX1iHbnn5EFbAAwpmbHTgO0E73jEQy/zDAmSfKc Mk8aw6zPXIVP+V8ALFGJM7jX2HeoOXqIFBSvxI1PmLf/9MVq0D7G8hjSC1ynT4Krsn qjlzlvXclUaZ61WqEk/ZxH2P+BjD0hCpdz0EEFr1iYMEujzKDSEJS4xRpcDj/JcaNO NY7bywshBD/SPJV5ye4RlGmPlBVzSsT9dsd9/8sFM0fr7F1oOYCke7VGPv3bIqCDZM VFqFD82PsN49Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 73ABF67828 for ; Wed, 27 Aug 2025 20:08: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 2afLLqGVSYiT for ; Wed, 27 Aug 2025 20:08:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346889; bh=EULpu+jY4LmC9tXfOHuWhTz2oUwl7ZL9Sy+jdvtZXXk=; 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=iGRfDeWHlUMy4fA2GH+Si3+9/v8zmNsuXXibkPcMt4MXcyNsiDyI1B14lJTCFY3Kq /Iw0dhAY9uQHkQzTdYYdCpatoaAmAIFFIYPDeS+Va77ahnaCVhGN1+vRHWj3js0/Bq K/xmcp5Gc5jfNYY24vTVXMJWNSPpEMpq8iQFC8r2pMxdtB5mNRCnZidXCZmELcSEw8 KJYe2HeWWmbvD1DFvvaS25kGgim/C3J6mYcV94F7KPqLTJSrLPMPWkcaejPtiN1fv8 Uiv+LmWjKzWkuj9x4SftOQ8rbP8kHvM6AaKavKNHlhyF6xJ7k3TJMfXKcWZO9onBRz W+bRXyLLR0Rug== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7FFAC6782E for ; Wed, 27 Aug 2025 20:08:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346886; bh=7ZR7Ebx8xHyrK5/uupzxw89qT/je1L0WT3ym1lhR7Ic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ElWF4MlTVhWe0wMI8m5Gd3KluYiOlubz8jfftX0LOAM6qmpw8VN38nQPa4ElquvFL /J3G/wLC97c3BaZ8GTHFvRsJA4hyMWguxuZxgvhqPGyVCQ70m4Q9WP1EWjNgPNR/zu 5ZHAF2j5HPpPHS/8midrwOaaF0o0oB0zOlb1iEJsI/eeFRNeiQg5qsFeEARyja7j6l IbxH0LseXtT57CFgpQsscOUvHVw6+R3tANqIMoFzlqFXrisiKzdNx0qeqp2Rey4ql5 vVI+YnRGH50sJ4y1rEz/mTVbjpnAHyHBHjbFmxhZjv80HI7Xgg0yoOa9aL/CuAfWCG KaFUGDf8hJ7/A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B48A4677CB; Wed, 27 Aug 2025 20:08:06 -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 m9bPxRdn2SgR; Wed, 27 Aug 2025 20:08:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346886; bh=mvgMYr1mbFXewv4TJsp7Smq1LnoaroFwjjGUx/oGLQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rr7c8zmI9ZbMWG2i5cj3H6EOKHKa1cE5vBchuZ8DSpGlkcpxGDaNQDLK9MV+D6Awb sfGzmI3QQ8nxFiyQbujvAYEjFodbYYxHUBfYEJAkOq/R9kbCsHW/8Oo3KWyQiCTjVL 759HO3mPr3E/pnUiBI7DsfK9O+UZqjo+tFl6M3rQvioid1DF0Cw/FPu2uhvZXJfDud G9hRfl763/QgHitOtov1jrvTKOc8MNwQkp5QdGPp9byD1NI17ffZ4JumEdIT+mknDw igJ2aia47JkPuM5onzgBaf0TF0q17JPB5v9uAi1k2831afcuewLX6UExPcawqBWpRC BT8swU7pDr5iA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EBE616777E; Wed, 27 Aug 2025 20:08:05 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:16 -0600 Message-ID: <20250828020732.981415-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: SQM6FEMCMAKSLJMWDBEDYZUD2YRMAD7Z X-Message-ID-Hash: SQM6FEMCMAKSLJMWDBEDYZUD2YRMAD7Z 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 13/20] efi: Add a command to help with shim 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 Shim is a program which normally comes before U-Boot in the boot process. But when the app runs first, it can sometimes chain Shim since that is what is contained within the bootaa64.efi file, for example. Add a simple command for dealing with shim. For now it only supports enabling verbosity. Co-developed-by: Claude Signed-off-by: Simon Glass --- cmd/Kconfig | 9 ++++ cmd/Makefile | 1 + cmd/shim.c | 65 ++++++++++++++++++++++++++ doc/usage/cmd/shim.rst | 101 +++++++++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + include/efi.h | 3 ++ include/efi_api.h | 4 ++ include/shim.h | 13 ++++++ lib/efi/device_path.c | 2 + 9 files changed, 199 insertions(+) create mode 100644 cmd/shim.c create mode 100644 doc/usage/cmd/shim.rst create mode 100644 include/shim.h diff --git a/cmd/Kconfig b/cmd/Kconfig index 99101ff6c82..6a3ef56b3b9 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -547,6 +547,15 @@ config SYS_XIMG_LEN It should be large enough to fit uncompressed size of FIT piece we are extracting. +config CMD_SHIM + bool "shim" + depends on CMD_NVEDIT_EFI + default y if SANDBOX || EFI_APP + help + Provides a few commands for dealing with Shim being in the boot + chain. This can be useful when debugging booting, particularly on + x86 machines. + config CMD_SPL bool "spl export - Export boot information for Falcon boot" depends on SPL diff --git a/cmd/Makefile b/cmd/Makefile index 407056b778b..bc381905729 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -174,6 +174,7 @@ obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o obj-$(CONFIG_CMD_SEAMA) += seama.o obj-$(CONFIG_CMD_SETEXPR) += setexpr.o obj-$(CONFIG_CMD_SETEXPR_FMT) += printf.o +obj-$(CONFIG_CMD_SHIM) += shim.o obj-$(CONFIG_CMD_SPI) += spi.o obj-$(CONFIG_CMD_STRINGS) += strings.o obj-$(CONFIG_CMD_SMBIOS) += smbios.o diff --git a/cmd/shim.c b/cmd/shim.c new file mode 100644 index 00000000000..903f1823f19 --- /dev/null +++ b/cmd/shim.c @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Control of settings for Shim + * + * Copyright 2025 Simon Glass + */ + +#define __efi_runtime + +#include +#include +#include +#include +#include +#include +#include + +static int do_shim_debug(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + efi_status_t eret; + struct abuf buf; + const char *sub; + u32 value; + int ret; + + sub = cmd_arg1(argc, argv); + if (!sub) { + ret = efi_read_var(SHIM_VERBOSE_VAR_NAME, &efi_shim_lock, NULL, + &buf, NULL); + if (ret == -ENOENT) { + value = 0; + } else if (ret) { + printf("Failed to read variable (err=%dE)\n", ret); + goto fail; + } else if (buf.size != sizeof(value)) { + printf("Invalid value size %zd\n", buf.size); + goto fail; + } else { + value = *(typeof(value) *)buf.data; + } + printf("%d\n", value); + } else { + value = hextoul(sub, NULL) ? 1 : 0; + eret = efi_set_variable_int(SHIM_VERBOSE_VAR_NAME, + &efi_shim_lock, + EFI_VARIABLE_BOOTSERVICE_ACCESS, + sizeof(value), &value, false); + if (eret) { + printf("Failed to write variable (err=%lx)\n", eret); + goto fail; + } + } + + return 0; + +fail: + return 1; +} + +U_BOOT_LONGHELP(shim, + "debug [<0/1>] - Enable / disable debug verbose mode"); + +U_BOOT_CMD_WITH_SUBCMDS(shim, "Shim utilities", shim_help_text, + U_BOOT_SUBCMD_MKENT(debug, 3, 1, do_shim_debug)); diff --git a/doc/usage/cmd/shim.rst b/doc/usage/cmd/shim.rst new file mode 100644 index 00000000000..285dd200558 --- /dev/null +++ b/doc/usage/cmd/shim.rst @@ -0,0 +1,101 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +shim command +============ + +Synopsis +-------- + +:: + + shim debug [<0/1>] + +Description +----------- + +The ``shim`` command provides utilities for controlling and configuring the +UEFI Shim bootloader when U-Boot is running as an EFI application. Shim is a +UEFI bootloader that is used to verify and boot signed operating system +loaders, commonly used in secure boot environments. + +The ``shim debug`` subcommand manages the Shim verbose debugging mode through +the ``SHIM_VERBOSE`` EFI variable. + +Subcommands +~~~~~~~~~~~ + +shim debug +^^^^^^^^^^ + +Controls the Shim verbose debugging mode. + +**Usage:** + +:: + + shim debug # Display current debug state (0 or 1) + shim debug 0 # Disable verbose debugging + shim debug 1 # Enable verbose debugging + +The command reads from or writes to the ``SHIM_VERBOSE`` EFI variable in the +Shim Lock GUID namespace. When verbose mode is enabled (value = 1), Shim will +output additional debugging information during the boot process. When disabled +(value = 0 or variable doesn't exist), Shim operates silently. + +**Parameters:** + +* ``<0/1>`` - Optional parameter to set debug mode: + + * ``0`` - Disable verbose debugging + * ``1`` - Enable verbose debugging + * If omitted, displays current debug state + +**Return value:** + +The command returns 0 on success, 1 on failure. + +**Examples:** + +Check current debug state:: + + => shim debug + 0 + +Enable verbose debugging:: + + => shim debug 1 + +Disable verbose debugging:: + + => shim debug 0 + +Configuration +~~~~~~~~~~~~~ + +The shim command is available when: + +* ``CONFIG_CMD_SHIM`` is enabled +* U-Boot is running as an EFI application +* EFI-variable support is available + +Implementation Details +~~~~~~~~~~~~~~~~~~~~~~ + +The command uses the EFI variable services to read and write the +``SHIM_VERBOSE`` variable with the following characteristics: + +* **Variable Name:** ``SHIM_VERBOSE`` (Unicode string) +* **GUID:** EFI Shim Lock GUID (``605dab50-e046-4300-abb6-3dd810dd8b23``) +* **Attributes:** ``EFI_VARIABLE_BOOTSERVICE_ACCESS`` +* **Data Type:** 32-bit unsigned integer (4 bytes) +* **Values:** 0 (disabled) or 1 (enabled) + +The variable is stored in the EFI variable store and persists across reboots +until explicitly changed or the variable store is cleared. + +See Also +~~~~~~~~ + +* :doc:`efidebug` - EFI debugging utilities +* :doc:`bootefi` - Boot EFI applications +* :doc:`/develop/uefi/u-boot_on_efi` diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 585aa3f9784..3b45d443d5c 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -115,6 +115,7 @@ Shell commands cmd/seama cmd/setexpr cmd/sf + cmd/shim cmd/size cmd/sleep cmd/sm diff --git a/include/efi.h b/include/efi.h index 07d07050c01..2ca7cc30d52 100644 --- a/include/efi.h +++ b/include/efi.h @@ -163,6 +163,9 @@ extern const efi_guid_t efi_guid_component_name2; /* GUIDs for authentication - most of these are still in efi_loader.h */ extern const efi_guid_t efi_guid_image_security_database; +/* Access to Shim variables */ +extern const efi_guid_t efi_shim_lock; + /* Generic EFI table header */ struct efi_table_hdr { u64 signature; diff --git a/include/efi_api.h b/include/efi_api.h index b3f6172e97a..00a9d29b8fe 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -487,6 +487,10 @@ struct efi_runtime_services { EFI_GUID(0x6a7a5cff, 0xe8d9, 0x4f70, \ 0xba, 0xda, 0x75, 0xab, 0x30, 0x25, 0xce, 0x14) +#define EFI_SHIM_LOCK_GUID \ + EFI_GUID(0x605dab50, 0xe046, 0x4300, \ + 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23) + /** * struct efi_configuration_table - EFI Configuration Table * diff --git a/include/shim.h b/include/shim.h new file mode 100644 index 00000000000..23061398933 --- /dev/null +++ b/include/shim.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Shim features and settings + * + * Copyright 2025 Simon Glass + */ + +#ifndef __SHIM_H +#define __SHIM_H + +#define SHIM_VERBOSE_VAR_NAME L"SHIM_VERBOSE" + +#endif diff --git a/lib/efi/device_path.c b/lib/efi/device_path.c index bae9e5c537a..b09ea030341 100644 --- a/lib/efi/device_path.c +++ b/lib/efi/device_path.c @@ -43,6 +43,8 @@ const efi_guid_t efi_guid_component_name2 = EFI_COMPONENT_NAME2_PROTOCOL_GUID; const efi_guid_t efi_guid_image_security_database = EFI_IMAGE_SECURITY_DATABASE_GUID; +const efi_guid_t efi_shim_lock = EFI_SHIM_LOCK_GUID; + /* template EFI_DP_END node: */ const struct efi_device_path EFI_DP_END = { .type = DEVICE_PATH_TYPE_END, From patchwork Thu Aug 28 02:07: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: 157 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=1756346891; bh=OEwibsZiBXLCu+i4WkVPXrH3Tq90zXbANVmnJowgIyY=; 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=LdDCeMk3KfLBnwvTdw/lOPDqjH23CCmq11sciRDep1y6q067U6Mg6ei8FqVA08k3A 6fJCoEWtL5PaW8maIcjNCY9XmHUX03R4ktVMOZQw09z5nqqu6FdihFKOkx9zK1ef2v zd6DYhk2E8JoBEEtkx3vk5zs4EkLcEdmKw6sih4TPkpIFvUaR83A5Wq5Cjp2zfgIZ5 CZZ6Mdh/J5oQFU21/5DiwTAd0n8ENON/0MKc5yD592mU5k/xSMKsbzwwL7gf+hfzjo ywna2y/O5hmupxMKir0olwsHGx36hLPcVvHO3I2OhSnSIeut6n+qCFpW6fWiij5zZU AOt+FY0HyrM2Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C8B556777E for ; Wed, 27 Aug 2025 20:08: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 YYQ1vcn4614m for ; Wed, 27 Aug 2025 20:08:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346890; bh=OEwibsZiBXLCu+i4WkVPXrH3Tq90zXbANVmnJowgIyY=; 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=vbv1FgQDizPnYBhyrpQwCQFWA7/Bq1aScTx69JMUAYvPKobIZTzJrWFTXBk5DDmnz rM4iRlVbZaVbbwQN+kx2i0IihfyCLY5j89Zb5uls78ccekcWntJFbu3lAgB4R22eMh 5aL0whCZFc+8nIJiMnhUO3dPgNH7sMSVAQGbwIMdnwTO7DqGDgbUyIoZ+JSVXMuD5F ISqCjgi4dxq11SlSBLrP86k3bwitIQmZCES/8R6+HOMCuDV8FDm0w2H6O2XfsYox/a ZC8qvAYUPgTDfIKkMxaVOOsDZXQT3OO05zlULB0bCbf0Aud03hggBSau3XjAFI3M8y BsxpP9NUW71qA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 05BE767834 for ; Wed, 27 Aug 2025 20:08:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346887; bh=OV9O8a3rWPf3+xo2IMantD6UHs6NgSSeuhgaau5B/5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pGcZug0rcyDeQIJtJsxJpTKZhIwz4Ju4kFyHzxFshZl2NbmUourgSGa2Ad1UCE+oQ EuYd0XU34lFmR33yiU/Q5GkiIDiqrS7n6d1uS6n/HpXuIESeE6HsDLwR/i8amhSUiG JspbOqgK59Tx3obWGq9jHh1hBjMq6/Nd9826NcDrFxA4KqfaEKQUL12x1k8yqYDc3M dh/O+NBwFGKh9kI1Dj3iZvcju7hkcLcqKNOBgOoCyLPT91RSdrhY/Fwj1cP7V9DRa2 UvU/cFn15juMhXN/RFlSTzuHC4CuZqAySXZYboIVLu4BWePCStlfid7BafZzqUu++x eIgmlRb3jUe6g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BA2386743E; Wed, 27 Aug 2025 20:08:07 -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 bEqdJI3baT8u; Wed, 27 Aug 2025 20:08:07 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346887; bh=VAoEwHr+VrgPWkeyin/sSkz19Ct5J5+kFRr5Dp33WDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pIYaJUFEjktGWi7E9aHSY1zu6/oU8Ju2k3mOQhP5WchiG3Lm9FcxsCfTdr6G0Cm/i Q8mpRGZuw4xzpYcW7QKNqvJP9JtTBaIh2HMk+cvObrC/19MxPJOfG2y0hznr2aRfmL 2ShUP27OVNbx5WY59nrCjhyYnBCIR0oZCojyLXJnJGTOoLL0FfZeIu0E4cmFv5O2sL IrMBcWy9QvecxRtVDzL/mfZsdt5X9nE/w/ifNX3untgl2hzvePAoL6369eGdVb2jmU uRCY/P7j45pm0cdW8l6h5NZAX3JjVEKOLcvMWOcnuwno2ERRcPY7ng6S1TF9yyYumh /4unehu1SzwOQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 00FAB6777E; Wed, 27 Aug 2025 20:08:06 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:17 -0600 Message-ID: <20250828020732.981415-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: J62B6KPWOFHE2IRIM3XGN5IX4WJYL7LM X-Message-ID-Hash: J62B6KPWOFHE2IRIM3XGN5IX4WJYL7LM 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 14/20] efi: Add an efi subcommand to show the loaded image 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 Sometimes it is useful to see the device-path of the app itself. Add a new 'efi image' command for this. Signed-off-by: Simon Glass --- cmd/efi.c | 15 +++++++++++++++ doc/usage/cmd/efi.rst | 14 ++++++++++++++ include/efi.h | 2 ++ 3 files changed, 31 insertions(+) diff --git a/cmd/efi.c b/cmd/efi.c index 91feec1c051..c59219ddf01 100644 --- a/cmd/efi.c +++ b/cmd/efi.c @@ -17,6 +17,19 @@ DECLARE_GLOBAL_DATA_PTR; +static int do_efi_image(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct efi_priv *priv = efi_get_priv(); + struct efi_loaded_image *lim = priv->loaded_image; + u16 *path; + + path = efi_dp_str(lim->file_path); + printf("Loaded-image path: %ls\n", path); + + return 0; +} + static int h_cmp_entry(const void *v1, const void *v2) { const struct efi_mem_desc *desc1 = v1; @@ -186,6 +199,7 @@ static int do_efi_tables(struct cmd_tbl *cmdtp, int flag, int argc, } static struct cmd_tbl efi_commands[] = { + U_BOOT_CMD_MKENT(image, 1, 1, do_efi_image, "", ""), U_BOOT_CMD_MKENT(mem, 1, 1, do_efi_mem, "", ""), U_BOOT_CMD_MKENT(tables, 1, 1, do_efi_tables, "", ""), }; @@ -211,6 +225,7 @@ static int do_efi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) U_BOOT_CMD( efi, 3, 1, do_efi, "EFI access", + "image Dump loaded-image info\n" "mem [all] Dump memory information [include boot services]\n" "tables Dump tables" ); diff --git a/doc/usage/cmd/efi.rst b/doc/usage/cmd/efi.rst index b19d36188a9..e5d8913c94b 100644 --- a/doc/usage/cmd/efi.rst +++ b/doc/usage/cmd/efi.rst @@ -12,6 +12,7 @@ Synopsis :: + efi image efi mem [all] efi tables @@ -26,6 +27,16 @@ information. When running as an EFI payload, EFI boot services have been stopped, so it uses the information collected by the boot stub before that happened. +efi image +~~~~~~~~~ + +This shows the loaded image path information for the currently running EFI +application. The loaded image protocol provides access to the device path +from which the image was loaded. + +The output shows the file path in EFI device path format, displayed as a +human-readable Unicode string. + efi mem ~~~~~~~ @@ -71,6 +82,9 @@ Example :: + => efi image + Loaded-image path: u-boot-app.efi + => efi mem EFI table at 0, memory map 000000001ad38b60, size 1260, key a79, version 1, descr. size 0x30 # Type Physical Virtual Size Attributes diff --git a/include/efi.h b/include/efi.h index 2ca7cc30d52..530b127bde4 100644 --- a/include/efi.h +++ b/include/efi.h @@ -881,4 +881,6 @@ int efi_dp_from_bootdev(const struct udevice *dev, int efi_read_var(const u16 *name, const efi_guid_t *guid, u32 *attrp, struct abuf *buf, u64 *timep); +uint16_t *efi_dp_str(struct efi_device_path *dp); + #endif /* _LINUX_EFI_H */ From patchwork Thu Aug 28 02:07:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 158 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=1756346892; bh=xdse5vLq7j6SwL1IkTqPAf+FYO8/Ls8/vphUz0djCGw=; 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=jBuc7mnOQMIcQSEzo2ZrTX3Z+WykisSQJCjGVRi3PvGYtE2GhADKp2QD31AK1T+yP GkL5a7tdmB7/9okeK+iysBVXTcBLu88L+eRHV8Ttc97ZKzt67JRKEIUrxs6KCCNb8V ndDQsmnnMdk+iQ7RkrLqoSGjNKDqYSgRPf3SEp3CsPFbXCph1geiK59B3gfG/3rE6s hpXDYo8bnQgfcTJgBPpCvUFmu/s7s3tBeRhG4lUUZRzMniOYc1H3YstwY0oEcjrEDe Co/WZflRE0Q5IcDxKWkQD4Xjv5NwJlZGcaj6bcIemr6LleOrQXbtejAWfbVDfJIbfW h9bYIrnPm5ADw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3298D67828 for ; Wed, 27 Aug 2025 20:08:12 -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 0Akxzw7CS04b for ; Wed, 27 Aug 2025 20:08:12 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346890; bh=xdse5vLq7j6SwL1IkTqPAf+FYO8/Ls8/vphUz0djCGw=; 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=B5UH7+AGdobOTq4v2yPa5qrKckYsr2YgxnyzDHMSSCKDga64Kyg27nMHMqyaXr1UN 7nPFsYw55QyGPKSEaruCf2Zrc1enkeJTuoRbLqOClbbACr3W20e5E6zfFC0STFGxqZ By0smDM2Y6k7+a5gD45pT//xD3liOqJZF/oxIR91IRcKoG089lzCaUahY88nW67WY/ d7T1/M45xh/7frcXFgQM4ZRCBl/xIfMTvL100a4l3a5s6m79RMJyTmYJRQtfxbIY1y jHGqdqf6LD67ucnR6rnQHuzmZ4x5hguh0ior3l5zttEYNXw/f4y5DfoCfwbPZaWD4k Owk4qlDtbXDsg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4ECEA67837 for ; Wed, 27 Aug 2025 20:08:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346888; bh=va+FYHfVW4FGPXxJXeIzfl5lDhFLvQWvd07eDe5EzQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bl8ydHMqx1klHb/yW9DjONhvit9zwgPpHmK+nqUnXYncHan9sovUXzuy5TZWHm5f8 eNWy+MVIsqpM80uuBYSbGILzNA61qqCKoFYzFpuda1K3KowacrXVhSEq35fZ00nge2 1tpPBEOfe7qjaixOCjCwRaeNJLBxJOOwuQXsOWj894RuFm4qhVsjl3sG7hTYjUFUFD 9SBvQqaiaP+PMLA774f0EL3+I7wRT1+c+PsaZX3X9R3mD+b3jpO5svvVACEIqgBQzq SDftbiXmVoUXM2EkMCNX+Oa1MgbCzD2gAgcHjHYp43T2huXF964r8p719Xk2GxBTQd FWrCwx1csX28w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BE8446777F; Wed, 27 Aug 2025 20:08:08 -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 KZkUaNAfBmjk; Wed, 27 Aug 2025 20:08:08 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346888; bh=3kTf7+pZ5cY/zNv/ZF0cI/hKAr0dEAgOE0knYwYNTng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b8Pz6rs2h4DnsuQ406TpiLGKVkGs9ExAT6OKynPRrsLISoKNcwGsi6E5anx8Psi2J mkUljM0xbu6tWPEdsdmLAudhuyyURKSoUM7bRw7gT+iOOqaQPZQNHvn88GYO4gf40O kfELlC8pQA7aVVe8HiOTwvi9GBooKQVvhrMQMgtS63DjInsa2M3C0WoKcK5L/Zn2ut 4Izo+wYNtlKryvFUhH93u+QdhX77Gtirh7lpCP6VE47651GPhljITIZf+yyYQYwcIR cOlo3q1bdqiLaSQyqYizTgjwustpd7rFHvwpPdg8g/BNlL0XXBsb1IFiVhZ+OotIyI Ztz9miO0k1ibw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F041D6777E; Wed, 27 Aug 2025 20:08:07 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:18 -0600 Message-ID: <20250828020732.981415-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FOVIYM4TWVGCSIRMJEHF5M3NZ737PZBG X-Message-ID-Hash: FOVIYM4TWVGCSIRMJEHF5M3NZ737PZBG 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 15/20] fdt: Add a function to show the reserved-memory nodes 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 Add a new helper which lists the subnodes of the reserved-memory node. This can be helpful when checking the devicetree before booting. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fdt_support.c | 54 +++++++++++++++++++++++++++++++++++++++++++ include/fdt_support.h | 7 ++++++ 2 files changed, 61 insertions(+) diff --git a/boot/fdt_support.c b/boot/fdt_support.c index 92f2f534ee0..f42eaa488de 100644 --- a/boot/fdt_support.c +++ b/boot/fdt_support.c @@ -2259,3 +2259,57 @@ int fdt_fixup_pmem_region(void *fdt, u64 pmem_start, u64 pmem_size) return 0; } + +void fdt_print_reserved(void *fdt) +{ + int node, reserved, id; + int addr_cells, size_cells; + + printf("%-4s %-20s %-18s %-18s\n", "ID", "Name", "Start", "Size"); + printf("--------------------------------------------------------" + "--------\n"); + + reserved = fdt_path_offset(fdt, "/reserved-memory"); + if (reserved < 0) { + printf("No /reserved-memory node found in device tree\n"); + return; + } + + /* Get #address-cells and #size-cells from reserved-memory node */ + fdt_support_default_count_cells(fdt, reserved, &addr_cells, + &size_cells); + + id = 0; + fdt_for_each_subnode(node, fdt, reserved) { + const char *name = fdt_get_name(fdt, node, NULL); + const fdt32_t *reg; + u64 rsv_start = 0, rsv_size = 0; + int len; + + reg = fdt_getprop(fdt, node, "reg", &len); + if (reg && len >= (addr_cells + size_cells) * sizeof(fdt32_t)) { + int cells = 0; + + /* Parse address */ + for (int i = 0; i < addr_cells; i++) + rsv_start = (rsv_start << 32) | + fdt32_to_cpu(reg[cells++]); + + /* Parse size */ + for (int i = 0; i < size_cells; i++) + rsv_size = (rsv_size << 32) | + fdt32_to_cpu(reg[cells++]); + + printf("%-4d %-20s 0x%-16llx 0x%-16llx\n", + id++, name ? name : "(unnamed)", rsv_start, + rsv_size); + } else { + printf("%-4d %-20s %-18s %-18s\n", + id++, name ? name : "(unnamed)", "(no reg)", + "(no reg)"); + } + } + + if (!id) + printf("No reserved-memory regions found\n"); +} diff --git a/include/fdt_support.h b/include/fdt_support.h index eca9e7e3ac3..abd7504ad9b 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -529,4 +529,11 @@ int fdt_print(const void *fdt, int nodeoffset, int depth); */ int fdt_print_path(const char *pathp, char *prop, int depth); +/** + * fdt_print_reserved() - Print all device tree reserved-memory nodes + * + * @fdt: Device tree blob + */ +void fdt_print_reserved(void *fdt); + #endif /* ifndef __FDT_SUPPORT_H */ From patchwork Thu Aug 28 02:07:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 160 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=1756346897; bh=bxAFgjfqttDLbsLnPfgTbZIf1qnYhYb8BC2Fx+34LTA=; 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=o3JZWfkK0bfRSWvzkGTG1Zkp7f+vX2g1ZwMM8cTDv1wVKIkcGZhNdJH2OxKTnPD2W lfbOtZY38cCkeisbg/frsYM3jzsKO0WLVRdpLAQyDlygcUtC8PAfv26s67p2YuvjmM JuXH4xvYFC5t44D6PEXRqtRoC8NAl8+QgSuaJ9EIVY82svAYEkR0Bbw4POcT1MozFf TbWZwUxClwaXr6tqL3oSudpWplyQASEc3nOWCWFq9Q6HgtauVIIFMmTkx3eZ8dQsZz DC6+SGy5O18vjn0r+8ixgR4dza7A4Ec6vJWE4igQam0FkTHKl9WfXnr061IfJV7Me2 DqPkI+A5N57wg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 007A76782F for ; Wed, 27 Aug 2025 20:08:17 -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 3hST2ctRbOie for ; Wed, 27 Aug 2025 20:08:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346896; bh=bxAFgjfqttDLbsLnPfgTbZIf1qnYhYb8BC2Fx+34LTA=; 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=X+bRZSMF//LCXESixeIkMyQVQLzpS9VE3IleApoRNeVLMkQ7jUw/EjmvSLVwvyWtL c2VlowZxUqUZ0619m7dmRQJFkjxpX9EtYOSKie31IA8BeYhee3OOI33OjNpa6lbT9n mcO+408g7z72yxC/WjqSLIdPXxkCpIMoGQIxh4TlHjybyPUhhfdtPDnaJPOk4rtGJv /kIkjte3gAwy9COMDaeiqTw/bB2JNd4TzY0yAC//BF9f0cDlkbaLQwEIGavBnBh+pH 2KGdWjynBYRyn1dc6DzWyaWr4SWExOXVq6nQj1xZ9K3TRm6pBcE+2nVkTt1HthPi8L 4Igmy5CR+trOg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E431A6776F for ; Wed, 27 Aug 2025 20:08:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346894; bh=M9Xa2CtYpuFTeuhWXNdpWwBNQXqDLXYuLTUjZ8Me9zE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IrkvB/dpINuqS7nPO04UTamdzmjsDNYQ4850N8P1MNQXezbt9vSeiZ/ojJrd2ZoD9 veGYOdA6FIHJxoPLXiZcaaIR0lK6lq3J0WE1DfIwmkk+aMsOex3bPnuIKbub6aZEyx Edr8pSQbl1YXLuWMCbQM3uqvtmIVgEI8wReJj7ug7nk4kpSviv8+VTwwxFmR3Ty4Kf sdUaIF0+ctL+i3zevx47kyecSjDmhegUNjZFkFFCTX2UtUhrIXQxKCyfukSuiYtwUu U8pBnoYOnFgjiiaYVIqbsgPdhGy81l9gA9hod9wTtB5tgnI/UzA3Mi54C5NW7Eb84K x3GstUZUqKjqA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7DEBD6777A; Wed, 27 Aug 2025 20:08:14 -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 c6w27XOOtclr; Wed, 27 Aug 2025 20:08:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346889; bh=/PHA0blrRqE3o9w5NXIdIF8pcJhDrUbb/RZ1Nx3o9zg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U0uCZLYBN35mThLnbLHoMXNhNN75IEX4EBwJO7XfW+SEL3vIWjrISRe/ddVJSIEBt 9fMzUL0Yw5mvWthFjPpniGujJLlr8mkYz4A7bq8+pDbiToFXH93dm3R44I3TP0wyw5 9Ou7Uuwa8Um7hbGfhJUY5DE959VL0F+WX4uCcJAohzv02LtC+RwqDtt1oLCI1i1AYv WC5O78CoGNwkc8QMxPj5k+JaG+7qbN4x0xmctIkmS31vnb3LaK6Da+h4X/Z9hw/sGq xCcw/LuQkuHmFu7sW9+TlWuE2n7X5wn1rzO/QzNvfvGq//5L4svN9aJNroX7tlsxXD HT6Uvi2e6lUkA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F1531677B6; Wed, 27 Aug 2025 20:08:08 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:19 -0600 Message-ID: <20250828020732.981415-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 4D6L4UCVZA3RWJOFKDEHTXHEIIC3VXNQ X-Message-ID-Hash: 4D6L4UCVZA3RWJOFKDEHTXHEIIC3VXNQ 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 16/20] fdt: Add a command to show reserved-memory regions 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 Add a new 'fdt reserved' subcommand that displays all reserved memory regions defined in the device tree's /reserved-memory node. This command provides a formatted table showing the ID, name, start address, and size of each reserved memory region. Avoid a conflict with the existing 'fdt resize' command. Update the docs and add a test. Co-developed-by: Claude Signed-off-by: Simon Glass --- cmd/fdt.c | 7 ++++++- doc/usage/cmd/fdt.rst | 26 ++++++++++++++++++++++++++ test/cmd/fdt.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/cmd/fdt.c b/cmd/fdt.c index 4aedac6116e..7fe0d9dc22c 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -768,8 +768,12 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_FAILURE; } #endif + /* print reserved memory regions */ + else if (strncmp(argv[1], "rese", 4) == 0) { + fdt_print_reserved(working_fdt); + /* resize the fdt */ - else if (strncmp(argv[1], "re", 2) == 0) { + } else if (strncmp(argv[1], "re", 2) == 0) { uint extrasize; if (argc > 2) extrasize = hextoul(argv[2], NULL); @@ -902,6 +906,7 @@ U_BOOT_LONGHELP(fdt, #endif "fdt move - Copy the fdt to and make it active\n" "fdt resize [] - Resize fdt to size + padding to 4k addr + some optional if needed\n" + "fdt reserved - Print reserved-memory regions\n" "fdt print [] - Recursive print starting at \n" "fdt list [] - Print one level starting at \n" "fdt get value [] - Get and store in \n" diff --git a/doc/usage/cmd/fdt.rst b/doc/usage/cmd/fdt.rst index 71a9fc627e5..2fbb50e5013 100644 --- a/doc/usage/cmd/fdt.rst +++ b/doc/usage/cmd/fdt.rst @@ -12,6 +12,7 @@ Synopsis :: fdt addr [-cq] [addr [len]] + fdt reserved Description ----------- @@ -48,6 +49,22 @@ If the `len` argument is provided, then the device tree is expanded to that size. This can be used to make space for more nodes and properties. It is assumed that there is enough space in memory for this expansion. +fdt reserved +~~~~~~~~~~~~ + +This command prints all reserved memory regions defined in the device tree's +`/reserved-memory` node. The output shows a formatted table with the following +columns: + +- **ID**: Sequential number for each region +- **Name**: Node name of the reserved memory region +- **Start**: Start address of the reserved memory region in hexadecimal +- **Size**: Size of the reserved memory region in hexadecimal + +If no `/reserved-memory` node exists in the device tree, the command will +display an appropriate message. This command is useful for debugging memory +layout issues and verifying that reserved memory regions are properly defined. + Example ------- @@ -67,6 +84,15 @@ address and expand it to 0xf000 in size:: => md 10000 4 00010000: edfe0dd0 00f00000 78000000 7c270000 ...........x..'| +Print all reserved memory regions:: + + => fdt reserved + ID Name Start Size + ---------------------------------------------------------------- + 0 secmon@1f000000 0x000000001f000000 0x0000000001000000 + 1 atf@40000000 0x0000000040000000 0x0000000000200000 + 2 linux,cma 0x0000000050000000 0x0000000008000000 + Return value ------------ diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 9de79870c40..10a2f309a45 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -1464,3 +1464,43 @@ static int fdt_test_apply(struct unit_test_state *uts) return 0; } FDT_TEST(fdt_test_apply, UTF_CONSOLE); + +/* Test 'fdt reserved' reading reserved-memory nodes */ +static int fdt_test_reserved(struct unit_test_state *uts) +{ + struct fdt_header *old_working_fdt; + char fdt[8192]; + ulong addr; + + if (!IS_ENABLED(CONFIG_SANDBOX)) + return -EAGAIN; + + /* Save the original working_fdt */ + old_working_fdt = working_fdt; + + /* Set working_fdt to control FDT (sandbox has reserved memory) */ + working_fdt = (struct fdt_header *)gd->fdt_blob; + + ut_assertok(run_command("fdt reserved", 0)); + + /* Just verify we get the header */ + ut_assert_nextlinen("ID"); + ut_assert_nextlinen("------"); + + /* Verify we get a tcg_event_log entry with correct address/size */ + ut_assert_nextline("0 tcg_event_log 0x100000 0x2000 "); + + /* Test with FDT that has no reserved-memory node */ + ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt), &addr)); + ut_assertok(run_command("fdt reserved", 0)); + ut_assert_nextlinen("ID Name Start Size"); + ut_assert_nextline("----------------------------------------------------------------"); + ut_assert_nextline("No /reserved-memory node found in device tree"); + ut_assert_console_end(); + + /* Restore the original working_fdt */ + working_fdt = old_working_fdt; + + return 0; +} +FDT_TEST(fdt_test_reserved, UTF_CONSOLE); From patchwork Thu Aug 28 02:07:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 159 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=1756346896; bh=hlon67LNBzK1Zo4RaW2QtgyKunlikCdowyoSXxuoTmA=; 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=IZuI0KHKEiaRPRqxdapu7aUSTlqvBvkAnwYAcwhCv2VFgPECEOyA59CI8y+ugw3d/ hNtOTRtVm5CB24YcQpVbQq3d1Krnv+1Pm9HcPqjCLfhg04TIljAy7eeb2HEJFbSmmA 9Yxe4RFKGffHQ6D/aSLvFWxVTQQsBBooSnwePjbeNuEyRH+z4X7SR9gTvoTvCpUCQZ 14NV5IDPhdkwgq3bqwB1HvdRWm7q1Y2U4ILzBStVCG3sbMWVBAcIKA3pv/1bsh+CrH /NnEdiqcGEqX/mx99qWmJb7i1tQRkox9RK2HBe91MuWkuSckxCHtjGP3DLZDlHg9iR 9wCpki/DG8tDg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B70E1677B6 for ; Wed, 27 Aug 2025 20:08:16 -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 ZtzOB4Cq4Z2u for ; Wed, 27 Aug 2025 20:08:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346896; bh=hlon67LNBzK1Zo4RaW2QtgyKunlikCdowyoSXxuoTmA=; 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=IZuI0KHKEiaRPRqxdapu7aUSTlqvBvkAnwYAcwhCv2VFgPECEOyA59CI8y+ugw3d/ hNtOTRtVm5CB24YcQpVbQq3d1Krnv+1Pm9HcPqjCLfhg04TIljAy7eeb2HEJFbSmmA 9Yxe4RFKGffHQ6D/aSLvFWxVTQQsBBooSnwePjbeNuEyRH+z4X7SR9gTvoTvCpUCQZ 14NV5IDPhdkwgq3bqwB1HvdRWm7q1Y2U4ILzBStVCG3sbMWVBAcIKA3pv/1bsh+CrH /NnEdiqcGEqX/mx99qWmJb7i1tQRkox9RK2HBe91MuWkuSckxCHtjGP3DLZDlHg9iR 9wCpki/DG8tDg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 95D0B6777A for ; Wed, 27 Aug 2025 20:08:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346894; bh=XqONq9aPipkpZICfXhHcjP18+OjmWFHSk2gze8nWTsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dHZ5K6aupyDMs1PJ7sc6P+zlspo5UTl5dlW6Nv8rH/IJxAj4Xq8+m7lknHeAna/oi diqYHMhpbSEipwFQLgZ5PEzscgUZQASBplesR722vdtP7fOHPegAiN08xa/D0CNZw7 PNMYgBe6HQQOrg3b8hS3ZtNR8Ntb5RA7eyNuuPtvzrhca7r03DxToUam6wOjLI6gXG H3QEPimLv/LwRkzLGtPALrcangK99buKq/rhEvvJRoILUMHsSkLgj0n1hHRciQ8SCm JEejpKumfAxwSPZVPC2qVcq78I8HmwNs5M/rOLYdKPqjedd4M1AvpilBVMubV6KFTp vENBV1JzK2IbA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7CB796776F; Wed, 27 Aug 2025 20:08:14 -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 Ja1N9wohMJMI; Wed, 27 Aug 2025 20:08:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346890; bh=AjZydVfi0wQEywkR9uKesm/mv6oiiHeZ+iPbj4ZV1O4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k+sVi0KJklxZ1JpI1y/OqdJT/aakc6JGUoxc4AxvPierxolnxwblzppH+bmtSgi4p ixHr7Q0lml3hHj6Pl/jPC5sAjpGXu5lMKTPYtg0nq4lwEL44ZK1b2zzM+wq+Fw6B2C 4cWbREMULKkG+Yku9BwxozOB/IM/owXTrpg6jluOxct/86Zw6G9lHF3mvSNm3QVNf/ 1uO0M3zvaMavKBD63knsuk3qcwRkHX3fz7azw1C41+nvBgO23CUp111SayZbdWja7Y lKFyfWfbQzlKcayU9n/vKAK8jErDcuAWP86ppVfhuUud1k94fxo3a5StexoLVVcB1R ohBinVVXzt0hA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EB0FB67833; Wed, 27 Aug 2025 20:08:09 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:20 -0600 Message-ID: <20250828020732.981415-18-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3KPUNKP35AKKILLVENOSH3NHHBA4UTYE X-Message-ID-Hash: 3KPUNKP35AKKILLVENOSH3NHHBA4UTYE 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 17/20] efi: Provide a way to sync EFI reserved-memory to fdt 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 When booting Linux with EFI the devicetree memory-map is ignored and Linux calls through EFI to obtain the real memory map. When booting Linux from the EFI app, without EFI, we must pass the reserved memory onto Linux using the devicetree. Add a function to support this. It reads the EFI memory-map and adds any missing regions to the reserved-memory node. Co-developed-by: Claude Signed-off-by: Simon Glass --- include/efi.h | 16 +++ lib/efi_client/efi.c | 249 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 263 insertions(+), 2 deletions(-) diff --git a/include/efi.h b/include/efi.h index 530b127bde4..b3f9c0b694f 100644 --- a/include/efi.h +++ b/include/efi.h @@ -794,6 +794,22 @@ static inline bool efi_mem_is_boot_services(int type) */ const char *efi_mem_type_name(enum efi_memory_type type); +/** + * efi_mem_reserved_sync() - Sync EFI memory map with DT reserved-memory nodes + * + * This function compares the EFI memory map with the device tree's reserved-memory + * nodes and prints out regions that are reserved in EFI but not mentioned in the + * device tree's /reserved-memory node. This helps identify memory regions that + * EFI considers reserved but which Linux might try to use. + * + * Note: This only works with #address-cells and #size-cells of 2 + * + * @fdt: Pointer to the device tree blob + * @verbose: If true, show detailed output; if false, only show errors + * Return: Number of regions synced, or -ve on error + */ +int efi_mem_reserved_sync(void *fdt, bool verbose); + /** * efi_dump_mem_table() - Dump out the EFI memory map * diff --git a/lib/efi_client/efi.c b/lib/efi_client/efi.c index 12a646a36b7..9d064484dbf 100644 --- a/lib/efi_client/efi.c +++ b/lib/efi_client/efi.c @@ -13,10 +13,13 @@ #include #include #include -#include -#include #include #include +#include +#include +#include +#include +#include enum { /* magic number to trigger gdb breakpoint */ @@ -213,3 +216,245 @@ uint16_t *efi_dp_str(struct efi_device_path *dp) return val; } + +/** + * is_reserved() - Check if EFI memory type should be preserved + * + * @type: EFI memory type + * Return: true if memory type should be preserved, false otherwise + */ +static bool is_reserved(u32 type) +{ + switch (type) { + case EFI_RESERVED_MEMORY_TYPE: + case EFI_RUNTIME_SERVICES_CODE: + case EFI_RUNTIME_SERVICES_DATA: + case EFI_UNUSABLE_MEMORY: + case EFI_ACPI_RECLAIM_MEMORY: + case EFI_ACPI_MEMORY_NVS: + return true; + default: + return false; + } +} + +/** + * dt_region_exists() - Check if memory region is covered by DT reserved-memory + * + * @fdt: Device tree blob + * @start: Start address of region to check + * @end: End address of region to check + * Return: true if region overlaps with any reserved-memory node, else false + */ +static bool dt_region_exists(void *fdt, u64 start, u64 end) +{ + int node, reserved; + + reserved = fdt_path_offset(fdt, "/reserved-memory"); + if (reserved < 0) + return false; + + fdt_for_each_subnode(node, fdt, reserved) { + const fdt32_t *reg; + u64 start, size, end; + int len; + + reg = fdt_getprop(fdt, node, "reg", &len); + if (!reg || len < sizeof(u32) * 2) + continue; + + /* Parse reg property - assuming #address-cells=2, #size-cells=2 */ + start = fdt64_to_cpu(*(fdt64_t *)reg); + size = fdt64_to_cpu(*((fdt64_t *)reg + 1)); + end = start + size - 1; + + /* Check for overlap */ + if (!(end < start || start > end)) + return true; + } + + return false; +} + +/** + * dt_add_reserved() - Add EFI reserved region to device tree reserved-memory + * + * @fdt: Device tree blob + * @start: Start address of region + * @size: Size of region + * @type_name: EFI memory type name for node naming + * Return: 0 on success, negative error code on failure + */ +static int dt_add_reserved(void *fdt, u64 start, u64 size, + const char *type_name) +{ + int reserved, node; + char node_name[64]; + fdt32_t reg_prop[4]; + char *p; + int ret; + + /* Find or create /reserved-memory node */ + reserved = fdt_path_offset(fdt, "/reserved-memory"); + if (reserved < 0) { + /* Create /reserved-memory node */ + reserved = fdt_add_subnode(fdt, 0, "reserved-memory"); + if (reserved < 0) { + printf("Failed to create /reserved-memory node: %s\n", + fdt_strerror(reserved)); + return reserved; + } + + ret = fdt_setprop_u64(fdt, reserved, "#address-cells", 2); + if (ret) + return ret; + + ret = fdt_setprop_u64(fdt, reserved, "#size-cells", 2); + if (ret) + return ret; + + ret = fdt_setprop(fdt, reserved, "ranges", NULL, 0); + if (ret) + return ret; + } + + /* Create node name based on type and address */ + snprintf(node_name, sizeof(node_name), "efi-%s@%llx", type_name, start); + + /* Convert spaces and underscores to hyphens for a valid node name */ + for (p = node_name; *p; p++) { + if (*p == ' ' || *p == '_') + *p = '-'; + } + + /* Add new subnode */ + node = fdt_add_subnode(fdt, reserved, node_name); + if (node < 0) { + printf("Failed to create node %s: %s\n", node_name, + fdt_strerror(node)); + return node; + } + + /* Set reg property - #address-cells=2, #size-cells=2 */ + reg_prop[0] = cpu_to_fdt32(start >> 32); + reg_prop[1] = cpu_to_fdt32(start & 0xffffffff); + reg_prop[2] = cpu_to_fdt32(size >> 32); + reg_prop[3] = cpu_to_fdt32(size & 0xffffffff); + + ret = fdt_setprop(fdt, node, "reg", reg_prop, sizeof(reg_prop)); + if (ret) { + printf("Failed to set reg property: %s\n", fdt_strerror(ret)); + return ret; + } + + /* Add no-map property to prevent Linux from using this memory */ + ret = fdt_setprop(fdt, node, "no-map", NULL, 0); + if (ret) { + printf("Failed to set no-map property: %s\n", + fdt_strerror(ret)); + return ret; + } + + printf("added reserved-memory node: %s (0x%llx - 0x%llx)\n", + node_name, start, start + size - 1); + + return 0; +} + +/** + * sync_to_dt() - Print EFI reserved regions and add missing ones to DT + * + * @fdt: Device tree blob + * Return: true if any uncovered regions found, false otherwise + */ +static int sync_to_dt(void *fdt, bool verbose) +{ + struct efi_mem_desc *map, *desc, *end; + int desc_size, size, upto; + uint version, key; + int synced = 0; + int ret; + + /* Get the EFI memory map */ + ret = efi_get_mmap(&map, &size, &key, &desc_size, &version); + if (ret) { + printf("Failed to get EFI memory map: %d\n", ret); + return ret; + } + + if (verbose) { + printf("EFI Memory Map Analysis:\n"); + printf("%-4s %-18s %-18s %-18s %s\n", "ID", "Type", "Start", + "End", "In DT?"); + printf("-------------------------------------------------------" + "-----------------\n"); + } + + end = (void *)map + size; + for (upto = 0, desc = map; desc < end; + desc = efi_get_next_mem_desc(desc, desc_size), upto++) { + u64 start = desc->physical_start; + u64 end_addr = start + (desc->num_pages << EFI_PAGE_SHIFT) - 1; + u64 region_size = desc->num_pages << EFI_PAGE_SHIFT; + bool present; + + if (!is_reserved(desc->type)) + continue; + + present = dt_region_exists(fdt, start, end_addr); + + /* Print the region */ + if (verbose) { + printf("%-4d %-18s 0x%-16llx 0x%-16llx %s", upto, + efi_mem_type_name(desc->type), start, end_addr, + present ? "yes" : "no"); + } + + if (!present) { + const char *type_name; + int ret; + + if (verbose) + printf(" -> adding\n"); + + /* Add this region to device tree */ + type_name = efi_mem_type_name(desc->type); + ret = dt_add_reserved(fdt, start, region_size, + type_name); + if (ret) { + printf("Failed to add region: %s\n", + fdt_strerror(ret)); + free(map); + return ret; + } + synced++; + } else if (verbose) { + printf("\n"); + } + } + free(map); + + return synced; +} + +int efi_mem_reserved_sync(void *fdt, bool verbose) +{ + int synced; + + if (verbose) + printf("Comparing EFI memory-map with reserved-memory\n"); + + synced = sync_to_dt(fdt, verbose); + if (synced < 0) { + printf("Failed to sync EFI reserved regions: error %d\n", + synced); + return synced; + } + + if (verbose) { + printf("Regions added: %d\n", synced); + fdt_print_reserved(fdt); + } + + return synced; +} From patchwork Thu Aug 28 02:07:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 161 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=1756346899; bh=LH6fwMpswn7xHWfOcHWu0XuVJ3/zZn9KFmK+v+xlsIE=; 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=LPZoUYCCfBZNIZGuioMYQsYDMxarvl4veSDBw4RV7in2WAkpD1yZyn2F6vMfx9mVZ L8WJ4vh2ROg+m09XvZxTL3QAYhjLbBytxuzannSJ28nZjoE7DPlGMrSNxVgoj0hyBf aeeP9is21uwNK91mirgF9mMAs1kNkGbB4NBChADmPSKyMR+bBkDzEZKvDyHvsgcd// jpPAB4VrgXDj+w5Y8RNHq0yEZkWcRbtCwvJlrQ155quxrYfn/ALFIESCtTo9TJ4b+e r9ZX12uS9UqShXz48f9MOlxI3VOPxgSAovhy8pI6+7fsAjrljcWDdRc4eaQHmaygEA HrQ6e0UYUHS4w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 41B496783A for ; Wed, 27 Aug 2025 20:08:19 -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 Kl7TUsnKlZ7K for ; Wed, 27 Aug 2025 20:08:19 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346897; bh=LH6fwMpswn7xHWfOcHWu0XuVJ3/zZn9KFmK+v+xlsIE=; 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=E7iwJOamlJpEpyicUNE7inOenJwjx1xh0q5vT/D2ITxnu7tP3y337WWsXnFDZwoz4 xQLMXN++IucOYaNr+AIY5FjMFruW4TZR47zvIWIb5j826Pz7AS7mGuHNxtHX5CsFwh cRstIVK1F9dbjU4CfWxaBJiV1TaRMxDnHXhp4WHfyMElVlL+wOKsF5nzftK/Q3+kTt Vxc6pR/3ohzsUDMQQFav+4e82Tw7wCnUxboNpEoKzNvktByEx8zGuOHP6QtpfR73Du 2ZXpso8U6APauTowe5KARyS+2uIQc1QFef6iHA76FkuT7uJS7xsK5xGJ2IEBe93x9b /KqBBiSVRc+8Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A9B3F6777A for ; Wed, 27 Aug 2025 20:08:17 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346894; bh=xbtyvgrMVc69xROoLfVr4egJjyUTRs5l0poKwA46nkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ShVoW9TZjGAdeJiqkQ4gTT/2S33dvwWkJEDsXlpTDG1UzIaIjgbQevYzfF//nhsus KwnjRWKk8K5lh1CTlwUlW8zueAUI4dtAHWkPX2+WPjYYKy3Lz26ngeYeCYhHewNqzo Mm1w7PqF60ympA/i0I5H75eVONZg+pB3jhfKBOfsyXEE10vm0+RHW7U3LrZydR1Y1u LH74kOvqTWfDB3hwZGuY82imh5n7H4Bzy022z2BrVJ2lQIAYwDmiJUOdfcpcWDiBF/ 012OZWxY9niJuJFszTESJrYzbL6OENgCqwsZMlFGcx8uTJUj0QmMVXFDq9/U/T3VS1 bCnkfE8eQlTaw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8FDEC6777F; Wed, 27 Aug 2025 20:08:14 -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 2M4SXjAOchBb; Wed, 27 Aug 2025 20:08:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346891; bh=BbP7B5ZkoVkx6QFQDvaSNoJy0+VNnns7FFdhYwE7P00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YqzQUqSbYiETNQrqBxKyJ+25rO2xF6yUShXAvU9OQRA8lbfheNWMD77077pGg4qiA 3RTDQgHEhq5naGXuq0hOrQFEUFh3+uqU0JHilOAe11QfW6J4Y1UnzIlaa0dMd1SXh1 LiegbKoDE0bOUc2EjU/r7yaztuG6jYrlW15CHMjv0eDwcbpN85Fmj3e1XWJBRquMTn rkqplOjS++2JZMRzODOsfdvnctC5d5wY+QoWiGGVVCzgttT7pnXMSY2bWQurp/JaOm 0/0FhMSJaGsUc5ZQz2oVJZGzknCkoEHE32tmZ5uHPFnQo7xDK6yWuceYfHo5rnbeQn KpjbXoM8PlcPA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 08E766783A; Wed, 27 Aug 2025 20:08:10 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:21 -0600 Message-ID: <20250828020732.981415-19-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: CHNKHGA72WEXLLRMTRTGBY65EMGFFUN2 X-Message-ID-Hash: CHNKHGA72WEXLLRMTRTGBY65EMGFFUN2 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 18/20] fdt: Provide a command to sync the reserve-memory node 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 Provide a command to sync reserved-memory with EFI's version of reserved memory. Co-developed-by: Claude Signed-off-by: Simon Glass --- cmd/efi.c | 22 ++++++++++++++++++++-- doc/usage/cmd/efi.rst | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/cmd/efi.c b/cmd/efi.c index c59219ddf01..c329e6eede8 100644 --- a/cmd/efi.c +++ b/cmd/efi.c @@ -198,9 +198,26 @@ static int do_efi_tables(struct cmd_tbl *cmdtp, int flag, int argc, return 0; } +static int do_efi_memsync(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + bool verbose = false; + int ret; + + if (argc > 1 && !strcmp(argv[1], "-v")) + verbose = true; + + ret = efi_mem_reserved_sync(working_fdt, verbose); + if (ret < 0) + return CMD_RET_FAILURE; + + return 0; +} + static struct cmd_tbl efi_commands[] = { U_BOOT_CMD_MKENT(image, 1, 1, do_efi_image, "", ""), U_BOOT_CMD_MKENT(mem, 1, 1, do_efi_mem, "", ""), + U_BOOT_CMD_MKENT(memsync, 2, 1, do_efi_memsync, "", ""), U_BOOT_CMD_MKENT(tables, 1, 1, do_efi_tables, "", ""), }; @@ -223,9 +240,10 @@ static int do_efi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) } U_BOOT_CMD( - efi, 3, 1, do_efi, + efi, 4, 1, do_efi, "EFI access", "image Dump loaded-image info\n" "mem [all] Dump memory information [include boot services]\n" - "tables Dump tables" + "memsync [-v] Sync EFI memory map with DT reserved-memory\n" + "tables Dump tables" ); diff --git a/doc/usage/cmd/efi.rst b/doc/usage/cmd/efi.rst index e5d8913c94b..f91a2bd7bec 100644 --- a/doc/usage/cmd/efi.rst +++ b/doc/usage/cmd/efi.rst @@ -14,6 +14,7 @@ Synopsis efi image efi mem [all] + efi memsync [-v] efi tables Description @@ -69,6 +70,24 @@ Attributes Shows a code for memory attributes. The key for this is shown below the table. +efi memsync +~~~~~~~~~~~ + +This synchronizes EFI reserved memory regions with the device tree's +reserved-memory nodes. When running as an EFI application, U-Boot can access +the EFI memory map to identify regions that EFI considers reserved (such as +runtime services code/data, ACPI tables, etc.). This command compares these +EFI reserved regions with the device tree's /reserved-memory nodes and adds +any missing regions to prevent Linux from using memory that EFI has reserved. + +Use the optional '-v' flag for verbose output showing the detailed memory +map analysis. Without this flag, only errors are displayed. + +This is useful for ensuring proper memory management when transitioning from +EFI boot services to the operating system, particularly in complex firmware +environments where EFI may have reserved memory regions not explicitly +documented in the device tree. + efi tables ~~~~~~~~~~ @@ -234,3 +253,20 @@ Example 000000001fb7e000 eb9d2d30-2d88-11d3-9a16-0090273fc14d EFI_GUID_EFI_ACPI1 000000001fb7e014 8868e871-e4f1-11d3-bc22-0080c73c8881 ACPI table 000000001e654018 dcfa911d-26eb-469f-a220-38b7dc461220 (unknown) + + => efi memsync + Regions added: 2 + + => efi memsync -v + Comparing EFI memory-map with reserved-memory + EFI Memory Map Analysis: + ID Type Start End In DT? + ------------------------------------------------------------------------ + 0 EFI_RUNTIME_SERVICES_CODE 0x001f9ef000 0x001faef000 no -> adding + 1 EFI_ACPI_RECLAIM_MEMORY 0x001fb6f000 0x001fb7f000 no -> adding + 2 EFI_ACPI_MEMORY_NVS 0x001fb7f000 0x001fbff000 yes + Regions added: 2 + Reserved memory regions: + 0 tcg_event_log 0x100000 0x2000 + 1 efi-runtime-services-code@1f9ef000 0x1f9ef000 0x100000 + 2 efi-acpi-reclaim@1fb6f000 0x1fb6f000 0x10000 From patchwork Thu Aug 28 02:07:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 162 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=1756346899; bh=xr7W2gINqgKeGR+S2TkKRb3lzZu61abYyXIX1ndScYs=; 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=Mi0Hc/W3VBKk8KOqf1ENrT1Qr+VlYOrPI7JPQTy1Bf++qOV6Kab9Tn3c2N4TQ20XO JZO7TdkWauu9vrfyWu7AraAeMdERabMx7A8fqr6QP4DUK8IEB3u16wP+8YnrQeHbCT u4IEwR/OTaeaGZCteWyYx9QNyqrSpNcRG5ph8BWyajm/v2m4cL3zriCs5+oudzUWxc 0qTjEDN+pA82bqRArYChGGh0nFVW1xKNOFCglr/5H90ciWR4u4pLo8ziZffbWduJ9h AYXzKnraGwU2t8rXnPgVFx1HCi3Sb6XMfinFPM6/Zv73CM+pXpRifbfW3Y4Hf81U9k ikZagg609Iq/w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 76B016776F for ; Wed, 27 Aug 2025 20:08:19 -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 HclDF4bQWoJI for ; Wed, 27 Aug 2025 20:08:19 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346898; bh=xr7W2gINqgKeGR+S2TkKRb3lzZu61abYyXIX1ndScYs=; 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=e5/mFAt8QrJoip4wnzTd20WsAmC4uykI7RpYDp3B/FPs/n7nHVk9QqhrjrqI11X3m ZL88FtTZLB9oDyyB3izk5ZJwjdMSfqIXJgQuxMr4l0KQFhVmJZdHujBGO7YSdiRvfj 2IPP3tCUv8Qx/gVQmc/kP3c/Aphx9krA3xlULEBmrcl61i8m3FQ/2ia1N8s06BHMyA Jakn7URPuk5ncS0cunE4mU1h4PT08rBhsEx+MfSctQkwPMnOos7AIkzHGKWhpy6gs3 hkS43sFgye8+bd+uuU5fQ7ns7oZHAgg6bnZBmhFviK8Tkd98si+emnYHLj+fDwQAj7 SAbCH8si4bYGg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A9CA26780C for ; Wed, 27 Aug 2025 20:08:18 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346894; bh=Vmz0qk/jQhkW/6ZM6QjfXs2fpCaYoJP7MAHHjBzWnJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uwBEHd4HuhjWjWXlGHKCdltyfOXaaf5orJNHOBh2BLjF+50wM49GcYpYwpr1gvhJZ kRm/uBiZtChHSwsdFc10Ce4LacXjglF9lbtKgF7XJgYmnc4qGsPh08MhllzwYU+W1Z J0ex/2UqEc2LeL0cy9zzquRosIAZFz8iwfrrqMorbK6tgCTa3YxVzXw7Vn1Bf3jeTW F1M1nnDWO2Hky81Vn73G9/m0qDBYyOSTVf7jg2KvwBFmS+J4vhvlBdlKOgSErPLzgv zIY/ieZg7v0LRqC/ha8UwhW54ktYqAvyhqySrgcyurF2DJo2Nr4S/veO7f8oo4CxeQ zv1YWqKj7yc3A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 98CCF677B6; Wed, 27 Aug 2025 20:08:14 -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 7I0gbaioxtwd; Wed, 27 Aug 2025 20:08:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346892; bh=KEHkdroDqh8OpM8xhxouecF9Px/GZZCXboIIsIgNEP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hMR8vjlZG3ojLYbSTS4rha1SduUDYtCWm43BgGtkOu+p7bm9q6zKQtSgg1PeaoH37 B82a0ZC35Wiz+zTBuZ7WrFOXqZoNtOUAnPHV0Pg5MwTJ1yWJgKjFA9X4NxqhjGnxwv utXxh0v/U8fBFDwQON32dLdSh44PwdGnupufWoDmPkCtQUhobGrJLk4crvYAhg6VSS VdLR4pn37vWIDtOY2rA5+QRXxZvfIDAJXLglouCJPDe8epLu2vTK7u4fieCkBYhvSL FGbnnxFP4qIDRIPMyIYNxUmLXZoMbi6La9f5BevIlL8ZjPCA0b3llt/8AQAkPJXWBX 4trMovBCh6vQg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F2F1D67832; Wed, 27 Aug 2025 20:08:11 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:22 -0600 Message-ID: <20250828020732.981415-20-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: G4GAVHG6BFTGMMTGZL52G6JU3CC2EPLJ X-Message-ID-Hash: G4GAVHG6BFTGMMTGZL52G6JU3CC2EPLJ 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 19/20] efi: app: Add a simple-framebuffer node if enabled 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 The EFI app cannot make the EFI GOP available to Linux directly, since it calls exit-boot-services before booting Linux. The easiest way to provide an early console is with the simple-framebuffer feature. Add this node to the devicetree if the feature is enabled. Co-developed-by: Claude Signed-off-by: Simon Glass --- lib/efi_client/efi_app.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index f67973dbb85..33ed3f2a874 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -348,9 +348,11 @@ int ft_system_setup(void *fdt, struct bd_info *bd) return ret; } - ret = fdt_simplefb_add_node(fdt); - if (ret) - log_warning("failed to set up simplefb\n"); + if (IS_ENABLED(CONFIG_FDT_SIMPLEFB)) { + ret = fdt_simplefb_add_node(fdt); + if (ret) + log_warning("failed to set up simplefb\n"); + } free(map); From patchwork Thu Aug 28 02:07:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 163 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=1756346899; bh=sU0HYOxkpBzYrKAkvBZyzCN8c++I40dcjQQJgceELSY=; 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=YxDenSvvZ//ahCu0S5atQgn+GJt49sXiq6okGhon8NZMsD0CgI31pVdPBdWdbxXap AJG1eIn7uOUWxTaOHe6y+jHsqCy+/TJbbeoSN98lEHY6aZGSQfFjPYimauEhi9VhWs CnpuIzBF8aMltNOjsiuzvWixDtC3Fs613RhUZY7fp92nfQHDdSU43WOg2TiqBY6Eh7 pjpfk7ICkPOHrX1h7wvAp2KdA1Y65ol0ODzIfNCpVrWLshUgrRVbCr0I8eOs+HmgkJ rWBDQptcRYFFQci/OnBh9cqX02cKkW/rA85AGGcGlJxLWpS3k4abscwE+IHCtsMSIa Z+wPUHUsa++UA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9D8D267831 for ; Wed, 27 Aug 2025 20:08:19 -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 VD9kmr_9yiM6 for ; Wed, 27 Aug 2025 20:08:19 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346899; bh=sU0HYOxkpBzYrKAkvBZyzCN8c++I40dcjQQJgceELSY=; 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=YxDenSvvZ//ahCu0S5atQgn+GJt49sXiq6okGhon8NZMsD0CgI31pVdPBdWdbxXap AJG1eIn7uOUWxTaOHe6y+jHsqCy+/TJbbeoSN98lEHY6aZGSQfFjPYimauEhi9VhWs CnpuIzBF8aMltNOjsiuzvWixDtC3Fs613RhUZY7fp92nfQHDdSU43WOg2TiqBY6Eh7 pjpfk7ICkPOHrX1h7wvAp2KdA1Y65ol0ODzIfNCpVrWLshUgrRVbCr0I8eOs+HmgkJ rWBDQptcRYFFQci/OnBh9cqX02cKkW/rA85AGGcGlJxLWpS3k4abscwE+IHCtsMSIa Z+wPUHUsa++UA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0B42F67835 for ; Wed, 27 Aug 2025 20:08:19 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346894; bh=9e3NVjsC1ZSup1kOZQFyldEeIXWo/3GjG2NN2liEfDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YXrySZ5nTwix54oPMSgF6uPVtrwo7xIrr+oK0hIOev1/7z/SvvsxNz0s3FYd2VzHl bCe7Jbn5Sw90AAvvFpDfMyx5CCe5JOS6srMro/oDity23IdMK/RjnZATdcfXT//LDy O/s9wBkl/Srl9ju7CqIX5xNt8jh3JPxQ0rD2e8KRTiwoD3c4ZFpPYDxp3bCpy2vDkL AdLUoxivRLA14mbnkn1W++/jGBIRC0wdV63a14EW9IlxI582oba/mVeApYHl7tBBdK qaBvsPModd3ELohmbX7oLqzRryyC8nAaswRvW/Fuqw1d02ckZkujsIatIDbH+blY/d Ac745Lsp9vBKw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A1EE6677CB; Wed, 27 Aug 2025 20:08:14 -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 iMs-CyZs6H8Q; Wed, 27 Aug 2025 20:08:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346893; bh=1z/G2i34GqpI0V7eVaB5PUzOYlpP2Ws6xauyrkBQP8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JqlPaHkTybAz42axh/A89dLfbwGS8WCCmisDFUwr5w+0NjC908mxJ8vFS1rr2aU7E mLw3OdCrykUc+dr7ab9QAo0QgQ0r1PD5Y89m2hr7804D+9lm4KfHPPWIl4BI23HvFJ QlVj3VvlIWa4s7x4j85pBvgTAvr+68AjibSulx/Iv+7CCTj+C/geyEnRvgp99xgfcZ lp1Y7bnqMXBBG1149+MoF7CYj3tUA4M90YqpZCMlhMSarJe93aFAaYawADUiYNztso gSjdrKwgCyOV7tGYI3zKmwutUeOqfgDuHaBFzuvdIIcCxpJgdYY56Ok92hkYJc1LHU S628vNBTpjuSg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D78EB6777E; Wed, 27 Aug 2025 20:08:12 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:23 -0600 Message-ID: <20250828020732.981415-21-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: O4ZBDJM5SM7C5DTANDSD3TVWOA2JZM2Y X-Message-ID-Hash: O4ZBDJM5SM7C5DTANDSD3TVWOA2JZM2Y 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 20/20] efi: app: Sync EFI reserved-memory to the devicetree 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 Obtain EFI's view of reserved memory and ensure that everything mentioned there is present in a devicetree reserved-memory node. This ensures that the OS doesn't try to access memory it shouldn't. Signed-off-by: Simon Glass --- lib/efi_client/efi_app.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index 33ed3f2a874..6b8b53fbb41 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -354,6 +354,11 @@ int ft_system_setup(void *fdt, struct bd_info *bd) log_warning("failed to set up simplefb\n"); } + /* Compare EFI memory map with device tree reserved regions */ + ret = efi_mem_reserved_sync(fdt, true); + if (ret) + log_warning("failed to set up reserved memory\n"); + free(map); return 0;