From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by mx.groups.io with SMTP id smtpd.web09.7971.1604904406251863871 for ; Sun, 08 Nov 2020 22:46:46 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@corthon-com.20150623.gappssmtp.com header.s=20150623 header.b=nphKlPMF; spf=none, err=permanent DNS error (domain: corthon.com, ip: 209.85.210.174, mailfrom: bret@corthon.com) Received: by mail-pf1-f174.google.com with SMTP id z3so7175202pfb.10 for ; Sun, 08 Nov 2020 22:46:46 -0800 (PST) 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=zuwOxZUgQ7rlywNsYNQfA9pS0c+r0r8VjJn+RWDLIfY=; b=nphKlPMFT4JgYcVeRckS8Vu44RgZR9FIO+2v7tK3FRbwbQZ5h1Wj4fvHs/6P8bMZJL h+uVxLYzY+Nu1eTXRRl9qaelJhqS4nsD1v+QM/BNO55ScsnymP2byOB06K8lxemA/F3y qdpmVGf8cAL3jUbENFtA0VYhMCwSmWzougKdc+YQEZ3GoHqH2VcQJ+UY3qXRvyRlJQWr UhQ5uKB9mgEiQs8RmtMM9rFO5k5ntRXdshmMtRXg4VOWUV63F3HiQi+8ga8DZb8q2QI8 L+EpTCB2SZRKOyq4mdb4+/TB7lakeaah+ja8vEe2WFNt+mvSsP7K+N85tXzBI6kxevg9 Scsw== 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=zuwOxZUgQ7rlywNsYNQfA9pS0c+r0r8VjJn+RWDLIfY=; b=nIqy0MIKfGyVC00FN2BSHpyQSy/glu/NsmjyiXrr7us/ZnMA3ZLw2+yY7s0U9i132g Xcp3Rjg/gMU7l4HvSwcyP1Qd/UNoLmWQSOMksXZo6uCnBtLKcwD9fQIU1fFKQl1X1h9i dWhxfCJOyBe8MG121fbNpPEIgDFnuBYV/jTjVQkjwnz7thhAdvj+K7yhqLUnVYVNgbu3 +FXj5R+U6ySbTA8NgyPxmykHVveldPnnWVP4YVJIBWuTvfz4mpz79GrPfDOFbVy15kso H/ptlIYldW7+VGcXQrxsmd9Vh+o5Otg8kbpUAUS+LMXCeroN5IaZMXGmBl9qg+JCFIgi mlUg== X-Gm-Message-State: AOAM533CPDUCYaCYpDwppkcy6w2P6cNqqB6Gb/fDHHivWDoRNlf0D8Sc nEWz+xjmbMd3f2Noq1Goeu6A5TnxMfS8f4UT X-Google-Smtp-Source: ABdhPJymQJsT337j2s/0grLCmlQA6hReLGolmqo0EKTBhGE7KqhBZ1ovhIJ7NzsGko1qWvvr+JYEnQ== X-Received: by 2002:aa7:8b0b:0:b029:152:900d:2288 with SMTP id f11-20020aa78b0b0000b0290152900d2288mr12492139pfd.53.1604904405565; Sun, 08 Nov 2020 22:46:45 -0800 (PST) Return-Path: Received: from localhost.localdomain ([71.212.128.184]) by smtp.gmail.com with ESMTPSA id s145sm10215111pfs.187.2020.11.08.22.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Nov 2020 22:46:44 -0800 (PST) From: "Bret Barkelew" X-Google-Original-From: Bret Barkelew To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Liming Gao , Bret Barkelew , Dandan Bi Subject: [PATCH v9 13/13] MdeModulePkg: Drop VarLock from RuntimeDxe variable driver Date: Sun, 8 Nov 2020 22:45:22 -0800 Message-Id: <20201109064522.919-14-bret.barkelew@microsoft.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201109064522.919-1-bret.barkelew@microsoft.com> References: <20201109064522.919-1-bret.barkelew@microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Bret Barkelew 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 Reviewed-by: Dandan Bi Acked-by: Jian J Wang --- MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c | 4= 9 +------------- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableLockRequestToLock.c | 7= 1 ++++++++++++++++++++ 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/VariableLockRequest= ToLock.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableLockRequestTo= Lock.c new file mode 100644 index 000000000000..4aa854aaf260 --- /dev/null +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableLockRequestToLock.c @@ -0,0 +1,71 @@ +/** @file -- VariableLockRequestToLock.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..c9434df631ee 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 + VariableLockRequestToLock.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..eaa97a01c6e5 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 + VariableLockRequestToLock.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..fada0bf3c57f 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 + VariableLockRequestToLock.c=0D =0D [Packages]=0D MdePkg/MdePkg.dec=0D --=20 2.28.0.windows.1