From patchwork Wed Mar 16 12:55:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 551838 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp252168mag; Wed, 16 Mar 2022 05:55:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz57gkm+rfRZfwNRmx97FJeyge5dnWTeohlNkgy8mmYjDyM4pUhveAxvua/SC2dCb/g0Jsx X-Received: by 2002:aa7:d945:0:b0:418:f041:f9bc with SMTP id l5-20020aa7d945000000b00418f041f9bcmr260463eds.305.1647435329127; Wed, 16 Mar 2022 05:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647435329; cv=none; d=google.com; s=arc-20160816; b=sGE/BRKtH+8GmWK6dOa6Wc23KNq6eoHYJ0Kx06FArufTqomSUOog7eStUIL2vO4PHL hyZZbcMUKyVZIluYf9768XY/3JV7KAp9VoLfBMKxCCmhurMUNnCfj22VvzXBV+sAx/wQ 6tQ2COF3DiG0xc5EDqA3OkjNSAG/8hxmhnLty2wLhJF8i8ZD0LL0XZnxLEHvtcyqSQoE Azc6whBerc6bsqLrKbFsMntXo1AMswm3nxkbr3xTy0hrXE6BXPA8YKL0T37FGcB7InW6 D++iLVRisvVAorUfwWnm9zCJa3cbMTSsLCMmClFRX5TtqMQiLdTndUyUa/P41H26B2j9 DhdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=wLUD07cHGAM62qH3TCPQhUdhlWwwTDttR9BAKTPXVaw=; b=rKjj2ZzHFwyAvPjqkrcgxyiqdbFWiKhuaijva6qmDkm/bBP3GLppvWMBsoSp6uN5BD k7JsF5JyH4QcD7eFalHcEoy8/97/be9O1HVzl6Wqdy+tkUU+Eu1+nhwPENNuWsmHP9+Q 6y5AXYNeDnTDeFpioNFiF+MXOUZPlsv4gvxDwaVBqYvXUckBPp6W9dXstfaQyhc2QaE2 VDsIaOeILyNERPXqUYr2xYvT7Gq02MsuUOVjzNnUJUTeCNcaPHkLRlGsNjolwLSLm+0K cNQauuutPctXTapRJ2isPCXDWoUkCEzEp2KX86mP1jp1Irzy7mneTHtwrYNtp2WUB/B8 V+Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W6daiLX7; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id qf12-20020a1709077f0c00b006da8ec1f477si1270832ejc.814.2022.03.16.05.55.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 05:55:29 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W6daiLX7; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8BC59838AB; Wed, 16 Mar 2022 13:55:25 +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="W6daiLX7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 076528301E; Wed, 16 Mar 2022 13:55:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) (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 DEB5B8301E for ; Wed, 16 Mar 2022 13:55:19 +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-x32c.google.com with SMTP id p184-20020a1c29c1000000b0037f76d8b484so1340604wmp.5 for ; Wed, 16 Mar 2022 05:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wLUD07cHGAM62qH3TCPQhUdhlWwwTDttR9BAKTPXVaw=; b=W6daiLX7MwtKgsw5hXyZ7S/lqORFXNNQ2bxEFzpeQSTTxVGNKe2/y66nBBR/570p0o LG6HPndrMJzgpCQoWW2BQPN26y3xlj0yu/WSKzgyQ+u7+u01a2VMx/X6IEr31hG9glhU abk3UxHiXFPfLCLYtYSFieJEc8/cq3v8dVP5e4cFOF2EKZBq3dsWtwrfdLYi585JCxzR 5bb0zYaFaRP+BGEPF/F1Fvy0pMkFRdi0HhiMqGAE9aQHfDOtaLU6Wcs/NTL8322P6H+8 oCyOXWtAbspBbcCRuy5xQkJNGkxwpNvSXbc+YeCxK2ajS9H2PnnQbFVYPT574v6zTnhn arBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wLUD07cHGAM62qH3TCPQhUdhlWwwTDttR9BAKTPXVaw=; b=zhoga3Y4PIl5UgG+K7uKPvWaYsHhBJFf+QTHGvYLWp2d7ZO85TK4wPpZTe/X1DdJaO p6DdwgZ4Vcui+3yuqnTe86+1QN52lwKgsCHy5KIrROkK3PeexEJ1hey6COKXbLbpi6iI lfnZwFrWuhxLt+82aTmNtMh24rzmZbrW2Q6QYSjix97RvdHHssMNGEvOe4AjPEA4l+i9 MAXRpt+kOr8X5Xoi4zqhi7J5RNgq1h95zChV9JgS8Muhb3D/Cwnij4H6EKwQoi+su5/c mYiO0cxRx9pr5u7cp5qZs73RwHHsaKGV0M4ITofqxFyKVWLQouSROogB6mscW17SOpgb KS6Q== X-Gm-Message-State: AOAM5316ashyGjRA+AGZ0PFgVTK08b9b3jozfJePspm42UW1i8jKeVwM 2pMjfaYYkc55RvZlyHG7pAJUDg== X-Received: by 2002:a05:600c:1c9f:b0:389:cf43:da64 with SMTP id k31-20020a05600c1c9f00b00389cf43da64mr7306665wms.206.1647435319421; Wed, 16 Mar 2022 05:55:19 -0700 (PDT) Received: from hades.. ([2a02:587:4679:5116:3efd:feff:fe6b:c5cb]) by smtp.gmail.com with ESMTPSA id q16-20020adfea10000000b00203e0735791sm1200938wrm.39.2022.03.16.05.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 05:55:19 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: Stuart.Yoder@arm.com, paul.liu@linaro.org, Ilias Apalodimas , u-boot@lists.denx.de Subject: [PATCH] efi_loader: Set variable attributes when EFI_BUFFER_TOO_SMALL is returned Date: Wed, 16 Mar 2022 14:55:16 +0200 Message-Id: <20220316125516.1458348-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 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 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 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) { + 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); + 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);