Hi liming: Yes, NV Variable Data is not changed in PEI phase in normal case. This issue was found when we did a special coding, and when found variable in the IndexTable, it found the variable before the last changed if didn't add the following condition: " if ((VariableHeader->State == VAR_ADDED) || (VariableHeader->State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)))"
Maybe our specail coding had some defect,and caused this issue. On Fri, Sep 30, 2022 at 10:46 AM, gaoliming wrote: > > > > Jiading: > > > > Hob Variable Store Info IndexTable is NULL. So, this logic doesn’t work > for HOB variable store. NV Variable Store Info has IndexTable. When its > IndexTable is initialized, its IndexTable will only record the variable > with VAR_ADDED attribute. Because NV Variable Data is not changed in PEI > phase, this check is not required by NV variable. > > > > > > > > Thanks > > > > Liming > > > > *发件人 :* devel@edk2.groups.io <devel@edk2.groups.io> *代表* Jiading Zhang > *发送时间 :* 2022 年 9 月 28 日 11:05 > *收件人 :* devel@edk2.groups.io > *主题 :* [edk2-devel] [PATCH] MdeModulePkg VariablePei: Add Variable state > check when find variable in IndexTable. > > > > > > > > > When read a variable in PEI, it will find it first in the HOB, then find > in variable store. When find in variable store, it will check the variable > state, but find in HOB, it doesn't check the state, so if the variable was > changed, it will find the obsolete variable in the HOB. > > > > > > > > > > Signed-off-by: jdzhang < jdzh...@kunluntech.com.cn > > > > > > --- > > > > > MdeModulePkg/Universal/Variable/Pei/Variable.c | 12 +++++++----- > > > > > 1 file changed, 7 insertions(+), 5 deletions(-) > > > > > > > > > > diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.c > b/MdeModulePkg/Universal/Variable/Pei/Variable.c > > > > > index 26a4c73b45..dffbd8cdb1 100644 > > > > > --- a/MdeModulePkg/Universal/Variable/Pei/Variable.c > > > > > +++ b/MdeModulePkg/Universal/Variable/Pei/Variable.c > > > > > @@ -866,11 +866,13 @@ FindVariableEx ( > > > > > Offset += IndexTable->Index[Index]; > > > > > MaxIndex = (VARIABLE_HEADER *)((UINT8 *)IndexTable->StartPtr + Offset); > > > > > GetVariableHeader (StoreInfo, MaxIndex, &VariableHeader); > > > > > - if (CompareWithValidVariable (StoreInfo, MaxIndex, VariableHeader, > VariableName, VendorGuid, PtrTrack) == EFI_SUCCESS) { > > > > > - if (VariableHeader->State == (VAR_IN_DELETED_TRANSITION & > VAR_ADDED)) { > > > > > - InDeletedVariable = PtrTrack->CurrPtr; > > > > > - } else { > > > > > - return EFI_SUCCESS; > > > > > + if ((VariableHeader->State == VAR_ADDED) || (VariableHeader->State > == (VAR_IN_DELETED_TRANSITION & VAR_ADDED))) { > > > > > + if (CompareWithValidVariable (StoreInfo, MaxIndex, > VariableHeader, VariableName, VendorGuid, PtrTrack) == EFI_SUCCESS) { > > > > > + if (VariableHeader->State == (VAR_IN_DELETED_TRANSITION & > VAR_ADDED)) { > > > > > + InDeletedVariable = PtrTrack->CurrPtr; > > > > > + } else { > > > > > + return EFI_SUCCESS; > > > > > + } > > > > > } > > > > > } > > > > > } > > > > > -- > > > > > 2.20.1.windows.1 > > > > > > > > > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#94851): https://edk2.groups.io/g/devel/message/94851 Mute This Topic: https://groups.io/mt/94009355/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-