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 71220C433EF for ; Wed, 16 Mar 2022 14:04:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B7F8F83959; Wed, 16 Mar 2022 15:04:40 +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="oK4YLuLL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 464C2837C9; Wed, 16 Mar 2022 15:04:39 +0100 (CET) Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (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 6E4E0838AE for ; Wed, 16 Mar 2022 15:04:35 +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-wm1-x32b.google.com with SMTP id m42-20020a05600c3b2a00b00382ab337e14so3277845wms.3 for ; Wed, 16 Mar 2022 07:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=l9aEBLch6bvOD3k+rOcLrcOIPTr6JQwLB/13U/eQSjU=; b=oK4YLuLLUcfQD5E35sW5+x34zSSWOdqkM+ZirvFz6NAtI/IV+Y6O8JpwcBT67w3fXK nzsqYhjieu8aOtRUczPWdu5QZfokzKaZKrAypbAAHjsvuhCak8nHwhHT7AoOTXiihnlJ cEuFE5RPJwIUd0785xWpvGCSnGNJXLlfa+T6lNSO91hfcIy9B/l56/0ZyLKHRYZwtTqE qWue0/Jo/cg6qEpEzQ0P0A2mjI7NhT6aweSSFfKqBRIm/dPOPC7l4FqInLcsJ0qm7ga4 G1Re1eYcJWYkdabylJnNu0Rwhgm2r+AJPkQMlrEsby2jhoCKYSjzOknn+55Br6mcW67a Yd5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=l9aEBLch6bvOD3k+rOcLrcOIPTr6JQwLB/13U/eQSjU=; b=NVRbOvm9FuOoOB1w2sRF21sMapvgF/78V//eAu01HRqzpphmHmlRRnI+ALRxXUP0Vs MPjVQc1zeJxINASNzLLgnEAvN9H4reQn1aF1EZM8rcEZYXi5SPMvdyzmIFscf066K4+E kDhD4PsCZXddsI1unp1+QciVoe2jIAPNQCInZCSE0P/PE3Kp30mvKYx0kYsFoyBUalR4 6vx7o8qwBBM2x9ku+khJCs+02RFqlAFTvL9wbQ8lbEp7tM+m3LyjA+UpVHHnzr4xujUZ N+SXGa8SSKdhdTXZAaUI01iQcUMnjcfob3DV5NRQT7KnsU6e5CtDPy2tE6hkToVUv6A/ +45Q== X-Gm-Message-State: AOAM531efNyFed4l4mgQBK5rieAoDx90HTudlBnmI5nfXlhDdc40ROzV NeHnIEY0MvvcIRiguIRMFy3nfQ== X-Google-Smtp-Source: ABdhPJzQuLlhJPd3455/FIjcgkUU4PV8qcYkZN5fkZBh1SyfHY7o7mPhgSlAwahXS8IA5IeVS53suQ== X-Received: by 2002:a05:600c:26c8:b0:389:a542:c20b with SMTP id 8-20020a05600c26c800b00389a542c20bmr7576888wmv.46.1647439474884; Wed, 16 Mar 2022 07:04:34 -0700 (PDT) Received: from hades (athedsl-4461682.home.otenet.gr. [94.71.4.98]) by smtp.gmail.com with ESMTPSA id t14-20020a5d49ce000000b001f036a29f42sm1694916wrs.116.2022.03.16.07.04.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 07:04:34 -0700 (PDT) Date: Wed, 16 Mar 2022 16:04:31 +0200 From: Ilias Apalodimas To: Heinrich Schuchardt Cc: Stuart.Yoder@arm.com, paul.liu@linaro.org, u-boot@lists.denx.de Subject: Re: [PATCH] efi_loader: Set variable attributes when EFI_BUFFER_TOO_SMALL is returned Message-ID: References: <20220316125516.1458348-1-ilias.apalodimas@linaro.org> <066dd1cb-25cc-1cbe-fd9a-0a8a675ced3f@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <066dd1cb-25cc-1cbe-fd9a-0a8a675ced3f@gmx.de> 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.5 at phobos.denx.de X-Virus-Status: Clean On Wed, Mar 16, 2022 at 02:40:20PM +0100, Heinrich Schuchardt wrote: > On 3/16/22 13:55, Ilias Apalodimas wrote: > > Starting UEFI Spec 2.8 we must fill in the variable attributes when > > GetVariable() returns EFI_BUFFER_TOO_SMALL and Attributes is non-NULL. > > > > This code was written with 2.7 in mind so let's move the code around a > > bit and fill in the attributes EFI_BUFFER_TOO_SMALL is returned > > In the UEFI spec changelog: > > 1954 set (*Attributes) when GetVariable() returns EFI_BUFFER_TOO_SMALL > and Attributes is non-NULL > > In efi_get_variable_mem() this already works correctly. > > > > > Signed-off-by: Ilias Apalodimas > > --- > > lib/efi_loader/efi_variable_tee.c | 27 ++++++++++++++++++--------- > > 1 file changed, 18 insertions(+), 9 deletions(-) > > > > diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c > > index 58931c4efd74..33c7dfc53d14 100644 > > --- a/lib/efi_loader/efi_variable_tee.c > > +++ b/lib/efi_loader/efi_variable_tee.c > > @@ -408,22 +408,31 @@ efi_status_t efi_get_variable_int(const u16 *variable_name, > > /* Communicate */ > > ret = mm_communicate(comm_buf, payload_size); > > if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) { > > You could make the code easier to read with: > > if (ret != EFI_SUCCESS && ret != EFI_BUFFER_TOO_SMALL) > goto out; > Sure > > + int tmp; > > /* Update with reported data size for trimmed case */ > > *data_size = var_acc->data_size; > > + /* > > + * UEFI > 2.7 needs the attributes set even if the buffer is > > + * smaller > > + */ > > + tmp = get_property_int(variable_name, name_size, vendor, > > + &var_property); > > Why call get_property_int() if (!attributes)? > You don't use the data in this case. > Good point. I just moved the code around, but i'll fix that along the way Thanks /Ilias > Best regards > > Heinrich > > > + if (tmp != EFI_SUCCESS) { > > + ret = tmp; > > + goto out; > > + } > > + > > + if (attributes) { > > + *attributes = var_acc->attr; > > + if (var_property.property & > > + VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY) > > + *attributes |= EFI_VARIABLE_READ_ONLY; > > + } > > } > > - if (ret != EFI_SUCCESS) > > - goto out; > > > > - ret = get_property_int(variable_name, name_size, vendor, &var_property); > > if (ret != EFI_SUCCESS) > > goto out; > > > > - if (attributes) { > > - *attributes = var_acc->attr; > > - if (var_property.property & VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY) > > - *attributes |= EFI_VARIABLE_READ_ONLY; > > - } > > - > > if (data) > > memcpy(data, (u8 *)var_acc->name + var_acc->name_size, > > var_acc->data_size); >