From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web09.3735.1607673687007706411 for ; Fri, 11 Dec 2020 00:01:27 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: michael.d.kinney@intel.com) IronPort-SDR: y+PsRIoabK3ENa9N7StELissGC3FhNTOv1A+QxLoVVFxRLuhKWQsq/GCNJlI+ai2QCWua76MZd jMGTZnniA0nA== X-IronPort-AV: E=McAfee;i="6000,8403,9831"; a="192732136" X-IronPort-AV: E=Sophos;i="5.78,410,1599548400"; d="scan'208";a="192732136" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2020 00:01:26 -0800 IronPort-SDR: Q0cMwY5qmUdKmSZqICb2nXlsu0aJF3IWsuy8Df3ADVuXcytxLYuDwjOoTpAk+8I021/pSBRJz2 6A/pmH93hvOg== X-IronPort-AV: E=Sophos;i="5.78,410,1599548400"; d="scan'208";a="333917976" Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.202.206]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2020 00:01:25 -0800 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Hao A Wu , Liming Gao , Bret Barkelew Subject: [Patch v4 0/2] MdeModulePkg/Variable/RuntimeDxe: Restore Variable Lock Protocol behavior Date: Fri, 11 Dec 2020 00:01:16 -0800 Message-Id: <20201211080118.1885-1-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit New in V4 ========== * Fix spelling in unit tests * Call ValidateSetVariable() with DataSize=0, Attributes=0 New in V3 ========== * Split into 2 patches. One for code change. Second for unit tests. * Remove duplicate code and use ValidateSetVariable() to detect if a variable is already locked. https://bugzilla.tianocore.org/show_bug.cgi?id=3111 The VariableLock shim currently fails if called twice because the underlying Variable Policy engine returns an error if a policy is set on an existing variable. This breaks existing code which expect it to silently pass if a variable is locked multiple times (because it should "be locked"). Refactor the shim to confirm that the variable is indeed locked and then change the error to EFI_SUCCESS and generate a DEBUG_ERROR message so the duplicate lock can be reported in a debug log and removed. Add host based unit tests for the multiple lock case using Variable Lock Protocol, Variable Policy Protocol, and mixes of Variable Lock Protocol and Variable Policy Protocol. Cc: Michael D Kinney Cc: Hao A Wu Cc: Liming Gao Signed-off-by: Bret Barkelew Bret Barkelew (1): MdeModulePkg/Variable/RuntimeDxe: Restore Variable Lock Protocol behavior Michael D Kinney (1): MdeModulePkg/Variable/RuntimeDxe: Add Variable Lock Protocol Unit Tests MdeModulePkg/Test/MdeModulePkgHostTest.dsc | 11 + .../VariableLockRequestToLockUnitTest.c | 565 ++++++++++++++++++ .../VariableLockRequestToLockUnitTest.inf | 36 ++ .../RuntimeDxe/VariableLockRequestToLock.c | 95 +-- 4 files changed, 671 insertions(+), 36 deletions(-) create mode 100644 MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c create mode 100644 MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.inf -- 2.29.2.windows.2