Re: [edk2] [PATCH v2] VariableDxe: convert mLockedVariableList to virtual addresses

Subject: Re: [edk2] [PATCH v2] VariableDxe: convert mLockedVariableList to virtual addresses

From: "Ni, Ruiyu" <ruiyu.ni@intel.com>

To: Laszlo Ersek <lersek@redhat.com>, "edk2-devel@lists.sourceforge.net" <edk2-devel@lists.sourceforge.net>

Date: 2013-06-13 10:02:08

Reviewed-by: Ruiyu Ni 

Do you have the rights to check in the patch? If not I can help to do that.

Thanks,
Ray

-----Original Message-----
From: Laszlo Ersek [mailto:lersek@redhat.com] 
Sent: Sunday, June 09, 2013 5:47 PM
To: Ni, Ruiyu; edk2-devel@lists.sourceforge.net
Subject: [PATCH v2] VariableDxe: convert mLockedVariableList to virtual addresses

The list of locked variables is traversed at runtime, hence we must
convert the list when transferring from physical to virtual mode.

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek 
---
 v2:
 - moved definition of "Entry" to function scope from block scope, in
   VariableClassAddressChangeEvent()

 .../Universal/Variable/RuntimeDxe/VariableDxe.c    |   23 ++++++++++++++++++++
 .../VariableAuthenticated/RuntimeDxe/VariableDxe.c |   23 ++++++++++++++++++++
 2 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
index 3cb2c6b..a697ae1 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
@@ -3,6 +3,7 @@
   Implement all four UEFI Runtime Variable services for the nonvolatile
   and volatile storage space and install variable architecture protocol.
   
+Copyright (C) 2013, Red Hat, Inc.
 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -21,6 +22,7 @@ extern VARIABLE_INFO_ENTRY *gVariableInfo; EFI_HANDLE mHandle = NULL; EFI_EVENT mVirtualAddressChangeEvent = NULL; EFI_EVENT mFtwRegistration = NULL; +extern LIST_ENTRY mLockedVariableList; extern BOOLEAN mEndOfDxe; EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock = { VariableLockRequestToLock }; @@ -220,6 +222,10 @@ VariableClassAddressChangeEvent ( IN VOID *Context ) { + LIST_ENTRY *Link; + VARIABLE_ENTRY *Entry; + EFI_STATUS Status; + EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetBlockSize); EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetPhysicalAddress); EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetAttributes); @@ -236,6 +242,23 @@ VariableClassAddressChangeEvent ( EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->VariableGlobal.HobVariableBase); EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal); EfiConvertPointer (0x0, (VOID **) &mNvVariableCache); + + // + // in the list of locked variables, convert the name pointers first + // + for ( Link = GetFirstNode (&mLockedVariableList) + ; !IsNull (&mLockedVariableList, Link) + ; Link = GetNextNode (&mLockedVariableList, Link) + ) { + Entry = BASE_CR (Link, VARIABLE_ENTRY, Link); + Status = EfiConvertPointer (0x0, (VOID **) &Entry->Name); + ASSERT_EFI_ERROR (Status); + } + // + // second, convert the list itself using UefiRuntimeLib + // + Status = EfiConvertList (0x0, &mLockedVariableList); + ASSERT_EFI_ERROR (Status); } diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableDxe.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableDxe.c index a2e764c..ef53a96 100644 --- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableDxe.c +++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableDxe.c @@ -2,6 +2,7 @@ Implement all four UEFI Runtime Variable services for the nonvolatile and volatile storage space and install variable architecture protocol. +Copyright (C) 2013, Red Hat, Inc. Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -21,6 +22,7 @@ extern VARIABLE_INFO_ENTRY *gVariableInfo; EFI_HANDLE mHandle = NULL; EFI_EVENT mVirtualAddressChangeEvent = NULL; EFI_EVENT mFtwRegistration = NULL; +extern LIST_ENTRY mLockedVariableList; extern BOOLEAN mEndOfDxe; EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock = { VariableLockRequestToLock }; @@ -220,6 +222,10 @@ VariableClassAddressChangeEvent ( IN VOID *Context ) { + LIST_ENTRY *Link; + VARIABLE_ENTRY *Entry; + EFI_STATUS Status; + EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetBlockSize); EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetPhysicalAddress); EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetAttributes); @@ -238,6 +244,23 @@ VariableClassAddressChangeEvent ( EfiConvertPointer (0x0, (VOID **) &mStorageArea); EfiConvertPointer (0x0, (VOID **) &mSerializationRuntimeBuffer); EfiConvertPointer (0x0, (VOID **) &mNvVariableCache); + + // + // in the list of locked variables, convert the name pointers first + // + for ( Link = GetFirstNode (&mLockedVariableList) + ; !IsNull (&mLockedVariableList, Link) + ; Link = GetNextNode (&mLockedVariableList, Link) + ) { + Entry = BASE_CR (Link, VARIABLE_ENTRY, Link); + Status = EfiConvertPointer (0x0, (VOID **) &Entry->Name); + ASSERT_EFI_ERROR (Status); + } + // + // second, convert the list itself using UefiRuntimeLib + // + Status = EfiConvertList (0x0, &mLockedVariableList); + ASSERT_EFI_ERROR (Status); } -- 1.7.1 ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel