From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mx.groups.io with SMTP id smtpd.web11.436.1599603444897334707 for ; Tue, 08 Sep 2020 15:17:25 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@corthon-com.20150623.gappssmtp.com header.s=20150623 header.b=wnSEcGdt; spf=none, err=permanent DNS error (domain: corthon.com, ip: 209.85.210.172, mailfrom: bret@corthon.com) Received: by mail-pf1-f172.google.com with SMTP id w7so350477pfi.4 for ; Tue, 08 Sep 2020 15:17:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corthon-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GwvPZ5iF3QSYMCUOygKsaeqOQtAtGURL4nCSsyGlDzI=; b=wnSEcGdttTouJcXs/gOzY23V/u+apXkFt3tPUlaIHOP+EEpBKaa2wZO3PHFFBKAVM0 m9c1ZHbIrhPjkdm7NfrvBA2gACcaxN4L1vbH9fFtDAAgO4wZtWIrdYm7oBzMUIWXJ4yf y0vT/mPQYjW2qQYmgoprO4ht4JqAu9poPM/+ODJrby1SufzwogTf1Dc5e+meIPZHZlz3 THsOavr0Xtk2i4v5sRo+piRoAZQVZ4EUfwUFy4bBN3BVW/IhVTl/Sh3ou+fv05EGoMc1 OFXxecHUU2ZLJJgo74wVT89OGuQj8mlznkbYLtNRxhQLpO8um2u7QhzidOgdvA9aP0fb P3rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GwvPZ5iF3QSYMCUOygKsaeqOQtAtGURL4nCSsyGlDzI=; b=poVnH66hiiY+PJKJUE4yAhhXLtwD7Ti9ekc/t+7yhnlsFRbYTnDgzpKby1jjKgibP7 82OFGEsABLM2ulnktP/1y4qX5piNduea5HDwm01eODeXF/FgjeU6pxzo1oPNW3d+rbya sjj3dQsUX8EJmwINzq8srnuocEL8Xs43XBFq3924mVRu5IKFrvmTgHWNwrLthaiKek1o HOrWzDyMzdAmq50PCyfJ1PZgX3QrzW5QFGW7Lvwa5TBm6IWuiKjpwaRAU8VlhbITau0o X98KuwV4g+D3K8UZyZmH3b8a4AbXWuVZjBUp99zW7Q5lEESiJvL/vJGGBqmkwYvklPPK NM8w== X-Gm-Message-State: AOAM532LHDLKnDrey/e2yc15xwTgNAXBme+x+4SwpV3xBKX9VQWe5Dcw g82HiYEXMVuP+Kl6cYNITKmVpoUzz57KueMmJIs= X-Google-Smtp-Source: ABdhPJzswBPmENP8jmdUZZiRs/W1cWOe+UZ5sULAkIhlS3ijrST3JpNfDv09byRxT4ZS6WtxsCqkWQ== X-Received: by 2002:a17:902:d88c:: with SMTP id b12mr709796plz.96.1599603444037; Tue, 08 Sep 2020 15:17:24 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([71.212.128.185]) by smtp.gmail.com with ESMTPSA id q20sm246350pgi.70.2020.09.08.15.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 15:17:23 -0700 (PDT) From: "Bret Barkelew" X-Google-Original-From: Bret Barkelew To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Liming Gao Subject: [PATCH v7 13/14] MdeModulePkg: Drop VarLock from RuntimeDxe variable driver Date: Tue, 8 Sep 2020 15:17:12 -0700 Message-Id: <20200908221713.2728-1-brbarkel@microsoft.com> X-Mailer: git-send-email 2.28.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable https://bugzilla.tianocore.org/show_bug.cgi?id=3D2522 Now that everything should be moved to VariablePolicy, drop support for the deprecated VarLock SMI interface and associated functions from variable RuntimeDxe. Cc: Jian J Wang Cc: Hao A Wu Cc: Liming Gao Cc: Bret Barkelew Signed-off-by: Bret Barkelew --- MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c | 49= +------------- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableLockRequstToLock.c | 71= ++++++++++++++++++++ MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf | 1= + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf | 1= + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf | 1= + 5 files changed, 75 insertions(+), 48 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c b/MdeMod= ulePkg/Universal/Variable/RuntimeDxe/VarCheck.c index f15219df5eb8..486d85b022e1 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c @@ -3,60 +3,13 @@ and variable lock protocol based on VarCheckLib.=0D =0D Copyright (c) 2015, Intel Corporation. All rights reserved.
=0D +Copyright (c) Microsoft Corporation.=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D =0D #include "Variable.h"=0D =0D -/**=0D - Mark a variable that will become read-only after leaving the DXE phase o= f execution.=0D - Write request coming from SMM environment through EFI_SMM_VARIABLE_PROTO= COL is allowed.=0D -=0D - @param[in] This The VARIABLE_LOCK_PROTOCOL instance.=0D - @param[in] VariableName A pointer to the variable name that will be mad= e read-only subsequently.=0D - @param[in] VendorGuid A pointer to the vendor GUID that will be made = read-only subsequently.=0D -=0D - @retval EFI_SUCCESS The variable specified by the VariableName= and the VendorGuid was marked=0D - as pending to be read-only.=0D - @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.=0D - Or VariableName is an empty string.=0D - @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVE= NT_GROUP_READY_TO_BOOT has=0D - already been signaled.=0D - @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the l= ock request.=0D -**/=0D -EFI_STATUS=0D -EFIAPI=0D -VariableLockRequestToLock (=0D - IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,=0D - IN CHAR16 *VariableName,=0D - IN EFI_GUID *VendorGuid=0D - )=0D -{=0D - EFI_STATUS Status;=0D - VAR_CHECK_VARIABLE_PROPERTY Property;=0D -=0D - AcquireLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.Variab= leServicesLock);=0D -=0D - Status =3D VarCheckLibVariablePropertyGet (VariableName, VendorGuid, &Pr= operty);=0D - if (!EFI_ERROR (Status)) {=0D - Property.Property |=3D VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY;=0D - } else {=0D - Property.Revision =3D VAR_CHECK_VARIABLE_PROPERTY_REVISION;=0D - Property.Property =3D VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY;=0D - Property.Attributes =3D 0;=0D - Property.MinSize =3D 1;=0D - Property.MaxSize =3D MAX_UINTN;=0D - }=0D - Status =3D VarCheckLibVariablePropertySet (VariableName, VendorGuid, &Pr= operty);=0D -=0D - DEBUG ((EFI_D_INFO, "[Variable] Lock: %g:%s %r\n", VendorGuid, VariableN= ame, Status));=0D -=0D - ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.Variab= leServicesLock);=0D -=0D - return Status;=0D -}=0D -=0D /**=0D Register SetVariable check handler.=0D =0D diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableLockRequstT= oLock.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableLockRequstToLo= ck.c new file mode 100644 index 000000000000..1f7f0b7ef06c --- /dev/null +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableLockRequstToLock.c @@ -0,0 +1,71 @@ +/** @file -- VariableLockRequstToLock.c=0D +Temporary location of the RequestToLock shim code while=0D +projects are moved to VariablePolicy. Should be removed when deprecated.=0D +=0D +Copyright (c) Microsoft Corporation.=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +=0D +#include =0D +#include =0D +=0D +#include =0D +=0D +#include =0D +#include =0D +#include =0D +=0D +=0D +/**=0D + DEPRECATED. THIS IS ONLY HERE AS A CONVENIENCE WHILE PORTING.=0D + Mark a variable that will become read-only after leaving the DXE phase o= f execution.=0D + Write request coming from SMM environment through EFI_SMM_VARIABLE_PROTO= COL is allowed.=0D +=0D + @param[in] This The VARIABLE_LOCK_PROTOCOL instance.=0D + @param[in] VariableName A pointer to the variable name that will be mad= e read-only subsequently.=0D + @param[in] VendorGuid A pointer to the vendor GUID that will be made = read-only subsequently.=0D +=0D + @retval EFI_SUCCESS The variable specified by the VariableName= and the VendorGuid was marked=0D + as pending to be read-only.=0D + @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.=0D + Or VariableName is an empty string.=0D + @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVE= NT_GROUP_READY_TO_BOOT has=0D + already been signaled.=0D + @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the l= ock request.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +VariableLockRequestToLock (=0D + IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,=0D + IN CHAR16 *VariableName,=0D + IN EFI_GUID *VendorGuid=0D + )=0D +{=0D + EFI_STATUS Status;=0D + VARIABLE_POLICY_ENTRY *NewPolicy;=0D +=0D + NewPolicy =3D NULL;=0D + Status =3D CreateBasicVariablePolicy( VendorGuid,=0D + VariableName,=0D + VARIABLE_POLICY_NO_MIN_SIZE,=0D + VARIABLE_POLICY_NO_MAX_SIZE,=0D + VARIABLE_POLICY_NO_MUST_ATTR,=0D + VARIABLE_POLICY_NO_CANT_ATTR,=0D + VARIABLE_POLICY_TYPE_LOCK_NOW,=0D + &NewPolicy );=0D + if (!EFI_ERROR( Status )) {=0D + Status =3D RegisterVariablePolicy( NewPolicy );=0D + }=0D + if (EFI_ERROR( Status )) {=0D + DEBUG(( DEBUG_ERROR, "%a - Failed to lock variable %s! %r\n", __FUNCTI= ON__, VariableName, Status ));=0D + ASSERT_EFI_ERROR( Status );=0D + }=0D + if (NewPolicy !=3D NULL) {=0D + FreePool( NewPolicy );=0D + }=0D +=0D + return Status;=0D +}=0D diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.= inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf index 8debc560e6dc..3005e9617423 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf @@ -49,6 +49,7 @@ [Sources] VarCheck.c=0D VariableExLib.c=0D SpeculationBarrierDxe.c=0D + VariableLockRequstToLock.c=0D =0D [Packages]=0D MdePkg/MdePkg.dec=0D diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf b/M= deModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf index bbc8d2080193..26fbad97339f 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf @@ -58,6 +58,7 @@ [Sources] VariableExLib.c=0D TcgMorLockSmm.c=0D SpeculationBarrierSmm.c=0D + VariableLockRequstToLock.c=0D =0D [Packages]=0D MdePkg/MdePkg.dec=0D diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneM= m.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf index 62f2f9252f43..7c6fdf4d65fd 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf @@ -58,6 +58,7 @@ [Sources] VariableExLib.c=0D TcgMorLockSmm.c=0D SpeculationBarrierSmm.c=0D + VariableLockRequstToLock.c=0D =0D [Packages]=0D MdePkg/MdePkg.dec=0D --=20 2.28.0.windows.1