From patchwork Wed Mar 17 19:55:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 403221 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp777717jai; Wed, 17 Mar 2021 12:56:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQt+ZBR/WkQDo0rxnwabyOQpqWZPH6ereOQ1tw9PG/RiWmdbxTkOFAzUOeF18unVcpgGfe X-Received: by 2002:a17:906:abcd:: with SMTP id kq13mr38159991ejb.477.1616010963451; Wed, 17 Mar 2021 12:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616010963; cv=none; d=google.com; s=arc-20160816; b=Xqql58lkykjB+BqCK8LClQy0+lFpEolRIvC4xRr2qGxco5BEm6QZ1hVAe3Bj8UKF4B 9CDLQlGht+5+O1Z3qiUeaMc9HvuH2qPXfyQBV72LsEAgs9mtv7b60BfQbfz1xktFa1Ws HLV8TjlXm4DBBPw6q39SJ+wIfIbfAtXXG3rGmZxXP6NEEQdiRsxw/fcmVhHNUcE2XIj0 T8SPSR7cCfpeOqpYLtQDmnxXm2G5Z3SEzQEPc1mjJHWtRRtfrbzSXH2pFd7ZLjglGn/F WNpx0xgoGVwHS6O35hVyzikMbFtD6SRzqBoNranqmSQNWFwQOEWayMOPGkzw6Z47at8v buLQ== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Wu8/J2Xru6ryD0NwjsWqGxk7wNVygVdeHIrIgE48aww=; b=pf7kenv24KRj2SVTV+MEgyTD8DmHCqbgf9jxaYH1iUxPVpTmAUxuWLZiF+ffcZlaWO bnnsipJVr1gAg+34NaHMvvy5zDp6FCQl1WMxId0N6pRn32J8DGyEq29JOc2zUwAUUwfT lRLJHdkRr35iEsGKWNKQmpWVKGe0O/yH8mESDAtKv1XKw/wRIOoWgiTfwYbslNRXkI5h 5kaE82UgkapvaaDiRZD1RRW/sNEFmZA/Ed/Gira33U+wEIfh0Syh+vgnelkiW3zgwIKu gv9VSIGyjvXACqpu9iJ+uSUb0nOeufR5PPvLsZEbjDzm13BOIeKGGHa4TTVBmhzGrOu4 ov0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DZpOXjrV; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id r20si17979815edw.406.2021.03.17.12.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Mar 2021 12:56:03 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DZpOXjrV; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=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 6D5C082843; Wed, 17 Mar 2021 20:55:34 +0100 (CET) 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="DZpOXjrV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DB34C82822; Wed, 17 Mar 2021 20:55:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 8C80E80040 for ; Wed, 17 Mar 2021 20:55:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wm1-x32f.google.com with SMTP id u5-20020a7bcb050000b029010e9316b9d5so2022768wmj.2 for ; Wed, 17 Mar 2021 12:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wu8/J2Xru6ryD0NwjsWqGxk7wNVygVdeHIrIgE48aww=; b=DZpOXjrVxk4ObauBZZZ/ZOxdMZBtqwIRa1z7+uMMJVM3AIXeyFYphu8mAipgPOD6y5 iOrxOv4C58psgAzBzGBanLnV7p4bahMOMNnOkwoOx0oQAUgXn1DECp4xRAX6QfOufwHb Ph+w/i80VV7LM5JEvBVYZg8BxXlAf4ub4U3W8jhPl5zyoNcOh8TC6Eu9/6wjcGn2Ybi6 L4pJmmcf/CtRuqc+QbK20jsb9milcQZ9iQDqi2KhY2cua4eW2cdOC2I0JhwB1xLUgp+X hgmKibM5TXEirvB+lG2mlIh0Hu5iN+KgR+dXFnhLK7uAe6psIzf/2Dug8q6bOIasjDKK mpXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wu8/J2Xru6ryD0NwjsWqGxk7wNVygVdeHIrIgE48aww=; b=MwgI+V0GHDWjLEJp3fW4as/w843eV0Hbx23cV8HeUI+EYVbyGhZBpS2QdZgdC5bRes qXCGZZHlIR78rOxo1pk6n9KaSGekIpqKp6vJQwh56aWLnXZEWExMnxmtu4czWndQ4kvx YGVf5Sxwg1+zwpHa37GU0AdSayIiViZQz+9QGkoWAUCcR/Fxkjpqlu8bvwlVnoiPKrMw 3iSaEp7fo7Ex6mjCBRhoDnfqlRGSKbQYi8S/VUc8YrPBcG75JjRWmDr5iRbkZNhBS0Kt jOkfV08XVqH8TSfImphN45ufx5rfxbqLnTKReVHLLuT2wXvhWbeaYisRG3OuYtfyMOMY OwJA== X-Gm-Message-State: AOAM532y3eCzvsKCQL625tpmlwnL2HblFLbtRwmnTH5wXZzQ0LXHxxF+ G+LWIwckWZXa25if/NMEpvtOdw== X-Received: by 2002:a05:600c:47d7:: with SMTP id l23mr398178wmo.155.1616010925021; Wed, 17 Mar 2021 12:55:25 -0700 (PDT) Received: from localhost.localdomain (ppp-94-64-113-158.home.otenet.gr. [94.64.113.158]) by smtp.gmail.com with ESMTPSA id z82sm3343853wmg.19.2021.03.17.12.55.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Mar 2021 12:55:24 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: takahiro.akashi@linaro.org, Ilias Apalodimas , Alexander Graf , Sughosh Ganu , u-boot@lists.denx.de Subject: [PATCH 4/5 v4] efidebug: add multiple device path instances on Boot#### Date: Wed, 17 Mar 2021 21:55:01 +0200 Message-Id: <20210317195505.337105-5-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210317195505.337105-1-ilias.apalodimas@linaro.org> References: <20210317195505.337105-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.4 at phobos.denx.de X-Virus-Status: Clean The UEFI spec allows a packed array of UEFI device paths in the FilePathList[] of an EFI_LOAD_OPTION. The first file path must describe the loaded image but the rest are OS specific. Previous patches parse the device path and try to use the second member of the array as an initrd. So let's modify efidebug slightly and install the second file described in the command line as the initrd device path. Signed-off-by: Ilias Apalodimas --- cmd/efidebug.c | 191 ++++++++++++++---- doc/board/emulation/qemu_capsule_update.rst | 4 +- doc/uefi/uefi.rst | 2 +- .../test_efi_capsule/test_capsule_firmware.py | 6 +- test/py/tests/test_efi_secboot/test_signed.py | 16 +- .../test_efi_secboot/test_signed_intca.py | 8 +- .../tests/test_efi_secboot/test_unsigned.py | 8 +- 7 files changed, 177 insertions(+), 58 deletions(-) -- 2.31.0 diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 55c7abe3d078..80ddd598e0a1 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include #define BS systab.boottime #define RT systab.runtime @@ -798,6 +800,54 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int flag, return CMD_RET_SUCCESS; } +/** + * create_initrd_dp() - Create a special device for our Boot### option + * + * @dev: Device + * @part: Disk partition + * @file: Filename + * Return: Pointer to the device path or ERR_PTR + * + */ +static +struct efi_device_path *create_initrd_dp(const char *dev, const char *part, + const char *file) + +{ + struct efi_device_path *tmp_dp = NULL, *tmp_fp = NULL; + struct efi_device_path *initrd_dp = NULL; + efi_status_t ret; + const struct efi_initrd_dp id_dp = { + .vendor = { + { + DEVICE_PATH_TYPE_MEDIA_DEVICE, + DEVICE_PATH_SUB_TYPE_VENDOR_PATH, + sizeof(id_dp.vendor), + }, + EFI_INITRD_MEDIA_GUID, + }, + .end = { + DEVICE_PATH_TYPE_END, + DEVICE_PATH_SUB_TYPE_END, + sizeof(id_dp.end), + } + }; + + ret = efi_dp_from_name(dev, part, file, &tmp_dp, &tmp_fp); + if (ret != EFI_SUCCESS) { + printf("Cannot create device path for \"%s %s\"\n", part, file); + goto out; + } + + initrd_dp = efi_dp_append((const struct efi_device_path *)&id_dp, + tmp_fp); + +out: + efi_free_pool(tmp_dp); + efi_free_pool(tmp_fp); + return initrd_dp; +} + /** * do_efi_boot_add() - set UEFI load option * @@ -810,7 +860,9 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int flag, * * Implement efidebug "boot add" sub-command. Create or change UEFI load option. * - * efidebug boot add