public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2 1/2] MdeModulePkg/Variable: Return GetVariable() attr if EFI_BUFFER_TOO_SMALL
@ 2020-03-25  2:59 Michael Kubacki
  2020-03-27 14:39 ` [edk2-devel] " Wang, Jian J
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Kubacki @ 2020-03-25  2:59 UTC (permalink / raw)
  To: devel; +Cc: Bret Barkelew, Liming Gao, Michael D Kinney, Jian J Wang,
	Hao A Wu

From: Michael Kubacki <michael.kubacki@microsoft.com>

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2062

The UEFI specification v2.8 Errata A Section 8.2 "GetVariable()"
"Attributes" parameter description states:

"If not NULL, a pointer to the memory location to return the
 attributes bitmask for the variable. See 'Related Definitions.'
 If not NULL, then Attributes is set on output both when
 EFI_SUCCESS and when EFI_BUFFER_TOO_SMALL is returned."

The attributes were previously only returned from the implementation
in Variable.c on EFI_SUCCESS. They are now returned on EFI_SUCCESS or
EFI_BUFFER_TOO_SMALL according to spec.

Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c              | 10 +++++++---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c | 10 ++++++----
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index d23aea4bc712..1e71fc642c76 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -18,6 +18,8 @@
 
 Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
 (C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP<BR>
+Copyright (c) Microsoft Corporation.<BR>
+
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -2379,9 +2381,6 @@ VariableServiceGetVariable (
     }
 
     CopyMem (Data, GetVariableDataPtr (Variable.CurrPtr, mVariableModuleGlobal->VariableGlobal.AuthFormat), VarDataSize);
-    if (Attributes != NULL) {
-      *Attributes = Variable.CurrPtr->Attributes;
-    }
 
     *DataSize = VarDataSize;
     UpdateVariableInfo (VariableName, VendorGuid, Variable.Volatile, TRUE, FALSE, FALSE, FALSE, &gVariableInfo);
@@ -2395,6 +2394,11 @@ VariableServiceGetVariable (
   }
 
 Done:
+  if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) {
+    if (Attributes != NULL && Variable.CurrPtr != NULL) {
+      *Attributes = Variable.CurrPtr->Attributes;
+    }
+  }
   ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
   return Status;
 }
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
index 2cf0ed32ae55..ca833fb0244d 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
@@ -14,6 +14,7 @@
   InitCommunicateBuffer() is really function to check the variable data size.
 
 Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
+Copyright (c) Microsoft Corporation.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -642,10 +643,6 @@ FindVariableInRuntimeCache (
         }
 
         CopyMem (Data, GetVariableDataPtr (RtPtrTrack.CurrPtr, mVariableAuthFormat), TempDataSize);
-        if (Attributes != NULL) {
-          *Attributes = RtPtrTrack.CurrPtr->Attributes;
-        }
-
         *DataSize = TempDataSize;
 
         UpdateVariableInfo (VariableName, VendorGuid, RtPtrTrack.Volatile, TRUE, FALSE, FALSE, TRUE, &mVariableInfo);
@@ -661,6 +658,11 @@ FindVariableInRuntimeCache (
   }
 
 Done:
+  if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) {
+    if (Attributes != NULL && RtPtrTrack.CurrPtr != NULL) {
+      *Attributes = RtPtrTrack.CurrPtr->Attributes;
+    }
+  }
   mVariableRuntimeCacheReadLock = FALSE;
 
   return Status;
-- 
2.16.3.windows.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [PATCH v2 1/2] MdeModulePkg/Variable: Return GetVariable() attr if EFI_BUFFER_TOO_SMALL
  2020-03-25  2:59 [PATCH v2 1/2] MdeModulePkg/Variable: Return GetVariable() attr if EFI_BUFFER_TOO_SMALL Michael Kubacki
@ 2020-03-27 14:39 ` Wang, Jian J
  2020-03-27 16:39   ` Michael Kubacki
  0 siblings, 1 reply; 3+ messages in thread
From: Wang, Jian J @ 2020-03-27 14:39 UTC (permalink / raw)
  To: devel@edk2.groups.io, michael.kubacki@outlook.com
  Cc: Bret Barkelew, Gao, Liming, Kinney, Michael D, Wu, Hao A

Michael,

I know this is related to UEFI spec. But I think the PEI variable driver should be
consistent with RT driver's behavior. Otherwise it will cause confusion. I suggest
to make similar change to PEI variable driver.

Regards,
Jian

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael
> Kubacki
> Sent: Wednesday, March 25, 2020 11:00 AM
> To: devel@edk2.groups.io
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>; Gao, Liming
> <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>;
> Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>
> Subject: [edk2-devel] [PATCH v2 1/2] MdeModulePkg/Variable: Return
> GetVariable() attr if EFI_BUFFER_TOO_SMALL
> 
> From: Michael Kubacki <michael.kubacki@microsoft.com>
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2062
> 
> The UEFI specification v2.8 Errata A Section 8.2 "GetVariable()"
> "Attributes" parameter description states:
> 
> "If not NULL, a pointer to the memory location to return the
>  attributes bitmask for the variable. See 'Related Definitions.'
>  If not NULL, then Attributes is set on output both when
>  EFI_SUCCESS and when EFI_BUFFER_TOO_SMALL is returned."
> 
> The attributes were previously only returned from the implementation
> in Variable.c on EFI_SUCCESS. They are now returned on EFI_SUCCESS or
> EFI_BUFFER_TOO_SMALL according to spec.
> 
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
> ---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c              | 10
> +++++++---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c |
> 10 ++++++----
>  2 files changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> index d23aea4bc712..1e71fc642c76 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> @@ -18,6 +18,8 @@
> 
>  Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
>  (C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP<BR>
> +Copyright (c) Microsoft Corporation.<BR>
> +
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -2379,9 +2381,6 @@ VariableServiceGetVariable (
>      }
> 
>      CopyMem (Data, GetVariableDataPtr (Variable.CurrPtr,
> mVariableModuleGlobal->VariableGlobal.AuthFormat), VarDataSize);
> -    if (Attributes != NULL) {
> -      *Attributes = Variable.CurrPtr->Attributes;
> -    }
> 
>      *DataSize = VarDataSize;
>      UpdateVariableInfo (VariableName, VendorGuid, Variable.Volatile, TRUE,
> FALSE, FALSE, FALSE, &gVariableInfo);
> @@ -2395,6 +2394,11 @@ VariableServiceGetVariable (
>    }
> 
>  Done:
> +  if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) {
> +    if (Attributes != NULL && Variable.CurrPtr != NULL) {
> +      *Attributes = Variable.CurrPtr->Attributes;
> +    }
> +  }
>    ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal-
> >VariableGlobal.VariableServicesLock);
>    return Status;
>  }
> diff --git
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
> index 2cf0ed32ae55..ca833fb0244d 100644
> ---
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
> +++
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
> @@ -14,6 +14,7 @@
>    InitCommunicateBuffer() is really function to check the variable data size.
> 
>  Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) Microsoft Corporation.<BR>
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -642,10 +643,6 @@ FindVariableInRuntimeCache (
>          }
> 
>          CopyMem (Data, GetVariableDataPtr (RtPtrTrack.CurrPtr,
> mVariableAuthFormat), TempDataSize);
> -        if (Attributes != NULL) {
> -          *Attributes = RtPtrTrack.CurrPtr->Attributes;
> -        }
> -
>          *DataSize = TempDataSize;
> 
>          UpdateVariableInfo (VariableName, VendorGuid, RtPtrTrack.Volatile, TRUE,
> FALSE, FALSE, TRUE, &mVariableInfo);
> @@ -661,6 +658,11 @@ FindVariableInRuntimeCache (
>    }
> 
>  Done:
> +  if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) {
> +    if (Attributes != NULL && RtPtrTrack.CurrPtr != NULL) {
> +      *Attributes = RtPtrTrack.CurrPtr->Attributes;
> +    }
> +  }
>    mVariableRuntimeCacheReadLock = FALSE;
> 
>    return Status;
> --
> 2.16.3.windows.1
> 
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [PATCH v2 1/2] MdeModulePkg/Variable: Return GetVariable() attr if EFI_BUFFER_TOO_SMALL
  2020-03-27 14:39 ` [edk2-devel] " Wang, Jian J
