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 3025FEB64DC for ; Sun, 9 Jul 2023 08:56:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 08DD88475F; Sun, 9 Jul 2023 10:56:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de 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; secure) header.d=gmx.de header.i=xypron.glpk@gmx.de header.b="gP+uh8Yn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 891938477A; Sun, 9 Jul 2023 10:56:13 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4B48B846F7 for ; Sun, 9 Jul 2023 10:56:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1688892970; x=1689497770; i=xypron.glpk@gmx.de; bh=1MDamdgapisYzxpSpZMAJRAZiUi1HuYxMUdF0wsMsSI=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=gP+uh8YnaKP4fQf+qNb+UjjL+DCvVQZy5qM4Wcbq+w7l20B9CRq4gUrFD0Uu9TLSUCiRiec VENPVNub8W33M5VhBgMnLl7gHN2tXP4191nnqW1v2VcETgOLeG47BaS8wjKiXv01PgVq6cTis UOp2HKd7zzJNc9E+4P/IhoSnfSxFNHcmOLMOFSP0SVdUZW9Ul5rnZypfR7jZsjdm2rHdtpXsW f8Qfc/Z31Bqe0Spo39PCKv11dKEXE//dnojK8mB8/ZA5wo4hVT656KaM9g+tGnJN6Q7EGsw+A iFaLjkbwnXaq4JnResbb/qxxQlNMEbB3eHxIdvGrhLr8oTFnSdfg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.123.94] ([84.119.33.219]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M3lc9-1qI96116jD-000vdK; Sun, 09 Jul 2023 10:56:10 +0200 Message-ID: Date: Sun, 9 Jul 2023 10:56:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v10 3/4] Boot var automatic management for removable medias Content-Language: en-US To: Raymond Mao Cc: Ilias Apalodimas , Simon Glass , Masahisa Kojima , u-boot@lists.denx.de References: <20230619212303.128288-1-raymond.mao@linaro.org> <20230619212303.128288-4-raymond.mao@linaro.org> From: Heinrich Schuchardt In-Reply-To: <20230619212303.128288-4-raymond.mao@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:qSAfWyjBgsLr7D2b7tn9FVn5XGlnQc2TE2sngRtwh5eYU8Z6Wg1 oA3FiQ/VQJDKXu9lOhqA7amWd6ZTdH3tOAnMkaxZ1mmELHSOhgdiUEOxzIsTP263/AU/FDG HWrovdtgD/Rr4o75OZCJJdO3KOQK6fffZRHabuUTqvmVm2i+XtLYJ1wcNeFAZGZ8Szwbk/A zRKreiCGUWXI4XJBtHS8w== UI-OutboundReport: notjunk:1;M01:P0:K4eTX58hvSY=;GhURN/fTxvN05r0Vq5zuYqNAtkE eXeQHq/VTtEoZ0YTmpXvEiE8JifXjjyFlkD/sxxZmKBQ7IRJ8LwWlKMAI/8t4bSDk+G+NhyTf znJNn4YceIFk1lnu/4tKDWeaozgG6clIXrFPJDkJzd7oILJ1OYFlGEaFo31zV0njNvl/MwLr2 X00hS5iqYlLjjiHDGGyAWSyq/kkeBubQGfwkCSBfqZHyf6zKBh2DQ+vw18WbAXA6+MeRXqUx9 ZJdjymZ8FyfvU+PrCvAISIqP+1d7fNd64q/xIXdY6LJAYLwDvxcE8nodKrkExutn76wyMzcA2 rwfbwzSmvFHcesBK/WWOOFjFvCJ5Z9eWRzUEslAhunAb3VQ7y7qghizXKMyH4Nh6H5b+ZKkaJ J1lntuZ/eRJ9y00IuTVfHB3w5ZXv85F3gX+hMpfGuY6y4GtpHG/jlKGMv1I1RlzUIJZnTj4+P 2LG3KQfAA9zD8dao6YUvO4YQblT0PrsJvZUasWcOtkG/EPdBb+DXXHj90L9JBhTAs956fnvgx QIC2Yi69kX2pY0e9bIB69xJEWiMKIzcnDeXJtJiSnhGjDCdXVh1hRv744VqybWE6XOnW30mo2 dpl4EuMJ2gQoFScu5CL8BYMNl6+pBM8iniBcHWsO//hBqoS++pWTTDb1K57H1dFoHIPL94qsl SgZy9cvnPhItGyyl/CmealXTw9f38cS8PnJy42EJsK6tR7CbhwvFPa08OAeGQBqnN+acGwj0A 7lYfo5YXpgJNhw40rfoQ+n7keEwUWKn9PTtOHHpDKNdcli9RkGy0njLJTvZnkjdG/E3hEbQm7 kTzqSl2xsYSuvd/j0GE5Wkca/GBniiEZomBzqLN+Wrnz9uN9QpmyAdgJNRtfj3egTzkKDpZ9K zW99f06TWQ+b1wZml1MX0+Cba/AJnyn/EGJoGsSNHjBIqgYkx1dADE7EjM0q43dLtYFSNTZA5 YLNX38blTkodiYBhRsYq2Q8WpEE= 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 On 6/19/23 23:23, Raymond Mao wrote: > Changes for complying to EFI spec =C2=A73.5.1.1 > 'Removable Media Boot Behavior'. > Boot variables can be automatically generated during a removable > media is probed. At the same time, unused boot variables will be > detected and removed. > > Please note that currently the function 'efi_disk_remove' has no > ability to distinguish below two scenarios > a) Unplugging of a removable media under U-Boot > b) U-Boot exiting and booting an OS > Thus currently the boot variables management is not added into > 'efi_disk_remove' to avoid boot options being added/erased > repeatedly under scenario b) during power cycles > See TODO comments under function 'efi_disk_remove' for more details > > Signed-off-by: Raymond Mao > --- > Changes in v3 > - Split the patch into moving and renaming functions and > individual patches for each changed functionality > Changes in v5 > - Move function call of efi_bootmgr_update_media_device_boot_option() > from efi_init_variables() to efi_init_obj_list() > Changes in v6 > - Revert unrelated changes > Changes in v7 > - adapt the return code of function > efi_bootmgr_update_media_device_boot_option() > Changes in v8 > - add a note in the commit message for future reference > Changes in v9 > - amend the note text in the commit message > - add a TODO comment in 'efi_disk_remove' > Changes in v10 > - fix typo and build failures with 'CONFIG_CMD_BOOTEFI_BOOTMGR=3Dn' > > lib/efi_loader/efi_disk.c | 18 ++++++++++++++++++ > lib/efi_loader/efi_setup.c | 7 +++++++ > 2 files changed, 25 insertions(+) > > diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c > index d2256713a8..911a4adfb1 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 initiali= zed */ > + if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR) && efi_obj_list_initialized= =3D=3D EFI_SUCCESS) { > + ret =3D efi_bootmgr_update_media_device_boot_option(); > + if (ret !=3D EFI_SUCCESS) > + return -1; > + } > + > return 0; > } > > @@ -773,6 +780,17 @@ int efi_disk_remove(void *ctx, struct event *event) > return efi_disk_delete_part(dev); > else > return 0; > + > + /* > + * TODO A flag to distinguish below 2 different scenarios of this > + * function call is needed: > + * a) Unplugging of a removable media under U-Boot > + * b) U-Boot exiting and booting an OS > + * In case of scenario a), efi_bootmgr_update_media_device_boot_option= () > + * needs to be invoked here to update the boot options and remove the > + * unnecessary ones. > + */ As in future we want to integrate more EFI drivers with the driver model such a status should be in a global variable. It will have to be set in ExitBootServices() before invoking dm_remove_devices_flags(). Reviewed-by: Heinrich Schuchardt > + > } > > /** > diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c > index 58d4e13402..69c8b27730 100644 > --- a/lib/efi_loader/efi_setup.c > +++ b/lib/efi_loader/efi_setup.c > @@ -245,6 +245,13 @@ efi_status_t efi_init_obj_list(void) > if (ret !=3D EFI_SUCCESS) > goto out; > > + if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR)) { > + /* update boot option after variable service initialized */ > + ret =3D efi_bootmgr_update_media_device_boot_option(); > + if (ret !=3D EFI_SUCCESS) > + goto out; > + } > + > /* Define supported languages */ > ret =3D efi_init_platform_lang(); > if (ret !=3D EFI_SUCCESS)