From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93B20C76196 for ; Mon, 3 Apr 2023 10:34:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3B75685CE6; Mon, 3 Apr 2023 12:34:20 +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="TiODj1fs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7AC5785CF8; Mon, 3 Apr 2023 12:34:16 +0200 (CEST) Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (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 2C3E485CB1 for ; Mon, 3 Apr 2023 12:34:10 +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=ilias.apalodimas@linaro.org Received: by mail-ed1-x533.google.com with SMTP id eh3so115294076edb.11 for ; Mon, 03 Apr 2023 03:34:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680518049; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=6gtLCTxsAt5XkRdQNa+NxL0xyIR/Bip/lggE3iS6e4k=; b=TiODj1fsTrKdV/PVP4CZxdyUFOq4TUNc2ek7+sB3zsS0vIDLbQaYvZD9VfduV6XHTg CNvhQkBkedRnUR10OOhnKx3NW+KzpPNHJcn/PgUHfXXlaGJdXnSXEBVBbNs0vNAUKeyD kBrA2QARjjqb88n+2/QZGLW7YwPN9rZcjBngcSheQU1K5iFvCB5PHfm8ITJKVGN9157u yq7Llt4zh1PjgCH1YycAzTaVonYfLUFCQz09aGONVM+Nda3zZ7oxZ+F6qo0EPMtR/ZZa bjLkyDnH2F5TzqUSUwjx3qrX83a2yMBHaQLSVrrQk1nDST96RP3ONeqlK9PY+m+RYzwG Ar8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680518049; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6gtLCTxsAt5XkRdQNa+NxL0xyIR/Bip/lggE3iS6e4k=; b=ia7I8QLAvmT1tMubkdM3otZzbTh6C/G84PQS1Xadbj/hO37SjA0PN9JaRTJz+PeFie lp0YzMydclCzDHzzSnMr6IFLvtlCbKlEdU4eMAYeXn9E/cIDHZh+mXAfadaJ517P0LPP tuDxLqNCRawMPEu294TnASNuxjZoBYgY17JBR3N2mKnmCEQG6Yw6x5AHpEAMf0cME09u khHcI1mB6LaTaKFyVYmaCL3Ufkt3PsUpL1OIFXbczL1RHBmQPmYsAjx1CmauKxPDkrfp DtNNkzJfsIUPRxUpL2hu3O4Boo5FX3ALRnON+smilZb9jRFy0yJ5oPG4PXwG/7Qh7Sni cKgQ== X-Gm-Message-State: AAQBX9fQdLbXf/OAlDaUsAjGqzT8l7bOQ3fijrocFkLsBbupzHn0b0Om 6ouILDkH0jecWY/cJtvNIOeqTg== X-Google-Smtp-Source: AKy350Zm0fsT8Zwz3LJfz42/wEEYXL4hXOB59mx7v3Ed/DbCOHqqJ6J76T7GeDvWE3ZWo9NjX2E/nw== X-Received: by 2002:aa7:cb16:0:b0:4fb:d620:bd27 with SMTP id s22-20020aa7cb16000000b004fbd620bd27mr31279461edt.23.1680518049562; Mon, 03 Apr 2023 03:34:09 -0700 (PDT) Received: from hera (ppp176092130041.access.hol.gr. [176.92.130.41]) by smtp.gmail.com with ESMTPSA id 28-20020a508e5c000000b004c13fe8fabfsm4398099edx.84.2023.04.03.03.34.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 03:34:09 -0700 (PDT) Date: Mon, 3 Apr 2023 13:34:07 +0300 From: Ilias Apalodimas To: Raymond Mao Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Masahisa Kojima , Simon Glass Subject: Re: [PATCH 1/2] Boot var automatic management for removable medias Message-ID: References: <20230328164806.475324-1-raymond.mao@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230328164806.475324-1-raymond.mao@linaro.org> 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 Hi Raymond, [...] > + } > + } > + } > + > +out: > + if (opt) { > + for (i = 0; i < count; i++) { > + if (opt[i].lo) > + free(opt[i].lo); > + } > + free(opt); > + } > + efi_free_pool(volume_handles); > + > + return ret; > +} > diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c > index d2256713a8..1309e28134 100644 > --- a/lib/efi_loader/efi_disk.c > +++ b/lib/efi_loader/efi_disk.c > @@ -687,6 +687,13 @@ int efi_disk_probe(void *ctx, struct event *event) > return -1; > } > > + /* only do the boot option management when UEFI sub-system is initialized */ > + if (efi_obj_list_initialized == EFI_SUCCESS) { > + ret = efi_bootmgr_update_media_device_boot_option(); I am not sure if this is the problem, but with these patches applied and no media attached QEMU fails to initialize the EFI sub-system. IOW running qemu-system-aarch64 -bios u-boot.bin -machine virt,secure=off -cpu cortex-a53 -m 2G -nographic -no-acpi => efidebug boot dump No EFI system partition Error: Cannot initialize UEFI sub-system, r = 14 We should always start EFI, even if scanning for boot options fails. > + if (ret) > + return -1; > + } > + > return 0; > } > > diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c > index 1f4ab2b419..cdfd16ea77 100644 > --- a/lib/efi_loader/efi_helper.c > +++ b/lib/efi_loader/efi_helper.c > @@ -257,3 +257,28 @@ efi_status_t efi_next_variable_name(efi_uintn_t *size, u16 **buf, efi_guid_t *gu > > return ret; > } > + > +/** > + * efi_search_bootorder() - search the boot option index in BootOrder > + * > + * @bootorder: pointer to the BootOrder variable > + * @num: number of BootOrder entry > + * @target: target boot option index to search > + * @index: pointer to store the index of BootOrder variable > + * Return: true if exists, false otherwise > + */ > +bool efi_search_bootorder(u16 *bootorder, efi_uintn_t num, u32 target, u32 *index) > +{ > + u32 i; > + > + for (i = 0; i < num; i++) { > + if (target == bootorder[i]) { > + if (index) > + *index = i; > + > + return true; > + } > + } > + > + return false; > +} > diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c > index be95ed44e6..2f251553e1 100644 > --- a/lib/efi_loader/efi_variable.c > +++ b/lib/efi_loader/efi_variable.c > @@ -476,6 +476,10 @@ efi_status_t efi_init_variables(void) > log_err("Invalid EFI variable seed\n"); > } > > + ret = efi_init_secure_state(); > + if (ret != EFI_SUCCESS) > + return ret; > > - return efi_init_secure_state(); > + /* update boot option management after variable service initialized */ > + return efi_bootmgr_update_media_device_boot_option(); > } > diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c > index dfef18435d..a48d313ef0 100644 > --- a/lib/efi_loader/efi_variable_tee.c > +++ b/lib/efi_loader/efi_variable_tee.c > @@ -748,5 +748,6 @@ efi_status_t efi_init_variables(void) > if (ret != EFI_SUCCESS) > return ret; > > - return EFI_SUCCESS; > + /* update boot option management after variable service initialized */ > + return efi_bootmgr_update_media_device_boot_option(); > } > -- > 2.25.1 > Regards /Ilias