Message ID | 1466505034-10267-2-git-send-email-ard.biesheuvel@linaro.org |
---|---|
State | Accepted |
Commit | 8753858f84768fa6fa17191b86c97538457723ce |
Headers | show |
On 06/21/16 12:30, Ard Biesheuvel wrote: > Now that the generic Variable Runtime DXE code no longer distinguishes > between gEfiVariableGuid and gEfiAuthenticatedVariableGuid in the varstore > FV header, we can relax the check in the NOR flash driver to accept either > GUID regardless of whether we are running a secure boot capable build or not. > > This also means we can always use gEfiAuthenticatedVariableGuid when we > encounter an empty NOR flash that needs to be initialized before use. So > remove the mNorFlashVariableGuid global from the shared code and from both > versions of NorFlashDxe.inf. This essentially collapses the two drivers into > a single one, which means we can remove NorFlashAuthenticatedDxe entirely > in a subsequent patch. > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> > --- > ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedDxe.inf | 2 +- > ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedVariableDep.c | 19 ------------------- > ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h | 2 -- > ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf | 2 +- > ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c | 5 +++-- > ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashVariableDep.c | 19 ------------------- > 6 files changed, 5 insertions(+), 44 deletions(-) > > diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedDxe.inf b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedDxe.inf > index 6c5e6aef0ddf..0e25b8f6ed6d 100644 > --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedDxe.inf > +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedDxe.inf > @@ -28,7 +28,6 @@ [Sources.common] > NorFlashDxe.c > NorFlashFvbDxe.c > NorFlashBlockIoDxe.c > - NorFlashAuthenticatedVariableDep.c > > [Packages] > MdePkg/MdePkg.dec > @@ -50,6 +49,7 @@ [LibraryClasses] > > [Guids] > gEfiSystemNvDataFvGuid > + gEfiVariableGuid > gEfiAuthenticatedVariableGuid > gEfiEventVirtualAddressChangeGuid > > diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedVariableDep.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedVariableDep.c > deleted file mode 100644 > index 2ea8ead85d9b..000000000000 > --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedVariableDep.c > +++ /dev/null > @@ -1,19 +0,0 @@ > -/** @file NorFlashAuthenticatedVariableDep.c > - > - Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR> > - > - This program and the accompanying materials > - are licensed and made available under the terms and conditions of the BSD License > - which accompanies this distribution. The full text of the license may be found at > - http://opensource.org/licenses/bsd-license.php > - > - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > - > -**/ > - > -#include <Base.h> > - > -#include <Include/Guid/AuthenticatedVariableFormat.h> > - > -CONST EFI_GUID* CONST mNorFlashVariableGuid = &gEfiAuthenticatedVariableGuid; > diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h > index d0b5c5b12f9e..c24680098f62 100644 > --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h > +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h > @@ -152,8 +152,6 @@ struct _NOR_FLASH_INSTANCE { > NOR_FLASH_DEVICE_PATH DevicePath; > }; > > -extern CONST EFI_GUID* CONST mNorFlashVariableGuid; > - > EFI_STATUS > NorFlashReadCfiData ( > IN UINTN DeviceBaseAddress, > diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf > index 563d7573e7a2..812dafd065b2 100644 > --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf > +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf > @@ -26,7 +26,6 @@ [Sources.common] > NorFlashDxe.c > NorFlashFvbDxe.c > NorFlashBlockIoDxe.c > - NorFlashVariableDep.c > > [Packages] > MdePkg/MdePkg.dec > @@ -48,6 +47,7 @@ [LibraryClasses] > [Guids] > gEfiSystemNvDataFvGuid > gEfiVariableGuid > + gEfiAuthenticatedVariableGuid > gEfiEventVirtualAddressChangeGuid > > [Protocols] > diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c > index e0edc62c95eb..42be5c2a2dad 100644 > --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c > +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c > @@ -111,7 +111,7 @@ InitializeFvAndVariableStoreHeaders ( > // VARIABLE_STORE_HEADER > // > VariableStoreHeader = (VARIABLE_STORE_HEADER*)((UINTN)Headers + FirmwareVolumeHeader->HeaderLength); > - CopyGuid (&VariableStoreHeader->Signature, mNorFlashVariableGuid); > + CopyGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid); > VariableStoreHeader->Size = PcdGet32(PcdFlashNvStorageVariableSize) - FirmwareVolumeHeader->HeaderLength; > VariableStoreHeader->Format = VARIABLE_STORE_FORMATTED; > VariableStoreHeader->State = VARIABLE_STORE_HEALTHY; > @@ -181,7 +181,8 @@ ValidateFvHeader ( > VariableStoreHeader = (VARIABLE_STORE_HEADER*)((UINTN)FwVolHeader + FwVolHeader->HeaderLength); > > // Check the Variable Store Guid > - if (!CompareGuid (&VariableStoreHeader->Signature, mNorFlashVariableGuid)) { > + if (!CompareGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid) && > + !CompareGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid)) { > DEBUG ((EFI_D_INFO, "%a: Variable Store Guid non-compatible\n", > __FUNCTION__)); > return EFI_NOT_FOUND; > diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashVariableDep.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashVariableDep.c > deleted file mode 100644 > index 4d52296ce1a0..000000000000 > --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashVariableDep.c > +++ /dev/null > @@ -1,19 +0,0 @@ > -/** @file NorFlashVariableDep.c > - > - Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR> > - > - This program and the accompanying materials > - are licensed and made available under the terms and conditions of the BSD License > - which accompanies this distribution. The full text of the license may be found at > - http://opensource.org/licenses/bsd-license.php > - > - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > - > -**/ > - > -#include <Base.h> > - > -#include <Include/Guid/VariableFormat.h> > - > -CONST EFI_GUID* CONST mNorFlashVariableGuid = &gEfiVariableGuid; > Reviewed-by: Laszlo Ersek <lersek@redhat.com> _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedDxe.inf b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedDxe.inf index 6c5e6aef0ddf..0e25b8f6ed6d 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedDxe.inf +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedDxe.inf @@ -28,7 +28,6 @@ [Sources.common] NorFlashDxe.c NorFlashFvbDxe.c NorFlashBlockIoDxe.c - NorFlashAuthenticatedVariableDep.c [Packages] MdePkg/MdePkg.dec @@ -50,6 +49,7 @@ [LibraryClasses] [Guids] gEfiSystemNvDataFvGuid + gEfiVariableGuid gEfiAuthenticatedVariableGuid gEfiEventVirtualAddressChangeGuid diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedVariableDep.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedVariableDep.c deleted file mode 100644 index 2ea8ead85d9b..000000000000 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedVariableDep.c +++ /dev/null @@ -1,19 +0,0 @@ -/** @file NorFlashAuthenticatedVariableDep.c - - Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include <Base.h> - -#include <Include/Guid/AuthenticatedVariableFormat.h> - -CONST EFI_GUID* CONST mNorFlashVariableGuid = &gEfiAuthenticatedVariableGuid; diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h index d0b5c5b12f9e..c24680098f62 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h @@ -152,8 +152,6 @@ struct _NOR_FLASH_INSTANCE { NOR_FLASH_DEVICE_PATH DevicePath; }; -extern CONST EFI_GUID* CONST mNorFlashVariableGuid; - EFI_STATUS NorFlashReadCfiData ( IN UINTN DeviceBaseAddress, diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf index 563d7573e7a2..812dafd065b2 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf @@ -26,7 +26,6 @@ [Sources.common] NorFlashDxe.c NorFlashFvbDxe.c NorFlashBlockIoDxe.c - NorFlashVariableDep.c [Packages] MdePkg/MdePkg.dec @@ -48,6 +47,7 @@ [LibraryClasses] [Guids] gEfiSystemNvDataFvGuid gEfiVariableGuid + gEfiAuthenticatedVariableGuid gEfiEventVirtualAddressChangeGuid [Protocols] diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c index e0edc62c95eb..42be5c2a2dad 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c @@ -111,7 +111,7 @@ InitializeFvAndVariableStoreHeaders ( // VARIABLE_STORE_HEADER // VariableStoreHeader = (VARIABLE_STORE_HEADER*)((UINTN)Headers + FirmwareVolumeHeader->HeaderLength); - CopyGuid (&VariableStoreHeader->Signature, mNorFlashVariableGuid); + CopyGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid); VariableStoreHeader->Size = PcdGet32(PcdFlashNvStorageVariableSize) - FirmwareVolumeHeader->HeaderLength; VariableStoreHeader->Format = VARIABLE_STORE_FORMATTED; VariableStoreHeader->State = VARIABLE_STORE_HEALTHY; @@ -181,7 +181,8 @@ ValidateFvHeader ( VariableStoreHeader = (VARIABLE_STORE_HEADER*)((UINTN)FwVolHeader + FwVolHeader->HeaderLength); // Check the Variable Store Guid - if (!CompareGuid (&VariableStoreHeader->Signature, mNorFlashVariableGuid)) { + if (!CompareGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid) && + !CompareGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid)) { DEBUG ((EFI_D_INFO, "%a: Variable Store Guid non-compatible\n", __FUNCTION__)); return EFI_NOT_FOUND; diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashVariableDep.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashVariableDep.c deleted file mode 100644 index 4d52296ce1a0..000000000000 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashVariableDep.c +++ /dev/null @@ -1,19 +0,0 @@ -/** @file NorFlashVariableDep.c - - Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include <Base.h> - -#include <Include/Guid/VariableFormat.h> - -CONST EFI_GUID* CONST mNorFlashVariableGuid = &gEfiVariableGuid;
Now that the generic Variable Runtime DXE code no longer distinguishes between gEfiVariableGuid and gEfiAuthenticatedVariableGuid in the varstore FV header, we can relax the check in the NOR flash driver to accept either GUID regardless of whether we are running a secure boot capable build or not. This also means we can always use gEfiAuthenticatedVariableGuid when we encounter an empty NOR flash that needs to be initialized before use. So remove the mNorFlashVariableGuid global from the shared code and from both versions of NorFlashDxe.inf. This essentially collapses the two drivers into a single one, which means we can remove NorFlashAuthenticatedDxe entirely in a subsequent patch. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedDxe.inf | 2 +- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashAuthenticatedVariableDep.c | 19 ------------------- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h | 2 -- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf | 2 +- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c | 5 +++-- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashVariableDep.c | 19 ------------------- 6 files changed, 5 insertions(+), 44 deletions(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel