From patchwork Thu Apr 25 05:18:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 791986 Delivered-To: patch@linaro.org Received: by 2002:a05:6504:f10:b0:260:b6fd:90c with SMTP id en16csp1122727ltb; Wed, 24 Apr 2024 22:18:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUDnfuYBiUFU65DLk0RQ7S8U+591lS77q810TIoUnhlAAEwDxZP0gCIK+tnHlSZ6fV9sDyTtUfvzDOPDPW437tO X-Google-Smtp-Source: AGHT+IFfzrECoCdPjpuNWzSFg1+G/U+Nr7o7uLnm+av0I2itVvZcJ/1NS+LDm9gs0yGHry0xLYVz X-Received: by 2002:a5d:574a:0:b0:34a:e73a:56a3 with SMTP id q10-20020a5d574a000000b0034ae73a56a3mr2812773wrw.7.1714022335285; Wed, 24 Apr 2024 22:18:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714022335; cv=none; d=google.com; s=arc-20160816; b=oQRe5RmY1eYBX9nV+kFVqpEfXHP0MqSJJCG8b7haHWgnMVC1hzXyr27czAp4sWK6VU n1E0nL3ImAiHhovOT1AP7Yrss5bgYuyaQ0hgOHKGcPGLW/1/mzoTg5yYpt1byQ+0BUST 6mr3E/MUmTqZFk6MOiJ6ev71tAZhseCsZJ9WbdIW/CkxI2/ypQK1u+Jnpf+P4husXW+P Q2q1RW4VpL9hYZYnyTO5fBm9iS9FkvScGZgKUJtxsmLkZE77dvmT7lY+5PFpxog+JmoQ hH0dCCGkHtFl502DIfwkg6hwTJRbsRg9TdeKybsQBn+6pFM5YZhwhdzfG5V2cz2BiQJp B90w== 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=sZU5v0XKzUA+H+HmJwzMhgvN+Sc3gtgzBc0ugAZWcqY=; fh=r3T11POMt03ClPHECNN1R+djuGoIWWuXsijjvIhWVa4=; b=fLQQjXMz5U0JvaeLry52vo0bEwr6JMQViFS0sAlLY/hd7cBtCLo/Ho+ZOYekIhB+JY agRwBTIJJfOFUHNk9sCje8VVbFq6CSO9ji+VA6gJdlizB6jBuZomgT714D62eCkozxYx KKu2gBPDG9W9uQITKVTVoWkJa1wCGL3kAXKM1UW7BJoC+saMHI9S/ORdsE6pZEtdW9TB h8W1ef5GHPFddH6EdoFiGAmFHUcPjPO7AmydBfU3uIEO55KE4g/ZbOvdjJ+j7M11hLc2 dJbFSJhzfznIaCXwFZcjd6P1gqkJ9x5S3PtR0lsJVMQxK++QN6cQiXAWl7mbHDFGLldm Ubrw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tBg4HhbD; 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 d14-20020a5d644e000000b0033dc3ced58fsi8026900wrw.549.2024.04.24.22.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 22:18:55 -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=tBg4HhbD; 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 C8F4888EB1; Thu, 25 Apr 2024 07:18:30 +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="tBg4HhbD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C874F88EC1; Thu, 25 Apr 2024 07:18:29 +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-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) (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 9D7FF88E72 for ; Thu, 25 Apr 2024 07:18:27 +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-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-56e1baf0380so590997a12.3 for ; Wed, 24 Apr 2024 22:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714022307; x=1714627107; 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=sZU5v0XKzUA+H+HmJwzMhgvN+Sc3gtgzBc0ugAZWcqY=; b=tBg4HhbDWCGgl6a3P8Bs+jDJO61bUgc9Q4jiuonlAy93H5qF+5VMMx3iuyn8VtPTSn bO6QEzlh96OBsNyatiENmDzLS9WjWMHzk8pkKJL1PTe4TJshZ7/0//LB07F3dv5xI2Cf YxW/PaC1UTL6YePuRgEioX1fGJ8dIJVKMazddbVW0IRk+qQM9+MmZYtZAR0eOZrg4ueV LlXp/DGPjl9BNGz9xB+sIKszucACjY6aY66vhkPzv+fGgnvE+Xvcks1QI8BbEApvdlpW QNpfGyRVQLVx/e3MZJK99ADxcoQpSeYbMOtTRESAAyXngd0t+0fv7rSR6NELi78sgcY/ iitQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714022307; x=1714627107; 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=sZU5v0XKzUA+H+HmJwzMhgvN+Sc3gtgzBc0ugAZWcqY=; b=eiKgD4uV8Mvtb5vl20MHmo15xvnk9B2KjHSbFOWWReuIiyC9EBQnvzjA6bbdbrS4xh VuCmKBSz4fIZqjMG+K7y5MxwfDHoiacD4SWYQmMzuW3df+vP/JCzBL1dGVKqQNrp+HOV 1NEpmfcqe+w6lBeTPgFIMRjB6uKUScoYBEWJ8bch2YQEf/+7hGkEC+6f9aWz3ixUhEfm rOffY9oibMjia3favxBkw3J5GUmuUEzT9cAOuSd45LtvPNf/hDzft7lf4XwBiixbbvmH mmMTWamyM7zbkGX2U0e59afmBkH1HKMjn3AuG8evrU0rhdbkKQYv1n4bRDcLk9QQD5Dc YzXQ== X-Gm-Message-State: AOJu0Yx1L6uIU19ax/+LXLBFi6DtmNXIRpJw1LO2QTUVgfWV3nUTvycH TWxCF6wFOnP9GFMsmreWSjQ81iuwWBOyAw4ZuaJHO04kBuB0g2lBcYtboO+FTKH9gNOs0lpmB4w N280= X-Received: by 2002:a50:d607:0:b0:56e:32fb:bc7 with SMTP id x7-20020a50d607000000b0056e32fb0bc7mr2798318edi.36.1714022306906; Wed, 24 Apr 2024 22:18:26 -0700 (PDT) Received: from hades.. (ppp089210108048.access.hol.gr. [89.210.108.48]) by smtp.gmail.com with ESMTPSA id l6-20020aa7d946000000b005723151e99asm1410826eds.95.2024.04.24.22.18.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 22:18:26 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de, xypron.glpk@gmx.de Cc: Ilias Apalodimas Subject: [PATCH v2 1/3] efi_loader: enable QueryVariableInfo at runtime for file backed variables Date: Thu, 25 Apr 2024 08:18:19 +0300 Message-Id: <20240425051821.338842-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 --- Changes since v1: - require EFI_VARIABLE_RUNTIME_ACCESS to be set at runtime - return EFI_UNSUPPORTED for auth variables lib/efi_loader/efi_runtime.c | 4 +++ lib/efi_loader/efi_var_common.c | 6 ----- lib/efi_loader/efi_variable.c | 25 ++++++++++++++----- lib/efi_loader/efi_variable_tee.c | 5 ++++ .../efi_selftest_variables_runtime.c | 14 ++++++++--- 5 files changed, 39 insertions(+), 15 deletions(-) -- 2.40.1 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..1cc02acb3b26 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,17 @@ static efi_status_t __efi_runtime EFIAPI efi_query_variable_info_runtime( u64 *remaining_variable_storage_size, u64 *maximum_variable_size) { - return EFI_UNSUPPORTED; + if (!(attributes & EFI_VARIABLE_RUNTIME_ACCESS)) + return EFI_INVALID_PARAMETER; + if ((attributes & (EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | + EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | + EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS))) + 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 Thu Apr 25 05:18:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 791988 Delivered-To: patch@linaro.org Received: by 2002:a05:6504:f10:b0:260:b6fd:90c with SMTP id en16csp1122842ltb; Wed, 24 Apr 2024 22:19:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVB500HF59N6oJwsR0vPBOpYahsU5cueYQPcj6CTlDSd+8xq3SgW8Y4/qLrrtY2DDiNHEDgfeodgIzD1WdvI4z4 X-Google-Smtp-Source: AGHT+IFmfaDw/B/VC6FFkwoH3uCxxzgPhyORwcEMgc2AWJlzM3uzbtFvC8wYoVX52/fmTc5GGkz0 X-Received: by 2002:a05:600c:4685:b0:41a:adc3:f777 with SMTP id p5-20020a05600c468500b0041aadc3f777mr4061824wmo.16.1714022356754; Wed, 24 Apr 2024 22:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714022356; cv=none; d=google.com; s=arc-20160816; b=lXMRobZFeinIUum7NYK2+RqJ18dlAJWIVcGCCZ51Wew+hU1U8evdeYAJ208LXt6JIK rJGtj9amVOaD3hOlDrWCQu0eYqtcZhN6U3AjWIG/s9ycJZUzsVhpVWh+mvb8HHrZ07aK /gBdJM1allf0qHbGrWsR0ssA4NLNrka4EbAhP3aGhHRwdrO7IqdDvwV+dPsdVeSvtrMK dx5D/QUVnDOLZ+WrxNbOUSPOqyRQCDQ2X4quXsFyOBa2GpMAAY5BAEMyz5oGF9DHYgEz +yH8mm1cdz41rbFo4uCY2AoVCtuEhhFXjcP7ZypRlna1Nu8AFMO8mOz6iVw/QaNd6hUt lcPQ== 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=IuaPUZBqRAr7s509m9cf3KVgbgvPME4rCHMJnN4ptzw=; fh=r3T11POMt03ClPHECNN1R+djuGoIWWuXsijjvIhWVa4=; b=XO+fc/GTGq7hMLKi/a0uSEboLw2TpMd48PVmIJrIsgJaHATL9OERksUgbD1LMo2ZYi K4HfsugC5rCiw7wipp3mpAHfzh0PsQjK4m2AH+Sh5SjluCVPNjP1K0r6WRITRMXqXUV+ fu9bNZ1Oj6sXRcuJIn1iMEEojIrdNFGwTzyZMLwvQ9kaJ3IU8j8n2bx/q5Dq3hUFTlKr systqLWSAFhY/rFdNDIGSlTyF/uW/Zc1IgiBSNYPXP0Y2gewrmGfeX+W6t+Jzx7vRO+p XkJD48R3JweVJRUHjt1pga9+Pz4en8nN4JHjg/uqzl4r/z2xdEyvPNoPE/cjxy32oHnd Zg6w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KGFF65XJ; 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 l3-20020a05600c4f0300b0041a1186921esi5229949wmq.195.2024.04.24.22.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 22:19:16 -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=KGFF65XJ; 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 CFCDC88EEC; Thu, 25 Apr 2024 07:18:34 +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="KGFF65XJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CF73788EBD; Thu, 25 Apr 2024 07:18:31 +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-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) (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 892E488EB5 for ; Thu, 25 Apr 2024 07:18:28 +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-lj1-x229.google.com with SMTP id 38308e7fff4ca-2dd6a7ae2dcso7377391fa.1 for ; Wed, 24 Apr 2024 22:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714022308; x=1714627108; 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=IuaPUZBqRAr7s509m9cf3KVgbgvPME4rCHMJnN4ptzw=; b=KGFF65XJIHviga5ujb93zaDTX7UbvUP08S0JRs2aXu2rNzwczE8UQchqL+vhbsyWmV H8eu+V8pZUJ2/fJaCwqY0ETNGcLRpLpaEtpo+SHHkK3KK/Ovtak05FJ2CmkO2bDMW9bi SmrfRA4UWCxlH5pk+1vQ9rYX+EAjpyyMNlE1yB0ETACwsZ9IsWZzteoC8Y9FbX60ypdp KF0iB+AWfnv25q13Ky8Obc0/bJ6bCgCpi71B5NBUJ9uZwKDGLHL6cj4o5Ltf61T/wn8R Ee69ZHbqgiWUpZc8a7Dh+2lY7LNIdRHZG6q6WXxMTPf+wY4vftFbdXh4tOZVvyBhL2JP UqJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714022308; x=1714627108; 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=IuaPUZBqRAr7s509m9cf3KVgbgvPME4rCHMJnN4ptzw=; b=TABITWMXi42nxG8OQtR8CKm3PwHQweeWf+9lSrbt+7uVFVvPbzWF4gv2KKDuIkaDQc nAN94hoHruad8ez4FIF9bNC2ZKPOvbqB5wuaOgz/GmIX3wp6RadbHVOY3XuYMfBGoePk dK14UYAjt57Ra5MfzxENNtbvY0ZAALlCMOxFpWq74AD1rlQjoEDnhq4O/Ka1WVM3+dJi nTM3iIBwektIrRe0w3hcPb/p1l0r7OQgjQaSHvpgqOxkpbqDl7mi4u4lyGJarojf4qBu jp9NeinnmoGBuyA15hSIr/A8wltDfWUyRDTZHALxep82/NTHkb/4GXDHNPLUGPpgRkry gNQw== X-Gm-Message-State: AOJu0YwCgJbxv/Dscj04Piu5FnkD9RXgbQJeFocwVmB7N2/SrYyDt3+N XQW1iOG/A6IkMQnqAa7ZKpWr7ljE1qMmNRKeTN5OI8tH+AU1uB63dKu698l47tTqhHPpo5uorfq WJIE= X-Received: by 2002:a2e:b947:0:b0:2d8:5af9:90c5 with SMTP id 7-20020a2eb947000000b002d85af990c5mr3400576ljs.39.1714022307775; Wed, 24 Apr 2024 22:18:27 -0700 (PDT) Received: from hades.. (ppp089210108048.access.hol.gr. [89.210.108.48]) by smtp.gmail.com with ESMTPSA id l6-20020aa7d946000000b005723151e99asm1410826eds.95.2024.04.24.22.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 22:18:27 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de, xypron.glpk@gmx.de Cc: Ilias Apalodimas Subject: [PATCH v2 2/3] efi_selftest: add tests for QueryVariableInfo at runtime Date: Thu, 25 Apr 2024 08:18:20 +0300 Message-Id: <20240425051821.338842-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240425051821.338842-1-ilias.apalodimas@linaro.org> References: <20240425051821.338842-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 --- Changes since v1: - Pass the attributers as well in efi_st_query_variable_common() and check for runtime/boottime include/efi_selftest.h | 11 +++ lib/efi_selftest/Makefile | 1 + .../efi_selftest_variables_common.c | 99 +++++++++++++++++++ .../efi_selftest_variables_runtime.c | 11 ++- 4 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 lib/efi_selftest/efi_selftest_variables_common.c -- 2.40.1 diff --git a/include/efi_selftest.h b/include/efi_selftest.h index 5bcebb368287..1b708849bcb9 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -147,6 +147,17 @@ 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 + * @attributes: Attributes used + * + * Return: EFI_ST_SUCCESS/FAILURE + */ +int efi_st_query_variable_common(struct efi_runtime_services *runtime, + u32 attributes); + /** * 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..e29a4be74a57 --- /dev/null +++ b/lib/efi_selftest/efi_selftest_variables_common.c @@ -0,0 +1,99 @@ +// 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, + u32 attributes) +{ + efi_status_t ret; + u64 max_storage, rem_storage, max_size; + + ret = runtime->query_variable_info(attributes, + &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_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(attributes, + 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(attributes, + &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(attributes, + &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(attributes | + 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; + } + + 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(attributes | 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..379c4f9c47b7 100644 --- a/lib/efi_selftest/efi_selftest_variables_runtime.c +++ b/lib/efi_selftest/efi_selftest_variables_runtime.c @@ -55,18 +55,21 @@ 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, EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS); + 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 Thu Apr 25 05:18:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 791987 Delivered-To: patch@linaro.org Received: by 2002:a05:6504:f10:b0:260:b6fd:90c with SMTP id en16csp1122784ltb; Wed, 24 Apr 2024 22:19:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXqypNIHOtNUfhsGPgJljghjtASRUhRT2Th21DTuw0ADOR+VNtgYViipD2cBoxLc3tmJKaNxkfITg2JYXL0cSCE X-Google-Smtp-Source: AGHT+IH2/dS7D8blZHpeXYRqimy8YNAbyuGKbb/nebay2mo50XjK6Oc74+3c74m2YaZR3Z9PVG+z X-Received: by 2002:a05:600c:1c16:b0:416:2a95:6e8b with SMTP id j22-20020a05600c1c1600b004162a956e8bmr3437447wms.26.1714022345201; Wed, 24 Apr 2024 22:19:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714022345; cv=none; d=google.com; s=arc-20160816; b=Yv8eGSctS+AXSIn+i0VWzjA0owphco0KrO58Y2RO73eU8k1WgkyidtmsMnylWUmbQ/ lmqb3HQ0e/M1g80ina8ejJeKXRdduN0aShbSA6TMLX2zEBxpLS0SrQw/8tNFFnrDMOpz YuRr5KGeaDyYhap8+ydM/uwvthKSL96m8Og7fAqKL3UbPyyjWD4Xf49Vh6ZyusjNhXuK ybRKbXCVqw9GG2ILFk5RL2t1K12YhtMdXpVp2Wn0BESfzLPICUGxzAezDU2zJCAIPKnr j+jH+9BDjmhI2YW8bmIouZYoduThAQDNYsozLT8gAH/kjAO3smXKoaWfcYugD84h3tDs U8GQ== 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=M9njVlxY+URj7SM1dSXGi3VJmiRfl04AVj95UvDee6Y=; fh=r3T11POMt03ClPHECNN1R+djuGoIWWuXsijjvIhWVa4=; b=Vm0zexodA+ptHCaKVjkdxuh2avV3fPbMxktPBRrbQe6L+T9VRE8QJWXQkDkbuXyPZR gXf+Px3o3BN3UhXunqQMvSYz/yaiVNZMg/3YQC/+PcwGD0PbM5OiTTklWcCpJWDg7REA 6Tj3o3I2w2iDK2+BVazw+Lo0rnENKrxbG8Me2tpO6B8u8wXkokiFuV72GY7JOziDId7a k22R7vGTQplAypTeAyvBCTQjR4o79IwpV4grz6whipagMhuBIOmbr19HOMTMfAKuFwY4 iYEUoZqYQB+zEmWWDwnb4fYP//oPFjR5pTUJWeOSKGF5R3RYRlHUTwg5WeYfJ6TQlDBj JVbw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EWWzKgeS; 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 o20-20020a05600c4fd400b004181e007dcfsi8395433wmq.234.2024.04.24.22.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 22:19: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=EWWzKgeS; 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 3AF9D88EBC; Thu, 25 Apr 2024 07:18:33 +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="EWWzKgeS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 10ACB88EBD; Thu, 25 Apr 2024 07:18:31 +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-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) (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 1D1AF88EBD for ; Thu, 25 Apr 2024 07:18:29 +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-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-56e6acb39d4so599907a12.1 for ; Wed, 24 Apr 2024 22:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714022308; x=1714627108; 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=M9njVlxY+URj7SM1dSXGi3VJmiRfl04AVj95UvDee6Y=; b=EWWzKgeSsY+dHMoaNYhEW1Bl/B+n61PKEJBR9I7AS2wkMmnqIHBey3psIrSGFvzmq7 fwk3s0wvzNj8qJOb6PkgihWZ/55SQ0vRSQ9z0l2e22RN1VeE4gKpeAQxAv80vfiL/DfA lXv93+Sdk3zZiO/3VOi2Gx+4OQ/sgS1C/TAVh9pQNzax0AyQ5bQC3pwFE0uYUF8aJ+ef ELgy8RqMvUenRXJDsyUxbTSEgTw/yh9Lh3Rq8ThVSgSl03KHQTsiXKEv8Ld20RV5VO9V 2Y1qrGQdVFsBClztudFd+L5MjT3HCTk8U9XbL2Q5iQGLSIHOckbV9OhS4WEP10cLErSz vwkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714022308; x=1714627108; 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=M9njVlxY+URj7SM1dSXGi3VJmiRfl04AVj95UvDee6Y=; b=VkDUcwIgcvo8LpAstXSuUWLsq5XqWdKzc3hP+iuIfCJa/l+OO4NZdW8qg/W46JAyl4 VC308AobdAkqWzSkrS6//cLCqHc3664KNK2Oh68ucIRZXtTZgfsiT7SCXhV2yyVW7XU+ pAS15tNFA5ZROo6vNzsUpIlYBtFkVexo3sMNocEpumraUUrVbNljDdpMfxmLmNMW2jbr T0dykSU0Wj9xSJ13Yrk7N7vDyZN4p20G+wvF2eUSHtUWZNgmUV4Hq8JCr3UKbMAqXjAM xGyeCGHlgnywicg0P2qeHus0dWv/iTAzsV0VAqsKbijYEej6ZJMiCn3pVuJrec6SEwul 3Uyg== X-Gm-Message-State: AOJu0YxrKrxHY0vT5ACUITBRC6vZ0a6UBkqrnb9xgQ2xGrS2UY9g4n2B mvoXZpTOfbnHKoMzqXL8ecPqvc6K+DlC3d88pIv5pJdR9WfyuwAod6dtogPR3/0HuLYmRSu2LyD VnNM= X-Received: by 2002:a50:ab49:0:b0:56e:2cbc:db77 with SMTP id t9-20020a50ab49000000b0056e2cbcdb77mr3072283edc.33.1714022308703; Wed, 24 Apr 2024 22:18:28 -0700 (PDT) Received: from hades.. (ppp089210108048.access.hol.gr. [89.210.108.48]) by smtp.gmail.com with ESMTPSA id l6-20020aa7d946000000b005723151e99asm1410826eds.95.2024.04.24.22.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 22:18:28 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de, xypron.glpk@gmx.de Cc: Ilias Apalodimas Subject: [PATCH v2 3/3] efi_selftest: add tests for QueryVariableInfo at boottime Date: Thu, 25 Apr 2024 08:18:21 +0300 Message-Id: <20240425051821.338842-3-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240425051821.338842-1-ilias.apalodimas@linaro.org> References: <20240425051821.338842-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 --- Changes since v1: - efi_st_query_variable_common() called with EFI_VARIABLE_BOOTSERVICE_ACCESS only lib/efi_selftest/efi_selftest_variables.c | 13 +++++-------- lib/efi_selftest/efi_selftest_variables_common.c | 3 +++ 2 files changed, 8 insertions(+), 8 deletions(-) -- 2.40.1 diff --git a/lib/efi_selftest/efi_selftest_variables.c b/lib/efi_selftest/efi_selftest_variables.c index 39ad03a090d4..3d5f38c68978 100644 --- a/lib/efi_selftest/efi_selftest_variables.c +++ b/lib/efi_selftest/efi_selftest_variables.c @@ -51,15 +51,12 @@ static int execute(void) u16 varname[EFI_ST_MAX_VARNAME_SIZE]; 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, + EFI_VARIABLE_BOOTSERVICE_ACCESS); + 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 e29a4be74a57..453bc8709a6f 100644 --- a/lib/efi_selftest/efi_selftest_variables_common.c +++ b/lib/efi_selftest/efi_selftest_variables_common.c @@ -23,6 +23,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_RUNTIME_ACCESS,