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 86C47C636CC for ; Thu, 16 Feb 2023 20:41:26 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 02D4585B7D; Thu, 16 Feb 2023 21:41:24 +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="w04kmPyF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4FDD785B7C; Thu, 16 Feb 2023 21:41:22 +0100 (CET) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) (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 A7AC385BB5 for ; Thu, 16 Feb 2023 21:41: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=ilias.apalodimas@linaro.org Received: by mail-wr1-x42e.google.com with SMTP id r2so3011993wrv.7 for ; Thu, 16 Feb 2023 12:41:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=O8YEyaEipLy5iA0HsbFTbHsqAoYE9PKYLb5TARJ5UHU=; b=w04kmPyFecH8PpedOwR/pXmSzKnrIijUoBfRHTMpzTdKIdDCGPcgLWs55+Xl/wlByJ jEEcJssgi2sBb4MvGMdL/hwcSQJ0if7E6hwEMWcL24bCsOrdkz4EefgwpI9B4qyaAMJq NMZEOCN8D1NCObOytzhgDJXbgadutUyG4IkhB2+zX5MTpBX5vDKazmVCBWsOfJLIPRDW ES+gvMiMDJtCsJ/VKCNFICuWXA1E2YmEqgN/gnVbGUzKDE0+DaEuW7k35s6mW6Lzt3c+ JJtW2PK1uW/a5sa7aET+Z+mK0VLmCVsDqm/Y8OpElJ9P3MOj5mCNoM25QE6rzdUUTeNl SwZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=O8YEyaEipLy5iA0HsbFTbHsqAoYE9PKYLb5TARJ5UHU=; b=yFghy9uPQzTtbnO1fTGibsaJn1hYiVSVDILs7hMaxKHUTa33KN5LQYswfrpL/KTUck i40Nas7x3GyiZCFU3T+YMQmIrjXOOSNuzr/Wk+xBedBG3qeH4TruYSYI3E1sF3Ku86VW lgcgZTFOShxbYITZGCn3h223yeIm8G5iU+OJpZ+yy5degmbnedv5U3fzbo3UwkeIk2uh 3HAEjBxeXjBKvBlqIdiGmH81/my9J9Hd6hMPxrMEcWpDYAhGQ1RtHD8hzq/ill6gzXM+ aqRxMDhOI7uqVe++R8umbW4vg0+/jkauqOacWJADSU6ghypYV85iuDRjEPusMTWMxNiX 5gUw== X-Gm-Message-State: AO0yUKUll5G+6wNrYjXKqduQg5UmexkQJzTIiQi/orvfZ/+7VRTqU1RG KJa3xmsNPvZ6r3KvKm5CiNfBMg== X-Google-Smtp-Source: AK7set+ARTH+QZvML/1mOUqVQrgbCEJHAscR02ETg/XPbjzQsJu5xLibU4ivPu5EWa9As+KO9qBJsQ== X-Received: by 2002:a05:6000:1787:b0:2c5:67e3:808d with SMTP id e7-20020a056000178700b002c567e3808dmr3294253wrg.35.1676580078066; Thu, 16 Feb 2023 12:41:18 -0800 (PST) Received: from hera (ppp176092130041.access.hol.gr. [176.92.130.41]) by smtp.gmail.com with ESMTPSA id x13-20020adfdccd000000b002c3e3ee7d1asm2353878wrm.79.2023.02.16.12.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 12:41:17 -0800 (PST) Date: Thu, 16 Feb 2023 22:41:15 +0200 From: Ilias Apalodimas To: Etienne Carriere Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: Re: [PATCH v2] efi_loader: set CapsuleMax from CONFIG_EFI_CAPSULE_MAX Message-ID: References: <20230216172141.2357759-1-etienne.carriere@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230216172141.2357759-1-etienne.carriere@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.6 at phobos.denx.de X-Virus-Status: Clean Hi Etienne, On Thu, Feb 16, 2023 at 06:21:41PM +0100, Etienne Carriere wrote: > Adds CONFIG_EFI_CAPSULE_MAX to configure the max index value used in > EFI capsule reports. The config default value is 65535 as the index max > value used before this change. Platforms with limited storage capacity > can set a lower configuration value to prevent storage capacity > overflow or even waste of storage space. > > Signed-off-by: Etienne Carriere > --- > Changes since v1 > - Changed CONFIG_EFI_CAPSULE_MAX default value from 65535 to 15. > --- > lib/efi_loader/Kconfig | 8 ++++++ > lib/efi_loader/efi_capsule.c | 48 +++++++++++++++++++++++++----------- > lib/efi_loader/efi_setup.c | 7 +++++- > 3 files changed, 48 insertions(+), 15 deletions(-) > > diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig > index c56904afc2..727241dc9c 100644 > --- a/lib/efi_loader/Kconfig > +++ b/lib/efi_loader/Kconfig > @@ -226,6 +226,14 @@ config EFI_CAPSULE_AUTHENTICATE > Select this option if you want to enable capsule > authentication > > +config EFI_CAPSULE_MAX > + int "Max value for capsule index" > + default 15 > + range 0 65535 > + help > + Select the max capsule index value used for capsule report > + variables. This value is used to create CapsuleMax variable. > + > config EFI_DEVICE_PATH_TO_TEXT > bool "Device path to text protocol" > default y > diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c > index 0997cd248f..d5d3ede7ae 100644 > --- a/lib/efi_loader/efi_capsule.c > +++ b/lib/efi_loader/efi_capsule.c > @@ -45,17 +45,7 @@ const efi_guid_t fwu_guid_os_request_fw_accept = > static struct efi_file_handle *bootdev_root; > #endif > > -/** > - * get_last_capsule - get the last capsule index > - * > - * Retrieve the index of the capsule invoked last time from "CapsuleLast" > - * variable. > - * > - * Return: > - * * > 0 - the last capsule index invoked > - * * 0xffff - on error, or no capsule invoked yet > - */ > -static __maybe_unused unsigned int get_last_capsule(void) > +static __maybe_unused unsigned int get_capsule_index(const u16 *variable_name) > { > u16 value16[11]; /* "CapsuleXXXX": non-null-terminated */ > char value[5]; > @@ -65,7 +55,7 @@ static __maybe_unused unsigned int get_last_capsule(void) > int i; > > size = sizeof(value16); > - ret = efi_get_variable_int(u"CapsuleLast", &efi_guid_capsule_report, > + ret = efi_get_variable_int(variable_name, &efi_guid_capsule_report, > NULL, &size, value16, NULL); Variable name is now an argument, but the value16 size remains an array of 11 u16's. We should test that before calling efi_get_variable_int() although the code currently just uses 'CapsuleLast' and 'CapsuleMax'. > if (ret != EFI_SUCCESS || size != 22 || > u16_strncmp(value16, u"Capsule", 7)) > @@ -84,6 +74,35 @@ err: > return index; > } > [...] Cheers /Ilias