| Message ID | 20260110202906.187370-1-sjg@u-boot.org |
|---|---|
| Headers |
Return-Path: <concept-bounces+u-boot-concept=u-boot.org@u-boot.org> 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=1768076961; bh=biW7woZU7l/NJ3YD9a5emCH/iQhktK7SkO2WjDgDSeQ=; h=From:To:Date:CC:Subject:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=jhXq1kdqyd+H7UyzvtxoEyjgimPhsA5dbohz6aLGbVEO+kgKku8QTlEMbKdTc9z3H 9G/dMFZruRJ2ykwFn+ZG6Fj5zS4CWWxcxGMoakYMqUBLnqIvIDgG0u+eYA7iWR39jk fEteghwm4TRs9LOUtADBqtcsC1L4NfV0/VfxHgI3uTONRWx/bU4VZUSBnR7MAZtZum 1yv9AsG6Gj1HwyYNfUDdRgYwp+JgxDjGD07LNEQikgUkhWsufsniD7UQn7NEvIpnPM UKmRdeeTLxuJTF5SabLDW2wlFiBgbHjswTn/K1ZjehUY2i5lya/unTMH+BvkjD3kWw Z1ataRdrN2frg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 774096928E for <u-boot-concept@u-boot.org>; Sat, 10 Jan 2026 13:29:21 -0700 (MST) 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 km9xhFTNqinU for <u-boot-concept@u-boot.org>; Sat, 10 Jan 2026 13:29:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076961; bh=biW7woZU7l/NJ3YD9a5emCH/iQhktK7SkO2WjDgDSeQ=; h=From:To:Date:CC:Subject:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=jhXq1kdqyd+H7UyzvtxoEyjgimPhsA5dbohz6aLGbVEO+kgKku8QTlEMbKdTc9z3H 9G/dMFZruRJ2ykwFn+ZG6Fj5zS4CWWxcxGMoakYMqUBLnqIvIDgG0u+eYA7iWR39jk fEteghwm4TRs9LOUtADBqtcsC1L4NfV0/VfxHgI3uTONRWx/bU4VZUSBnR7MAZtZum 1yv9AsG6Gj1HwyYNfUDdRgYwp+JgxDjGD07LNEQikgUkhWsufsniD7UQn7NEvIpnPM UKmRdeeTLxuJTF5SabLDW2wlFiBgbHjswTn/K1ZjehUY2i5lya/unTMH+BvkjD3kWw Z1ataRdrN2frg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6191B69286 for <u-boot-concept@u-boot.org>; Sat, 10 Jan 2026 13:29:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076960; bh=tx7aptnL+iuzTEUkqSoE76RFP+mb+2HzZf+tvM+fG1U=; h=From:To:Cc:Subject:Date:From; b=YPDQPLfoKbgdn9Bjb2wPNj1kRh+Z6P3GgHayiRjNWzzH6emo2thJgA87QDzFGgRy5 W3i504x/A7780RHiyXuyb/58HlXAjOPZYBzUILuuDfHPzMp84gDmFwzNavpL3rnW7N tDXx/XUI8iapkLmP7UQeW+zzDIXFEefmfiQ2rmxOzbERiZU+awzO4pDPCZRtZJkWCL J1w1G9ooa6d/got9+UGr4896mNbYENhWTsJwgYmTWlR61FoyuJe4LJP49BDljtUFTZ TZ5iNXvx90A+Bbr9DErWb6klOPusbL3edjDYLVpDymv7OqtSPqzYK3tMEdtFTCwf7b 0yCYg7hWgUIWQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2BAE569221; Sat, 10 Jan 2026 13:29:20 -0700 (MST) 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 cGSG6_obkok6; Sat, 10 Jan 2026 13:29:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076956; bh=kowX1vkgahzDblLnb9DJMcEJnF92YP6iPvYR69cmacY=; h=From:To:Cc:Subject:Date:From; b=tIujpnE6R7S8JaAIuLPAsNTel5AChI4jbxhZhhLTFgjIeKOTdfsi0/zMakuRygpbN WYzIiLrIiypc1vNNloCB8y0B3bQ8el5l1Zgk046aSlWAgbcXHBK6MCoNBd9vCPH+u8 z3yZh1bjPAKNcSRaVIONuqIsLidBNEDnOFBb7zrqE6T3miSEJWVW181zn4qNWrUVAb tuo4MBhUolAo4aizXD1VR37LuoUJK7Co0srbeIu081X/23qXUBz7u6IAqRpourw2kR S8zikuw4PSKTCA5pgLTgG/xz1/m/3NLaKz/IyL2UiCEn52QMX2hoONrdyfaifbDPcZ GVa9EOKafvp7Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C0B4769186; Sat, 10 Jan 2026 13:29:15 -0700 (MST) From: Simon Glass <sjg@u-boot.org> To: U-Boot Concept <concept@u-boot.org> Date: Sat, 10 Jan 2026 13:28:32 -0700 Message-ID: <20260110202906.187370-1-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Message-ID-Hash: FLREC3MUQ6OJZGNX4CQNFDYS3ANFTD34 X-Message-ID-Hash: FLREC3MUQ6OJZGNX4CQNFDYS3ANFTD34 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 <xypron.glpk@gmx.de>, Simon Glass <simon.glass@canonical.com> X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 00/26] boot: pxe: Add three-phase API and fix memory leaks List-Id: Discussion and patches related to U-Boot Concept <concept.u-boot.org> Archived-At: <https://lists.u-boot.org/archives/list/concept@u-boot.org/message/FLREC3MUQ6OJZGNX4CQNFDYS3ANFTD34/> List-Archive: <https://lists.u-boot.org/archives/list/concept@u-boot.org/> List-Help: <mailto:concept-request@u-boot.org?subject=help> List-Owner: <mailto:concept-owner@u-boot.org> List-Post: <mailto:concept@u-boot.org> List-Subscribe: <mailto:concept-join@u-boot.org> List-Unsubscribe: <mailto:concept-leave@u-boot.org> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit |
| Series |
boot: pxe: Add three-phase API and fix memory leaks
|
|
Message
Simon Glass
Jan. 10, 2026, 8:28 p.m. UTC
From: Simon Glass <simon.glass@canonical.com>
This series adds a callback-free API for PXE/extlinux parsing that
eparates the process into three distinct phases: parse, load, and boot.
The traditional API uses callbacks during parsing to load files
immediately. The new API instead collects file information (kernel,
initrd, FDT, overlays) into a list during parsing, allowing callers to
load files manually before booting.
Include files are handled in a similar way.
Rather than requiring the config files to be nul-termiated, the size of
the file is provided and used to determine the end of the configuration
file.
New functions:
- pxe_parse() - Parse config and return menu with file list
- pxe_load() - Load files for a selected label (optional helper)
- pxe_boot() - Boot using loaded files (renamed from pxe_do_boot)
- pxe_cleanup() - Clean up context and menu
The series also fixes several memory leaks in the parser found through
malloc dump analysis.
Size growth is unfortunately significant. On Thumb2 the memory-leak
fixes add 116 bytes; removing the need for nul-termination takes 116
bytes and the alists and and general logic take another 60
Simon Glass (26):
lib: abuf: Add abuf_init_addr() helper
boot: pxe: Free bmp in pxe_menu_uninit()
boot: pxe: Fix token memory leaks in parser
boot: pxe: Free menu label in label_destroy()
boot: pxe: Fix memory leak in parse_fdtoverlays()
boot: pxe: Make pxe_prepare() static and document it
boot: pxe: Simplify pxe_parse_include() to take only address
boot: pxe: Add struct pxe_file for file loading
boot: pxe: Replace pxe_fdtoverlay with pxe_file
boot: pxe: Use the files list instead of fdtoverlays
boot: pxe: Add a helper to add to the file list
boot: pxe: Add the kernel to the files list when parsing
boot: pxe: Add the initrd to the files list when parsing
boot: pxe: Add the FDT to the files list when parsing
boot: pxe: Set pxe_file_size in get_pxe_file()
boot: pxe: Set pxe_file_size in extlinux_read_all()
boot: pxe: Add size parameter to parse_pxefile()
boot: pxe: Add pxe_process_str() for nul-terminated strings
boot: pxe: Update parse_pxefile() to take struct abuf
boot: pxe: Remove unused base parameter from parse_menu()
boot: pxe: Remove unused base parameter from parse_pxefile_top()
boot: pxe: Add a limit parameter to parser functions
boot: pxe: Add a callback-free PXE API
test: pxe: Add a test for the callback-free files API
test: pxe: Add memory-leak check to files-API test
doc: bootstd: Add PXE parser API documentation
boot/ext_pxe_common.c | 5 +-
boot/pxe_parse.c | 242 +++++++++++++++++++----------
boot/pxe_utils.c | 127 ++++++++++++---
cmd/pxe.c | 2 +-
cmd/sysboot.c | 2 +-
doc/develop/bootstd/extlinux.rst | 2 +-
doc/develop/bootstd/index.rst | 1 +
doc/develop/bootstd/pxe_api.rst | 194 +++++++++++++++++++++++
doc/develop/bootstd/pxelinux.rst | 2 +-
include/abuf.h | 12 ++
include/pxe_utils.h | 176 ++++++++++++++++-----
lib/abuf.c | 6 +
test/boot/pxe.c | 255 +++++++++++++++++++++++++++----
test/lib/abuf.c | 23 +++
test/py/tests/test_pxe_parser.py | 11 ++
15 files changed, 876 insertions(+), 184 deletions(-)
create mode 100644 doc/develop/bootstd/pxe_api.rst