<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@DengXian";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">- Bret <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:michael.d.kinney=intel.com@groups.io">Michael D Kinney via groups.io</a><br>
<b>Sent: </b>Tuesday, January 5, 2021 7:51 PM<br>
<b>To: </b><a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a><br>
<b>Cc: </b><a href="mailto:Bret.Barkelew@microsoft.com">Bret Barkelew</a>; <a href="mailto:hao.a.wu@intel.com">
Hao A Wu</a>; <a href="mailto:gaoliming@byosoft.com.cn">Liming Gao</a><br>
<b>Subject: </b>[EXTERNAL] [edk2-devel] [Patch 1/1] MdeModulePkg/Library/VarCheckLib: Allow SetVariable from SMM</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">REF: <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D3154&amp;data=04%7C01%7Cbret.barkelew%40microsoft.com%7Cdd8b9b71d99a4ae7056e08d8b1f64465%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637455018562833685%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=0UiR50Bobd3%2BQdK9lRD3ffTSoaHCNbPlY40sVeTIx3s%3D&amp;reserved=0">
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D3154&amp;data=04%7C01%7Cbret.barkelew%40microsoft.com%7Cdd8b9b71d99a4ae7056e08d8b1f64465%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637455018562833685%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=0UiR50Bobd3%2BQdK9lRD3ffTSoaHCNbPlY40sVeTIx3s%3D&amp;reserved=0</a><br>
<br>
Update VarCheckLibSetVariableCheck() to allow locked variables<br>
to be updated if the RequestSource is VarCheckFromTrusted even<br>
if one or more variable check handlers return EFI_WRITE_PROTECTED.<br>
RequestSource is only set to VarCheckFromTrusted if the request<br>
is through the EFI_SMM_VARAIBLE_PROTOCOL.<br>
<br>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com><br>
Cc: Hao A Wu <hao.a.wu@intel.com><br>
Cc: Liming Gao <gaoliming@byosoft.com.cn><br>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com><br>
---<br>
 MdeModulePkg/Library/VarCheckLib/VarCheckLib.c | 9 ++++++++-<br>
 1 file changed, 8 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c<br>
index 470d782444bf..9596d760e945 100644<br>
--- a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c<br>
+++ b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c<br>
@@ -1,7 +1,7 @@<br>
 /** @file<br>
   Implementation functions and structures for var check services.<br>
 <br>
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR><br>
+Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR><br>
 SPDX-License-Identifier: BSD-2-Clause-Patent<br>
 <br>
 **/<br>
@@ -655,6 +655,13 @@ VarCheckLibSetVariableCheck (<br>
                DataSize,<br>
                Data<br>
                );<br>
+    if (Status == EFI_WRITE_PROTECTED && RequestSource == VarCheckFromTrusted) {<br>
+      //<br>
+      // If RequestSource is trusted, then allow variable to be set even if it<br>
+      // is write protected.<br>
+      //<br>
+      continue;<br>
+    }<br>
     if (EFI_ERROR (Status)) {<br>
       DEBUG ((EFI_D_INFO, "Variable Check handler fail %r - %g:%s\n", Status, VendorGuid, VariableName));<br>
       return Status;<br>
-- <br>
2.29.2.windows.2<br>
<br>
<br>
<br>
<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>


 <div width="1" style="color:white;clear:both">_._,_._,_</div> <hr> Groups.io Links:<p>   You receive all messages sent to this group.    <p> <a target="_blank" href="https://edk2.groups.io/g/devel/message/69781">View/Reply Online (#69781)</a> |    |  <a target="_blank" href="https://groups.io/mt/79468724/1813853">Mute This Topic</a>  | <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>    <a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> | <a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |  <a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>  [edk2-devel-archive@redhat.com]<br> <div width="1" style="color:white;clear:both">_._,_._,_</div>