From patchwork Wed Feb 16 06:16:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masami Hiramatsu X-Patchwork-Id: 543043 Delivered-To: patch@linaro.org Received: by 2002:ac0:e142:0:0:0:0:0 with SMTP id r2csp1090830imn; Tue, 15 Feb 2022 22:16:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzoGwzScFZSN5dr9WZcP8GRdjRgR0DcIPlIcQobVNo6adlk9G/dMN7UGXv10CODo4DoRkoZ X-Received: by 2002:a50:c04c:0:b0:410:b929:d658 with SMTP id u12-20020a50c04c000000b00410b929d658mr1346327edd.5.1644992200479; Tue, 15 Feb 2022 22:16:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644992200; cv=none; d=google.com; s=arc-20160816; b=ELvO9BDet1ch2WnZFhtQXg/6SxmNgSkj8CgwbT/fx+cKhx9naNrgS2jjGZQ+S211EK d4k2EsoezLFaTponVVZCthtj6B9jGqp8A3PV2J3civ4szlVDVjq5dUqhx3tTwBApdTaa NTHr41KXEqeaROmZlXtYVNTSsgAr5CLbzDPkgLTd+jbMmOHo8nSBH0ZPYIuWmdyzF5fT mJCtz0tKYFqRrbhBHxWUhvTxSrnB0LyRIB6MLJ27bCfNkD7IenVb7tQ90imo5MNR8K9w NbuSyhzTG23Dwn+HkwQVHLUJwT+k3lMlFHzg/OZLVXEiV5/W0ynDu6V4x8BZdsZgutbr 7dPA== 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:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=LumW1kbBw+ZbXeaNx023/i11I6rVSgeSVwxqUko2df0=; b=t8BtzvOnQtfqJloMxLKbVeCzq3q+8FzAK+E9U0iYp9WrzUeOQ8387absRr4teJziIG B958ydyh5m2NZgz2dcEh3C0kL+06gkJ/xHKxcJvcLabCC/kFmfvtB9XPCaRm37VvYFjy nBfWsg4l7mX6ReNHgJglMnr130vnUReV0/RSazsG6QlSWRGNMsCinM6V7SOJaYARqQKp jmKHxYCR9xjg3wWzfRcK+RkMijbNe/nVm5HniDN5AnXEi57igrX6cvPbwyjAqXs5w0NR G8XFiLNT7vL6M6L6D97UGlimt4X28D33z8gcsfpGfnq/XplY/qEwSPVOHpvf86jU7DR7 TR8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lBb9rvPQ; 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 z7si1451629edb.146.2022.02.15.22.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:16:40 -0800 (PST) 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=lBb9rvPQ; 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 8A0FA839FB; Wed, 16 Feb 2022 07:16:35 +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="lBb9rvPQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 85CF68380E; Wed, 16 Feb 2022 07:16:28 +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.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-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (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 DFE00838F4 for ; Wed, 16 Feb 2022 07:16:18 +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=masami.hiramatsu@linaro.org Received: by mail-pj1-x102b.google.com with SMTP id v13-20020a17090ac90d00b001b87bc106bdso5518731pjt.4 for ; Tue, 15 Feb 2022 22:16:18 -0800 (PST) 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 :user-agent:mime-version:content-transfer-encoding; bh=LumW1kbBw+ZbXeaNx023/i11I6rVSgeSVwxqUko2df0=; b=lBb9rvPQ6DuRGm/jHDKQfgCPZaeVRt91HDXbfD8qPgnzN6s8Gi0EboiQjMuODdYUom GDUZrsyF8DXEbYVe3ntoUj8LbxY4lwSbLjld98d38FtBX+1wkS1OOHMgHE4OYHXMwpB9 wKAZer6dmAD+lCAL6xS5BEfunYeO+AH91Q9sdft1I1ix83eLxjKGGpvj78qpmhESH1/3 DDueAHFqLOADK1uVnQfHVGXVRgPuGwu2pwBGB1LiC9/W8ne+FrCs4lTNi6kQplS1JS96 wp5tzIlzsV4Du3sTMuzv7bLyRqPtEIkyWY/zqduIZB17jzfHfZgXTlgItu1Kg4NonzO4 PUWA== 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:user-agent:mime-version:content-transfer-encoding; bh=LumW1kbBw+ZbXeaNx023/i11I6rVSgeSVwxqUko2df0=; b=Yifjnqk5VH1yPTWPJoy90pJi3O2XcNjl4HN5aXHZxtNsmpATjCKkgtuOlwE+AL2W0p Vlz4AhbPlyYehkcbqY/5XekyU+eDLdxeGQWKV+yAA93xjR7Hcy8fTGSbvk9IQ6e9YdnD nusZYnh9VtK6SrpiT+onrrN1zFiat5LpKGzfwfpUc0aRqgbkFSzAPpdaHhB4Rv/9CsX6 nn/fJMrrchLpcH9eHjblsn9hwMrIir5IK+T6vSa0rrQLfNlU7CA48z6eMtG3yH/392UH a4u2mWUwNdc/exzD7LeXSGdiiV4/sGzRZItQZ1ATQSRwvUECPzkNLqWosUxiNeSDdqBT 3O7w== X-Gm-Message-State: AOAM530U+2YhM5PYORq4gpg4PMRzt02jKFND3nEnGKRiK1vIAlVIhh5M O++3obQu0F3EZPIIX3PEx/vZJ8sMeiMisg== X-Received: by 2002:a17:903:11cc:b0:14d:a0d5:76f with SMTP id q12-20020a17090311cc00b0014da0d5076fmr1375846plh.109.1644992177048; Tue, 15 Feb 2022 22:16:17 -0800 (PST) Received: from localhost.localdomain (113x37x226x201.ap113.ftth.ucom.ne.jp. [113.37.226.201]) by smtp.gmail.com with ESMTPSA id j7sm39017952pfa.36.2022.02.15.22.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:16:16 -0800 (PST) From: Masami Hiramatsu To: u-boot@lists.denx.de Cc: Masami Hiramatsu , Patrick Delaunay , Patrice Chotard , Heinrich Schuchardt , Alexander Graf , AKASHI Takahiro , Simon Glass , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Tom Rini , Etienne Carriere , Sughosh Ganu , Paul Liu Subject: [PATCH v5 4/4] efi_loader: test/py: Reset system after capsule update on disk Date: Wed, 16 Feb 2022 15:16:12 +0900 Message-Id: <164499217249.688621.8559174804587563729.stgit@localhost> X-Mailer: git-send-email 2.25.1 In-Reply-To: <164499213192.688621.17382243642029677399.stgit@localhost> References: <164499213192.688621.17382243642029677399.stgit@localhost> User-Agent: StGit/0.19 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 Add a cold reset soon after processing capsule update on disk. This is required in UEFI specification 2.9 Section 8.5.5 "Delivery of Capsules via file on Mass Storage device" as; In all cases that a capsule is identified for processing the system is restarted after capsule processing is completed. This also reports the result of each capsule update so that the user can notice that the capsule update has been succeeded or not from console log. Signed-off-by: Masami Hiramatsu --- Changes in v5: - Update testcase because this will change the expected behavior. - Merge dfu_alt_info setting with showing esrt command. - Remove redundant assertion from the test update. Changes in v4: - Do not use sysreset because that is a warm reset. - Fix patch description. --- lib/efi_loader/efi_capsule.c | 18 +++++++++- .../test_efi_capsule/test_capsule_firmware.py | 37 ++++++++++++-------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index d8141176df..613b531b82 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -1120,8 +1121,11 @@ efi_status_t efi_launch_capsules(void) if (ret == EFI_SUCCESS) { ret = efi_capsule_update_firmware(capsule); if (ret != EFI_SUCCESS) - log_err("Applying capsule %ls failed\n", + log_err("Applying capsule %ls failed.\n", files[i]); + else + log_info("Applying capsule %ls succeeded.\n", + files[i]); /* create CapsuleXXXX */ set_capsule_result(index, capsule, ret); @@ -1142,6 +1146,16 @@ efi_status_t efi_launch_capsules(void) free(files[i]); free(files); - return ret; + /* + * UEFI spec requires to reset system after complete processing capsule + * update on the storage. + */ + log_info("Reboot after firmware update"); + /* Cold reset is required for loading the new firmware. */ + do_reset(NULL, 0, 0, NULL); + hang(); + /* not reach here */ + + return 0; } #endif /* CONFIG_EFI_CAPSULE_ON_DISK */ diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware.py b/test/py/tests/test_efi_capsule/test_capsule_firmware.py index 6e803f699f..1dcf1c70f4 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware.py @@ -143,13 +143,14 @@ class TestEfiCapsuleFirmwareFit(object): 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) assert 'Test01' in ''.join(output) - # reboot - u_boot_console.restart_uboot() - capsule_early = u_boot_config.buildconfig.get( 'config_efi_capsule_on_disk_early') capsule_auth = u_boot_config.buildconfig.get( 'config_efi_capsule_authenticate') + + # reboot + u_boot_console.restart_uboot(expect_reset = capsule_early) + with u_boot_console.log.section('Test Case 2-b, after reboot'): if not capsule_early: # make sure that dfu_alt_info exists even persistent variables @@ -162,7 +163,7 @@ class TestEfiCapsuleFirmwareFit(object): # need to run uefi command to initiate capsule handling output = u_boot_console.run_command( - 'env print -e Capsule0000') + 'env print -e Capsule0000', wait_for_reboot = True) output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, @@ -218,13 +219,14 @@ class TestEfiCapsuleFirmwareFit(object): 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) assert 'Test02' in ''.join(output) - # reboot - u_boot_console.restart_uboot() - capsule_early = u_boot_config.buildconfig.get( 'config_efi_capsule_on_disk_early') capsule_auth = u_boot_config.buildconfig.get( 'config_efi_capsule_authenticate') + + # reboot + u_boot_console.restart_uboot(expect_reset = capsule_early) + with u_boot_console.log.section('Test Case 3-b, after reboot'): if not capsule_early: # make sure that dfu_alt_info exists even persistent variables @@ -237,9 +239,12 @@ class TestEfiCapsuleFirmwareFit(object): # need to run uefi command to initiate capsule handling output = u_boot_console.run_command( - 'env print -e Capsule0000') + 'env print -e Capsule0000', wait_for_reboot = True) - output = u_boot_console.run_command_list(['efidebug capsule esrt']) + # make sure the dfu_alt_info exists because it is required for making ESRT. + output = u_boot_console.run_command_list([ + 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', + 'efidebug capsule esrt']) # ensure that EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID is in the ESRT. assert 'AE13FF2D-9AD4-4E25-9AC8-6D80B3B22147' in ''.join(output) @@ -293,13 +298,14 @@ class TestEfiCapsuleFirmwareFit(object): 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) assert 'Test03' in ''.join(output) - # reboot - u_boot_console.restart_uboot() - capsule_early = u_boot_config.buildconfig.get( 'config_efi_capsule_on_disk_early') capsule_auth = u_boot_config.buildconfig.get( 'config_efi_capsule_authenticate') + + # reboot + u_boot_console.restart_uboot(expect_reset = capsule_early) + with u_boot_console.log.section('Test Case 4-b, after reboot'): if not capsule_early: # make sure that dfu_alt_info exists even persistent variables @@ -312,9 +318,12 @@ class TestEfiCapsuleFirmwareFit(object): # need to run uefi command to initiate capsule handling output = u_boot_console.run_command( - 'env print -e Capsule0000') + 'env print -e Capsule0000', wait_for_reboot = True) - output = u_boot_console.run_command_list(['efidebug capsule esrt']) + # make sure the dfu_alt_info exists because it is required for making ESRT. + output = u_boot_console.run_command_list([ + 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', + 'efidebug capsule esrt']) # ensure that EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID is in the ESRT. assert 'E2BB9C06-70E9-4B14-97A3-5A7913176E3F' in ''.join(output)