From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by mx.groups.io with SMTP id smtpd.web10.41428.1591029218059746832 for ; Mon, 01 Jun 2020 09:33:38 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@corthon-com.20150623.gappssmtp.com header.s=20150623 header.b=VYaV/38r; spf=none, err=permanent DNS error (domain: corthon.com, ip: 209.85.216.54, mailfrom: bret@corthon.com) Received: by mail-pj1-f54.google.com with SMTP id q24so63727pjd.1 for ; Mon, 01 Jun 2020 09:33:38 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=2GR4B2JObRd7emsDEkhD44IrjhaoBkT6yfSbJfTnN4s=; b=VYaV/38rGJQRUOtz0Uh304QkF1ynMfvriVexJJPUV2Ca6y2XQQ98jIllEZN+J02+fH 39d4sWTD8RHD/gsFNJj0vCBn9zFQBW0e3O37bHE3hEXyZ17XfS4EEBbc3k8DUWDWE+6m L8Kwg+pzaUyVpygmpD9cmObXeRV/YZLj09jcS6Mt8x/kOTIvLP33mkIXF6WNUyAzby4B 34D4beZvqFiZJUCVXcxnIZIn97RWVohY9GeQRjWqr/KRlqpHhehglvMqiAAyGHQnuyJf 84F5UeSEAP6GE3m2C5JfidEhLni245I7ESBvdLxqoKgoOQta/Llup3K+Pv25c018G6fW OWpQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=2GR4B2JObRd7emsDEkhD44IrjhaoBkT6yfSbJfTnN4s=; b=oP+L5b92hHaDPHIOvDGA8w+TkvBVuhvjKd7Mj5sljxT3s5z2yP2KkelrCzdLnaV85b 1yMe3zcklLbE1WdmScrDb4+nG136L8pqJsGlsasDJgyaJVVWmNMbUsjr7G5aNAVkkbMK GMSrAttPTvXBWxvFAk7Jk4j9yeUdlyHuhB5i2qK6oZEL4noGMUYfdYz/zidJP7UbEeVh WA5y9Fs3goV1TzpOcc4p5D3LSdSg9VdV6OFUopGNwtIc5eoW9uyBdgGD7Lie44LuS15t tgAgJtw75/1jCdgbPQwS5S6oFOmzLqry6AGpcR4D6x8kd/HnY/oXOqp9Zew6dK9G8u3q WBlQ== X-Gm-Message-State: AOAM530AcjdjUEyBIjik0Wps+4zSgLWxjCJdy4P0md1txO72vr7Irn7T yDJCSLe36yXqzhKjrnXCoKyXgYh5NTo= X-Google-Smtp-Source: ABdhPJwmqaZhbOHVVscLMul61Cw83oEmcqeUyR4dSqp8ipq5KZaqyKCCKrKx2g99IQ0zw3Itjk+O1w== X-Received: by 2002:a17:902:6906:: with SMTP id j6mr21835076plk.261.1591029217364; Mon, 01 Jun 2020 09:33:37 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([71.212.144.72]) by smtp.gmail.com with ESMTPSA id np5sm91178pjb.43.2020.06.01.09.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 09:33:36 -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 v4 13/14] MdeModulePkg: Drop VarLock from RuntimeDxe variable driver Date: Mon, 1 Jun 2020 09:33:09 -0700 Message-Id: <20200601163310.1718-14-brbarkel@microsoft.com> X-Mailer: git-send-email 2.26.2.windows.1.8.g01c50adf56.20200515075929 In-Reply-To: <20200601163310.1718-1-brbarkel@microsoft.com> References: <20200601163310.1718-1-brbarkel@microsoft.com> 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.26.2.windows.1.8.g01c50adf56.20200515075929