From patchwork Wed Oct 25 06:28:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 737804 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp131002wrq; Tue, 24 Oct 2023 23:30:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFv0RPy0tctV7ZWiIA+bIGJ7HNchf4VOOMZ6hkBMJsF5slQ9ZwP8FWiFPv43LbnFTJza3+Q X-Received: by 2002:a19:434d:0:b0:503:655:12e7 with SMTP id m13-20020a19434d000000b00503065512e7mr9509344lfj.62.1698215414968; Tue, 24 Oct 2023 23:30:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698215414; cv=none; d=google.com; s=arc-20160816; b=okRHI0ywQFGxyQ/Yuay0YBbiAva7DfHrUc294cqcLa94wF0tJzxWSrl2kQXdeFy+rK W+yr9Vy0YaneZaMzog5Aer+SFdGcmBY4wSgAB5woiFJUpcn58MtgSdT9GMzPdRJLzzNA kGWE/0ITVyeNBdafB/eelrJv4u/I7wzOw2/3W2+L9sqp/1ZTX7UcpevsW9cr6PdbI2TY hJqrfzcVFMB6VFo9bMmxLGqs/G5YZzIVaAapE3akmyrf70ccvJy4S7kU8a6NuAVxtBHP bVXZevrsoSKYJR45qTeyLv7QTlD97ejMYTQ5P2rT/cL0ElJ+k1uphrUE5nfXtcfK+h3A 2+Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=rYUotnGdmCNtzm1+hJAOLPJwshlD+GNXRkbF3vPiWns=; fh=I7E+BwgHMByijVVN/pPHsLSpz7oP4y4e73noHEekrEE=; b=IBBM4RdejXQkJpp9ie0mF2RLy8cxwGaxVSRQqXtZRCva4bgLE2gqI6h4coHoXurtNI fIjDXEBjxESsQlHFK65+FKpgxAY/2VOYtfvFvffhP7SIwdwIpnK9OyLorkNHHmR9uvO3 5IbG/g5tBZJpIOSSKbTGonT3XUteiga/W1AuC4ouTpYon7//276NVDJEQG4t4HTZTmZT IP5WQBQdrfCpeAD5s8CLntA7U+3ayZkiRvjDHZDry/VB6oyyZ9jGd83R8N3o7D0xzEqm xBTfLk/3btEwWPsWzfQgr8VnMTEeB9y5rQ3TioUVEjC3xBX0pizTM9qtS6QvxqXc/jdd JgOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t9TByjLe; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id bi25-20020a05600c3d9900b004020039a81esi7821737wmb.89.2023.10.24.23.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 23:30:14 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t9TByjLe; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6E6EC87A26; Wed, 25 Oct 2023 08:30:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="t9TByjLe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C510387A2A; Wed, 25 Oct 2023 08:30:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NORMAL_HTTP_TO_IP, NUMERIC_HTTP_ADDR,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D3532879E0 for ; Wed, 25 Oct 2023 08:30:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masahisa.kojima@linaro.org Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6be0277c05bso4278747b3a.0 for ; Tue, 24 Oct 2023 23:30:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698215401; x=1698820201; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=rYUotnGdmCNtzm1+hJAOLPJwshlD+GNXRkbF3vPiWns=; b=t9TByjLeowMBXo1T3Nf0BP3ZniwuCuHU+bfqR4xQe5mC6ouryRJXl+YjgMhgcZa7YO So+KG0XPEA1k3DN9gxnkj7470wXk0G40BNwYTARfnqBDPTE4FFL+oBYW6I0PqcNvyzMk zMFxb/Il+HnaU3eLeQZnjNhwgzFiJGPiBpS6k2l4tqi9zHqc4Xi4DcGYdzF3pMEXp/L1 7w+HCLdUk1PIgF94lWGqcKr+40ARrj+c3K8KjbP3O3g8jDmaJjLa2Veg+2ahfgVfCVV+ qwdiPA6r0P1hX1g0dSnAiZTj/hJuwLYJGO/uMVdSFXY+4x/DjdZd9YEd+342DqOrd+ON SrZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698215401; x=1698820201; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rYUotnGdmCNtzm1+hJAOLPJwshlD+GNXRkbF3vPiWns=; b=wPQP4AdpnQBj44+uR7zFUMjNkpUDeGCaQmnGE2YjuQ4PYcX5J/euM+wL9bbLLRO2wO 6AI2H7Q6EKUcT1b9e3nZUYMbqjkByGeaLqhfJmVShtsDYix3ZqI/ymVBJhQikJ5lJNEF daS7wc5QcFqutYxy9U7YdGLvyT4/l2menZFfQifG47DvS7r3CnKMiARrN8ztVV4rJ4IG JvlaMwvGOcJmrJJoYkd55CNnCwcE6E0mhRWtCyersVYGuW2mjJ5la85TP6j3x/Uqm7wE eOdJo1N0B79By20U6a1IAOq7MFKiR+IhbCcFZQVNtaAqu30NiUa5FNojFRiaYH9331/4 8X7w== X-Gm-Message-State: AOJu0YxgsH6UDDQaGAAe6blkZ8PMKqxq2IWFpYBPmdXf/2n05SphXaCe ags9QWwRBhPUWHvsZtxEIB3PYWnV7CAgtOQTdQQ= X-Received: by 2002:a05:6a00:1302:b0:693:3f7a:eec2 with SMTP id j2-20020a056a00130200b006933f7aeec2mr13141516pfu.29.1698215400813; Tue, 24 Oct 2023 23:30:00 -0700 (PDT) Received: from localhost ([164.70.16.189]) by smtp.gmail.com with ESMTPSA id u133-20020a62798b000000b006862b2a6b0dsm9314707pfc.15.2023.10.24.23.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 23:30:00 -0700 (PDT) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Takahiro Akashi , Michal Simek , Masahisa Kojima Subject: [PATCH v8 0/7] Add EFI HTTP boot support Date: Wed, 25 Oct 2023 15:28:38 +0900 Message-Id: <20231025062845.3100964-1-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This series adds the EFI HTTP boot support. User can add the URI device path with "efidebug boot add" command. efibootmgr handles the URI device path, download the specified file using wget, mount the downloaded image with blkmap, then boot with the default file(e.g. EFI/BOOT/BOOTAA64.EFI) by selecting automatically created boot option when the new disk is detected. This version still does not include the test. To enable EFI HTTP boot, we need to enable the following Kconfig options. CONFIG_CMD_DNS CONFIG_CMD_WGET CONFIG_BLKMAP CONFIG_EFI_HTTP_BOOT On the Socionext Developerbox, enter the following commands then debian installer is downloaded into "loadaddr" and installer automatically starts. => dhcp => setenv serverip 192.168.1.1 => efidebug boot add -u 3 debian-netinst http://ftp.riken.jp/Linux/debian/debian-cd/12.1.0/arm64/iso-cd/debian-12.1.0-arm64-netinst.iso => efidebug boot order 3 => bootefi bootmgr Note that this debian installer can not proceed the installation bacause RAM disk of installer image is not recogniged by the kernel. I'm still investigating this issue, but drivers/nvdimm/of_pmem.c in linux will be one of the solution to recognize RAM disk from kernel. (In EDK2, the equivalent solution is called ACPI NFIT.) On QEMU, I can not make DNS work from the QEMU guest. The following commands work on qemu_arm64(manually set the http server ip in URI). => dhcp => setenv gatewayip 10.0.2.2 => setenv httpserverip 134.160.38.1 => efidebug boot add -u 3 debian-netinst http://134.160.38.1/Linux/debian/debian-cd/12.1.0/arm64/iso-cd/debian-12.1.0-arm64-netinst.iso => efidebug boot order 3 => bootefi bootmgr [TODO] - add test - stricter wget uri check - omit the dns process if the given uri has ip address -> this will be supported when the lwip migration completes - uri device path support in eficonfig [change log] v7 -> v8 - search the default file on the fly, instead of creating the boot option with default file - delete blkmap and reserved memory in case of error or when the EFI application returns - update the subject "Boot var automatic management for removable medias" since this automatic boot option management is also applied for non-removable medias - update error handling in efidebug command - call efi_add_memory_map() instead of exposing efi_reserve_memory() v6 -> v7 - rename the funtion name from load_default_file_boot_option() to load_mounted_image() - move some fix from patch #5 "efi_loader: support boot from URI device path" to patch #4 "efi_loader: create default file boot option". - fix missing free() of default_file_path v5 -> v6 - add patch #4 "Boot var automatic management for removable medias" - boot from automatically created boot option rather than searching default file on the fly - introduce new CONFIG_EFI_HTTP_BOOT Kconfig option - comment in one place - use log_err() rather than printf() - use env_get_hex("filesize", 0) instead of return value of net_loop() - use more suitable error code - blkmap can be build for SPL/TPL - add CDROM short-form device path support v4 -> v5 - add missing else statement - add NULL check of efi_dp_find_obj() call - update document to remove "limitation" v3 -> v4 - patch#8 is added to simplify the bootmgr default boot process - add function comments v2 -> v3 - Patch#6 is added, reserve the whole ramdisk memory region - remove .efi file extension check for PE-COFF image - use "if IS_ENABLED(..)" as much as possible - 1024 should be sizeof(net_boot_file_name) - call net_set_state(NETLOOP_FAIL) when wget encounters error - describe DNS ip address host name limitation in document v1 -> v2 - carve out the network handling(wget and dns code) under net/wget.c - carve out ramdisk creation code under drivers/block/blkmap_helper.c - wget supports the valid range check to store the received blocks using lmb - support when the downloaded image have no partiton table but a file system - not start the .efi file in try_load_entry() - call efi_check_pe() for .efi file to check the file is PE-COFF image - add documentation for EFI HTTP Boot Masahisa Kojima (6): net: wget: prevent overwriting reserved memory net: wget: add wget with dns utility function blk: blkmap: add ramdisk creation utility function efi_loader: support boot from URI device path cmd: efidebug: add uri device path doc: uefi: add HTTP Boot support Raymond Mao (1): efi_loader: Boot var automatic management cmd/bootefi.c | 5 + cmd/efidebug.c | 51 ++++ doc/develop/uefi/uefi.rst | 30 +++ drivers/block/Makefile | 3 +- drivers/block/blkmap.c | 15 -- drivers/block/blkmap_helper.c | 53 ++++ include/blkmap.h | 29 +++ include/efi_loader.h | 1 + include/net.h | 17 ++ lib/efi_loader/Kconfig | 9 + lib/efi_loader/efi_bootmgr.c | 229 ++++++++++++++++++ lib/efi_loader/efi_disk.c | 18 ++ lib/efi_loader/efi_setup.c | 7 + net/wget.c | 205 +++++++++++++++- test/py/tests/test_efi_secboot/test_signed.py | 42 ++-- .../test_efi_secboot/test_signed_intca.py | 14 +- .../tests/test_efi_secboot/test_unsigned.py | 14 +- .../test_fs/test_squashfs/test_sqfs_ls.py | 6 + 18 files changed, 690 insertions(+), 58 deletions(-) create mode 100644 drivers/block/blkmap_helper.c