From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web10.3901.1589283810770299896 for ; Tue, 12 May 2020 04:43:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jE874i/w; spf=pass (domain: redhat.com, ip: 207.211.31.81, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589283809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DVMvXU8zcFryTYKbC/SpCo0C5ueMXvQtounsDNLM5sI=; b=jE874i/wC7oQSNlQACIVqnts66S8nqd7TREA7mKMiN3n20xzj4SMh6SFMcTv8TNQzPXUeT U3/Qd3DRMrVvYB0pyvgPwSCjAMw3hH2YsLOT6SHYyHWgLkE3G0HPCNGQZODInH+CtL968v 8RvMmPZ75SV074i9w8dgOLKkoAEbs3w= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371--gfeI_xOMTaIngLx7g0mUQ-1; Tue, 12 May 2020 07:43:23 -0400 X-MC-Unique: -gfeI_xOMTaIngLx7g0mUQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA695835B40; Tue, 12 May 2020 11:43:21 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-120.ams2.redhat.com [10.36.114.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B77D619A5; Tue, 12 May 2020 11:43:20 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v2 02/12] MdeModulePkg: Define the VariablePolicyLib To: devel@edk2.groups.io, michael.kubacki@outlook.com Cc: Jian J Wang , Hao A Wu , Liming Gao References: <20200512064635.14640-1-michael.kubacki@outlook.com> From: "Laszlo Ersek" Message-ID: <7b36b87c-e9e5-b6cc-a43a-88a0a009bd4c@redhat.com> Date: Tue, 12 May 2020 13:43:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 05/12/20 08:46, Michael Kubacki wrote: > From: Bret Barkelew > > https://bugzilla.tianocore.org/show_bug.cgi?id=2522 > > VariablePolicy is an updated interface to > replace VarLock and VarCheckProtocol. > > Add the VariablePolicyLib library that implements > the portable business logic for the VariablePolicy > engine. > > Also add host-based CI test cases for the lib. > > Cc: Jian J Wang > Cc: Hao A Wu > Cc: Liming Gao > Signed-off-by: Michael Kubacki > --- > MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitNull.c | 46 + > MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitRuntimeDxe.c | 85 + > MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c | 806 +++++++ > MdeModulePkg/Library/VariablePolicyLib/VariablePolicyUnitTest/VariablePolicyUnitTest.c | 2285 ++++++++++++++++++++ > MdeModulePkg/Include/Library/VariablePolicyLib.h | 207 ++ > MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf | 44 + > MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.uni | 12 + > MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf | 52 + > MdeModulePkg/Library/VariablePolicyLib/VariablePolicyUnitTest/VariablePolicyUnitTest.inf | 41 + > MdeModulePkg/MdeModulePkg.dec | 3 + > MdeModulePkg/MdeModulePkg.dsc | 5 + > MdeModulePkg/Test/MdeModulePkgHostTest.dsc | 11 + > 12 files changed, 3597 insertions(+) > > diff --git a/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitNull.c b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitNull.c > new file mode 100644 > index 000000000000..ad2ee0b2fb8f > --- /dev/null > +++ b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitNull.c > @@ -0,0 +1,46 @@ > +/** @file -- VariablePolicyExtraInitNull.c > +This file contains extra init and deinit routines that don't do anything > +extra. > + > +Copyright (c) Microsoft Corporation. > +SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > + > + > +/** > + An extra init hook that enables the RuntimeDxe library instance to > + register VirtualAddress change callbacks. Among other things. > + > + @retval EFI_SUCCESS Everything is good. Continue with init. > + @retval Others Uh... don't continue. > + > +**/ > +EFI_STATUS > +VariablePolicyExtraInit ( > + VOID > + ) > +{ > + // NULL implementation. > + return EFI_SUCCESS; > +} > + > + > +/** > + An extra deinit hook that enables the RuntimeDxe library instance to > + register VirtualAddress change callbacks. Among other things. > + > + @retval EFI_SUCCESS Everything is good. Continue with deinit. > + @retval Others Uh... don't continue. > + > +**/ > +EFI_STATUS > +VariablePolicyExtraDeinit ( > + VOID > + ) > +{ > + // NULL implementation. > + return EFI_SUCCESS; > +} > diff --git a/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitRuntimeDxe.c b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitRuntimeDxe.c > new file mode 100644 > index 000000000000..8e63f4eb66a0 > --- /dev/null > +++ b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitRuntimeDxe.c > @@ -0,0 +1,85 @@ > +/** @file -- VariablePolicyExtraInitRuntimeDxe.c > +This file contains extra init and deinit routines that register and unregister > +VariableAddressChange callbacks. > + > +Copyright (c) Microsoft Corporation. > +SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > + > +extern EFI_GET_VARIABLE mGetVariableHelper = NULL; > +extern UINT8 *mPolicyTable = NULL; These two lines trigger a build failure with GCC48: > MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitRuntimeDxe.c:13:27: error: 'mGetVariableHelper' initialized and declared 'extern' [-Werror] > extern EFI_GET_VARIABLE mGetVariableHelper = NULL; > ^ > MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitRuntimeDxe.c:14:28: error: 'mPolicyTable' initialized and declared 'extern' [-Werror] > extern UINT8 *mPolicyTable = NULL; > ^ > cc1: all warnings being treated as errors Unfortunately, this is a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45977 More precisely, it is not a bug that gcc "warns" about this (it *would* be a gcc bug no-questions-asked if the diagnostic would be a hard error even without "-Werror"). Instead, the gcc bug at present is that gcc doesn't offer a "-Wno-error=FOOBAR"-style option for disabling "error treatment" for this specific warning. So please rework this in order to avoid triggering the gcc problem. Thanks! Laszlo