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 530F8C77B73 for ; Fri, 26 May 2023 21:40:15 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 605DF85D24; Fri, 26 May 2023 23:40:13 +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="bXrzYXq8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 85C9186176; Fri, 26 May 2023 23:40:12 +0200 (CEST) Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) (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 D01B7846A2 for ; Fri, 26 May 2023 23:40:09 +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=raymond.mao@linaro.org Received: by mail-qk1-x72c.google.com with SMTP id af79cd13be357-75b015c0508so84870085a.1 for ; Fri, 26 May 2023 14:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685137208; x=1687729208; 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=dLu4m9ApXXwRAfdqQ+ASYAXhHkBiEa/uebNPUrqjbFA=; b=bXrzYXq8sRco9Q3E9uiyVo3MxN1Ba5NPAqtfbM/XiNpD9c3kiVSNYUkidRl82NMJqv /hdXsCrOa2/E8poMp5nYdvnw7xGKJ39hoGA0xCiX/9a5DVz0Z4zrcGhTMmaNDhASMk+f UgvS8k9FY9zJ22iIZd+sEWXgGGtcugLNaQbbARcSYH8cwF7tSLfGIhuE2J7zSuQXiNUN EZsj0YfD583r3naoSIbsVQLN4UZxp45vcp4PrbgG9DlIdKxV5qvKtnoxLaGO9iRuQFgd B1c+P5ppGn4aGypbIUpQfrbLbVEoQGYBYdZXp9wKdKaT+e2gMSxzJrdcCZyhROe/pTPh 6fog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685137208; x=1687729208; 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=dLu4m9ApXXwRAfdqQ+ASYAXhHkBiEa/uebNPUrqjbFA=; b=HmxGCvDdGmCHJKDz2GofHNY8oUjWr3shUD6kkkqz11ZaybLBO2aGbL9NUWfPQqY7lN UQnvG8Zz/g+VIFy30kEVtlfS2953gsFq2fQLuyd0DbF5DPW53ukEr1AcUY/rfWMwWwYm 1oHnVhwt2jYtSd2XbPzsnlRFm+eNFzT26aOngHkrLhgRe9e48e9jEVnxjErDiaN1KGV6 DtfZw1778y6U0M+gz8+V1zW4BF8PZ4VkVvhXAd/mhXAcRccuA+CGVk8j0PIEDpz6MUOP tSQjvqhd75d487kAZYbm/DcHvrWy1qnoDGugw7q7DNxDrlLAE/mgQI/yJaY/DyXz5s4d 9zIg== X-Gm-Message-State: AC+VfDx9kcTG8xOofuCLYS2ZkQPLBLSkyXdTlWVrpkhxM19UujHwXJOn FFR5Z3+4CTsq3OG1PNYBQZf/lrr+56TClXPlECk= X-Google-Smtp-Source: ACHHUZ5ms81i/ijSYWuaRUcsS6bKqWUiVnlXS8UOxNpX7KH17lTFvZ85cat8vFH6BeQUPJPFD9YHtw== X-Received: by 2002:a05:620a:8082:b0:75b:23a1:3674 with SMTP id ef2-20020a05620a808200b0075b23a13674mr806362qkb.53.1685137208529; Fri, 26 May 2023 14:40:08 -0700 (PDT) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.114.251.9]) by smtp.gmail.com with ESMTPSA id p22-20020a05620a15f600b0075b196ae392sm1437529qkm.104.2023.05.26.14.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 14:40:08 -0700 (PDT) From: Raymond Mao To: u-boot@lists.denx.de Cc: Raymond Mao , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Masahisa Kojima Subject: [PATCH v6 2/3] Boot var automatic management for removable medias Date: Fri, 26 May 2023 14:36:51 -0700 Message-Id: <20230526213650.990816-3-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230526213650.990816-1-raymond.mao@linaro.org> References: <20230526213650.990816-1-raymond.mao@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Changes for complying to EFI spec ยง3.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. 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 lib/efi_loader/efi_disk.c | 7 +++++++ lib/efi_loader/efi_setup.c | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index d2256713a8..ca5f07f2ec 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(); + if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND) + return -1; + } + return 0; } diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index 58d4e13402..4686374995 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -245,6 +245,11 @@ efi_status_t efi_init_obj_list(void) if (ret != EFI_SUCCESS) goto out; + /* update boot option after variable service initialized */ + ret = efi_bootmgr_update_media_device_boot_option(); + if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND) + goto out; + /* Define supported languages */ ret = efi_init_platform_lang(); if (ret != EFI_SUCCESS) -- 2.25.1