@ 2020-03-27 16:39   ` Michael Kubacki
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Kubacki @ 2020-03-27 16:39 UTC (permalink / raw)
  To: devel, jian.j.wang
  Cc: Bret Barkelew, Gao, Liming, Kinney, Michael D, Wu, Hao A

That's a good point. I will send a v3 with the change added to VariablePei.

Thanks,
Michael

On 3/27/2020 7:39 AM, Wang, Jian J wrote:
> Michael,
> 
> I know this is related to UEFI spec. But I think the PEI variable driver should be
> consistent with RT driver's behavior. Otherwise it will cause confusion. I suggest
> to make similar change to PEI variable driver.
> 
> Regards,
> Jian
> 
>> -----Original Message-----
>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael
>> Kubacki
>> Sent: Wednesday, March 25, 2020 11:00 AM
>> To: devel@edk2.groups.io
>> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>; Gao, Liming
>> <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>;
>> Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>
>> Subject: [edk2-devel] [PATCH v2 1/2] MdeModulePkg/Variable: Return
>> GetVariable() attr if EFI_BUFFER_TOO_SMALL
>>
>> From: Michael Kubacki <michael.kubacki@microsoft.com>
>>
>> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2062
>>
>> The UEFI specification v2.8 Errata A Section 8.2 "GetVariable()"
>> "Attributes" parameter description states:
>>
>> "If not NULL, a pointer to the memory location to return the
>>   attributes bitmask for the variable. See 'Related Definitions.'
>>   If not NULL, then Attributes is set on output both when
>>   EFI_SUCCESS and when EFI_BUFFER_TOO_SMALL is returned."
>>
>> The attributes were previously only returned from the implementation
>> in Variable.c on EFI_SUCCESS. They are now returned on EFI_SUCCESS or
>> EFI_BUFFER_TOO_SMALL according to spec.
>>
>> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
>> Cc: Liming Gao <liming.gao@intel.com>
>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>> Cc: Jian J Wang <jian.j.wang@intel.com>
>> Cc: Hao A Wu <hao.a.wu@intel.com>
>> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
>> ---
>>   MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c              | 10
>> +++++++---
>>   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c |
>> 10 ++++++----
>>   2 files changed, 13 insertions(+), 7 deletions(-)
>>
>> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
>> b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
>> index d23aea4bc712..1e71fc642c76 100644
>> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
>> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
>> @@ -18,6 +18,8 @@
>>
>>   Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
>>   (C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP<BR>
>> +Copyright (c) Microsoft Corporation.<BR>
>> +
>>   SPDX-License-Identifier: BSD-2-Clause-Patent
>>
>>   **/
>> @@ -2379,9 +2381,6 @@ VariableServiceGetVariable (
>>       }
>>
>>       CopyMem (Data, GetVariableDataPtr (Variable.CurrPtr,
>> mVariableModuleGlobal->VariableGlobal.AuthFormat), VarDataSize);
>> -    if (Attributes != NULL) {
>> -      *Attributes = Variable.CurrPtr->Attributes;
>> -    }
>>
>>       *DataSize = VarDataSize;
>>       UpdateVariableInfo (VariableName, VendorGuid, Variable.Volatile, TRUE,
>> FALSE, FALSE, FALSE, &gVariableInfo);
>> @@ -2395,6 +2394,11 @@ VariableServiceGetVariable (
>>     }
>>
>>   Done:
>> +  if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) {
>> +    if (Attributes != NULL && Variable.CurrPtr != NULL) {
>> +      *Attributes = Variable.CurrPtr->Attributes;
>> +    }
>> +  }
>>     ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal-
>>> VariableGlobal.VariableServicesLock);
>>     return Status;
>>   }
>> diff --git
>> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
>> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
>> index 2cf0ed32ae55..ca833fb0244d 100644
>> ---
>> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
>> +++
>> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
>> @@ -14,6 +14,7 @@
>>     InitCommunicateBuffer() is really function to check the variable data size.
>>
>>   Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
>> +Copyright (c) Microsoft Corporation.<BR>
>>   SPDX-License-Identifier: BSD-2-Clause-Patent
>>
>>   **/
>> @@ -642,10 +643,6 @@ FindVariableInRuntimeCache (
>>           }
>>
>>           CopyMem (Data, GetVariableDataPtr (RtPtrTrack.CurrPtr,
>> mVariableAuthFormat), TempDataSize);
>> -        if (Attributes != NULL) {
>> -          *Attributes = RtPtrTrack.CurrPtr->Attributes;
>> -        }
>> -
>>           *DataSize = TempDataSize;
>>
>>           UpdateVariableInfo (VariableName, VendorGuid, RtPtrTrack.Volatile, TRUE,
>> FALSE, FALSE, TRUE, &mVariableInfo);
>> @@ -661,6 +658,11 @@ FindVariableInRuntimeCache (
>>     }
>>
>>   Done:
>> +  if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) {
>> +    if (Attributes != NULL && RtPtrTrack.CurrPtr != NULL) {
>> +      *Attributes = RtPtrTrack.CurrPtr->Attributes;
>> +    }
>> +  }
>>     mVariableRuntimeCacheReadLock = FALSE;
>>
>>     return Status;
>> --
>> 2.16.3.windows.1
>>
>>
>>
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-27 16:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-25  2:59 [PATCH v2 1/2] MdeModulePkg/Variable: Return GetVariable() attr if EFI_BUFFER_TOO_SMALL Michael Kubacki
2020-03-27 14:39 ` [edk2-devel] " Wang, Jian J
2020-03-27 16:39   ` Michael Kubacki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox