From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mx.groups.io with SMTP id smtpd.web12.8371.1591167602205729757 for ; Wed, 03 Jun 2020 00:00:02 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@corthon-com.20150623.gappssmtp.com header.s=20150623 header.b=MUn1XRp2; spf=none, err=permanent DNS error (domain: corthon.com, ip: 209.85.214.182, mailfrom: bret@corthon.com) Received: by mail-pl1-f182.google.com with SMTP id y17so492796plb.8 for ; Wed, 03 Jun 2020 00:00:02 -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=MUn1XRp2h3QtLUrDWqNlUrBXuU7GqkdeCkEYUuGhv37gmjVMX6ZHxR/tRkF0wXB62t doVfY4fBMfCf8aV+mD8GGpmztYto7Nr1fSnMkIx+N4901hb/5gHhVxKuJTrYQFXbhAYs eriMQKco2UTvKH9pJIpIfkyrNE3A1/o2Bf0n2APcbPtUhYoac6ioTbK+NVuXx5LUmn+k bAzIcZIX9kSKrQlDiKHD6j3X2RkUE5971fxsHHqtdUGZfJhePamqyAfsaKxLO3/vilso ka5RPpulb/xp/SWL4D4g/MejcYvu7Bfyx8uik1Mx72cZNecqvpDThmYYEMyBDtuRLls/ aZkg== 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=blW+PU2UiQ1V/YYQISH5lot26gMP4KjlPUO9MskESwJfNR0Who9NkY8AjKDturl01L 1Y+Bo+kHlTSqDOEobGpZtEKN5rs6UTmQ6/PulZN4YYEUqcQYWGNrphZJYcNtSmBqcpSp VhDWl/jtfZtHxGekn14xBljEiFmsYh1DOVMHZYszhloe/BNVAG+YBCfOQiNX3q9bsrt2 J3JoOYsZxdLe2AQdD9U5S5rHKW+VMY0NOouP/UY5nuZECQ7oidpeCfqTKGMeXK4LG6Cd 5gZct2mV8+RxxlgAHO5lX46MrTSHxLGJ9H++T5Gt8wfMS97D1JuXdmV3WxY8POh2WjH4 ibpw== X-Gm-Message-State: AOAM531+kuZF3wn+xAac9vrDYuqIJDk2yfcbJKTw45b3RWt7Q0QNQ7SC a+pamulZ+c2G0YI1G9Jsfp/CHNsGwwc= X-Google-Smtp-Source: ABdhPJwoP1hsMMcEzjTZbB0A+1XUvCZjanyk/D/G/LlcYoqNqGkJEcNSUzNW3gxyjuPqSShVOUPbrg== X-Received: by 2002:a17:902:c381:: with SMTP id g1mr28295869plg.117.1591167601488; Wed, 03 Jun 2020 00:00:01 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([71.212.144.72]) by smtp.gmail.com with ESMTPSA id y6sm1262003pjn.37.2020.06.03.00.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 00:00:01 -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 v5 13/14] MdeModulePkg: Drop VarLock from RuntimeDxe variable driver Date: Tue, 2 Jun 2020 23:58:09 -0700 Message-Id: <20200603065810.806-14-brbarkel@microsoft.com> X-Mailer: git-send-email 2.26.2.windows.1.8.g01c50adf56.20200515075929 In-Reply-To: <20200603065810.806-1-brbarkel@microsoft.com> References: <20200603065810.806-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