From patchwork Thu Apr 18 12:54: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: 789777 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp545671wrm; Thu, 18 Apr 2024 05:55:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWTbauhjSKvHKj+hx2+Gn6WWBV50lo+O9yFiqhXL6nVCO2YiVW/PQrPqDe2IstbZvhPCCCkVlrpHyrUjH/NGJue X-Google-Smtp-Source: AGHT+IGiejduMYVchoAP1niJJOFyTNr0BZYY3po6/nwtxDqq53inEqjdm4ph8IWgECOVp1pZhmaI X-Received: by 2002:a17:906:15c9:b0:a52:1086:5c7e with SMTP id l9-20020a17090615c900b00a5210865c7emr1628638ejd.24.1713444905832; Thu, 18 Apr 2024 05:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713444905; cv=none; d=google.com; s=arc-20160816; b=IAKrwLXLJv9Osdjkm7RpDsGU5LgqFL4+RvQpvXIuML05MCX1I7XDxvFmLXrsK85FAc EddLNotfQQwk9zTL5LEtZ0zgQXGtx5rgQpJgdhxxgQOIn2tTTXwP7ZvD4Coe331rY5Vf iNa2Upx6BIyv2LB1ZtkdzS7bxgorpBh4Xz100Br7kwGuCSBj4ilfj267/OCWBzJaAnE7 sOt/vD2sME4Yni8qSdrMbICBo+tArnTCGaUfCsMc8OaKbmaVCEuvyOS5rkYWsjMplCMC Vd8QEXxKO2K8jiAs+FFV6oPem6SLmgZwV/Z+Wjjwr5dZkx1ekDSzXjd908KtvrmoO2Bh Cplg== 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=/i5Gmnyf6MEJMGR4G17Ai/gv4bXGzU/rZcS3d6SytfQ=; fh=jUb1+8jIi+5uf8M1H3+j30HMOxoOL1fKFdyQdy974LE=; b=k7LLSPEnNU8q3zPyqo5qeE4mxcbJsne8/8RXLN5vDAQSsuB1yVvGLj1cGh/ABxI1Ll B+bui6fuw9r0Z/sS2pubWQ7N2kuYqRSJ/s5NEX79bpq0SIMPUdzv+itwdKdnsPQ7Gjxr z2V+x2jxx73+cb4iOlgGUcsFBr0jRgZ++0U2N69DOBUN1aAPhmz1B/StkzpFHy8mdor6 dEwWdoNC34NuPW02oikPyzu26yf/uze555+LNbunjVzIu3Ts4KNnwakfLEEv2ahvCOvE Jl2/x3JvHl1itef5MbW78hTn27fnNKpfRkiTBltBptCn4ILF/PY+ls2fnI7nJqImsCXJ jKKQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BHEfaUgV; 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 s23-20020a1709066c9700b00a3e3776fd57si871931ejr.28.2024.04.18.05.55.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 05:55:05 -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=BHEfaUgV; 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 1ED7A88553; Thu, 18 Apr 2024 14:55:05 +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="BHEfaUgV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0B7D58831A; Thu, 18 Apr 2024 14:55: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-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) (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 9EEFD88609 for ; Thu, 18 Apr 2024 14:55: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-ej1-x62b.google.com with SMTP id a640c23a62f3a-a5224dfa9adso153007666b.0 for ; Thu, 18 Apr 2024 05:55:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713444901; x=1714049701; 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=/i5Gmnyf6MEJMGR4G17Ai/gv4bXGzU/rZcS3d6SytfQ=; b=BHEfaUgVo2rvSxiMpGInvZJ65q18cOtoNJq0Cq0mgy/sLSOfptiBuEX5XFcTEJyBHR 4VcJREWVtJ5oJZmiA9KuVtOsCS5uMB2w9dyuIGNdMZi6X5y2FRmUpiXELyIdb1iJtGu8 5nie8rSJqZ6qEpZkZOv2jVDDFRHA4XOFsK+hB8HZJ5NlW5L/qhIuyCQBZQIDK7o8Kcfb pRCB7NU/M6f88Z03sMOMH/kgMbPcxW1CKx8Lq+qpjDN1nCQERkcCC2OQsnZM50O83J8o kF8BCwkxTgsQTAxh5xIgmi8zDunEk+sbq+dzoYGPWJz0aMxmpPmZ6QyvqvM1FWX+z6ot 2opA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713444901; x=1714049701; 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=/i5Gmnyf6MEJMGR4G17Ai/gv4bXGzU/rZcS3d6SytfQ=; b=sCYvdqkAtT5rWSRimqnD4D9JOVcfiLEmMHPGKO8FdLrSYCYn1HK2aiWW2fqNUOVobT YvaSCcEShPG7xTwPZgYYqEkOt6wSnd4sVUAiHF+PsgwMuI6cKazA8QmyY8OPpK/urwqe FZHxQ8z566h5Im+xk47LHN+epjVRWPtvBgZp7n/nXGiLUj7pv/e5t+BQvqnqitanZ/E5 /o/FlLWtv3218F16lBZsLFLW/3tqh3s/+ZqOga40O7hmz3tfdV/fAlLcUXyzvKcSlWRr 0pO63X0CN3AIWPSUsiPWawexRb78Ggs8kLRK9YPvUUhp9+sp51WvRLmPxvurMc6vtkMG TYEw== X-Forwarded-Encrypted: i=1; AJvYcCVrINKxEeZ+D5nzvs0Ng3PoEUE+efr9hlQLyoRY+8cSMqb6eSym1wcPQpJ1ZQV7i9rEoy/9dCmUWWYXuldVvxyfwSGGnw== X-Gm-Message-State: AOJu0YwbRVUkQEqaWcW/IzIYfGidHOgNh4s7cfGjb6r1CX2l2Eygq0Vr N5KITnJXNXis4cyx8ejvRc6gg+8ZZJ0kYwPCzRBZ5hSdIkgfIzL7dZnIQz4Ek68= X-Received: by 2002:a17:906:d8d7:b0:a55:75ff:ea12 with SMTP id re23-20020a170906d8d700b00a5575ffea12mr1153191ejb.4.1713444900999; Thu, 18 Apr 2024 05:55:00 -0700 (PDT) Received: from hades.. (ppp176092141112.access.hol.gr. [176.92.141.112]) by smtp.gmail.com with ESMTPSA id m11-20020a1709060d8b00b00a525a18f748sm847002eji.165.2024.04.18.05.54.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 05:55:00 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de, kettenis@openbsd.org Cc: caleb.connolly@linaro.org, sumit.garg@linaro.org, quic_llindhol@quicinc.com, ardb@kernel.org, pbrobinson@gmail.com, pjones@redhat.com, Ilias Apalodimas , Tom Rini , Masahisa Kojima , AKASHI Takahiro , Raymond Mao , Matthias Schiffer , Simon Glass , Janne Grunau , Abdellatif El Khlifi , Sughosh Ganu , Richard Henderson , Sam Edwards , Alper Nebi Yasak , Weizhao Ouyang , u-boot@lists.denx.de Subject: [PATCH v3 0/4] Date: Thu, 18 Apr 2024 15:54:49 +0300 Message-Id: <20240418125456.50944-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 Hi! This is v3 of SetVariable at runtime [0] Nothing changed drastically from v2. A few more test cases have been added, comments/suggestions have been addressed and a bug where deleting a variable by setting 'attributes' to 0 has been fixed. Changes since v2: - Add more selftests checking for variable deletion as well as the VarToFile header format - Use unaligned sized variables on tests - Add a new function to get the variable entry length instead of repurposing efi_var_mem_compare() - Converted VarToFile to RO - Added a few comments requested by Heinrich - Fixed a bug where SetVariable with attributes set to 0 did not delete the variable but returned EFI_INVALID_PARAMETER instead - Run FWTS 'uefitests' and attach the log in patch #1 - Added r-b tags from Heinrich Changes since v1: - Instead of Creating VarToFile at SetVariable, create it on GetVariable. This allows us to get rid of the preallocated RT buffer, since the address is user provided - convert Set/GetVariableRT -> Set/GetVariable at runtime - return EFI_INVALID_PARAM is NV is not set at runtime - Heinrich sent me the efi_var_collect_mem() variant Changes since the RFC: - Return EFI_INVALID_PARAM if attributes are not volatile - Add EFI_WRITE_PROTECTED checks for BS, RT *only* variables - Add 2 EFI variables and allow userspace to write the file - Add selftests I also have a patch enable QueryVariableInfo [1], but I don't want to introduce new patches now. This also needs a few more testcases of its own so I'll send it once we finalize this one. [0] https://lore.kernel.org/u-boot/20240417101928.119115-1-ilias.apalodimas@linaro.org/T/ [1] https://source.denx.de/u-boot/custodians/u-boot-tpm/-/commit/ce35270aaeb93686d7e013f3b028808e8af88cc0 Regards /Ilias Ilias Apalodimas (4): efi_loader: conditionally enable SetvariableRT efi_loader: Add OS notifications for SetVariable at runtime efi_loader: add an EFI variable with the file contents efi_selftest: add tests for setvariableRT include/efi_loader.h | 4 + include/efi_variable.h | 16 +- lib/charset.c | 2 +- lib/efi_loader/Kconfig | 16 ++ lib/efi_loader/efi_runtime.c | 42 ++++ lib/efi_loader/efi_var_common.c | 6 +- lib/efi_loader/efi_var_mem.c | 151 ++++++++----- lib/efi_loader/efi_variable.c | 122 ++++++++-- lib/efi_loader/efi_variable_tee.c | 5 - .../efi_selftest_variables_runtime.c | 211 +++++++++++++++++- 10 files changed, 495 insertions(+), 80 deletions(-) --- 2.40.1