From patchwork Mon Nov 6 11:39:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 741377 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp1036348wrr; Mon, 6 Nov 2023 03:42:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyrHdPdpKO26v3XWyGcGygkEnMJbatv5SloO8gaZKiZ115AkPdVMxSs9nqKYA+qGePyFsO X-Received: by 2002:a17:907:3f08:b0:9a5:9f3c:961e with SMTP id hq8-20020a1709073f0800b009a59f3c961emr9139304ejc.18.1699270957534; Mon, 06 Nov 2023 03:42:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699270957; cv=none; d=google.com; s=arc-20160816; b=cK2qOmKi7SvO1KoHhbCnlcF3Nt2ODf2hKCzbfFNBYHeavNpfTqf2hZAMtLFa/poUUK eeEl1eCc3zAmG+WO0o2a4IueI3SKaSGt1wd1uCPfnrP040eQVIW38VhkM438IMDB6gC+ 3Rof+4EJIdIVk/uj2PjfM1o+h28+cVWxZMlcdJGBmeBIVrrJgPC8ODWz4XEPVL04bHa7 5fWS+Lfro91m9iD42CPyKHOtHCPY6o7IAdlVm9a5/PgkpEkg1cJMom3YeTMwUNouvLFF dDnEstqam7BLGFrcUNWXA6LXAygwukctBo0JxAdYpOez9eKPijPbVp+PEUncv3Hu2XpT NV5g== 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=bKRfTkXsyxHbAbfC2fDvqXQoTddGeOCmf5imGSOro/k=; fh=I7E+BwgHMByijVVN/pPHsLSpz7oP4y4e73noHEekrEE=; b=apDCSpqDTjkf+AqbfCKbJvMdu1ficZAjlJZHyZBHtkQ+sW+QNSxCnyWz2cAe3ci7hi w3OMcH4/eVo+6B6o9BhncNkhlsuv5nbkDBj9UbeO3zMXZhIvn7lu5oa55uBSMZmHk54y Uc3UHoVeK4xuzmhmVfimlsZ3n44ui3RKUF3mroVmo/91dVme44CO31Wo9GlYqLSXeG/Y KNr/mCYqI1nueCXzCWYiqAUjkLpmPYUqxK2G+q+jG1YORnsv+HDZUyTYx9Nb5GJLTHV5 0nTZaiiEQ/muwM1Rr+Vyg+yk/L4zVfVc2cMc609fgomCkDTfSTPN4ey4I3zvJ0EkemOT WIwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wcu2jIAo; 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 gn25-20020a1709070d1900b0099381745ba0si4765324ejc.156.2023.11.06.03.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 03:42:37 -0800 (PST) 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=wcu2jIAo; 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 6244887026; Mon, 6 Nov 2023 12:41:29 +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="wcu2jIAo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E65FC8653E; Mon, 6 Nov 2023 12:41:15 +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-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 82AAB87049 for ; Mon, 6 Nov 2023 12:40:53 +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=masahisa.kojima@linaro.org Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6b497c8575aso4691255b3a.1 for ; Mon, 06 Nov 2023 03:40:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699270849; x=1699875649; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bKRfTkXsyxHbAbfC2fDvqXQoTddGeOCmf5imGSOro/k=; b=wcu2jIAo6rwE+z/OHSYaViKp3+9gsAIXFMqzqIwvjylTtamp799QA0q0vrjZJM0Mke ucUM1fjsQo5Jzs89JYx/BwdX5UK4B5rHDiGT1mAUpKPjcEURaCqfSds+Ju/3IkYivuUS +nRJb6YTRcxiJqFJqh/3UvEHtZC5Xj/sQXIjtgncdlQWBc7chaHGMUTfBLh4E6o+nMoD hw/lPWKkOLga3hJ2bAc/FgsMt3YYbM6TkLRl2nCJHpA24egaLRrDE1Gu4rKmYNknMXcV qiJo/7r98NoUiYybDrb7x59qgMyJJINxv/sLFKilJQBb1EqtJSdaQiu3cTfct5onPCy6 /9QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699270849; x=1699875649; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bKRfTkXsyxHbAbfC2fDvqXQoTddGeOCmf5imGSOro/k=; b=euLCokc52HUh66L07n4p5Lth4kOrUvytej1cJi5+Jiz8xmz6aA6JvhiUiMJvc2zaJq E/PI6fQz1B5iqTjGf4cZUn1II2iqCxrVBgBJec7QiSOmIeOdno6JT6VWmQxtZk3lv1oo S9NyYk8uBrAgTSGxYa3EO7d4zFGDwEWHWijnQ46l67dLS8baFtsXv8mEpQHOMw/oy2UR Qodpc0RZ/uwYuws50PvaHuDEoD5rgX++DQ0bvki9nMOf3vT9uk/h81HqOk+tdWuqsWeW fXUyYdZ1C/BwjgpO1QZU8i2rwSToYWi7rU6Gj73Y2Q0y4SM1UQxi7uysb/I3U5wh5uqT 3wlw== X-Gm-Message-State: AOJu0YzvSxWAurik4roGR5okprxcePEfAcCu3fLnbZW2YpaFAUQqOH0p FG9s1TqmO1SleVwqy+Yqz3JVunyxnBxmn1Izq/k= X-Received: by 2002:a05:6a20:c1aa:b0:17b:7505:8ab7 with SMTP id bg42-20020a056a20c1aa00b0017b75058ab7mr38922034pzb.46.1699270849227; Mon, 06 Nov 2023 03:40:49 -0800 (PST) Received: from localhost ([164.70.16.189]) by smtp.gmail.com with ESMTPSA id iy10-20020a170903130a00b001cc3a8af18dsm5740147plb.60.2023.11.06.03.40.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 03:40:48 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Takahiro Akashi , Michal Simek , Masahisa Kojima Subject: [RESEND PATCH v10 6/9] efi_loader: add return to efibootmgr event group Date: Mon, 6 Nov 2023 20:39:17 +0900 Message-Id: <20231106113920.3631591-7-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106113920.3631591-1-masahisa.kojima@linaro.org> References: <20231106113920.3631591-1-masahisa.kojima@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.8 at phobos.denx.de X-Virus-Status: Clean When the image loaded by efibootmgr returns, efibootmgr needs to clean the resources. Adding the event of returning to efibootmgr is useful to simplify the implementation. Signed-off-by: Masahisa Kojima Reviewed-by: Ilias Apalodimas --- cmd/bootefi.c | 12 ++++++++++++ include/efi_api.h | 3 +++ include/efi_loader.h | 2 ++ lib/efi_loader/efi_boottime.c | 3 +++ 4 files changed, 20 insertions(+) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 20e5c94a33..4d74969ad6 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -356,6 +356,7 @@ static efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options) efi_status_t ret; efi_uintn_t exit_data_size = 0; u16 *exit_data = NULL; + struct efi_event *evt; /* On ARM switch from EL3 or secure mode to EL2 or non-secure mode */ switch_to_non_secure_mode(); @@ -394,6 +395,17 @@ out: log_err("Failed to remove loadfile2 for initrd\n"); } + /* Notify EFI_EVENT_GROUP_RETURN_TO_EFIBOOTMGR event group. */ + list_for_each_entry(evt, &efi_events, link) { + if (evt->group && + !guidcmp(evt->group, + &efi_guid_event_group_return_to_efibootmgr)) { + efi_signal_event(evt); + EFI_CALL(systab.boottime->close_event(evt)); + break; + } + } + /* Control is returned to U-Boot, disable EFI watchdog */ efi_set_watchdog(0); diff --git a/include/efi_api.h b/include/efi_api.h index c2d6964467..0e92cb8a7f 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -404,6 +404,9 @@ struct efi_runtime_services { #define EFI_EVENT_GROUP_RESET_SYSTEM \ EFI_GUID(0x62da6a56, 0x13fb, 0x485a, 0xa8, 0xda, \ 0xa3, 0xdd, 0x79, 0x12, 0xcb, 0x6b) +#define EFI_EVENT_GROUP_RETURN_TO_EFIBOOTMGR \ + EFI_GUID(0xb4a40fe6, 0x9149, 0x4f29, 0x94, 0x47, \ + 0x49, 0x38, 0x7a, 0x7f, 0xab, 0x87) /* EFI Configuration Table and GUID definitions */ #define NULL_GUID \ diff --git a/include/efi_loader.h b/include/efi_loader.h index e164e6067d..31954e84c3 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -290,6 +290,8 @@ extern const efi_guid_t efi_guid_event_group_memory_map_change; extern const efi_guid_t efi_guid_event_group_ready_to_boot; /* event group ResetSystem() invoked (before ExitBootServices) */ extern const efi_guid_t efi_guid_event_group_reset_system; +/* event group return to efibootmgr */ +extern const efi_guid_t efi_guid_event_group_return_to_efibootmgr; /* GUID of the device tree table */ extern const efi_guid_t efi_guid_fdt; extern const efi_guid_t efi_guid_loaded_image; diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index f9b10a9763..3767fa2db4 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -90,6 +90,9 @@ const efi_guid_t efi_guid_event_group_ready_to_boot = /* event group ResetSystem() invoked (before ExitBootServices) */ const efi_guid_t efi_guid_event_group_reset_system = EFI_EVENT_GROUP_RESET_SYSTEM; +/* event group return to efibootmgr */ +const efi_guid_t efi_guid_event_group_return_to_efibootmgr = + EFI_EVENT_GROUP_RETURN_TO_EFIBOOTMGR; /* GUIDs of the Load File and Load File2 protocols */ const efi_guid_t efi_guid_load_file_protocol = EFI_LOAD_FILE_PROTOCOL_GUID; const efi_guid_t efi_guid_load_file2_protocol = EFI_LOAD_FILE2_PROTOCOL_GUID;