-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allocate Varaible cache buffer in PEI #5607
base: master
Are you sure you want to change the base?
Conversation
e8ef24d
to
071e26e
Compare
UINT64 MaxRuntimeVolatileCacheSize; | ||
} VARIABLE_RUNTIME_CACHE_CONTEXT_HOB; | ||
|
||
extern EFI_GUID gVariableRuntimeCacheContextHobGuid; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gEdkiiVariable...
} | ||
|
||
typedef struct { | ||
UINT64 ReadLockPtr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add more comments to each field in the structure?
At least including the buffer size each *Ptr points to.
Better to describe how each field is used in a cache logic.
|
||
VariableRuntimeCacheHob->HobFlushCompletePtr = (UINTN)Buffer; | ||
VariableRuntimeCacheHob->PendingUpdatePtr = ((UINTN)Buffer + sizeof (UINT64)); | ||
VariableRuntimeCacheHob->ReadLockPtr = ((UINTN)Buffer + 2 * sizeof (UINT64)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abstract to a structure
// | ||
GuidHob = GetFirstGuidHob (&gEdkiiFaultTolerantWriteGuid); | ||
if (GuidHob != NULL) { | ||
FtwLastWriteData = (FAULT_TOLERANT_WRITE_LAST_WRITE_DATA *)GET_GUID_HOB_DATA (GuidHob); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consult star about the code logic
**/ | ||
UINTN | ||
CalculateHobVariableCacheSize ( | ||
IN BOOLEAN AuthFlag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NvAuthFlag
} else { | ||
// | ||
// Need to calculate auth variable storage size converted from normal variable storage | ||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ASSERT (AuthFlag && !StoreInfo.AuthFlag);
UINTN | ||
CalculateAuthVarStorageSize ( | ||
IN VARIABLE_STORE_INFO *StoreInfo, | ||
IN VARIABLE_STORE_HEADER *NormalVarStorage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NormalHobVarStorage
@@ -58,10 +59,10 @@ UINTN mVariableRuntimeHobCacheBufferSize; | |||
UINTN mVariableRuntimeNvCacheBufferSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seperate patch to remove the unused global variable
mVariableRuntimeHobCacheBuffer = (VARIABLE_STORE_HEADER *)(UINTN)VariableRuntimeCacheHob->RuntimeHobCacheBuffer; | ||
mVariableRuntimeNvCacheBuffer = (VARIABLE_STORE_HEADER *)(UINTN)VariableRuntimeCacheHob->RuntimeNvCacheBuffer; | ||
mVariableRuntimeVolatileCacheBuffer = (VARIABLE_STORE_HEADER *)(UINTN)VariableRuntimeCacheHob->RuntimeVolatileCacheBuffer; | ||
mVariableRuntimeCachePendingUpdate = (BOOLEAN *)(UINTN)VariableRuntimeCacheHob->PendingUpdatePtr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a VARIABLE_RUNTIME_CACHE_CONTEXT_HOB global variable to cache the hob info
@@ -182,34 +176,12 @@ InitVariableCache ( | |||
|
|||
*TotalVariableCacheSize = ALIGN_VALUE (*TotalVariableCacheSize, sizeof (UINT32)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the alignment
UINT64 RuntimeHobCacheBuffer; | ||
UINT64 MaxRuntimeHobCacheSize; | ||
UINT64 RuntimeNvCacheBuffer; | ||
UINT64 MaxRuntimeNvCacheSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//RuntimeNvCachePages
39c76ac
to
e5994c9
Compare
This commit defines VARIABLE_RUNTIME_CACHE_INFO HOB. The HOB is used to store the address and size of the buffer that will be used for variable runtime service when the PcdEnableVariableRuntimeCache is TRUE. In following patches, when PcdEnableVariableRuntimeCache is TRUE, VariablePei module will install a callback of gEfiPeiMemoryDiscoveredPpiGuid to allocate needed buffer for different type cache, unblock the buffer and build HOB. Then VariableSmmRuntimeDxe driver will consume the gEdkiiVariableRuntimeCacheInfoHobGuid to initialize the variable runtime cache related content. Signed-off-by: Dun Tan <dun.tan@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Add MmUnblockMemoryLib in ArmVirtCloudHv.dsc. This lib will be required by VariablePei in following commits. Signed-off-by: Dun Tan <dun.tan@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Leif Lindholm <quic_llindhol@quicinc.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Cc: Gerd Hoffmann <kraxel@redhat.com>
Add MmUnblockMemoryLib in EmulatorPkg.dsc. This lib will be required by VariablePei in following commits. Signed-off-by: Dun Tan <dun.tan@intel.com> Cc: Andrew Fish <afish@apple.com> Cc: Ray Ni <ray.ni@intel.com>
Add MmUnblockMemoryLib in OvmfPkgIa32X64.dsc. This lib will be required by VariablePei in following commits. Signed-off-by: Dun Tan <dun.tan@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com>
Install the callback of gEfiPeiMemoryDiscoveredPpiGuid to create gEdkiiVariableRuntimeCacheInfoHobGuid in VariablePei module. When PcdEnableVariableRuntimeCache is TRUE, the callback will be installed to allocate the needed buffer for different type variable runtime cache, unblock the buffer and build this HOB. Then the runtime cache buffer address and size will be saved in the HOB content. Signed-off-by: Dun Tan <dun.tan@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Remove the two unnecessary global variables and replace them by two local variables: mVariableRuntimeNvCacheBufferSize mVariableRuntimeVolatileCacheBufferSize Signed-off-by: Dun Tan <dun.tan@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Consume gEdkiiVariableRuntimeCacheInfoHobGuid in VariableSmmRuntimeDxe driver to initialize the following variable cache related buffer: *mVariableRuntimeHobCacheBuffer *mVariableRuntimeNvCacheBuffer *mVariableRuntimeVolatileCacheBuffer *mVariableRuntimeCachePendingUpdate *mVariableRuntimeCacheReadLock *mHobFlushComplete The code to to allocate and unblock the buffer for different type cache in VariableSmmRuntimeDxe is also removed in this commit. Signed-off-by: Dun Tan <dun.tan@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Refine the code logic in InitVariableCache(). In this commit, three times calling of InitVariableCache() for different type cache are merged into one calling. This commit is to make the code looks cleaner and doesn't change any code functionality. Signed-off-by: Dun Tan <dun.tan@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Add global variable mVariableRtCacheInfo to save the content in gEdkiiVariableRuntimeCacheInfoHobGuid. With this new global variable, 7 global variables can be removed. Signed-off-by: Dun Tan <dun.tan@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
e5994c9
to
a54ec29
Compare
No description provided.