From patchwork Wed Apr 24 05:03:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 791495 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp650800wrq; Tue, 23 Apr 2024 22:04:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWPNIlaglBZO26+E5tT/xjT99PIsiaeWmU7OEwmInTOJMYywt81LxHrqmSPxcGITF/O4orc0ZFPS2PFFDmctIHW X-Google-Smtp-Source: AGHT+IEkQM3Gt0jxuxDDj8PS4tVW26xaTgeaazaJ6tpE/WlDNc4FMmCXqLQEVQ8mvofY4s0dmhWz X-Received: by 2002:a05:600c:548a:b0:41a:7ab1:fd98 with SMTP id iv10-20020a05600c548a00b0041a7ab1fd98mr964351wmb.21.1713935045831; Tue, 23 Apr 2024 22:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713935045; cv=none; d=google.com; s=arc-20160816; b=bmkETfHU8nRPmzsY2kFwDQskuH79jPojDP+Z7tkN2ZWK1rMniVNLM4MmAv4Bq4507p tRunMgusEMueqRaH7zghS3ck5PTugwbNWCOJBmzrf12c5TEe9naaFCNBmoNKzL9FQdjS DoYABedNhEppu+ljxkjBERx7z9DvmK0+MdDuCqJLsOso9GAmoLv5oi0t9gOsTAvZKUdh XHJiB4cjbFz1O7J0LO1uPTBpno4YWdAQIWc57D/dnxsGCoJQgyLpDAaQHrEyteRk0yu9 on0IE4WzIG0NVhB6gF0cyEnC3dwl8UM66ePcWiJyH7j7jY/LUdVQp4Wny2QikNmmv9lx nQZw== 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=EVHDPCZH4dUgdDh5TewEvZ9ii+SMu3g0x9ZgWOqncVY=; fh=r3T11POMt03ClPHECNN1R+djuGoIWWuXsijjvIhWVa4=; b=OT6BvURyW/jsKCdX8gnSAqnhkseBHN5VjHlR/ZKjX7Rw4knT05L1iP8/oZIjnidStL HGS/MowVpJrwKEjxzAD+YYPid50ILsEPCVr2qFSX5MLf2nxTtqTugV9tzGxodV85Oo6L lH00Hm2OEqdM1Uj5AweullUKWGhxKfBU7RS2Z7CN85ojJGCHMMqzjcskMcW2A29cEHVc wUmcBqIgu4j6YxAsmoDnLQ/jqgLJdxk4QqbDblzqwPERHgLx+deh0qKsKuz1krY9dJ2m ztuLln7E6W7N30zpjk9WtaYmQbnLZrbA5HcVrsk7TPzQqMNtPQzY4FUCpln2gTGsNrjG /C7A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x3DDcsIe; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id l16-20020a7bc350000000b00418a10c1620si8530090wmj.98.2024.04.23.22.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 22:04:05 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x3DDcsIe; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 B78EA88D96; Wed, 24 Apr 2024 07:04:04 +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="x3DDcsIe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8FA7B88D9C; Wed, 24 Apr 2024 07:04:03 +0200 (CEST) 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 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 7919488CD6 for ; Wed, 24 Apr 2024 07:04:01 +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=ilias.apalodimas@linaro.org Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-41af6701806so3480285e9.1 for ; Tue, 23 Apr 2024 22:04:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713935041; x=1714539841; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EVHDPCZH4dUgdDh5TewEvZ9ii+SMu3g0x9ZgWOqncVY=; b=x3DDcsIef1iipgl5A5cGq/Yk594ZaEijvGlqH9GXKlgpi4i0B+wReoQxqlSd90axEq mEvIVDL53NqUv1CuANddvPYe8l3eJ8wONfdJw4/B9/HPwIkQWT6pSZrIAKf6cCVJOK8t EhGPihOq+B2FKGbrfD+rVOF3mKyHGiKfygDHspdy3YYTQepnzvGZAn7DnHOFBEhB3bRj eke/SloXZRQAuJj4AhaSXW5oi9LUqDsvomYUF+K/2iEWhKa7RqOgXct/ZbBr46a61oWy LYAwh4t70UoWXi9ZF6m5UNnfDl1lmGntIvUi1cGcOOZStrH08xm3sLfBEvZ68UipsuBH Hx8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713935041; x=1714539841; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EVHDPCZH4dUgdDh5TewEvZ9ii+SMu3g0x9ZgWOqncVY=; b=m71b+zy15aBwy2W91IabxkLCKf+sPoty0K8gWV6dkn1TLIdf98s4ri+oZ0EQ4WEcgQ 50BqTCQ7ZOE12Pr1bFGtzEfd9257QtmIoGV71HYh0v3toXOwD5ESkK66Dxetu06bqTja D9/Yos28skewBdyfl4AEQ7AR0cOe9eeOolm4opoLKGA3a+z5PPXdOj+lDeU5Y7S22sIB D+C8MAvX5d7Yo1Mvq0O42TiDSyTdsVIV1KNeIYTHKqHXsdDm9HLnHcoD8UZ5f7d6TS5v Ob41LWMUDtXvsc//dU5yoFqllXYU6q8KvMYIU6jxKdVD3Lvv0fPigoRwhGfuPu0QKdgp C0bw== X-Gm-Message-State: AOJu0YyvSRyJ/oDURm9hIU6MAmWK3J9x7bxdhZOdBNQWiI44GHbqT6ib XVYGlvWkBx6Hd2zxoLLqd6Hf1Da9VgIPSaztZGLJRWoYuFGF/gjsy9VtFVyElTN3cYela7YIb50 jM3o= X-Received: by 2002:a05:6000:180f:b0:341:d912:1fec with SMTP id m15-20020a056000180f00b00341d9121fecmr773170wrh.49.1713935040824; Tue, 23 Apr 2024 22:04:00 -0700 (PDT) Received: from hades.. (ppp089210108048.access.hol.gr. [89.210.108.48]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b0041afe0f2f17sm861032wmb.16.2024.04.23.22.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 22:04:00 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de, xypron.glpk@gmx.de Cc: Ilias Apalodimas Subject: [PATCH 1/3] efi_loader: enable QueryVariableInfo at runtime for file backed variables Date: Wed, 24 Apr 2024 08:03:49 +0300 Message-Id: <20240424050351.318724-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.40.1 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.8 at phobos.denx.de X-Virus-Status: Clean Since commit c28d32f946f0 ("efi_loader: conditionally enable SetvariableRT") we are enabling the last bits of missing runtime services. Add support for QueryVariableInfo which we already support at boottime and we just need to mark some fucntions available at runtime and move some checks around. It's worth noting that pointer checks for maxmimum and remaining variable storage aren't when we store variables on the RPMB, since the Secure World backend is already performing them. Signed-off-by: Ilias Apalodimas --- lib/efi_loader/efi_runtime.c | 4 ++++ lib/efi_loader/efi_var_common.c | 6 ------ lib/efi_loader/efi_variable.c | 18 ++++++++++++------ lib/efi_loader/efi_variable_tee.c | 5 +++++ .../efi_selftest_variables_runtime.c | 14 +++++++++++--- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 73831c527e00..011bcd04836d 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -129,6 +129,10 @@ efi_status_t efi_init_runtime_supported(void) EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP | EFI_RT_SUPPORTED_CONVERT_POINTER; + if (IS_ENABLED(CONFIG_EFI_VARIABLE_FILE_STORE)) + rt_table->runtime_services_supported |= + EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO; + if (IS_ENABLED(CONFIG_EFI_RT_VOLATILE_STORE)) { u8 s = 0; diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c index 961139f005af..ea8d2a4cf98c 100644 --- a/lib/efi_loader/efi_var_common.c +++ b/lib/efi_loader/efi_var_common.c @@ -1,4 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0+ /* * UEFI runtime variable services * @@ -163,11 +162,6 @@ efi_status_t EFIAPI efi_query_variable_info( EFI_ENTRY("%x %p %p %p", attributes, maximum_variable_storage_size, remaining_variable_storage_size, maximum_variable_size); - if (!maximum_variable_storage_size || - !remaining_variable_storage_size || - !maximum_variable_size) - return EFI_EXIT(EFI_INVALID_PARAMETER); - ret = efi_query_variable_info_int(attributes, maximum_variable_storage_size, remaining_variable_storage_size, diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 0cbed53d1dbf..e039cecd82b6 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -406,12 +406,15 @@ efi_status_t efi_set_variable_int(const u16 *variable_name, return EFI_SUCCESS; } -efi_status_t efi_query_variable_info_int(u32 attributes, - u64 *maximum_variable_storage_size, - u64 *remaining_variable_storage_size, - u64 *maximum_variable_size) +efi_status_t __efi_runtime +efi_query_variable_info_int(u32 attributes, + u64 *maximum_variable_storage_size, + u64 *remaining_variable_storage_size, + u64 *maximum_variable_size) { - if (attributes == 0) + if (!maximum_variable_storage_size || + !remaining_variable_storage_size || + !maximum_variable_size || !attributes) return EFI_INVALID_PARAMETER; /* EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is deprecated */ @@ -460,7 +463,10 @@ static efi_status_t __efi_runtime EFIAPI efi_query_variable_info_runtime( u64 *remaining_variable_storage_size, u64 *maximum_variable_size) { - return EFI_UNSUPPORTED; + return efi_query_variable_info_int(attributes, + maximum_variable_storage_size, + remaining_variable_storage_size, + maximum_variable_size); } /** diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c index 4f1aa298da13..8b6b0a390869 100644 --- a/lib/efi_loader/efi_variable_tee.c +++ b/lib/efi_loader/efi_variable_tee.c @@ -873,6 +873,11 @@ efi_status_t efi_query_variable_info_int(u32 attributes, efi_status_t ret; u8 *comm_buf; + if (!max_variable_storage_size || + !remain_variable_storage_size || + !max_variable_size || !attributes) + return EFI_INVALID_PARAMETER; + payload_size = sizeof(*mm_query_info); comm_buf = setup_mm_hdr((void **)&mm_query_info, payload_size, SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO, diff --git a/lib/efi_selftest/efi_selftest_variables_runtime.c b/lib/efi_selftest/efi_selftest_variables_runtime.c index afa91be62c85..5794a7b2d405 100644 --- a/lib/efi_selftest/efi_selftest_variables_runtime.c +++ b/lib/efi_selftest/efi_selftest_variables_runtime.c @@ -60,9 +60,17 @@ static int execute(void) ret = runtime->query_variable_info(EFI_VARIABLE_BOOTSERVICE_ACCESS, &max_storage, &rem_storage, &max_size); - if (ret != EFI_UNSUPPORTED) { - efi_st_error("QueryVariableInfo failed\n"); - return EFI_ST_FAILURE; + + if (IS_ENABLED(CONFIG_EFI_VARIABLE_FILE_STORE)) { + if (ret != EFI_SUCCESS) { + efi_st_error("QueryVariableInfo failed\n"); + return EFI_ST_FAILURE; + } + } else { + if (ret != EFI_UNSUPPORTED) { + efi_st_error("QueryVariableInfo failed\n"); + return EFI_ST_FAILURE; + } } ret = runtime->set_variable(u"efi_st_var0", &guid_vendor0, From patchwork Wed Apr 24 05:03:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 791496 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp650855wrq; Tue, 23 Apr 2024 22:04:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWlaKeOa0aborfoqko737bIRSnYPY8yuojLxA29xlmy5ODbhuMjnoWMzefhivfHdUcr9NdwUoXyqsABb35QoLSt X-Google-Smtp-Source: AGHT+IH1QrN4yZ4nVTRXR4HuDkcWOpRo8uRmwQlzjw07Nd101m/7Ql4emDOt1qZFx9FIKE8PpGH3 X-Received: by 2002:a5d:42cf:0:b0:346:b581:ff57 with SMTP id t15-20020a5d42cf000000b00346b581ff57mr718961wrr.68.1713935057251; Tue, 23 Apr 2024 22:04:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713935057; cv=none; d=google.com; s=arc-20160816; b=fJCcFkc5DUe5f/Ve+pwAKRgbvtzOav/WObWcWmYYWKe5hQ8wcUG8NbMLD/tfxnAK+r f2IIYnPW+jS89LkEO84fePAuHDUKpoTAYcbuT9cWZeisTYNb4QpG2zFjVS/VPCXiqZ/7 fqWaOFrcTUkozIWEDYGVwvGXQ12h+T3G+uzHU81VavKPIE8S5nw9cSOfCXHdarg3kDxr /y1uwzWzxWg+q3jmdBM5R6fhMgNP8EjOPKZFH62BJNSpkU6sSRMOQCdsdIF+IMcpA3XY 4H+Tn3MhBTTiJa4JpxjqurlntVrk01F/FYbfXbyUw11ukTfxLfw+R7IaV6HfOjCO81MZ W4tw== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vbFHZkLIyTsnFbIYjd2AoiBzf3B0mbR9ncwmyQR2oNk=; fh=r3T11POMt03ClPHECNN1R+djuGoIWWuXsijjvIhWVa4=; b=lLjhZVwiSU5UurXWZWzECPfUvD0C6VzNoWvFzSZMzdHn3AqpaxnDIw+xZk4QtLzntf EYFZf02pjuBCcy0uKFMIwH+JNmRRd/8IFmUfVf2h1EI2lzNnRByiPhO7HcFGw9ja/Bn5 XaRHWaM8XgP5rRuu5judfgC7ZoNTzsW3hOBolIJLrFlzKqeELZR1rSPn3obnAOx8kkwa C+ivjbR4BNXlEKo2+TmC3HLFNsmHMSkPMuhgZJxlwS6rNi1rX8Nh9KI/oHCFybeUKJxj cJwkQnbgAPtSb1BGuk28uT+x65O1zv/gAOtf96mb1fwx6Z/cRr/IHiZMmZ4O/SYW/C01 ZfWw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="IqPGoS/3"; 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 e7-20020adfef07000000b00346c08e5997si6496151wro.279.2024.04.23.22.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 22:04:17 -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="IqPGoS/3"; 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 1ABA688D9B; Wed, 24 Apr 2024 07:04:06 +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="IqPGoS/3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 674D288CD6; Wed, 24 Apr 2024 07:04:04 +0200 (CEST) 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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (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 6388688D97 for ; Wed, 24 Apr 2024 07:04:02 +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=ilias.apalodimas@linaro.org Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-41b086d6676so846645e9.1 for ; Tue, 23 Apr 2024 22:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713935042; x=1714539842; darn=lists.denx.de; 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=vbFHZkLIyTsnFbIYjd2AoiBzf3B0mbR9ncwmyQR2oNk=; b=IqPGoS/3Hy94pgmpXyZm715H10TsmxVWdjp/D2O1gkE2VKdcC5uu8RMIGXOpcTTLJ2 w80B/7vCaYu3t1kOJA3kVakKJS0nHIqC676THTumIhPZ6MIwAg4nenPJDXe9BSkgdDip HSIyHJP5bPpgvGSY+C4SoAqX90bRYzRZFTFukTXymggtvO8rF9oduuPmuSvWZ9uwQdta Z46ADTjPvfiiweVoQpIPXt/6qYUa/n9nvEKuPFSQjBfZL7naHqoxJSF3K0p9wMCembzA 7ZqO0CzULooucZCa2tCUnSXY6XXc8bb73vlkQh4VotafKbS9k2oYMyQy5eq4mSsln8+Q IIwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713935042; x=1714539842; 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=vbFHZkLIyTsnFbIYjd2AoiBzf3B0mbR9ncwmyQR2oNk=; b=U/VgHzVAUa5OsjQ2yq9RnniqLOvk1jlG5sD/cANsmzztH29FMQOYbMbUSDTI9s3LZI 7CKxZa+cYMrFo1g7My7ARq8iJY0M8rS8rIrj3iBxDzl3NjvWIVYG0ERmtIqiAPiCeneq aymWye9lfjKA0m/Smy9TWW7hSn3b2vcuq9fiSx82YWbSSykwx+ILaMMxPlzjUfAtykGu lzLfN/0Y+OYl1Ofl6Pwmm4qJaV1pOA3O52gnlE1JocYmzeWkgBsZSsRXf9yzZ+lIcEkn IA+qk9e0PKS21zZfN3LG/Vk+4sxL1Y+tkYrvltmv81GdQ1SghjrVwaGadKutWJ8PC1RE 4s6A== X-Gm-Message-State: AOJu0YzSvWv3XWv+H0E8cVpTHvUzNZVtRziONFRYS8zlOd6tmqshzleL QuoQnruFFGxtIVLELope6xa/JBDU+wg0d8ykcWonzTy7XUwot/ZgKfvPk+jFoOyG64Hb1U6mO1m r3/w= X-Received: by 2002:a05:600c:208:b0:41a:aad8:e393 with SMTP id 8-20020a05600c020800b0041aaad8e393mr902439wmi.30.1713935041889; Tue, 23 Apr 2024 22:04:01 -0700 (PDT) Received: from hades.. (ppp089210108048.access.hol.gr. [89.210.108.48]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b0041afe0f2f17sm861032wmb.16.2024.04.23.22.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 22:04:01 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de, xypron.glpk@gmx.de Cc: Ilias Apalodimas Subject: [PATCH 2/3] efi_selftest: add tests for QueryVariableInfo at runtime Date: Wed, 24 Apr 2024 08:03:50 +0300 Message-Id: <20240424050351.318724-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240424050351.318724-1-ilias.apalodimas@linaro.org> References: <20240424050351.318724-1-ilias.apalodimas@linaro.org> 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.8 at phobos.denx.de X-Virus-Status: Clean Since we support QueryVariableInfo at runtime now add the relevant tests. Since we want those to be reusable at bootime, add them in a separate file Add tests for - Test QueryVariableInfo returns EFI_SUCCESS - Test null pointers for the function arguments - Test invalid combination of attributes Signed-off-by: Ilias Apalodimas --- include/efi_selftest.h | 9 ++ lib/efi_selftest/Makefile | 1 + .../efi_selftest_variables_common.c | 102 ++++++++++++++++++ .../efi_selftest_variables_runtime.c | 10 +- 4 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 lib/efi_selftest/efi_selftest_variables_common.c diff --git a/include/efi_selftest.h b/include/efi_selftest.h index 5bcebb368287..ca7ae948663e 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -147,6 +147,15 @@ void *efi_st_get_config_table(const efi_guid_t *guid); */ u16 efi_st_get_key(void); +/** + * efi_st_query_variable_common - Common variable tests for boottime/runtime + * + * @runtime: Pointer to services table + * + * Return: EFI_ST_SUCCESS/FAILURE + */ +int efi_st_query_variable_common(struct efi_runtime_services *runtime); + /** * struct efi_unit_test - EFI unit test * diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index e4d75420bff6..414701893f65 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -45,6 +45,7 @@ efi_selftest_textinputex.o \ efi_selftest_textoutput.o \ efi_selftest_tpl.o \ efi_selftest_util.o \ +efi_selftest_variables_common.o \ efi_selftest_variables.o \ efi_selftest_variables_runtime.o \ efi_selftest_watchdog.o diff --git a/lib/efi_selftest/efi_selftest_variables_common.c b/lib/efi_selftest/efi_selftest_variables_common.c new file mode 100644 index 000000000000..36bdfe6ff9c3 --- /dev/null +++ b/lib/efi_selftest/efi_selftest_variables_common.c @@ -0,0 +1,102 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * efi_selftest_variables_runtime + * + * Copyright (c) 2024 Ilias Apalodimas + * + * This unit test checks common service across boottime/runtime + */ + +#include + +#define EFI_INVALID_ATTR BIT(30) + +int efi_st_query_variable_common(struct efi_runtime_services *runtime) +{ + efi_status_t ret; + u64 max_storage, rem_storage, max_size; + + ret = runtime->query_variable_info(EFI_VARIABLE_BOOTSERVICE_ACCESS, + &max_storage, &rem_storage, + &max_size); + if (ret != EFI_SUCCESS) { + efi_st_error("QueryVariableInfo failed\n"); + return EFI_ST_FAILURE; + } + + ret = runtime->query_variable_info(EFI_VARIABLE_BOOTSERVICE_ACCESS, + NULL, &rem_storage, + &max_size); + if (ret != EFI_INVALID_PARAMETER) { + efi_st_error("QueryVariableInfo failed\n"); + return EFI_ST_FAILURE; + } + + ret = runtime->query_variable_info(EFI_VARIABLE_BOOTSERVICE_ACCESS, + &max_storage, NULL, + &max_size); + if (ret != EFI_INVALID_PARAMETER) { + efi_st_error("QueryVariableInfo failed\n"); + return EFI_ST_FAILURE; + } + + ret = runtime->query_variable_info(EFI_VARIABLE_BOOTSERVICE_ACCESS, + &max_storage, &rem_storage, + NULL); + if (ret != EFI_INVALID_PARAMETER) { + efi_st_error("QueryVariableInfo failed\n"); + return EFI_ST_FAILURE; + } + + ret = runtime->query_variable_info(0, &max_storage, &rem_storage, + &max_size); + if (ret != EFI_INVALID_PARAMETER) { + efi_st_error("QueryVariableInfo failed\n"); + return EFI_ST_FAILURE; + } + + ret = runtime->query_variable_info(EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | + EFI_VARIABLE_NON_VOLATILE, + &max_storage, &rem_storage, + &max_size); + if (ret != EFI_UNSUPPORTED) { + efi_st_error("QueryVariableInfo failed\n"); + return EFI_ST_FAILURE; + } + + /* Use an attribute bit not described in the EFI spec */ + ret = runtime->query_variable_info(EFI_INVALID_ATTR, &max_storage, + &rem_storage, &max_size); + if (ret != EFI_UNSUPPORTED) { + efi_st_error("QueryVariableInfo failed\n"); + return EFI_ST_FAILURE; + } + + ret = runtime->query_variable_info(EFI_VARIABLE_RUNTIME_ACCESS, &max_storage, &rem_storage, + &max_size); + if (ret != EFI_INVALID_PARAMETER) { + efi_st_error("QueryVariableInfo failed\n"); + return EFI_ST_FAILURE; + } + + ret = runtime->query_variable_info(EFI_VARIABLE_NON_VOLATILE, &max_storage, &rem_storage, + &max_size); + if (ret != EFI_INVALID_PARAMETER) { + efi_st_error("QueryVariableInfo failed\n"); + return EFI_ST_FAILURE; + } + + /* + * Use a mix existing/non-existing attribute bits from the + * UEFI spec + */ + ret = runtime->query_variable_info(EFI_INVALID_ATTR | EFI_VARIABLE_NON_VOLATILE, + &max_storage, &rem_storage, + &max_size); + if (ret != EFI_INVALID_PARAMETER) { + efi_st_error("QueryVariableInfo failed\n"); + return EFI_ST_FAILURE; + } + + return EFI_ST_SUCCESS; +} diff --git a/lib/efi_selftest/efi_selftest_variables_runtime.c b/lib/efi_selftest/efi_selftest_variables_runtime.c index 5794a7b2d405..6cb86771fe78 100644 --- a/lib/efi_selftest/efi_selftest_variables_runtime.c +++ b/lib/efi_selftest/efi_selftest_variables_runtime.c @@ -55,18 +55,20 @@ static int execute(void) u16 varname[EFI_ST_MAX_VARNAME_SIZE]; efi_guid_t guid; u64 max_storage, rem_storage, max_size; + int test_ret; memset(v2, 0x1, sizeof(v2)); - ret = runtime->query_variable_info(EFI_VARIABLE_BOOTSERVICE_ACCESS, - &max_storage, &rem_storage, - &max_size); if (IS_ENABLED(CONFIG_EFI_VARIABLE_FILE_STORE)) { - if (ret != EFI_SUCCESS) { + test_ret = efi_st_query_variable_common(runtime); + if (test_ret != EFI_ST_SUCCESS) { efi_st_error("QueryVariableInfo failed\n"); return EFI_ST_FAILURE; } } else { + ret = runtime->query_variable_info(EFI_VARIABLE_BOOTSERVICE_ACCESS, + &max_storage, &rem_storage, + &max_size); if (ret != EFI_UNSUPPORTED) { efi_st_error("QueryVariableInfo failed\n"); return EFI_ST_FAILURE; From patchwork Wed Apr 24 05:03:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 791497 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp650910wrq; Tue, 23 Apr 2024 22:04:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVWw5fXu2jnbHXeLNwp3Jir5X15d6g9TDu3uYTicr1sef15QGyo0yRm6NNIuoukjGfB/O64jZA+ypzsHW+MNy1d X-Google-Smtp-Source: AGHT+IFsJjEGf6QSG4yOzGhwlRK0WSCQVpEQUUsV9oip4/qGhqK52rHTsRnE/aka3wJQTzZP5CXC X-Received: by 2002:a5d:64ad:0:b0:33e:d865:41f with SMTP id m13-20020a5d64ad000000b0033ed865041fmr930376wrp.35.1713935068246; Tue, 23 Apr 2024 22:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713935068; cv=none; d=google.com; s=arc-20160816; b=bpeWQqY6QFNL9gG5lxFhRjNUhx9Fku1Pc+4oSTHh234Wv63+NUVK7KJ3+WmP8Ka0XU 1WkqSIxYrn7UCWAQGXJRPcyWraVSdH2LbdUfYnaB9vBn8lzuN+MNd0605Yp/y1QUQaNj /IC8Kpvq6HEOBK8U157jxREL+YcbTD5w93mNkyIECrlvO8QEI0ZJ7n6X+FrTOaSGbdJp oGXY36IF/uUtBOx1YpYOY9NcFQ6/9cMbq30xC4tpBPC4U1uildcxqfkWXNBFwbonDyeU uGwJKZ9QwaaYZO50f7uDmwtPJ8JvjY4EHtzWTjFF36OQOWlYzzfahgNwpUU3eUWLeE10 pn+Q== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=juxT4SQiTHHzad/I6QIeWGWaFJiZ0GQIxFhJo9JKBcQ=; fh=r3T11POMt03ClPHECNN1R+djuGoIWWuXsijjvIhWVa4=; b=qDZ6MCdXdTavyV+OkNJmFUfCSvBaz9dF0IroMyXGrh8GYJDex1pIABUUH4gxYP0orO bc/23adh6AFIchqAH+SGhI7b2xqseYlWi/IcXVe/ieDUmMwoeSJ0zbCOBEj8Bv94INXy QrYe/OgxoGec3bf3s1HgWy1iht0a6sLe9ucJjT4Qw80LqscMyC0EMN7WaeL8mj3wvF48 Ixan5DASMWxbXdwE+D/AO0MbuCrDCuLVVb86vRtMVOQ2BJcKQYJ1WizF8mhY4j7MNvue OGCbMlIZPZpX5l5Ad2Sw8BszH6p1ErhLw66PvrsJrbr/4JhGohLZiKwMN+MwaMFKTi2J 9sXg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G8j4e4Ry; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id fj6-20020a05600c0c8600b0041ac5708e32si1341872wmb.68.2024.04.23.22.04.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 22:04:28 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G8j4e4Ry; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 7951488DA2; Wed, 24 Apr 2024 07:04:08 +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="G8j4e4Ry"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 74FF088D9D; Wed, 24 Apr 2024 07:04:05 +0200 (CEST) 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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) (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 358D288D9A for ; Wed, 24 Apr 2024 07:04:03 +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=ilias.apalodimas@linaro.org Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-418e4cd2196so49003005e9.1 for ; Tue, 23 Apr 2024 22:04:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713935042; x=1714539842; darn=lists.denx.de; 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=juxT4SQiTHHzad/I6QIeWGWaFJiZ0GQIxFhJo9JKBcQ=; b=G8j4e4Ry7CddV2e0HEitC2wCU8OnLgC2AF69Az0qsiGCZIT847NTOIMON7cGvcBLwg HPFn5vQnIvNRmWmW+mzECw3Ex/PeKocIHCPIEZwBQmEZWaBa8Aqw0St+m+K87gyhrNUN KRHiF9Wbi7f1eIU2asI4ZZNc3v9B8fGcA0eUttUTcuQTVl+QalM8dtKfMtLiPn1Sn+Se UJADv0DLLuFmSJo8XLI2eKMUauK4iaC5dDynx6iYDQjy0JUmptkUFtY3vqiBjjULmz/s uAgACVnviahPQA59VX4JRqNf4Xe9LjaNu0Uk8Hirhl4ttVq3omx1rUIdRfNMhNu+D1Wr X4YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713935042; x=1714539842; 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=juxT4SQiTHHzad/I6QIeWGWaFJiZ0GQIxFhJo9JKBcQ=; b=S8onHLW/gTN9slUm+Q9h0zV1i1snwzFkZ5rFlwjBmiIEHCgiCqyAd7B4+wZ0IXelkX K7aho+BkSMSFvlyD46oJhgm5j/ERDoOngTZQSnYdniwnttkMLp/PVYAY/GfGov2m6EJY pLZnQAjVtmwZg+mBwdRk0ZLU1cAjIQ1POLsWbxXoO8d2GxEI3rzjeJoGbYD9OSegy4Ye /pSFwZnjMMFvivKGMIyQB/gW9gmzLGAzsuEVSaPpKau3wW6ty7AjUGyxpZjjATAVdJt0 AhlNO3pDLzR1SzOqk5l8CHsOEUUq7MV7XeAF4J5/y7trBleA6LdrRCne9d35YvajQ+Wq IQ5Q== X-Gm-Message-State: AOJu0Yx3jHs1g9j/hWsWUFRnUPAJXv3D3/dKoerXL0mcInpWl/MXEUCK vN358yw0FYy6dtynJZji1cjirGhQDJqH7+btQUTM6YADDeo6ChhUVEIWycWBowGf+ydLpYNLAp+ mI28= X-Received: by 2002:a05:600c:190b:b0:41a:a5ff:ea3a with SMTP id j11-20020a05600c190b00b0041aa5ffea3amr950446wmq.19.1713935042777; Tue, 23 Apr 2024 22:04:02 -0700 (PDT) Received: from hades.. (ppp089210108048.access.hol.gr. [89.210.108.48]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b0041afe0f2f17sm861032wmb.16.2024.04.23.22.04.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 22:04:02 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de, xypron.glpk@gmx.de Cc: Ilias Apalodimas Subject: [PATCH 3/3] efi_selftest: add tests for QueryVariableInfo at boottime Date: Wed, 24 Apr 2024 08:03:51 +0300 Message-Id: <20240424050351.318724-3-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240424050351.318724-1-ilias.apalodimas@linaro.org> References: <20240424050351.318724-1-ilias.apalodimas@linaro.org> 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.8 at phobos.denx.de X-Virus-Status: Clean Previous patches added QueryVariableInfo at runtime tests and split a common function that can be used at boottime. Weire it up and run a similar set of tets. While at it move a test which is checiking for 0 available storage in the common code Add tests for - Test QueryVariableInfo returns EFI_SUCCESS - Test null pointers for the function arguments - Test invalid combination of attributes Signed-off-by: Ilias Apalodimas --- lib/efi_selftest/efi_selftest_variables.c | 11 ++++------- lib/efi_selftest/efi_selftest_variables_common.c | 3 +++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/efi_selftest/efi_selftest_variables.c b/lib/efi_selftest/efi_selftest_variables.c index 39ad03a090d4..3c55938be1ce 100644 --- a/lib/efi_selftest/efi_selftest_variables.c +++ b/lib/efi_selftest/efi_selftest_variables.c @@ -52,14 +52,11 @@ static int execute(void) int flag; efi_guid_t guid; u64 max_storage, rem_storage, max_size; + int test_ret; - ret = runtime->query_variable_info(EFI_VARIABLE_BOOTSERVICE_ACCESS, - &max_storage, &rem_storage, - &max_size); - if (ret != EFI_SUCCESS) { - efi_st_todo("QueryVariableInfo failed\n"); - } else if (!max_storage || !rem_storage || !max_size) { - efi_st_error("QueryVariableInfo: wrong info\n"); + test_ret = efi_st_query_variable_common(runtime); + if (test_ret != EFI_ST_SUCCESS) { + efi_st_error("QueryVariableInfo failed\n"); return EFI_ST_FAILURE; } /* Set variable 0 */ diff --git a/lib/efi_selftest/efi_selftest_variables_common.c b/lib/efi_selftest/efi_selftest_variables_common.c index 36bdfe6ff9c3..435ccf4ac13a 100644 --- a/lib/efi_selftest/efi_selftest_variables_common.c +++ b/lib/efi_selftest/efi_selftest_variables_common.c @@ -22,6 +22,9 @@ int efi_st_query_variable_common(struct efi_runtime_services *runtime) if (ret != EFI_SUCCESS) { efi_st_error("QueryVariableInfo failed\n"); return EFI_ST_FAILURE; + } else if (!max_storage || !rem_storage || !max_size) { + efi_st_error("QueryVariableInfo: wrong info\n"); + return EFI_ST_FAILURE; } ret = runtime->query_variable_info(EFI_VARIABLE_BOOTSERVICE_ACCESS,