From patchwork Thu May 12 02:29:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1629887 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=xO6RPoSP; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KzG2b2n9wz9sFx for ; Thu, 12 May 2022 12:29:59 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BC37684372; Thu, 12 May 2022 04:29:50 +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="xO6RPoSP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B63A18435A; Thu, 12 May 2022 04:29:48 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) (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 77A6E8432D for ; Thu, 12 May 2022 04:29:45 +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=takahiro.akashi@linaro.org Received: by mail-pg1-x52e.google.com with SMTP id v10so3336359pgl.11 for ; Wed, 11 May 2022 19:29:45 -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=h6UUKFaHkOLSlGWXFN0CEMZtf9sWvPkPw+9EWwYGpCg=; b=xO6RPoSPvYlUhFbX0/+E+UGw3Nr8Yq4ww4z/u+SSg1z+gjWsI2impxphR188Rul2Ih /zZDTQJ/22luDiceJ1999Q+AaKk+dJO6ZdKQtCmyOTB45alSTv/+VmAUHYmtaqUpIqO5 4XSLFwDZ2byOzcbUA/k0gYSoygZyhQR/N0rqCG8QAR/NlwYhBRLxGxRfQBB+YDPLOieh dEyUB3isSYN8ZoGpE8adtsMDBBCTpSlzmxu6awmAdSa2h+Pm53EapLhW0lqZTnTjDT0G JcOy5oFRb1HQJVWkB4WUqgKeeKcXbRWiPVDO/GsavqJiH2pbfwogVPGDOlRL9oNN6DX9 2nmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h6UUKFaHkOLSlGWXFN0CEMZtf9sWvPkPw+9EWwYGpCg=; b=JuzkUvHXf+M8loPY+WJuNuVWa13pcfSDiVChGJJY9Iedpc5zXCPDbIRHoZk92D9TEQ ohjS5X1dRXW9VYDEiPGr0LhKXTmZbpA0ecdlTW/lmawVUlFNch/3sXoivWfHye6rrhkG zJ0FZ0/StCngLFglmbqX741ARrjT1g/J+kq+OB68hQm/CuMNe+ZjSAFIGsQssWKIxN50 5ktLclaeqJuSQrVcPAF979b0IXQX+LyBevwGMLrEdcer1W/rhhIqbJDTSTPUD4gpDfhO mFTNNqdqvN7XxfCAsBB4aTrF88/y9GkYufyB9gbOQJsTBICCDGfI34VBjve6USvheLfX vCeQ== X-Gm-Message-State: AOAM5320pGAtO+sCrqfdJsA8QztleX9uTh7qlCMBgB0mcKgPP2TX0aKF wmPygRm1JWR+SbfWS1yx08IooGQo0AFrqA== X-Google-Smtp-Source: ABdhPJxhhs0dPfo+v4jyZu8ZY/knKK8gQCfFLDiqBMoJfU00zIU19e04oFWdfE6g6CZcpziJ57ckKg== X-Received: by 2002:a63:82c7:0:b0:398:2d6d:848a with SMTP id w190-20020a6382c7000000b003982d6d848amr22110645pgd.343.1652322583903; Wed, 11 May 2022 19:29:43 -0700 (PDT) Received: from localhost.localdomain (p914133-ipoe.ipoe.ocn.ne.jp. [153.243.15.132]) by smtp.gmail.com with ESMTPSA id i4-20020aa78b44000000b0050dc7628190sm2445314pfd.106.2022.05.11.19.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 19:29:43 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de Cc: mark.kettenis@xs4all.nl, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 1/3] efi_loader: disk: add efi_disk_is_removable() Date: Thu, 12 May 2022 11:29:01 +0900 Message-Id: <20220512022903.65346-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220512022903.65346-1-takahiro.akashi@linaro.org> References: <20220512022903.65346-1-takahiro.akashi@linaro.org> 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.5 at phobos.denx.de X-Virus-Status: Clean This helper function will be used to determine if the device is removable media, initially for handling a short-path loading. Signed-off-by: AKASHI Takahiro Reviewed-by: Heinrich Schuchardt --- include/efi_loader.h | 3 +++ lib/efi_loader/efi_disk.c | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/efi_loader.h b/include/efi_loader.h index 40fbab816e2d..839184acb7ff 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -659,6 +659,9 @@ efi_status_t efi_set_timer(struct efi_event *event, enum efi_timer_delay type, /* Call this to signal an event */ void efi_signal_event(struct efi_event *event); +/* return true if the device is removable */ +bool efi_disk_is_removable(efi_handle_t handle); + /* open file system: */ struct efi_simple_file_system_protocol *efi_simple_file_system( struct blk_desc *desc, int part, struct efi_device_path *dp); diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index f5b462fb164a..1e82f52dc070 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -73,6 +73,33 @@ static efi_status_t EFIAPI efi_disk_reset(struct efi_block_io *this, return EFI_EXIT(EFI_SUCCESS); } +/** + * efi_disk_is_removable() - check if the device is removable media + * @handle: efi object handle; + * + * Examine the device and determine if the device is a local block device + * and removable media. + * + * Return: true if removable, false otherwise + */ +bool efi_disk_is_removable(efi_handle_t handle) +{ + struct efi_handler *handler; + struct efi_block_io *io; + efi_status_t ret; + + ret = efi_search_protocol(handle, &efi_block_io_guid, &handler); + if (ret != EFI_SUCCESS) + return false; + + io = handler->protocol_interface; + + if (!io || !io->media) + return false; + + return (bool)io->media->removable_media; +} + enum efi_disk_direction { EFI_DISK_READ, EFI_DISK_WRITE, From patchwork Thu May 12 02:29:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1629888 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=I64cbdyO; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KzG2x69vzz9sFx for ; Thu, 12 May 2022 12:30:17 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B990A8435B; Thu, 12 May 2022 04:29:56 +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="I64cbdyO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CB3A284375; Thu, 12 May 2022 04:29:51 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) (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 EA18584356 for ; Thu, 12 May 2022 04:29:47 +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=takahiro.akashi@linaro.org Received: by mail-pf1-x429.google.com with SMTP id p8so3536607pfh.8 for ; Wed, 11 May 2022 19:29:47 -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=exTxoWac+E6AKTuBh7PTaqLLySWqDQS4GkpNUV0KF64=; b=I64cbdyOOA00G/4wZHwzSLV4Pxl8dhqHFA5lnYJbPrDmfI7Z/RMoVDZvpsP3CiqsMI VS3VCF8XgjnRJTppx7HiUcD3XrLaTjg69u+wm25DL1Gyl59fPRyGuqWnvKJR9yTRirR8 a/BZmgSpXAzj4uNrXWK8GKXbm0ajC3f9fyhesITHWWmAXaHfDdYbb4c98ZiYPW5E/WJs C1BNE9YFboLyKCbNOAEPjMfNPgaGYAl5ijpEu1N9+f12HBoAdHus2+oyFEQn6RhU+1yn ZUa1sx92UcG9MPrvfsGLpbcka0Mu0bsPu2xvCKxGp/pwzNXVBU7mPagP9qAcHtDhHtWx v0aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=exTxoWac+E6AKTuBh7PTaqLLySWqDQS4GkpNUV0KF64=; b=E0BNx7tS6jnspAreW2eMkyQU5l5Ok65d3P5/LQk3jIyjav4OV+g9AoDasaJA/FN+iZ kUvHPs2D5cpWG+31Zh1S8aQvQ4oE+gKNvctpSthZiTlvqp2STOK54tNLLybScUly9716 UOEhdwugmbbfcAycqTyBCwmSSfIwx6Ay4ONPVLjmmbp0X5qdNHu5FIz+ra03C7iH73EM WBjG5pZfiwfNeQ6Be+BJIUt3cRoFyyNL+7LiRLWexW6fgauYUgtUbWphfQgm5XN79yNE nR3udNVzFtyi7oqIIr7nI2w2DcdcvbBnrE7Pz6IG2PenDBtQRFqbDtsBqJGFqFIoCtiA qnuQ== X-Gm-Message-State: AOAM532SgYIoKFEIrl+/lDsF0e7+agmpZmM7F8G2etd3vAaxjT4KnrRT gjyEMSz19KZo6RFXhU0WV6DBig== X-Google-Smtp-Source: ABdhPJwDFW1CC3UQ6udxurVNQL8SoNtwKYLg6iEAJ7BYFsMpw0krJNKT02vq1e2S54TTpUMD/H94QA== X-Received: by 2002:a63:5cb:0:b0:3da:fe5d:4448 with SMTP id 194-20020a6305cb000000b003dafe5d4448mr8033576pgf.583.1652322586010; Wed, 11 May 2022 19:29:46 -0700 (PDT) Received: from localhost.localdomain (p914133-ipoe.ipoe.ocn.ne.jp. [153.243.15.132]) by smtp.gmail.com with ESMTPSA id i4-20020aa78b44000000b0050dc7628190sm2445314pfd.106.2022.05.11.19.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 19:29:45 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de Cc: mark.kettenis@xs4all.nl, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 2/3] efi_loader: bootmgr: fix a problem in loading an image from a short-path Date: Thu, 12 May 2022 11:29:02 +0900 Message-Id: <20220512022903.65346-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220512022903.65346-1-takahiro.akashi@linaro.org> References: <20220512022903.65346-1-takahiro.akashi@linaro.org> 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.5 at phobos.denx.de X-Virus-Status: Clean Booting from a short-form device path which starts with the first element being a File Path Media Device Path failed because it doesn't contain any valid device with simple file system protocol and efi_dp_find_obj() in efi_load_image_from_path() will return NULL. For instance, /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(0,0)/\helloworld.efi -> shortened version: /\helloworld.efi With this patch applied, all the media devices with simple file system protocol are enumerated and the boot manager attempts to boot temporarily generated device paths one-by-one. This new implementation is still a bit incompatible with the UEFI specification in terms of: * not creating real boot options * not try "If a device does not support the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, but supports the EFI_BLOCK_IO_PROTOCOL protocol, then the EFI Boot Service ConnectController must be called for this device with DriverImageHandle and RemainingDevicePath set to NULL and the Recursive flag is set to TRUE." (See section 3.1.2 "Load Option Processing".) But it still gives us a closer and better solution than the current. Fixes: commit 9cdf470274ff ("efi_loader: support booting via short-form device-path") Signed-off-by: AKASHI Takahiro --- lib/efi_loader/efi_bootmgr.c | 98 ++++++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 4 deletions(-) diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 631a25d76e9e..3608e433503e 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -76,6 +76,91 @@ struct efi_device_path *expand_media_path(struct efi_device_path *device_path) return full_path; } +static efi_status_t __try_load(efi_handle_t *fs_handles, efi_uintn_t num, + struct efi_device_path *fp, + efi_handle_t *handle, bool removable) +{ + struct efi_handler *handler; + struct efi_device_path *dp; + int i; + efi_status_t ret; + + for (i = 0; i < num; i++) { + if (removable && !efi_disk_is_removable(fs_handles[i])) + continue; + if (!removable && efi_disk_is_removable(fs_handles[i])) + continue; + + ret = efi_search_protocol(fs_handles[i], &efi_guid_device_path, + &handler); + if (ret != EFI_SUCCESS) + /* unlikely */ + continue; + + dp = handler->protocol_interface; + if (!dp) + /* unlikely */ + continue; + + dp = efi_dp_append(dp, fp); + if (!dp) + /* unlikely */ + continue; + + ret = EFI_CALL(efi_load_image(true, efi_root, dp, NULL, 0, + handle)); + efi_free_pool(dp); + if (ret == EFI_SUCCESS) + return ret; + } + + return EFI_NOT_FOUND; +} + +/** + * try_load_from_short_path + * @fp: file path + * @handle: pointer to handle for newly installed image + * + * Enumerate all the devices which support file system operations, + * prepend its media device path to the file path, @fp, and + * try to load the file. + * This function should be called when handling a short-form path + * which is starting with a file device path. + * + * Return: status code + */ +static efi_status_t try_load_from_short_path(struct efi_device_path *fp, + efi_handle_t *handle) +{ + efi_handle_t *fs_handles; + efi_uintn_t num; + efi_status_t ret; + + ret = EFI_CALL(efi_locate_handle_buffer( + BY_PROTOCOL, + &efi_simple_file_system_protocol_guid, + NULL, + &num, &fs_handles)); + if (ret != EFI_SUCCESS) + return ret; + if (!num) + return EFI_NOT_FOUND; + + /* removable media first */ + ret = __try_load(fs_handles, num, fp, handle, true); + if (ret == EFI_SUCCESS) + goto out; + + /* fixed media */ + ret = __try_load(fs_handles, num, fp, handle, false); + if (ret == EFI_SUCCESS) + goto out; + +out: + return ret; +} + /** * try_load_entry() - try to load image for boot option * @@ -116,10 +201,15 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, log_debug("trying to load \"%ls\" from %pD\n", lo.label, lo.file_path); - file_path = expand_media_path(lo.file_path); - ret = EFI_CALL(efi_load_image(true, efi_root, file_path, - NULL, 0, handle)); - efi_free_pool(file_path); + if (EFI_DP_TYPE(lo.file_path, MEDIA_DEVICE, FILE_PATH)) { + /* file_path doesn't contain a device path */ + ret = try_load_from_short_path(lo.file_path, handle); + } else { + file_path = expand_media_path(lo.file_path); + ret = EFI_CALL(efi_load_image(true, efi_root, file_path, + NULL, 0, handle)); + efi_free_pool(file_path); + } if (ret != EFI_SUCCESS) { log_warning("Loading %ls '%ls' failed\n", varname, lo.label); From patchwork Thu May 12 02:29:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1629889 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=SsmFlNOD; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KzG3C26GYz9sFx for ; Thu, 12 May 2022 12:30:31 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 000A1843A0; Thu, 12 May 2022 04:30:12 +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="SsmFlNOD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A83FB8434B; Thu, 12 May 2022 04:29:56 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) (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 CED818435B for ; Thu, 12 May 2022 04:29:49 +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=takahiro.akashi@linaro.org Received: by mail-pf1-x42d.google.com with SMTP id x52so3522838pfu.11 for ; Wed, 11 May 2022 19:29:49 -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=YPOFOE3NvbBxeFM2xBwqWvtaayvQyGUKm3Se3idq6Ps=; b=SsmFlNODfJSlGg1/GzfrjpowU+g+L77tVd42+uncQjxlSaDLvpE/MykYvuE0ogwIPn bPckli3bSMqHw0aThII8f8RuGmnRAk0kYnAAN7T8uZzYOUFEVYGOdrL9fcPMVMjPik44 YGv7m4DOUcnhY4N74zi8CGWPxHk9UTwf8zS4xoM/XYs3PKsjYQWVRyxyqh3oKJqDb/dD 04nRHPKEfvsRP3wG/9ZFzL8MEttTq1BfBoKPirhueQVpnt9i4c3ovXacwfch8zt44X63 HwcZxuhzeORy8J0e+s/0AyknMuESmDiekps30+ahn+v+9xkfFxLv8O6Fe+7A1tbizFFB vKvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YPOFOE3NvbBxeFM2xBwqWvtaayvQyGUKm3Se3idq6Ps=; b=L3ZHDVPkxXbR1sDcXe9mRP8+gIHZDihILlrMNJxIaHd/14Fx1aPPIiPX76HbYwurML ytaN7D9OwpO2Jw2ZrvJhagaIq+BV4QDLxOZ919BUsqxwOsKYGsL8Q/EIN5/hDUG1uRMf BOA5CRhKw6tpyjDx3GfD+pP1YD8Eg7ouYdt61f/SBrmPPqUK88A45A1MnLwbFSTh9G/D GwCbfnjba2V5ZKXwLaRV90Net9F4tMwaxVWetExw7tMfe6oTR7hNeiH3DANC5yvbNK+a +CyQns/YKZrxg+pcw/qEQs9iR7sgaGb0MoJ3WhcYxl6abT7IpGzmZrdpVTFmtYY3xwgd KUww== X-Gm-Message-State: AOAM532qEQrDb5l8zrOre1bKjvtNAWDBz0fjkt59gokFoBN15lhXzGQt hX1GmIO7OofCjbNzEm2SR9PiZA== X-Google-Smtp-Source: ABdhPJxbfjujlzIoWJNjk3kfR+MH+md0GlvQDEyXIDUVEwD07unOMKR9IWC4H5sClj1SsLkkJVb1AA== X-Received: by 2002:a63:286:0:b0:3ab:971a:eb4c with SMTP id 128-20020a630286000000b003ab971aeb4cmr23456016pgc.105.1652322588096; Wed, 11 May 2022 19:29:48 -0700 (PDT) Received: from localhost.localdomain (p914133-ipoe.ipoe.ocn.ne.jp. [153.243.15.132]) by smtp.gmail.com with ESMTPSA id i4-20020aa78b44000000b0050dc7628190sm2445314pfd.106.2022.05.11.19.29.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 19:29:47 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de Cc: mark.kettenis@xs4all.nl, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 3/3] test: efi_bootmgr: add a test case for a short-form path Date: Thu, 12 May 2022 11:29:03 +0900 Message-Id: <20220512022903.65346-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220512022903.65346-1-takahiro.akashi@linaro.org> References: <20220512022903.65346-1-takahiro.akashi@linaro.org> 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.5 at phobos.denx.de X-Virus-Status: Clean A short-form path starting with a file device path will be tested in a new test case. This type of short-form path will be created with "efidebug boot add -b", in particular, when a file system has no partition table. Signed-off-by: AKASHI Takahiro --- test/py/tests/test_efi_bootmgr/conftest.py | 25 +++++++++++++++++++ .../test_efi_bootmgr/test_efi_bootmgr.py | 25 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/test/py/tests/test_efi_bootmgr/conftest.py b/test/py/tests/test_efi_bootmgr/conftest.py index a0a754afbe1b..5cd7252671fa 100644 --- a/test/py/tests/test_efi_bootmgr/conftest.py +++ b/test/py/tests/test_efi_bootmgr/conftest.py @@ -38,3 +38,28 @@ def efi_bootmgr_data(u_boot_config): shell=True) return image_path + +@pytest.fixture(scope='session') +def efi_bootmgr_data2(u_boot_config): + """Set up a file system without a partition table to be used + in UEFI bootmanager tests + + Args: + u_boot_config -- U-boot configuration. + + Return: + A path to disk image to be used for testing + """ + mnt_point = u_boot_config.persistent_data_dir + '/test_efi_bootmgr' + image_path = u_boot_config.persistent_data_dir + '/efi_bootmgr_data2.img' + + shutil.rmtree(mnt_point, ignore_errors=True) + os.mkdir(mnt_point, mode = 0o755) + + shutil.copyfile(u_boot_config.build_dir + '/lib/efi_loader/helloworld.efi', + mnt_point + '/helloworld.efi') + + check_call(f'virt-make-fs --size=+1M --type=vfat {mnt_point} {image_path}', + shell=True) + + return image_path diff --git a/test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py b/test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py index 75a6e7c96296..ab3d53a2dc95 100644 --- a/test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py +++ b/test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py @@ -41,3 +41,28 @@ def test_efi_bootmgr(u_boot_console, efi_bootmgr_data): u_boot_console.run_command(cmd = 'efidebug boot rm 0001') u_boot_console.run_command(cmd = 'efidebug boot rm 0002') + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('cmd_efidebug') +@pytest.mark.buildconfigspec('cmd_bootefi_bootmgr') +def test_efi_bootmgr_short(u_boot_console, efi_bootmgr_data2): + """ Unit test for UEFI bootmanager with a short-form path + In this test case, + - File system has no partition table + - UEFI load option has a short-form path starting with a file device path + + Args: + u_boot_console -- U-Boot console + efi_bootmgr_data2 -- Path to the disk image used for testing. + """ + u_boot_console.run_command(cmd = f'host bind 0 {efi_bootmgr_data2}') + + u_boot_console.run_command(cmd = 'efidebug boot add ' \ + '-b 0001 TEST2 host 0:0 helloworld.efi') + response = u_boot_console.run_command(cmd = 'efidebug boot dump') + assert 'file_path: /helloworld.efi' in response + u_boot_console.run_command(cmd = 'efidebug boot next 0001') + response = u_boot_console.run_command(cmd = 'bootefi bootmgr') + assert 'Hello, world!' in response + + u_boot_console.run_command(cmd = 'efidebug boot rm 0001')