VirtualBox

Ignore:
Timestamp:
Oct 29, 2015 4:30:44 AM (9 years ago)
Author:
vboxsync
Message:

EFI/Firmware: Merged in the svn:eol-style, svn:mime-type and trailing whitespace cleanup that was done after the initial UDK2014.SP1 import: svn merge /vendor/edk2/UDK2014.SP1 /vendor/edk2/current .

Location:
trunk/src/VBox/Devices/EFI/Firmware
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware

  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/AuthService.c

    r58459 r58466  
    44
    55Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    6 This program and the accompanying materials 
    7 are licensed and made available under the terms and conditions of the BSD License 
    8 which accompanies this distribution.  The full text of the license may be found at 
     6This program and the accompanying materials
     7are licensed and made available under the terms and conditions of the BSD License
     8which accompanies this distribution.  The full text of the license may be found at
    99http://opensource.org/licenses/bsd-license.php
    1010
    11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
     11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    1212WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    1313
     
    6262  ASSERT (mVariableModuleGlobal->HashContext[Physical] != NULL);
    6363  //
    64   // Check "AuthVarKeyDatabase" variable's existence. 
    65   // If it doesn't exist, create a new one with initial value of 0 and EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set. 
     64  // Check "AuthVarKeyDatabase" variable's existence.
     65  // If it doesn't exist, create a new one with initial value of 0 and EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set.
    6666  //
    6767  Status = FindVariable (
    68              mVariableModuleGlobal->VariableName[Physical][VAR_AUTH_KEY_DB], 
    69              &gEfiAuthenticatedVariableGuid, 
    70              &Variable, 
     68             mVariableModuleGlobal->VariableName[Physical][VAR_AUTH_KEY_DB],
     69             &gEfiAuthenticatedVariableGuid,
     70             &Variable,
    7171             &mVariableModuleGlobal->VariableGlobal[Physical],
    7272             mVariableModuleGlobal->FvbInstance
     
    9797    //
    9898    Valid = IsValidVariableHeader (
    99               Variable.CurrPtr, 
    100               Variable.Volatile, 
    101               &mVariableModuleGlobal->VariableGlobal[Physical], 
    102               mVariableModuleGlobal->FvbInstance, 
     99              Variable.CurrPtr,
     100              Variable.Volatile,
     101              &mVariableModuleGlobal->VariableGlobal[Physical],
     102              mVariableModuleGlobal->FvbInstance,
    103103              &VariableHeader
    104104              );
     
    118118  }
    119119  //
    120   // Check "SetupMode" variable's existence. 
     120  // Check "SetupMode" variable's existence.
    121121  // If it doesn't exist, check PK database's existence to determine the value.
    122   // Then create a new one with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set. 
     122  // Then create a new one with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set.
    123123  //
    124124  Status = FindVariable (
    125              mVariableModuleGlobal->VariableName[Physical][VAR_SETUP_MODE], 
    126              &gEfiGlobalVariableGuid, 
    127              &Variable, 
     125             mVariableModuleGlobal->VariableName[Physical][VAR_SETUP_MODE],
     126             &gEfiGlobalVariableGuid,
     127             &Variable,
    128128             &mVariableModuleGlobal->VariableGlobal[Physical],
    129129             mVariableModuleGlobal->FvbInstance
     
    132132  if (Variable.CurrPtr == 0x0) {
    133133    Status = FindVariable (
    134                mVariableModuleGlobal->VariableName[Physical][VAR_PLATFORM_KEY], 
    135                &gEfiGlobalVariableGuid, 
    136                &Variable, 
     134               mVariableModuleGlobal->VariableName[Physical][VAR_PLATFORM_KEY],
     135               &gEfiGlobalVariableGuid,
     136               &Variable,
    137137               &mVariableModuleGlobal->VariableGlobal[Physical],
    138138               mVariableModuleGlobal->FvbInstance
     
    170170  }
    171171  //
    172   // Check "SignatureSupport" variable's existence. 
    173   // If it doesn't exist, then create a new one with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set. 
     172  // Check "SignatureSupport" variable's existence.
     173  // If it doesn't exist, then create a new one with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set.
    174174  //
    175175  Status = FindVariable (
    176              EFI_SIGNATURE_SUPPORT_NAME, 
    177              &gEfiGlobalVariableGuid, 
    178              &Variable, 
     176             EFI_SIGNATURE_SUPPORT_NAME,
     177             &gEfiGlobalVariableGuid,
     178             &Variable,
    179179             &mVariableModuleGlobal->VariableGlobal[Physical],
    180180             mVariableModuleGlobal->FvbInstance
     
    365365  Rsa = RsaNew ();
    366366  ASSERT (Rsa != NULL);
    367   // 
     367  //
    368368  // Set RSA Key Components.
    369369  // NOTE: Only N and E are needed to be set as RSA public key for signature verification.
     
    381381  //
    382382  Status = RsaPkcs1Verify (
    383              Rsa, 
    384              Digest, 
    385              SHA256_DIGEST_SIZE, 
    386              CertBlock->Signature, 
     383             Rsa,
     384             Digest,
     385             SHA256_DIGEST_SIZE,
     386             CertBlock->Signature,
    387387             EFI_CERT_TYPE_RSA2048_SHA256_SIZE
    388388             );
     
    420420
    421421  Status = FindVariable (
    422              Global->VariableName[VirtualMode][VAR_SETUP_MODE], 
    423              Global->GlobalVariableGuid[VirtualMode], 
    424              &Variable, 
     422             Global->VariableName[VirtualMode][VAR_SETUP_MODE],
     423             Global->GlobalVariableGuid[VirtualMode],
     424             &Variable,
    425425             &Global->VariableGlobal[VirtualMode],
    426426             Global->FvbInstance
     
    460460
    461461  @retval EFI_INVALID_PARAMETER           Invalid parameter.
    462   @retval EFI_SECURITY_VIOLATION          The variable does NOT pass the validation 
    463                                           check carried out by the firmware. 
     462  @retval EFI_SECURITY_VIOLATION          The variable does NOT pass the validation
     463                                          check carried out by the firmware.
    464464  @retval EFI_SUCCESS                     The variable passed validation successfully.
    465465
     
    508508    if (Variable->CurrPtr != 0x0) {
    509509      Valid = IsValidVariableHeader (
    510                 Variable->CurrPtr, 
    511                 Variable->Volatile, 
    512                 &Global->VariableGlobal[VirtualMode], 
    513                 Global->FvbInstance, 
     510                Variable->CurrPtr,
     511                Variable->Volatile,
     512                &Global->VariableGlobal[VirtualMode],
     513                Global->FvbInstance,
    514514                &VariableHeader
    515515                );
     
    527527    //
    528528    Status = FindVariable (
    529                Global->VariableName[VirtualMode][VAR_PLATFORM_KEY], 
    530                Global->GlobalVariableGuid[VirtualMode], 
    531                &PkVariable, 
     529               Global->VariableName[VirtualMode][VAR_PLATFORM_KEY],
     530               Global->GlobalVariableGuid[VirtualMode],
     531               &PkVariable,
    532532               &Global->VariableGlobal[VirtualMode],
    533533               Global->FvbInstance
     
    549549    if (!EFI_ERROR (Status)) {
    550550      Status = UpdateVariable (
    551                  VariableName, 
    552                  VendorGuid, 
    553                  (UINT8*)Data + AUTHINFO_SIZE, 
    554                  DataSize - AUTHINFO_SIZE, 
    555                  Attributes, 
    556                  0, 
    557                  CertData->MonotonicCount, 
    558                  VirtualMode, 
     551                 VariableName,
     552                 VendorGuid,
     553                 (UINT8*)Data + AUTHINFO_SIZE,
     554                 DataSize - AUTHINFO_SIZE,
     555                 Attributes,
     556                 0,
     557                 CertData->MonotonicCount,
     558                 VirtualMode,
    559559                 Global,
    560560                 Variable
     
    597597
    598598  @retval EFI_INVALID_PARAMETER           Invalid parameter.
    599   @retval EFI_SECURITY_VIOLATION          The variable did NOT pass the validation 
    600                                           check carried out by the firmware. 
     599  @retval EFI_SECURITY_VIOLATION          The variable did NOT pass the validation
     600                                          check carried out by the firmware.
    601601  @retval EFI_SUCCESS                     The variable passed validation successfully.
    602602
     
    641641    if (Variable->CurrPtr != 0x0) {
    642642      Valid = IsValidVariableHeader (
    643                 Variable->CurrPtr, 
    644                 Variable->Volatile, 
    645                 &Global->VariableGlobal[VirtualMode], 
    646                 Global->FvbInstance, 
     643                Variable->CurrPtr,
     644                Variable->Volatile,
     645                &Global->VariableGlobal[VirtualMode],
     646                Global->FvbInstance,
    647647                &VariableHeader
    648648                );
     
    660660    //
    661661    Status = FindVariable (
    662                Global->VariableName[VirtualMode][VAR_KEY_EXCHANGE_KEY], 
    663                Global->GlobalVariableGuid[VirtualMode], 
    664                &KekVariable, 
     662               Global->VariableName[VirtualMode][VAR_KEY_EXCHANGE_KEY],
     663               Global->GlobalVariableGuid[VirtualMode],
     664               &KekVariable,
    665665               &Global->VariableGlobal[VirtualMode],
    666666               Global->FvbInstance
     
    699699    if (!EFI_ERROR (Status)) {
    700700      Status = UpdateVariable (
    701                  VariableName, 
    702                  VendorGuid, 
    703                  (UINT8*)Data + AUTHINFO_SIZE, 
    704                  DataSize - AUTHINFO_SIZE, 
    705                  Attributes, 
    706                  0, 
    707                  CertData->MonotonicCount, 
     701                 VariableName,
     702                 VendorGuid,
     703                 (UINT8*)Data + AUTHINFO_SIZE,
     704                 DataSize - AUTHINFO_SIZE,
     705                 Attributes,
     706                 0,
     707                 CertData->MonotonicCount,
    708708                 VirtualMode,
    709709                 Global,
     
    716716    //
    717717    Status = UpdateVariable (
    718                VariableName, 
    719                VendorGuid, 
    720                Data, 
    721                DataSize, 
    722                Attributes, 
    723                0, 
    724                0, 
     718               VariableName,
     719               VendorGuid,
     720               Data,
     721               DataSize,
     722               Attributes,
     723               0,
     724               0,
    725725               VirtualMode,
    726726               Global,
     
    749749                                          EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set.
    750750  @retval EFI_SECURITY_VIOLATION          The variable is with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
    751                                           set, but the AuthInfo does NOT pass the validation 
    752                                           check carried out by the firmware. 
     751                                          set, but the AuthInfo does NOT pass the validation
     752                                          check carried out by the firmware.
    753753  @retval EFI_SUCCESS                     The variable is not write-protected, or passed validation successfully.
    754754
     
    790790  if (Variable->CurrPtr != 0x0) {
    791791    Valid = IsValidVariableHeader (
    792               Variable->CurrPtr, 
    793               Variable->Volatile, 
    794               &Global->VariableGlobal[VirtualMode], 
    795               Global->FvbInstance, 
     792              Variable->CurrPtr,
     793              Variable->Volatile,
     794              &Global->VariableGlobal[VirtualMode],
     795              Global->FvbInstance,
    796796              &VariableHeader
    797797              );
     
    821821      IsFirstTime = FALSE;
    822822    }
    823   } else if (Valid && (VariableHeader.Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) { 
     823  } else if (Valid && (VariableHeader.Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {
    824824      //
    825825      // If the variable is already write-protected, it always needs authentication before update.
     
    865865      return EFI_SECURITY_VIOLATION;
    866866    }
    867   } 
     867  }
    868868  //
    869869  // Verify the certificate in Data payload.
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/AuthService.h

    r48674 r58466  
    44
    55Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
    6 This program and the accompanying materials 
    7 are licensed and made available under the terms and conditions of the BSD License 
    8 which accompanies this distribution.  The full text of the license may be found at 
     6This program and the accompanying materials
     7are licensed and made available under the terms and conditions of the BSD License
     8which accompanies this distribution.  The full text of the license may be found at
    99http://opensource.org/licenses/bsd-license.php
    1010
    11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
     11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    1212WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    1313
     
    4747                                          EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set.
    4848  @retval EFI_SECURITY_VIOLATION          The variable is with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
    49                                           set, but the AuthInfo does NOT pass the validation 
    50                                           check carried out by the firmware. 
     49                                          set, but the AuthInfo does NOT pass the validation
     50                                          check carried out by the firmware.
    5151  @retval EFI_SUCCESS                     The variable is not write-protected, or passed validation successfully.
    5252
     
    100100
    101101  @retval EFI_INVALID_PARAMETER           Invalid parameter.
    102   @retval EFI_SECURITY_VIOLATION          The variable does NOT pass the validation 
    103                                           check carried out by the firmware. 
     102  @retval EFI_SECURITY_VIOLATION          The variable does NOT pass the validation
     103                                          check carried out by the firmware.
    104104  @retval EFI_SUCCESS                     The variable passed validation successfully.
    105105
     
    132132
    133133  @retval EFI_INVALID_PARAMETER           Invalid parameter.
    134   @retval EFI_SECURITY_VIOLATION          The variable does NOT pass the validation 
    135                                           check carried out by the firmware. 
     134  @retval EFI_SECURITY_VIOLATION          The variable does NOT pass the validation
     135                                          check carried out by the firmware.
    136136  @retval EFI_SUCCESS                     The variable passed validation successfully.
    137137
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.inf

    r58459 r58466  
    3030#  VALID_ARCHITECTURES           = IPF
    3131#
    32 #  VIRTUAL_ADDRESS_MAP_CALLBACK  =  VariableClassAddressChangeEvent             
     32#  VIRTUAL_ADDRESS_MAP_CALLBACK  =  VariableClassAddressChangeEvent
    3333#
    3434
     
    7474  ## PRODUCES             ## Variable:L"SignatureSupport"
    7575  gEfiGlobalVariableGuid
    76  
     76
    7777  ## PRODUCES             ## GUID # Variable store header
    7878  ## CONSUMES             ## GUID # Variable store header
     
    8080  ## SOMETIMES_PRODUCES   ## SystemTable
    8181  gEfiAuthenticatedVariableGuid
    82  
     82
    8383  gEfiEventVirtualAddressChangeGuid             ## CONSUMES               ## Event
    8484  gEfiCertRsa2048Sha256Guid                     ## CONSUMES               ## GUID        # Unique ID for the format of the CertType.
     
    9595  gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize                     ## CONSUMES
    9696  gEfiMdeModulePkgTokenSpaceGuid.PcdHwErrStorageSize                      ## CONSUMES
    97  
     97
    9898[FeaturePcd.common]
    9999  gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics             ## CONSUMES    # statistic the information of variable.
    100100
    101101[Depex]
    102   gEfiExtendedSalFvBlockServicesProtocolGuid AND gEfiFaultTolerantWriteProtocolGuid 
     102  gEfiExtendedSalFvBlockServicesProtocolGuid AND gEfiFaultTolerantWriteProtocolGuid
    103103
    104104[UserExtensions.TianoCore."ExtraFiles"]
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/InitVariable.c

    r48674 r58466  
    33
    44Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
    5 This program and the accompanying materials 
    6 are licensed and made available under the terms and conditions of the BSD License 
    7 which accompanies this distribution.  The full text of the license may be found at 
     5This program and the accompanying materials
     6are licensed and made available under the terms and conditions of the BSD License
     7which accompanies this distribution.  The full text of the license may be found at
    88http://opensource.org/licenses/bsd-license.php
    99
    10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
     10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    1111WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    1212
     
    5656{
    5757  SAL_RETURN_REGS ReturnVal;
    58  
     58
    5959  ReturnVal.r9  = 0;
    6060  ReturnVal.r10 = 0;
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Reclaim.c

    r48674 r58466  
    44
    55Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
    6 This program and the accompanying materials 
    7 are licensed and made available under the terms and conditions of the BSD License 
    8 which accompanies this distribution.  The full text of the license may be found at 
     6This program and the accompanying materials
     7are licensed and made available under the terms and conditions of the BSD License
     8which accompanies this distribution.  The full text of the license may be found at
    99http://opensource.org/licenses/bsd-license.php
    1010
    11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
     11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    1212WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    1313
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c

    r58459 r58466  
    33
    44Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    5 This program and the accompanying materials 
    6 are licensed and made available under the terms and conditions of the BSD License 
    7 which accompanies this distribution.  The full text of the license may be found at 
     5This program and the accompanying materials
     6are licensed and made available under the terms and conditions of the BSD License
     7which accompanies this distribution.  The full text of the license may be found at
    88http://opensource.org/licenses/bsd-license.php
    99
    10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
     10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    1111WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    1212
     
    163163      return EFI_INVALID_PARAMETER;
    164164    }
    165    
     165
    166166    //
    167167    // For volatile variable, a simple memory copy is enough.
     
    182182                          EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,
    183183                          EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,
    184                           GetPhysicalAddressFunctionId, 
    185                           Instance, 
    186                           (UINT64) &FvVolHdr, 
    187                           0, 
    188                           0, 
    189                           0, 
    190                           0, 
     184                          GetPhysicalAddressFunctionId,
     185                          Instance,
     186                          (UINT64) &FvVolHdr,
     187                          0,
     188                          0,
     189                          0,
     190                          0,
    191191                          0
    192192                          ).Status;
     
    200200    return EFI_INVALID_PARAMETER;
    201201  }
    202  
     202
    203203  LinearOffset  = (UINTN) FwVolHeader;
    204204  CurrWritePtr  = StartAddress;
     
    228228                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,
    229229                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,
    230                                     WriteFunctionId, 
    231                                     Instance, 
    232                                     LbaNumber, 
    233                                     (CurrWritePtr - LinearOffset), 
    234                                     (UINT64) &CurrWriteSize, 
    235                                     (UINT64) CurrBuffer, 
    236                                     0, 
     230                                    WriteFunctionId,
     231                                    Instance,
     232                                    LbaNumber,
     233                                    (CurrWritePtr - LinearOffset),
     234                                    (UINT64) &CurrWriteSize,
     235                                    (UINT64) CurrBuffer,
     236                                    0,
    237237                                    0
    238238                                    ).Status;
     
    241241                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,
    242242                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,
    243                                     ReadFunctionId, 
    244                                     Instance, 
    245                                     LbaNumber, 
    246                                     (CurrWritePtr - LinearOffset), 
    247                                     (UINT64) &CurrWriteSize, 
    248                                     (UINT64) CurrBuffer, 
    249                                     0, 
     243                                    ReadFunctionId,
     244                                    Instance,
     245                                    LbaNumber,
     246                                    (CurrWritePtr - LinearOffset),
     247                                    (UINT64) &CurrWriteSize,
     248                                    (UINT64) CurrBuffer,
     249                                    0,
    250250                                    0
    251251                                    ).Status;
     
    261261                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,
    262262                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,
    263                                     WriteFunctionId, 
    264                                     Instance, 
    265                                     LbaNumber, 
    266                                     (CurrWritePtr - LinearOffset), 
    267                                     (UINT64) &Size, 
    268                                     (UINT64) CurrBuffer, 
    269                                     0, 
     263                                    WriteFunctionId,
     264                                    Instance,
     265                                    LbaNumber,
     266                                    (CurrWritePtr - LinearOffset),
     267                                    (UINT64) &Size,
     268                                    (UINT64) CurrBuffer,
     269                                    0,
    270270                                    0
    271271                                    ).Status;
     
    274274                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,
    275275                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,
    276                                     ReadFunctionId, 
    277                                     Instance, 
    278                                     LbaNumber, 
    279                                     (CurrWritePtr - LinearOffset), 
    280                                     (UINT64) &Size, 
    281                                     (UINT64) CurrBuffer, 
    282                                     0, 
     276                                    ReadFunctionId,
     277                                    Instance,
     278                                    LbaNumber,
     279                                    (CurrWritePtr - LinearOffset),
     280                                    (UINT64) &Size,
     281                                    (UINT64) CurrBuffer,
     282                                    0,
    283283                                    0
    284284                                    ).Status;
     
    333333             VarStoreAddress,
    334334             sizeof (VARIABLE_STORE_HEADER),
    335              VarStoreHeader   
     335             VarStoreHeader
    336336             );
    337337  ASSERT_EFI_ERROR (Status);
     
    373373             VariableAddress,
    374374             sizeof (VARIABLE_HEADER),
    375              &LocalVariableHeader   
     375             &LocalVariableHeader
    376376             );
    377377
     
    521521             Address,
    522522             VariableHeader.NameSize,
    523              VariableName   
     523             VariableName
    524524             );
    525525  ASSERT_EFI_ERROR (Status);
     
    572572             Address,
    573573             VariableHeader.DataSize,
    574              VariableData   
     574             VariableData
    575575             );
    576576  ASSERT_EFI_ERROR (Status);
     
    627627  Gets the pointer to the first variable header in given variable store area.
    628628
    629   This function gets the pointer to the first variable header in given variable 
     629  This function gets the pointer to the first variable header in given variable
    630630  store area. The variable store area is given by its start address.
    631631
     
    676676             VarStoreHeaderAddress,
    677677             sizeof (VARIABLE_STORE_HEADER),
    678              &VariableStoreHeader   
     678             &VariableStoreHeader
    679679             );
    680680
     
    686686  Updates variable info entry in EFI system table for statistical information.
    687687
    688   Routine used to track statistical information about variable usage. 
     688  Routine used to track statistical information about variable usage.
    689689  The data is stored in the EFI system table so it can be accessed later.
    690   VariableInfo.efi can dump out the table. Only Boot Services variable 
     690  VariableInfo.efi can dump out the table. Only Boot Services variable
    691691  accesses are tracked by this code. The PcdVariableCollectStatistics
    692   build flag controls if this feature is enabled. 
    693   A read that hits in the cache will have Read and Cache true for 
     692  build flag controls if this feature is enabled.
     693  A read that hits in the cache will have Read and Cache true for
    694694  the transaction. Data is allocated by this routine, but never
    695695  freed.
     
    743743    }
    744744
    745    
     745
    746746    for (Entry = gVariableInfo; Entry != NULL; Entry = Entry->Next) {
    747747      if (CompareGuid (VendorGuid, &Entry->VendorGuid)) {
     
    827827  for (Index = 0, Entry = mVariableCache; Index < sizeof (mVariableCache)/sizeof (VARIABLE_CACHE_ENTRY); Index++, Entry++) {
    828828    if (CompareGuid (VendorGuid, Entry->Guid)) {
    829       if (StrCmp (VariableName, Entry->Name) == 0) { 
     829      if (StrCmp (VariableName, Entry->Name) == 0) {
    830830        Entry->Attributes = Attributes;
    831831        if (DataSize == 0) {
     
    929929    }
    930930  }
    931  
     931
    932932  return EFI_NOT_FOUND;
    933933}
     
    10041004    }
    10051005    while (IsValidVariableHeader (Variable[Index], Volatile, Global, Instance, &VariableHeader)) {
    1006       if (VariableHeader.State == VAR_ADDED || 
     1006      if (VariableHeader.State == VAR_ADDED ||
    10071007          VariableHeader.State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)
    10081008         ) {
     
    11631163    // Collect VAR_ADDED variables, and variables in delete transition status.
    11641164    //
    1165     if (VariableHeader.State == VAR_ADDED || 
     1165    if (VariableHeader.State == VAR_ADDED ||
    11661166        VariableHeader.State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)
    11671167       ) {
     
    11741174
    11751175  //
    1176   // Reserve the 1 Bytes with Oxff to identify the 
    1177   // end of the variable buffer. 
    1178   // 
     1176  // Reserve the 1 Bytes with Oxff to identify the
     1177  // end of the variable buffer.
     1178  //
    11791179  MaximumBufferSize += 1;
    11801180  ValidBuffer = AllocatePool (MaximumBufferSize);
     
    11931193  //
    11941194  // Reinstall all ADDED variables
    1195   // 
     1195  //
    11961196  Variable = GetStartPointer (VariableBase);
    11971197  while (IsValidVariableHeader (Variable, IsVolatile, VariableGlobal, Instance, &VariableHeader)) {
     
    12111211  //
    12121212  // Reinstall in delete transition variables
    1213   // 
     1213  //
    12141214  Variable = GetStartPointer (VariableBase);
    12151215  while (IsValidVariableHeader (Variable, IsVolatile, VariableGlobal, Instance, &VariableHeader)) {
     
    12181218
    12191219      //
    1220       // Buffer has cached all ADDED variable. 
     1220      // Buffer has cached all ADDED variable.
    12211221      // Per IN_DELETED variable, we have to guarantee that
    1222       // no ADDED one in previous buffer. 
    1223       // 
     1222      // no ADDED one in previous buffer.
     1223      //
    12241224      FoundAdded = FALSE;
    12251225      AddedVariable = GetStartPointer ((EFI_PHYSICAL_ADDRESS) ValidBuffer);
     
    13281328  IN  CHAR8            *Lang,
    13291329  IN  BOOLEAN          Iso639Language
    1330   ) 
     1330  )
    13311331{
    13321332  UINTN    Index;
     
    13631363      //
    13641364      for (CompareLength = 0; SupportedLang[CompareLength] != '\0' && SupportedLang[CompareLength] != ';'; CompareLength++);
    1365      
    1366       if ((CompareLength == LanguageLength) && 
     1365
     1366      if ((CompareLength == LanguageLength) &&
    13671367          (AsciiStrnCmp (Lang, SupportedLang, CompareLength) == 0)) {
    13681368        //
     
    14661466
    14671467/**
    1468   Returns a pointer to an allocated buffer that contains the best matching language 
    1469   from a set of supported languages. 
    1470  
    1471   This function supports both ISO 639-2 and RFC 4646 language codes, but language 
     1468  Returns a pointer to an allocated buffer that contains the best matching language
     1469  from a set of supported languages.
     1470
     1471  This function supports both ISO 639-2 and RFC 4646 language codes, but language
    14721472  code types may not be mixed in a single call to this function. This function
    14731473  supports a variable argument list that allows the caller to pass in a prioritized
     
    14771477
    14781478  @param[in]  SupportedLanguages  A pointer to a Null-terminated ASCII string that
    1479                                   contains a set of language codes in the format 
     1479                                  contains a set of language codes in the format
    14801480                                  specified by Iso639Language.
    14811481  @param[in]  Iso639Language      If TRUE, then all language codes are assumed to be
     
    14831483                                  codes are assumed to be in RFC 4646 language format.
    14841484  @param[in]  VirtualMode         Current calling mode for this function.
    1485   @param[in]  ...                 A variable argument list that contains pointers to 
     1485  @param[in]  ...                 A variable argument list that contains pointers to
    14861486                                  Null-terminated ASCII strings that contain one or more
    14871487                                  language codes in the format specified by Iso639Language.
    14881488                                  The first language code from each of these language
    14891489                                  code lists is used to determine if it is an exact or
    1490                                   close match to any of the language codes in 
     1490                                  close match to any of the language codes in
    14911491                                  SupportedLanguages.  Close matches only apply to RFC 4646
    14921492                                  language codes, and the matching algorithm from RFC 4647
    1493                                   is used to determine if a close match is present.  If 
     1493                                  is used to determine if a close match is present.  If
    14941494                                  an exact or close match is found, then the matching
    14951495                                  language code from SupportedLanguages is returned.  If
    14961496                                  no matches are found, then the next variable argument
    1497                                   parameter is evaluated.  The variable argument list 
     1497                                  parameter is evaluated.  The variable argument list
    14981498                                  is terminated by a NULL.
    14991499
    15001500  @retval NULL   The best matching language could not be found in SupportedLanguages.
    1501   @retval NULL   There are not enough resources available to return the best matching 
     1501  @retval NULL   There are not enough resources available to return the best matching
    15021502                 language.
    1503   @retval Other  A pointer to a Null-terminated ASCII string that is the best matching 
     1503  @retval Other  A pointer to a Null-terminated ASCII string that is the best matching
    15041504                 language in SupportedLanguages.
    15051505
     
    15071507CHAR8 *
    15081508VariableGetBestLanguage (
    1509   IN CONST CHAR8  *SupportedLanguages, 
     1509  IN CONST CHAR8  *SupportedLanguages,
    15101510  IN BOOLEAN      Iso639Language,
    15111511  IN BOOLEAN      VirtualMode,
     
    15831583      } else {
    15841584        //
    1585         // If RFC 4646 mode, then trim Language from the right to the next '-' character 
     1585        // If RFC 4646 mode, then trim Language from the right to the next '-' character
    15861586        //
    15871587        for (LanguageLength--; LanguageLength > 0 && Language[LanguageLength] != '-'; LanguageLength--);
     
    15921592
    15931593  //
    1594   // No matches were found 
     1594  // No matches were found
    15951595  //
    15961596  return NULL;
     
    16651665
    16661666    //
    1667     // PlatformLang holds a single language from PlatformLangCodes, 
     1667    // PlatformLang holds a single language from PlatformLangCodes,
    16681668    // so the size of PlatformLangCodes is enough for the PlatformLang.
    16691669    //
     
    16951695  }
    16961696
    1697   if (SetLanguageCodes 
     1697  if (SetLanguageCodes
    16981698      && (Global->PlatformLangCodes[VirtualMode] != NULL)
    16991699      && (Global->LangCodes[VirtualMode] != NULL)) {
     
    17331733               sizeof (DataSize),
    17341734               &DataSize
    1735                ); 
     1735               );
    17361736    ASSERT_EFI_ERROR (Status);
    17371737  }
     
    18121812
    18131813        Status = UpdateVariable (
    1814                    PredefinedVariableName[VAR_PLATFORM_LANG], 
    1815                    Global->GlobalVariableGuid[VirtualMode], 
    1816                    BestPlatformLang, 
    1817                    AsciiStrSize (BestPlatformLang), 
    1818                    Attributes, 
     1814                   PredefinedVariableName[VAR_PLATFORM_LANG],
     1815                   Global->GlobalVariableGuid[VirtualMode],
     1816                   BestPlatformLang,
     1817                   AsciiStrSize (BestPlatformLang),
     1818                   Attributes,
    18191819                   0,
    18201820                   0,
    1821                    VirtualMode, 
    1822                    Global, 
     1821                   VirtualMode,
     1822                   Global,
    18231823                   &Variable
    18241824                   );
     
    18321832
    18331833/**
    1834   Update the variable region with Variable information. These are the same 
     1834  Update the variable region with Variable information. These are the same
    18351835  arguments as the EFI Variable services.
    18361836
     
    18411841  @param[in] Attributes         Attributes of the variable.
    18421842  @param[in] KeyIndex           Index of associated public key.
    1843   @param[in] MonotonicCount     Value of associated monotonic count. 
     1843  @param[in] MonotonicCount     Value of associated monotonic count.
    18441844  @param[in] VirtualMode        Current calling mode for this function.
    18451845  @param[in] Global             Context of this Extended SAL Variable Services Class call.
     
    18571857  IN      VOID                    *Data,
    18581858  IN      UINTN                   DataSize,
    1859   IN      UINT32                  Attributes OPTIONAL, 
     1859  IN      UINT32                  Attributes OPTIONAL,
    18601860  IN      UINT32                  KeyIndex  OPTIONAL,
    18611861  IN      UINT64                  MonotonicCount  OPTIONAL,
     
    18991899    //
    19001900    Volatile = Variable->Volatile;
    1901    
    1902     if (EfiAtRuntime ()) {       
    1903       //
    1904       // If EfiAtRuntime and the variable is Volatile and Runtime Access, 
    1905       // the volatile is ReadOnly, and SetVariable should be aborted and 
     1901
     1902    if (EfiAtRuntime ()) {
     1903      //
     1904      // If EfiAtRuntime and the variable is Volatile and Runtime Access,
     1905      // the volatile is ReadOnly, and SetVariable should be aborted and
    19061906      // return EFI_WRITE_PROTECTED.
    19071907      //
     
    19151915      if ((VariableHeader.Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {
    19161916        Status = EFI_INVALID_PARAMETER;
    1917         goto Done;     
     1917        goto Done;
    19181918      }
    19191919    }
     
    19221922    // specified causes it to be deleted.
    19231923    //
    1924     if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {   
     1924    if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {
    19251925      State = VariableHeader.State;
    19261926      State &= VAR_DELETED;
     
    19341934                 sizeof (UINT8),
    19351935                 &State
    1936                  ); 
     1936                 );
    19371937      if (!EFI_ERROR (Status)) {
    19381938        UpdateVariableInfo (VariableName, VendorGuid, Volatile, FALSE, FALSE, TRUE, FALSE);
    19391939        UpdateVariableCache (VariableName, VendorGuid, Attributes, DataSize, Data);
    19401940      }
    1941       goto Done;     
     1941      goto Done;
    19421942    }
    19431943    //
     
    19721972                 sizeof (UINT8),
    19731973                 &State
    1974                  );     
     1974                 );
    19751975      if (EFI_ERROR (Status)) {
    1976         goto Done; 
    1977       }
    1978     }   
     1976        goto Done;
     1977      }
     1978    }
    19791979  } else {
    19801980    //
    19811981    // Create a new variable
    1982     // 
    1983    
     1982    //
     1983
    19841984    //
    19851985    // Make sure we are trying to create a new variable.
    1986     // Setting a data variable with no access, or zero DataSize attributes means to delete it.   
     1986    // Setting a data variable with no access, or zero DataSize attributes means to delete it.
    19871987    //
    19881988    if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {
     
    19901990      goto Done;
    19911991    }
    1992    
     1992
    19931993    //
    19941994    // Only variable have NV|RT attribute can be created in Runtime
     
    19981998      Status = EFI_INVALID_PARAMETER;
    19991999      goto Done;
    2000     }         
     2000    }
    20012001  }
    20022002
     
    20512051    //
    20522052    Volatile = FALSE;
    2053    
     2053
    20542054    GetVarStoreHeader (VariableGlobal->NonVolatileVariableBase, FALSE, VariableGlobal, Instance, &VariableStoreHeader);
    2055     if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) 
     2055    if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0)
    20562056             && ((HEADER_ALIGN (VarSize) + Global->HwErrVariableTotalSize) > PcdGet32(PcdHwErrStorageSize)))
    2057              || (((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == 0) 
     2057             || (((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == 0)
    20582058             && ((HEADER_ALIGN (VarSize) + Global->CommonVariableTotalSize) > VariableStoreHeader.Size - sizeof (VARIABLE_STORE_HEADER) - PcdGet32(PcdHwErrStorageSize)))) {
    20592059      if (EfiAtRuntime ()) {
     
    20732073      // If still no enough space, return out of resources
    20742074      //
    2075       if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) 
     2075      if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0)
    20762076               && ((HEADER_ALIGN (VarSize) + Global->HwErrVariableTotalSize) > PcdGet32(PcdHwErrStorageSize)))
    2077                || (((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == 0) 
     2077               || (((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == 0)
    20782078               && ((HEADER_ALIGN (VarSize) + Global->CommonVariableTotalSize) > VariableStoreHeader.Size - sizeof (VARIABLE_STORE_HEADER) - PcdGet32(PcdHwErrStorageSize)))) {
    20792079        Status = EFI_OUT_OF_RESOURCES;
     
    20842084    // Four steps
    20852085    // 1. Write variable header
    2086     // 2. Set variable state to header valid 
     2086    // 2. Set variable state to header valid
    20872087    // 3. Write variable data
    20882088    // 4. Set variable state to valid
     
    21662166    //
    21672167    // Create a volatile variable
    2168     //     
     2168    //
    21692169    Volatile = TRUE;
    21702170
     
    22412241  This function implements EsalGetVariable function of Extended SAL Variable Services Class.
    22422242  It is equivalent in functionality to the EFI Runtime Service GetVariable().
    2243  
     2243
    22442244  @param[in]      VariableName    A Null-terminated Unicode string that is the name of
    22452245                                  the vendor's variable.
    22462246  @param[in]      VendorGuid      A unique identifier for the vendor.
    2247   @param[out]     Attributes      If not NULL, a pointer to the memory location to return the 
     2247  @param[out]     Attributes      If not NULL, a pointer to the memory location to return the
    22482248                                  attributes bitmask for the variable.
    22492249  @param[in, out] DataSize        Size of Data found. If size is less than the
    22502250                                  data, this value contains the required size.
    2251   @param[out]     Data            On input, the size in bytes of the return Data buffer. 
     2251  @param[out]     Data            On input, the size in bytes of the return Data buffer.
    22522252                                  On output, the size of data returned in Data.
    22532253  @param[in]      VirtualMode     Current calling mode for this function.
    22542254  @param[in]      Global          Context of this Extended SAL Variable Services Class call.
    22552255
    2256   @retval EFI_SUCCESS            The function completed successfully. 
     2256  @retval EFI_SUCCESS            The function completed successfully.
    22572257  @retval EFI_NOT_FOUND          The variable was not found.
    2258   @retval EFI_BUFFER_TOO_SMALL   DataSize is too small for the result.  DataSize has 
     2258  @retval EFI_BUFFER_TOO_SMALL   DataSize is too small for the result.  DataSize has
    22592259                                 been updated with the size needed to complete the request.
    22602260  @retval EFI_INVALID_PARAMETER  VariableName is NULL.
     
    23502350    UpdateVariableInfo (VariableName, VendorGuid, Variable.Volatile, TRUE, FALSE, FALSE, FALSE);
    23512351    UpdateVariableCache (VariableName, VendorGuid, VariableHeader.Attributes, VarDataSize, Data);
    2352  
     2352
    23532353    Status = EFI_SUCCESS;
    23542354    goto Done;
     
    23722372  This function implements EsalGetNextVariableName function of Extended SAL Variable Services Class.
    23732373  It is equivalent in functionality to the EFI Runtime Service GetNextVariableName().
    2374  
     2374
    23752375  @param[in, out] VariableNameSize Size of the variable
    23762376  @param[in, out] VariableName     On input, supplies the last VariableName that was returned by GetNextVariableName().
    23772377                                   On output, returns the Null-terminated Unicode string of the current variable.
    23782378  @param[in, out] VendorGuid       On input, supplies the last VendorGuid that was returned by GetNextVariableName().
    2379                                    On output, returns the VendorGuid of the current variable. 
     2379                                   On output, returns the VendorGuid of the current variable.
    23802380  @param[in]      VirtualMode      Current calling mode for this function.
    23812381  @param[in]      Global           Context of this Extended SAL Variable Services Class call.
    23822382
    2383   @retval EFI_SUCCESS             The function completed successfully. 
     2383  @retval EFI_SUCCESS             The function completed successfully.
    23842384  @retval EFI_NOT_FOUND           The next variable was not found.
    2385   @retval EFI_BUFFER_TOO_SMALL    VariableNameSize is too small for the result. 
     2385  @retval EFI_BUFFER_TOO_SMALL    VariableNameSize is too small for the result.
    23862386                                  VariableNameSize has been updated with the size needed to complete the request.
    23872387  @retval EFI_INVALID_PARAMETER   VariableNameSize is NULL.
     
    25132513  This function implements EsalSetVariable function of Extended SAL Variable Services Class.
    25142514  It is equivalent in functionality to the EFI Runtime Service SetVariable().
    2515  
     2515
    25162516  @param[in]  VariableName       A Null-terminated Unicode string that is the name of the vendor's
    2517                                  variable.  Each VariableName is unique for each 
    2518                                  VendorGuid.  VariableName must contain 1 or more 
    2519                                  Unicode characters.  If VariableName is an empty Unicode 
     2517                                 variable.  Each VariableName is unique for each
     2518                                 VendorGuid.  VariableName must contain 1 or more
     2519                                 Unicode characters.  If VariableName is an empty Unicode
    25202520                                 string, then EFI_INVALID_PARAMETER is returned.
    25212521  @param[in]  VendorGuid         A unique identifier for the vendor.
     
    25272527  @param[in]  Global             Context of this Extended SAL Variable Services Class call.
    25282528
    2529   @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as 
     2529  @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as
    25302530                                 defined by the Attributes.
    2531   @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits was supplied, or the 
     2531  @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits was supplied, or the
    25322532                                 DataSize exceeds the maximum allowed.
    25332533  @retval EFI_INVALID_PARAMETER  VariableName is an empty Unicode string.
     
    25672567  if (VariableName == NULL || VariableName[0] == 0 || VendorGuid == NULL) {
    25682568    return EFI_INVALID_PARAMETER;
    2569   } 
     2569  }
    25702570
    25712571  if (DataSize != 0 && Data == NULL) {
     
    25862586      //
    25872587      return EFI_SECURITY_VIOLATION;
    2588     } 
    2589     PayloadSize = DataSize - AUTHINFO_SIZE; 
     2588    }
     2589    PayloadSize = DataSize - AUTHINFO_SIZE;
    25902590  } else {
    2591     PayloadSize = DataSize; 
    2592   }
    2593 
    2594  
     2591    PayloadSize = DataSize;
     2592  }
     2593
     2594
    25952595  if ((UINTN)(~0) - PayloadSize < StrSize(VariableName)){
    25962596    //
    2597     // Prevent whole variable size overflow 
    2598     // 
     2597    // Prevent whole variable size overflow
     2598    //
    25992599    return EFI_INVALID_PARAMETER;
    26002600  }
     
    26262626    if (StrSize (VariableName) + PayloadSize > PcdGet32(PcdMaxVariableSize) - sizeof (VARIABLE_HEADER)) {
    26272627      return EFI_INVALID_PARAMETER;
    2628     } 
    2629   } 
     2628    }
     2629  }
    26302630
    26312631  AcquireLockOnlyAtBootTime(&VariableGlobal->VariableServicesLock);
     
    26772677        //
    26782678        Status = UpdateVariable (
    2679                    VariableName, 
    2680                    VendorGuid, 
    2681                    (UINT8*)Data + AUTHINFO_SIZE, 
    2682                    DataSize - AUTHINFO_SIZE, 
    2683                    Attributes, 
    2684                    KeyIndex, 
    2685                    MonotonicCount, 
    2686                    VirtualMode, 
    2687                    Global, 
     2679                   VariableName,
     2680                   VendorGuid,
     2681                   (UINT8*)Data + AUTHINFO_SIZE,
     2682                   DataSize - AUTHINFO_SIZE,
     2683                   Attributes,
     2684                   KeyIndex,
     2685                   MonotonicCount,
     2686                   VirtualMode,
     2687                   Global,
    26882688                   &Variable
    26892689                   );
    26902690      } else {
    26912691        //
    2692         // Update variable as usual 
     2692        // Update variable as usual
    26932693        //
    26942694        Status = UpdateVariable (
    2695                    VariableName, 
    2696                    VendorGuid, 
    2697                    Data, 
    2698                    DataSize, 
    2699                    Attributes, 
    2700                    0, 
    2701                    0, 
    2702                    VirtualMode, 
    2703                    Global, 
     2695                   VariableName,
     2696                   VendorGuid,
     2697                   Data,
     2698                   DataSize,
     2699                   Attributes,
     2700                   0,
     2701                   0,
     2702                   VirtualMode,
     2703                   Global,
    27042704                   &Variable
    27052705                   );
     
    27212721  @param[in]  Attributes                   Attributes bitmask to specify the type of variables
    27222722                                           on which to return information.
    2723   @param[out] MaximumVariableStorageSize   On output the maximum size of the storage space available for 
    2724                                            the EFI variables associated with the attributes specified. 
    2725   @param[out] RemainingVariableStorageSize Returns the remaining size of the storage space available for EFI 
     2723  @param[out] MaximumVariableStorageSize   On output the maximum size of the storage space available for
     2724                                           the EFI variables associated with the attributes specified.
     2725  @param[out] RemainingVariableStorageSize Returns the remaining size of the storage space available for EFI
    27262726                                           variables associated with the attributes specified.
    2727   @param[out] MaximumVariableSize          Returns the maximum size of an individual EFI variable 
     2727  @param[out] MaximumVariableSize          Returns the maximum size of an individual EFI variable
    27282728                                           associated with the attributes specified.
    27292729  @param[in]  VirtualMode                  Current calling mode for this function
     
    27322732  @retval EFI_SUCCESS                      Valid answer returned.
    27332733  @retval EFI_INVALID_PARAMETER            An invalid combination of attribute bits was supplied.
    2734   @retval EFI_UNSUPPORTED                  The attribute is not supported on this platform, and the 
    2735                                            MaximumVariableStorageSize, RemainingVariableStorageSize, 
     2734  @retval EFI_UNSUPPORTED                  The attribute is not supported on this platform, and the
     2735                                           MaximumVariableStorageSize, RemainingVariableStorageSize,
    27362736                                           MaximumVariableSize are undefined.
    27372737**/
     
    27652765    return EFI_INVALID_PARAMETER;
    27662766  }
    2767  
     2767
    27682768  if((Attributes & (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) == 0) {
    27692769    //
    27702770    // Make sure the Attributes combination is supported by the platform.
    27712771    //
    2772     return EFI_UNSUPPORTED; 
     2772    return EFI_UNSUPPORTED;
    27732773  } else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS) {
    27742774    //
     
    29182918
    29192919  VarSize = ((VARIABLE_STORE_HEADER *) ((UINTN) mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase))->Size;
    2920   Status  = EFI_SUCCESS; 
     2920  Status  = EFI_SUCCESS;
    29212921  //
    29222922  //Allowable max size of common variable storage space
     
    29252925
    29262926  RemainingCommonVariableSpace = CommonVariableSpace - mVariableModuleGlobal->CommonVariableTotalSize;
    2927  
     2927
    29282928  RemainingHwErrVariableSpace = PcdGet32 (PcdHwErrStorageSize) - mVariableModuleGlobal->HwErrVariableTotalSize;
    29292929  //
     
    29312931  //
    29322932  if ((RemainingCommonVariableSpace < PcdGet32 (PcdMaxVariableSize))
    2933     || ((PcdGet32 (PcdHwErrStorageSize) != 0) && 
     2933    || ((PcdGet32 (PcdHwErrStorageSize) != 0) &&
    29342934       (RemainingHwErrVariableSpace < PcdGet32 (PcdMaxHardwareErrorVariableSize)))){
    29352935    Status = Reclaim (
     
    30573057  // Note that in EdkII variable driver implementation, Hardware Error Record type variable
    30583058  // is stored with common variable in the same NV region. So the platform integrator should
    3059   // ensure that the value of PcdHwErrStorageSize is less than or equal to the value of 
     3059  // ensure that the value of PcdHwErrStorageSize is less than or equal to the value of
    30603060  // PcdFlashNvStorageVariableSize.
    30613061  //
     
    31343134                               EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,
    31353135                               EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,
    3136                                GetPhysicalAddressFunctionId, 
    3137                                Instance, 
    3138                                (UINT64) &FvVolHdr, 
    3139                                0, 
    3140                                0, 
    3141                                0, 
    3142                                0, 
     3136                               GetPhysicalAddressFunctionId,
     3137                               Instance,
     3138                               (UINT64) &FvVolHdr,
     3139                               0,
     3140                               0,
     3141                               0,
     3142                               0,
    31433143                               0
    31443144                               ).Status;
     
    32383238    //
    32393239    Status = EfiCreateEventReadyToBootEx (
    3240                TPL_NOTIFY, 
    3241                ReclaimForOS, 
    3242                NULL, 
     3240               TPL_NOTIFY,
     3241               ReclaimForOS,
     3242               NULL,
    32433243               &ReadyToBootEvent
    32443244               );
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.h

    r48674 r58466  
    33
    44Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
    5 This program and the accompanying materials 
    6 are licensed and made available under the terms and conditions of the BSD License 
    7 which accompanies this distribution.  The full text of the license may be found at 
     5This program and the accompanying materials
     6are licensed and made available under the terms and conditions of the BSD License
     7which accompanies this distribution.  The full text of the license may be found at
    88http://opensource.org/licenses/bsd-license.php
    99
    10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
     10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    1111WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    1212
     
    6464
    6565///
    66 /// The maximum size of the public key database, restricted by maximum individal EFI 
     66/// The maximum size of the public key database, restricted by maximum individal EFI
    6767/// varible size, and excluding the variable header and name size.
    6868///
     
    192192  This function implements EsalGetVariable function of Extended SAL Variable Services Class.
    193193  It is equivalent in functionality to the EFI Runtime Service GetVariable().
    194  
     194
    195195  @param[in]      VariableName    A Null-terminated Unicode string that is the name of
    196196                                  the vendor's variable.
    197197  @param[in]      VendorGuid      A unique identifier for the vendor.
    198   @param[out]     Attributes      If not NULL, a pointer to the memory location to return the 
     198  @param[out]     Attributes      If not NULL, a pointer to the memory location to return the
    199199                                  attributes bitmask for the variable.
    200200  @param[in, out] DataSize        Size of Data found. If size is less than the
    201201                                  data, this value contains the required size.
    202   @param[out]     Data            On input, the size in bytes of the return Data buffer. 
     202  @param[out]     Data            On input, the size in bytes of the return Data buffer.
    203203                                  On output, the size of data returned in Data.
    204204  @param[in]      VirtualMode     Current calling mode for this function.
    205205  @param[in]      Global          Context of this Extended SAL Variable Services Class call.
    206206
    207   @retval EFI_SUCCESS            The function completed successfully. 
     207  @retval EFI_SUCCESS            The function completed successfully.
    208208  @retval EFI_NOT_FOUND          The variable was not found.
    209   @retval EFI_BUFFER_TOO_SMALL   DataSize is too small for the result.  DataSize has 
     209  @retval EFI_BUFFER_TOO_SMALL   DataSize is too small for the result.  DataSize has
    210210                                 been updated with the size needed to complete the request.
    211211  @retval EFI_INVALID_PARAMETER  VariableName is NULL.
     
    234234  This function implements EsalGetNextVariableName function of Extended SAL Variable Services Class.
    235235  It is equivalent in functionality to the EFI Runtime Service GetNextVariableName().
    236  
     236
    237237  @param[in, out] VariableNameSize Size of the variable
    238238  @param[in, out] VariableName     On input, supplies the last VariableName that was returned by GetNextVariableName().
    239239                                   On output, returns the Null-terminated Unicode string of the current variable.
    240240  @param[in, out] VendorGuid       On input, supplies the last VendorGuid that was returned by GetNextVariableName().
    241                                    On output, returns the VendorGuid of the current variable. 
     241                                   On output, returns the VendorGuid of the current variable.
    242242  @param[in]      VirtualMode      Current calling mode for this function.
    243243  @param[in]      Global           Context of this Extended SAL Variable Services Class call.
    244244
    245   @retval EFI_SUCCESS             The function completed successfully. 
     245  @retval EFI_SUCCESS             The function completed successfully.
    246246  @retval EFI_NOT_FOUND           The next variable was not found.
    247   @retval EFI_BUFFER_TOO_SMALL    VariableNameSize is too small for the result. 
     247  @retval EFI_BUFFER_TOO_SMALL    VariableNameSize is too small for the result.
    248248                                  VariableNameSize has been updated with the size needed to complete the request.
    249249  @retval EFI_INVALID_PARAMETER   VariableNameSize is NULL.
     
    268268  This function implements EsalSetVariable function of Extended SAL Variable Services Class.
    269269  It is equivalent in functionality to the EFI Runtime Service SetVariable().
    270  
     270
    271271  @param[in]  VariableName       A Null-terminated Unicode string that is the name of the vendor's
    272                                  variable.  Each VariableName is unique for each 
    273                                  VendorGuid.  VariableName must contain 1 or more 
    274                                  Unicode characters.  If VariableName is an empty Unicode 
     272                                 variable.  Each VariableName is unique for each
     273                                 VendorGuid.  VariableName must contain 1 or more
     274                                 Unicode characters.  If VariableName is an empty Unicode
    275275                                 string, then EFI_INVALID_PARAMETER is returned.
    276276  @param[in]  VendorGuid         A unique identifier for the vendor.
     
    282282  @param[in]  Global             Context of this Extended SAL Variable Services Class call.
    283283
    284   @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as 
     284  @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as
    285285                                 defined by the Attributes.
    286   @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits was supplied, or the 
     286  @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits was supplied, or the
    287287                                 DataSize exceeds the maximum allowed.
    288288  @retval EFI_INVALID_PARAMETER  VariableName is an empty Unicode string.
     
    315315  @param[in]  Attributes                   Attributes bitmask to specify the type of variables
    316316                                           on which to return information.
    317   @param[out] MaximumVariableStorageSize   On output the maximum size of the storage space available for 
    318                                            the EFI variables associated with the attributes specified. 
    319   @param[out] RemainingVariableStorageSize Returns the remaining size of the storage space available for EFI 
     317  @param[out] MaximumVariableStorageSize   On output the maximum size of the storage space available for
     318                                           the EFI variables associated with the attributes specified.
     319  @param[out] RemainingVariableStorageSize Returns the remaining size of the storage space available for EFI
    320320                                           variables associated with the attributes specified.
    321   @param[out] MaximumVariableSize          Returns the maximum size of an individual EFI variable 
     321  @param[out] MaximumVariableSize          Returns the maximum size of an individual EFI variable
    322322                                           associated with the attributes specified.
    323323  @param[in]  VirtualMode                  Current calling mode for this function
     
    326326  @retval EFI_SUCCESS                      Valid answer returned.
    327327  @retval EFI_INVALID_PARAMETER            An invalid combination of attribute bits was supplied.
    328   @retval EFI_UNSUPPORTED                  The attribute is not supported on this platform, and the 
    329                                            MaximumVariableStorageSize, RemainingVariableStorageSize, 
     328  @retval EFI_UNSUPPORTED                  The attribute is not supported on this platform, and the
     329                                           MaximumVariableStorageSize, RemainingVariableStorageSize,
    330330                                           MaximumVariableSize are undefined.
    331331**/
     
    437437
    438438/**
    439   Update the variable region with Variable information. These are the same 
     439  Update the variable region with Variable information. These are the same
    440440  arguments as the EFI Variable services.
    441441
     
    446446  @param[in] Attributes         Attributes of the variable.
    447447  @param[in] KeyIndex           Index of associated public key.
    448   @param[in] MonotonicCount     Value of associated monotonic count. 
     448  @param[in] MonotonicCount     Value of associated monotonic count.
    449449  @param[in] VirtualMode        Current calling mode for this function.
    450450  @param[in] Global             Context of this Extended SAL Variable Services Class call.
     
    462462  IN      VOID                    *Data,
    463463  IN      UINTN                   DataSize,
    464   IN      UINT32                  Attributes OPTIONAL, 
     464  IN      UINT32                  Attributes OPTIONAL,
    465465  IN      UINT32                  KeyIndex  OPTIONAL,
    466466  IN      UINT64                  MonotonicCount  OPTIONAL,
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/Pei/Variable.c

    r58459 r58466  
    11/** @file
    22  Implement ReadOnly Variable Services required by PEIM and install PEI
    3   ReadOnly Varaiable2 PPI. These services operates the non-volatile 
     3  ReadOnly Varaiable2 PPI. These services operates the non-volatile
    44  storage space.
    55
    66Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    7 This program and the accompanying materials 
    8 are licensed and made available under the terms and conditions of the BSD License 
    9 which accompanies this distribution.  The full text of the license may be found at 
     7This program and the accompanying materials
     8are licensed and made available under the terms and conditions of the BSD License
     9which accompanies this distribution.  The full text of the license may be found at
    1010http://opensource.org/licenses/bsd-license.php
    1111
    12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
     12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    1313WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    1414
     
    3434/**
    3535  Provide the functionality of the variable services.
    36  
    37   @param  FileHandle   Handle of the file being invoked. 
     36
     37  @param  FileHandle   Handle of the file being invoked.
    3838                       Type EFI_PEI_FILE_HANDLE is defined in FfsFindNextFile().
    3939  @param  PeiServices  General purpose services available to every PEIM.
     
    193193{
    194194  UINTN Value;
    195  
     195
    196196  //
    197197  // Be careful about pad size for alignment
     
    451451
    452452        NvStorageSize = PcdGet32 (PcdFlashNvStorageVariableSize);
    453         NvStorageBase = (EFI_PHYSICAL_ADDRESS) (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0 ? 
    454                                                 PcdGet64 (PcdFlashNvStorageVariableBase64) : 
     453        NvStorageBase = (EFI_PHYSICAL_ADDRESS) (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0 ?
     454                                                PcdGet64 (PcdFlashNvStorageVariableBase64) :
    455455                                                PcdGet32 (PcdFlashNvStorageVariableBase)
    456456                                               );
     
    493493          break;
    494494        }
    495        
     495
    496496        VariableStoreHeader = (VARIABLE_STORE_HEADER *) ((UINT8 *) FvHeader + FvHeader->HeaderLength);
    497497
     
    503503          // If it's the first time to access variable region in flash, create a guid hob to record
    504504          // VAR_ADDED type variable info.
    505           // Note that as the resource of PEI phase is limited, only store the limited number of 
     505          // Note that as the resource of PEI phase is limited, only store the limited number of
    506506          // VAR_ADDED type variables to reduce access time.
    507507          //
     
    619619  EFI_PHYSICAL_ADDRESS  SpareAddress;
    620620  UINTN                 PartialSize;
    621  
     621
    622622  if (StoreInfo->FtwLastWriteData != NULL) {
    623623    TargetAddress = StoreInfo->FtwLastWriteData->TargetAddress;
     
    826826               StoreInfo,
    827827               VariableName,
    828                VendorGuid, 
     828               VendorGuid,
    829829               PtrTrack
    830830               );
     
    840840  This service retrieves a variable's value using its name and GUID.
    841841
    842   Read the specified variable from the UEFI variable store. If the Data 
     842  Read the specified variable from the UEFI variable store. If the Data
    843843  buffer is too small to hold the contents of the variable, the error
    844844  EFI_BUFFER_TOO_SMALL is returned and DataSize is set to the required buffer
     
    856856  @retval EFI_SUCCESS           The variable was read successfully.
    857857  @retval EFI_NOT_FOUND         The variable could not be found.
    858   @retval EFI_BUFFER_TOO_SMALL  The DataSize is too small for the resulting data. 
    859                                 DataSize is updated with the size required for 
     858  @retval EFI_BUFFER_TOO_SMALL  The DataSize is too small for the resulting data.
     859                                DataSize is updated with the size required for
    860860                                the specified variable.
    861861  @retval EFI_INVALID_PARAMETER VariableName, VariableGuid, DataSize or Data is NULL.
     
    921921  Return the next variable name and GUID.
    922922
    923   This function is called multiple times to retrieve the VariableName 
    924   and VariableGuid of all variables currently available in the system. 
    925   On each call, the previous results are passed into the interface, 
    926   and, on return, the interface returns the data for the next 
    927   interface. When the entire variable list has been returned, 
     923  This function is called multiple times to retrieve the VariableName
     924  and VariableGuid of all variables currently available in the system.
     925  On each call, the previous results are passed into the interface,
     926  and, on return, the interface returns the data for the next
     927  interface. When the entire variable list has been returned,
    928928  EFI_NOT_FOUND is returned.
    929929
     
    934934  @param  VariableName      On entry, a pointer to a null-terminated string that is the variable's name.
    935935                            On return, points to the next variable's null-terminated name string.
    936   @param  VariableGuid      On entry, a pointer to an EFI_GUID that is the variable's GUID. 
     936  @param  VariableGuid      On entry, a pointer to an EFI_GUID that is the variable's GUID.
    937937                            On return, a pointer to the next variable's GUID.
    938938
     
    10131013      }
    10141014      //
    1015       // Capture the case that 
     1015      // Capture the case that
    10161016      // 1. current storage is the last one, or
    10171017      // 2. no further storage
     
    10541054                   &StoreInfoForHob,
    10551055                   GetVariableNamePtr (Variable.CurrPtr),
    1056                    &VariableHeader->VendorGuid, 
     1056                   &VariableHeader->VendorGuid,
    10571057                   &VariableInHob
    10581058                   );
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/Pei/Variable.h

    r58459 r58466  
    44
    55Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
    6 This program and the accompanying materials 
    7 are licensed and made available under the terms and conditions of the BSD License 
    8 which accompanies this distribution.  The full text of the license may be found at 
     6This program and the accompanying materials
     7are licensed and made available under the terms and conditions of the BSD License
     8which accompanies this distribution.  The full text of the license may be found at
    99http://opensource.org/licenses/bsd-license.php
    1010
    11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
     11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    1212WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    1313
     
    5555/**
    5656  Provide the functionality of the variable services.
    57  
    58   @param  FileHandle  Handle of the file being invoked. 
     57
     58  @param  FileHandle  Handle of the file being invoked.
    5959                      Type EFI_PEI_FILE_HANDLE is defined in FfsFindNextFile().
    6060  @param  PeiServices  General purpose services available to every PEIM.
     
    7474  This service retrieves a variable's value using its name and GUID.
    7575
    76   Read the specified variable from the UEFI variable store. If the Data 
     76  Read the specified variable from the UEFI variable store. If the Data
    7777  buffer is too small to hold the contents of the variable, the error
    7878  EFI_BUFFER_TOO_SMALL is returned and DataSize is set to the required buffer
     
    9090  @retval EFI_SUCCESS           The variable was read successfully.
    9191  @retval EFI_NOT_FOUND         The variable could not be found.
    92   @retval EFI_BUFFER_TOO_SMALL  The DataSize is too small for the resulting data. 
    93                                 DataSize is updated with the size required for 
     92  @retval EFI_BUFFER_TOO_SMALL  The DataSize is too small for the resulting data.
     93                                DataSize is updated with the size required for
    9494                                the specified variable.
    9595  @retval EFI_INVALID_PARAMETER VariableName, VariableGuid, DataSize or Data is NULL.
     
    111111  Return the next variable name and GUID.
    112112
    113   This function is called multiple times to retrieve the VariableName 
    114   and VariableGuid of all variables currently available in the system. 
    115   On each call, the previous results are passed into the interface, 
    116   and, on return, the interface returns the data for the next 
    117   interface. When the entire variable list has been returned, 
     113  This function is called multiple times to retrieve the VariableName
     114  and VariableGuid of all variables currently available in the system.
     115  On each call, the previous results are passed into the interface,
     116  and, on return, the interface returns the data for the next
     117  interface. When the entire variable list has been returned,
    118118  EFI_NOT_FOUND is returned.
    119119
     
    124124                            On return, points to the next variable's null-terminated name string.
    125125
    126   @param  VariableGuid      On entry, a pointer to an UEFI _GUID that is the variable's GUID. 
     126  @param  VariableGuid      On entry, a pointer to an UEFI _GUID that is the variable's GUID.
    127127                            On return, a pointer to the next variable's GUID.
    128128
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c

    r58459 r58466  
    1010     The whole SMM authentication variable design relies on the integrity of flash part and SMM.
    1111  which is assumed to be protected by platform.  All variable code and metadata in flash/SMM Memory
    12   may not be modified without authorization. If platform fails to protect these resources, 
     12  may not be modified without authorization. If platform fails to protect these resources,
    1313  the authentication service provided in this driver will be broken, and the behavior is undefined.
    1414
     
    8989  @retval TRUE      This variable is protected, only a physical present user could set this variable.
    9090  @retval FALSE     This variable is not protected.
    91  
     91
    9292**/
    9393BOOLEAN
     
    101101    return TRUE;
    102102  }
    103  
     103
    104104  return FALSE;
    105105}
     
    123123    return TRUE;
    124124  }
    125  
     125
    126126  return FALSE;
    127127}
     
    257257    ASSERT ((DataSize != 0) && (Data != NULL));
    258258    //
    259     // "AuthVarKeyDatabase" is an internal variable. Its DataSize is always ensured not to exceed mPubKeyStore buffer size(See definition before) 
     259    // "AuthVarKeyDatabase" is an internal variable. Its DataSize is always ensured not to exceed mPubKeyStore buffer size(See definition before)
    260260    //  Therefore, there is no memory overflow in underlying CopyMem.
    261261    //
     
    270270    DEBUG ((EFI_D_INFO, "Variable %s exists.\n", EFI_PLATFORM_KEY_NAME));
    271271  }
    272  
     272
    273273  //
    274274  // Create "SetupMode" variable with BS+RT attribute set.
     
    294294    return Status;
    295295  }
    296  
     296
    297297  //
    298298  // Create "SignatureSupport" variable with BS+RT attribute set.
     
    391391    return Status;
    392392  }
    393  
     393
    394394  DEBUG ((EFI_D_INFO, "Variable %s is %x\n", EFI_CUSTOM_MODE_NAME, CustomMode));
    395395
    396396  //
    397397  // Check "certdb" variable's existence.
    398   // If it doesn't exist, then create a new one with 
     398  // If it doesn't exist, then create a new one with
    399399  // EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS set.
    400400  //
     
    424424      return Status;
    425425    }
    426   } 
     426  }
    427427
    428428  //
     
    481481
    482482  @param[in]  PubKey                  Input pointer to Public Key data
    483   @param[in]  VariableDataEntry       The variable data entry 
     483  @param[in]  VariableDataEntry       The variable data entry
    484484
    485485  @return                             Index of new added item
     
    544544        return 0;
    545545      }
    546      
     546
    547547      Status = Reclaim (
    548548                 mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase,
     
    574574      ASSERT ((DataSize != 0) && (Data != NULL));
    575575      //
    576       // "AuthVarKeyDatabase" is an internal used variable. Its DataSize is always ensured not to exceed mPubKeyStore buffer size(See definition before) 
     576      // "AuthVarKeyDatabase" is an internal used variable. Its DataSize is always ensured not to exceed mPubKeyStore buffer size(See definition before)
    577577      //  Therefore, there is no memory overflow in underlying CopyMem.
    578578      //
     
    582582      if (mPubKeyNumber == mMaxKeyNumber) {
    583583        return 0;
    584       }     
     584      }
    585585    }
    586586
     
    657657  VOID                            *Rsa;
    658658  UINTN                           PayloadSize;
    659  
     659
    660660  PayloadSize = DataSize - AUTHINFO_SIZE;
    661661  Rsa         = NULL;
     
    895895  @return EFI_INVALID_PARAMETER           Invalid signature list format.
    896896  @return EFI_SUCCESS                     Passed signature list format check successfully.
    897  
     897
    898898**/
    899899EFI_STATUS
     
    923923    IsPk = TRUE;
    924924  } else if ((CompareGuid (VendorGuid, &gEfiGlobalVariableGuid) && StrCmp (VariableName, EFI_KEY_EXCHANGE_KEY_NAME) == 0) ||
    925              (CompareGuid (VendorGuid, &gEfiImageSecurityDatabaseGuid) && 
     925             (CompareGuid (VendorGuid, &gEfiImageSecurityDatabaseGuid) &&
    926926              (StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE) == 0 || StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE1) == 0))){
    927927    IsPk = FALSE;
     
    943943      if (CompareGuid (&SigList->SignatureType, &mSupportSigItem[Index].SigType)) {
    944944        //
    945         // The value of SignatureSize should always be 16 (size of SignatureOwner 
     945        // The value of SignatureSize should always be 16 (size of SignatureOwner
    946946        // component) add the data length according to signature type.
    947947        //
    948         if (mSupportSigItem[Index].SigDataSize != ((UINT32) ~0) && 
     948        if (mSupportSigItem[Index].SigDataSize != ((UINT32) ~0) &&
    949949          (SigList->SignatureSize - sizeof (EFI_GUID)) != mSupportSigItem[Index].SigDataSize) {
    950950          return EFI_INVALID_PARAMETER;
     
    987987    }
    988988    SigCount += (SigList->SignatureListSize - sizeof (EFI_SIGNATURE_LIST) - SigList->SignatureHeaderSize) / SigList->SignatureSize;
    989    
     989
    990990    SigDataSize -= SigList->SignatureListSize;
    991991    SigList = (EFI_SIGNATURE_LIST *) ((UINT8 *) SigList + SigList->SignatureListSize);
     
    10081008  @return EFI_SUCCESS           Variable is updated successfully.
    10091009  @return Others                Failed to update variable.
    1010  
     1010
    10111011**/
    10121012EFI_STATUS
     
    10221022  }
    10231023  mVendorKeyState = VENDOR_KEYS_MODIFIED;
    1024  
     1024
    10251025  FindVariable (EFI_VENDOR_KEYS_NV_VARIABLE_NAME, &gEfiVendorKeysNvGuid, &Variable, &mVariableModuleGlobal->VariableGlobal, FALSE);
    10261026  Status = UpdateVariable (
     
    10941094  UINTN                       PayloadSize;
    10951095
    1096   if ((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0 || 
     1096  if ((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0 ||
    10971097      (Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) == 0) {
    10981098    //
     
    12541254      return Status;
    12551255    }
    1256    
     1256
    12571257    Status = UpdateVariable (
    12581258               VariableName,
     
    13391339    return EFI_SECURITY_VIOLATION;
    13401340  }
    1341  
     1341
    13421342  //
    13431343  // A time-based authenticated variable and a count-based authenticated variable
    13441344  // can't be updated by each other.
    1345   // 
    1346   if (Variable->CurrPtr != NULL) {   
     1345  //
     1346  if (Variable->CurrPtr != NULL) {
    13471347    if (((Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) &&
    13481348        ((Variable->CurrPtr->Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0)) {
    1349       return EFI_SECURITY_VIOLATION;     
    1350     }
    1351    
    1352     if (((Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) && 
     1349      return EFI_SECURITY_VIOLATION;
     1350    }
     1351
     1352    if (((Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) &&
    13531353        ((Variable->CurrPtr->Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0)) {
    1354       return EFI_SECURITY_VIOLATION;     
    1355     }
    1356   }
    1357    
     1354      return EFI_SECURITY_VIOLATION;
     1355    }
     1356  }
     1357
    13581358  //
    13591359  // Process Time-based Authenticated variable.
     
    13931393      IsFirstTime = FALSE;
    13941394    }
    1395   } else if ((Variable->CurrPtr != NULL) && 
     1395  } else if ((Variable->CurrPtr != NULL) &&
    13961396             ((Variable->CurrPtr->Attributes & (EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS)) != 0)
    13971397            ) {
     
    14241424    //
    14251425    // 2 cases need to check here
    1426     //   1. Internal PubKey variable. PubKeyIndex is always 0 
     1426    //   1. Internal PubKey variable. PubKeyIndex is always 0
    14271427    //   2. Other counter-based AuthVariable. Check input PubKey.
    14281428    //
     
    14791479  @param[in, out]  Data              Pointer to original EFI_SIGNATURE_LIST.
    14801480  @param[in]       DataSize          Size of Data buffer.
    1481   @param[in]       FreeBufSize       Size of free data buffer 
     1481  @param[in]       FreeBufSize       Size of free data buffer
    14821482  @param[in]       NewData           Pointer to new EFI_SIGNATURE_LIST to be appended.
    14831483  @param[in]       NewDataSize       Size of NewData buffer.
     
    17151715      // Check whether VariableName matches.
    17161716      //
    1717       if ((NameSize == StrLen (VariableName)) && 
     1717      if ((NameSize == StrLen (VariableName)) &&
    17181718          (CompareMem (Data + Offset, VariableName, NameSize * sizeof (CHAR16)) == 0)) {
    17191719        Offset = Offset + NameSize * sizeof (CHAR16);
     
    17241724
    17251725        if (CertDataSize != NULL) {
    1726           *CertDataSize = CertSize;       
     1726          *CertDataSize = CertSize;
    17271727        }
    17281728
     
    17451745  }
    17461746
    1747   return EFI_NOT_FOUND; 
     1747  return EFI_NOT_FOUND;
    17481748}
    17491749
     
    17791779    return EFI_INVALID_PARAMETER;
    17801780  }
    1781  
     1781
    17821782  //
    17831783  // Get variable "certdb".
     
    17891789             &mVariableModuleGlobal->VariableGlobal,
    17901790             FALSE
    1791              );     
     1791             );
    17921792  if (EFI_ERROR (Status)) {
    17931793    return Status;
     
    18521852    return EFI_INVALID_PARAMETER;
    18531853  }
    1854  
     1854
    18551855  //
    18561856  // Get variable "certdb".
     
    18621862             &mVariableModuleGlobal->VariableGlobal,
    18631863             FALSE
    1864              );     
     1864             );
    18651865  if (EFI_ERROR (Status)) {
    18661866    return Status;
     
    19301930  //
    19311931  // Set "certdb".
    1932   // 
    1933   VarAttr  = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS; 
     1932  //
     1933  VarAttr  = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
    19341934  Status   = UpdateVariable (
    19351935               EFI_CERT_DB_NAME,
     
    19851985    return EFI_INVALID_PARAMETER;
    19861986  }
    1987  
     1987
    19881988  //
    19891989  // Get variable "certdb".
     
    19951995             &mVariableModuleGlobal->VariableGlobal,
    19961996             FALSE
    1997              );     
     1997             );
    19981998  if (EFI_ERROR (Status)) {
    19991999    return Status;
     
    20312031  //
    20322032  NameSize      = (UINT32) StrLen (VariableName);
    2033   CertNodeSize  = sizeof (AUTH_CERT_DB_DATA) + (UINT32) CertDataSize + NameSize * sizeof (CHAR16); 
     2033  CertNodeSize  = sizeof (AUTH_CERT_DB_DATA) + (UINT32) CertDataSize + NameSize * sizeof (CHAR16);
    20342034  NewCertDbSize = (UINT32) DataSize + CertNodeSize;
    20352035  if (NewCertDbSize > mMaxCertDbSize) {
     
    20542054  CopyMem (&Ptr->NameSize, &NameSize, sizeof (UINT32));
    20552055  CopyMem (&Ptr->CertDataSize, &CertDataSize, sizeof (UINT32));
    2056  
     2056
    20572057  CopyMem (
    20582058    (UINT8 *) Ptr + sizeof (AUTH_CERT_DB_DATA),
     
    20662066    CertDataSize
    20672067    );
    2068  
     2068
    20692069  //
    20702070  // Set "certdb".
    2071   // 
    2072   VarAttr  = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS; 
     2071  //
     2072  VarAttr  = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
    20732073  Status   = UpdateVariable (
    20742074               EFI_CERT_DB_NAME,
     
    23772377        goto Exit;
    23782378      }
    2379    
     2379
    23802380      if ((CertStackSize != CertsSizeinDb) ||
    23812381          (CompareMem (SignerCerts, CertsInCertDb, CertsSizeinDb) != 0)) {
     
    24202420    RootCert      = Cert->SignatureData;
    24212421    RootCertSize  = CertList->SignatureSize - (sizeof (EFI_SIGNATURE_DATA) - 1);
    2422    
     2422
    24232423    // Verify Pkcs7 SignedData via Pkcs7Verify library.
    24242424    //
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.h

    r58459 r58466  
    1010     The whole SMM authentication variable design relies on the integrity of flash part and SMM.
    1111  which is assumed to be protected by platform.  All variable code and metadata in flash/SMM Memory
    12   may not be modified without authorization. If platform fails to protect these resources, 
     12  may not be modified without authorization. If platform fails to protect these resources,
    1313  the authentication service provided in this driver will be broken, and the behavior is undefined.
    1414
     
    5151/// "certdb" variable stores the signer's certificates for non PK/KEK/DB/DBX
    5252/// variables with EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS set.
    53 /// 
     53///
    5454///
    5555#define EFI_CERT_DB_NAME        L"certdb"
     
    168168  @return EFI_INVALID_PARAMETER           Invalid signature list format.
    169169  @return EFI_SUCCESS                     Passed signature list format check successfully.
    170  
     170
    171171**/
    172172EFI_STATUS
     
    255255  @param[in, out]  Data             Pointer to original EFI_SIGNATURE_LIST.
    256256  @param[in]       DataSize         Size of Data buffer.
    257   @param[in]       FreeBufSize      Size of free data buffer 
     257  @param[in]       FreeBufSize      Size of free data buffer
    258258  @param[in]       NewData          Pointer to new EFI_SIGNATURE_LIST to be appended.
    259259  @param[in]       NewDataSize      Size of NewData buffer.
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/RuntimeDxe/Measurement.c

    r58464 r58466  
    5757
    5858  for (Index = 0; Index < sizeof(mVariableType)/sizeof(mVariableType[0]); Index++) {
    59     if ((StrCmp (VariableName, mVariableType[Index].VariableName) == 0) && 
     59    if ((StrCmp (VariableName, mVariableType[Index].VariableName) == 0) &&
    6060        (CompareGuid (VendorGuid, mVariableType[Index].VendorGuid))) {
    6161      return TRUE;
     
    7070  @param[in]  VarName           A Null-terminated string that is the name of the vendor's variable.
    7171  @param[in]  VendorGuid        A unique identifier for the vendor.
    72   @param[in]  VarData           The content of the variable data. 
    73   @param[in]  VarSize           The size of the variable data. 
    74  
     72  @param[in]  VarData           The content of the variable data.
     73  @param[in]  VarSize           The size of the variable data.
     74
    7575  @retval EFI_SUCCESS           Operation completed successfully.
    7676  @retval EFI_OUT_OF_RESOURCES  Out of memory.
     
    135135
    136136/**
    137   Returns the status whether get the variable success. The function retrieves 
    138   variable  through the UEFI Runtime Service GetVariable().  The 
     137  Returns the status whether get the variable success. The function retrieves
     138  variable  through the UEFI Runtime Service GetVariable().  The
    139139  returned buffer is allocated using AllocatePool().  The caller is responsible
    140140  for freeing this buffer with FreePool().
     
    171171    *Size  = 0;
    172172  }
    173  
     173
    174174  Status = gRT->GetVariable ((CHAR16 *) Name, (EFI_GUID *) Guid, NULL, &BufferSize, *Value);
    175175  if (Status != EFI_BUFFER_TOO_SMALL) {
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/RuntimeDxe/Reclaim.c

    r58459 r58466  
    44
    55Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    6 This program and the accompanying materials 
    7 are licensed and made available under the terms and conditions of the BSD License 
    8 which accompanies this distribution.  The full text of the license may be found at 
     6This program and the accompanying materials
     7are licensed and made available under the terms and conditions of the BSD License
     8which accompanies this distribution.  The full text of the license may be found at
    99http://opensource.org/licenses/bsd-license.php
    1010
    11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
     11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    1212WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    1313
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c

    r58459 r58466  
    593593  Check the PubKeyIndex is a valid key or not.
    594594
    595   This function will iterate the NV storage to see if this PubKeyIndex is still referenced 
     595  This function will iterate the NV storage to see if this PubKeyIndex is still referenced
    596596  by any valid count-based auth variabe.
    597  
     597
    598598  @param[in]  PubKeyIndex     Index of the public key in public key store.
    599599
    600600  @retval     TRUE            The PubKeyIndex is still in use.
    601601  @retval     FALSE           The PubKeyIndex is not referenced by any count-based auth variabe.
    602  
     602
    603603**/
    604604BOOLEAN
     
    618618
    619619  while (IsValidVariableHeader (Variable, VariableStoreEnd)) {
    620     if ((Variable->State == VAR_ADDED || Variable->State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)) && 
     620    if ((Variable->State == VAR_ADDED || Variable->State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)) &&
    621621        Variable->PubKeyIndex == PubKeyIndex) {
    622622      return TRUE;
     
    624624    Variable = GetNextVariablePtr (Variable);
    625625  }
    626  
     626
    627627  return FALSE;
    628628}
     
    631631
    632632  Get the number of valid public key in PubKeyStore.
    633  
     633
    634634  @param[in]  PubKeyNumber     Number of the public key in public key store.
    635635
     
    646646
    647647  Counter = 0;
    648  
     648
    649649  for (PubKeyIndex = 1; PubKeyIndex <= PubKeyNumber; PubKeyIndex++) {
    650650    if (IsValidPubKeyIndex (PubKeyIndex)) {
     
    652652    }
    653653  }
    654  
     654
    655655  return Counter;
    656656}
     
    660660  Filter the useless key in public key store.
    661661
    662   This function will find out all valid public keys in public key database, save them in new allocated 
     662  This function will find out all valid public keys in public key database, save them in new allocated
    663663  buffer NewPubKeyStore, and give the new PubKeyIndex. The caller is responsible for freeing buffer
    664664  NewPubKeyIndex and NewPubKeyStore with FreePool().
     
    669669  @param[out]  NewPubKeyStore       Saved all valid public keys in PubKeyStore.
    670670  @param[out]  NewPubKeySize        Buffer size of the NewPubKeyStore.
    671  
     671
    672672  @retval  EFI_SUCCESS              Trim operation is complete successfully.
    673673  @retval  EFI_OUT_OF_RESOURCES     No enough memory resources, or no useless key in PubKeyStore.
    674  
     674
    675675**/
    676676EFI_STATUS
     
    686686  UINT32        CopiedKey;
    687687  UINT32        NewPubKeyNumber;
    688  
     688
    689689  NewPubKeyNumber = GetValidPubKeyNumber (PubKeyNumber);
    690690  if (NewPubKeyNumber == PubKeyNumber) {
     
    740740  @param[in]      NewVariableSize         New variable size.
    741741  @param[in]      ReclaimPubKeyStore      Reclaim for public key database or not.
    742  
     742
    743743  @return EFI_SUCCESS                  Reclaim operation has finished successfully.
    744744  @return EFI_OUT_OF_RESOURCES         No enough memory resources or variable space.
     
    874874      NextVariable = GetNextVariablePtr (Variable);
    875875      if (Variable->State == VAR_ADDED || Variable->State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)) {
    876         if ((StrCmp (GetVariableNamePtr (Variable), AUTHVAR_KEYDB_NAME) == 0) && 
     876        if ((StrCmp (GetVariableNamePtr (Variable), AUTHVAR_KEYDB_NAME) == 0) &&
    877877            (CompareGuid (&Variable->VendorGuid, &gEfiAuthenticatedVariableGuid))) {
    878878          //
     
    883883          continue;
    884884        }
    885        
     885
    886886        VariableSize = (UINTN) NextVariable - (UINTN) Variable;
    887887        CopyMem (CurrPtr, (UINT8 *) Variable, VariableSize);
     
    910910    StrCpy (GetVariableNamePtr (Variable), GetVariableNamePtr (PubKeyHeader));
    911911    CopyMem (GetVariableDataPtr (Variable), NewPubKeyStore, NewPubKeySize);
    912     CurrPtr = (UINT8*) GetNextVariablePtr (Variable); 
     912    CurrPtr = (UINT8*) GetNextVariablePtr (Variable);
    913913    CommonVariableTotalSize += (UINTN) CurrPtr - (UINTN) Variable;
    914914  } else {
     
    15251525  @param[in] Attributes         Variable attributes for Variable entries.
    15261526  @param ...                    The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.
    1527                                 A NULL terminates the list. The VariableSize of 
     1527                                A NULL terminates the list. The VariableSize of
    15281528                                VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.
    15291529                                It will be changed to variable total size as output.
     
    18041804        VariableEntry[0].Guid = &gEfiGlobalVariableGuid;
    18051805        VariableEntry[0].Name = EFI_LANG_VARIABLE_NAME;
    1806        
     1806
    18071807        VariableEntry[1].VariableSize = AsciiStrSize (BestPlatformLang);
    18081808        VariableEntry[1].Guid = &gEfiGlobalVariableGuid;
     
    20102010        goto Done;
    20112011      }
    2012      
     2012
    20132013      //
    20142014      // Only variable that have RT attributes can be updated/deleted in Runtime.
     
    21042104
    21052105        //
    2106         // Set Max Common Variable Data Size as default MaxDataSize 
     2106        // Set Max Common Variable Data Size as default MaxDataSize
    21072107        //
    21082108        MaxDataSize = PcdGet32 (PcdMaxVariableSize) - DataOffset;
     
    21172117          Status = AppendSignatureList (
    21182118                     BufferForMerge,
    2119                      Variable->CurrPtr->DataSize, 
     2119                     Variable->CurrPtr->DataSize,
    21202120                     MaxDataSize - Variable->CurrPtr->DataSize,
    21212121                     Data,
     
    25312531  Check if a Unicode character is a hexadecimal character.
    25322532
    2533   This function checks if a Unicode character is a 
    2534   hexadecimal character.  The valid hexadecimal character is 
     2533  This function checks if a Unicode character is a
     2534  hexadecimal character.  The valid hexadecimal character is
    25352535  L'0' to L'9', L'a' to L'f', or L'A' to L'F'.
    25362536
     
    27022702  @retval TRUE      This variable is read-only variable.
    27032703  @retval FALSE     This variable is NOT read-only variable.
    2704  
     2704
    27052705**/
    27062706BOOLEAN
     
    27232723    }
    27242724  }
    2725  
     2725
    27262726  return FALSE;
    27272727}
     
    30783078  if ((UINTN)(~0) - PayloadSize < StrSize(VariableName)){
    30793079    //
    3080     // Prevent whole variable size overflow 
    3081     // 
     3080    // Prevent whole variable size overflow
     3081    //
    30823082    return EFI_INVALID_PARAMETER;
    30833083  }
     
    31853185  } else if (CompareGuid (VendorGuid, &gEfiGlobalVariableGuid) && (StrCmp (VariableName, EFI_KEY_EXCHANGE_KEY_NAME) == 0)) {
    31863186    Status = ProcessVarWithPk (VariableName, VendorGuid, Data, DataSize, &Variable, Attributes, FALSE);
    3187   } else if (CompareGuid (VendorGuid, &gEfiImageSecurityDatabaseGuid) && 
     3187  } else if (CompareGuid (VendorGuid, &gEfiImageSecurityDatabaseGuid) &&
    31883188          ((StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE) == 0) || (StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE1) == 0))) {
    31893189    Status = ProcessVarWithPk (VariableName, VendorGuid, Data, DataSize, &Variable, Attributes, FALSE);
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.h

    r58459 r58466  
    44
    55Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    6 This program and the accompanying materials 
    7 are licensed and made available under the terms and conditions of the BSD License 
    8 which accompanies this distribution.  The full text of the license may be found at 
     6This program and the accompanying materials
     7are licensed and made available under the terms and conditions of the BSD License
     8which accompanies this distribution.  The full text of the license may be found at
    99http://opensource.org/licenses/bsd-license.php
    1010
    11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
     11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    1212WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    1313
     
    229229  @param[in] Attributes         Variable attributes for Variable entries.
    230230  @param ...                    The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.
    231                                 A NULL terminates the list. The VariableSize of 
     231                                A NULL terminates the list. The VariableSize of
    232232                                VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.
    233233                                It will be changed to variable total size as output.
     
    243243  ...
    244244  );
    245  
     245
    246246/**
    247247  Update the variable region with Variable information. If EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is set,
     
    273273  IN      UINT64          MonotonicCount  OPTIONAL,
    274274  IN OUT  VARIABLE_POINTER_TRACK *Variable,
    275   IN      EFI_TIME        *TimeStamp  OPTIONAL 
     275  IN      EFI_TIME        *TimeStamp  OPTIONAL
    276276  );
    277277
     
    279279/**
    280280  Return TRUE if ExitBootServices () has been called.
    281  
     281
    282282  @retval TRUE If ExitBootServices () has been called.
    283283**/
     
    290290  Initializes a basic mutual exclusion lock.
    291291
    292   This function initializes a basic mutual exclusion lock to the released state 
    293   and returns the lock.  Each lock provides mutual exclusion access at its task 
     292  This function initializes a basic mutual exclusion lock to the released state
     293  and returns the lock.  Each lock provides mutual exclusion access at its task
    294294  priority level.  Since there is no preemption or multiprocessor support in EFI,
    295295  acquiring the lock only consists of raising to the locks TPL.
     
    309309  );
    310310
    311  
     311
    312312/**
    313313  Acquires lock only at boot time. Simply returns at runtime.
     
    343343ReleaseLockOnlyAtBootTime (
    344344  IN EFI_LOCK  *Lock
    345   ); 
     345  );
    346346
    347347/**
     
    355355  @retval EFI_UNSUPPORTED       The device does not support the FVB protocol.
    356356  @retval EFI_INVALID_PARAMETER FvBlockHandle is not a valid EFI_HANDLE or FvBlock is NULL.
    357  
     357
    358358**/
    359359EFI_STATUS
     
    381381/**
    382382  Function returns an array of handles that support the FVB protocol
    383   in a buffer allocated from pool. 
     383  in a buffer allocated from pool.
    384384
    385385  @param[out]  NumberHandles    The number of handles returned in Buffer.
     
    392392  @retval EFI_OUT_OF_RESOURCES  There is not enough pool memory to store the matching results.
    393393  @retval EFI_INVALID_PARAMETER NumberHandles is NULL or Buffer is NULL.
    394  
     394
    395395**/
    396396EFI_STATUS
     
    428428  @param[in]      NewVariableSize         New variable size.
    429429  @param[in]      ReclaimPubKeyStore      Reclaim for public key database or not.
    430  
     430
    431431  @return EFI_SUCCESS                  Reclaim operation has finished successfully.
    432432  @return EFI_OUT_OF_RESOURCES         No enough memory resources or variable space.
     
    448448/**
    449449  This function reclaims variable storage if free size is below the threshold.
    450  
     450
    451451**/
    452452VOID
    453453ReclaimForOS(
    454454  VOID
    455   ); 
     455  );
    456456
    457457
     
    467467  VOID
    468468  );
    469  
     469
    470470/**
    471471  Retrive the SMM Fault Tolerent Write protocol interface.
     
    512512                                    data, this value contains the required size.
    513513  @param Data                       Data pointer.
    514                      
     514
    515515  @return EFI_INVALID_PARAMETER     Invalid parameter.
    516516  @return EFI_SUCCESS               Find the specified variable.
     
    645645  OUT UINT64                 *RemainingVariableStorageSize,
    646646  OUT UINT64                 *MaximumVariableSize
    647   ); 
     647  );
    648648
    649649/**
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableRuntimeDxe.inf

    r58459 r58466  
    22#  Provides authenticated variable service
    33#
    4 #  This module installs variable arch protocol and variable write arch protocol to provide 
     4#  This module installs variable arch protocol and variable write arch protocol to provide
    55#  variable services: SetVariable, GetVariable, GetNextVariableName and QueryVariableInfo.
    66#
    77#  Caution: This module requires additional review when modified.
    88#  This driver will have external input - variable data.
    9 #  This external input must be validated carefully to avoid security issues such as 
     9#  This external input must be validated carefully to avoid security issues such as
    1010#  buffer overflow or integer overflow.
    1111#
     
    8585  ## SOMETIMES_PRODUCES   ## SystemTable
    8686  gEfiAuthenticatedVariableGuid
    87  
     87
    8888  ## SOMETIMES_CONSUMES   ## Variable:L"PlatformLang"
    8989  ## SOMETIMES_PRODUCES   ## Variable:L"PlatformLang"
     
    9898  ## PRODUCES             ## Variable:L"SecureBoot"
    9999  ## CONSUMES             ## Variable:L"SignatureSupport"
    100   ## PRODUCES             ## Variable:L"SignatureSupport" 
     100  ## PRODUCES             ## Variable:L"SignatureSupport"
    101101  ## PRODUCES             ## Variable:L"VendorKeys"
    102102  gEfiGlobalVariableGuid
    103  
     103
    104104  ## SOMETIMES_CONSUMES   ## Variable:L"DB"
    105105  ## SOMETIMES_CONSUMES   ## Variable:L"DBX"
    106106  gEfiImageSecurityDatabaseGuid
    107  
     107
    108108  ## CONSUMES             ## Variable:L"SecureBootEnable"
    109109  ## PRODUCES             ## Variable:L"SecureBootEnable"
    110110  gEfiSecureBootEnableDisableGuid
    111  
     111
    112112  ## CONSUMES             ## Variable:L"CustomMode"
    113113  ## PRODUCES             ## Variable:L"CustomMode"
    114114  gEfiCustomModeEnableGuid
    115  
     115
    116116  ## CONSUMES             ## Variable:L"certdb"
    117117  ## PRODUCES             ## Variable:L"certdb"
    118118  gEfiCertDbGuid
    119  
     119
    120120  ## CONSUMES             ## Variable:L"VendorKeysNv"
    121121  ## PRODUCES             ## Variable:L"VendorKeysNv"
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.c

    r58459 r58466  
    11/** @file
    2   The sample implementation for SMM variable protocol. And this driver 
    3   implements an SMI handler to communicate with the DXE runtime driver 
     2  The sample implementation for SMM variable protocol. And this driver
     3  implements an SMI handler to communicate with the DXE runtime driver
    44  to provide variable services.
    55
     
    1111  SmmVariableHandler() will receive untrusted input and do basic validation.
    1212
    13   Each sub function VariableServiceGetVariable(), VariableServiceGetNextVariableName(), 
    14   VariableServiceSetVariable(), VariableServiceQueryVariableInfo(), ReclaimForOS(), 
     13  Each sub function VariableServiceGetVariable(), VariableServiceGetNextVariableName(),
     14  VariableServiceSetVariable(), VariableServiceQueryVariableInfo(), ReclaimForOS(),
    1515  SmmVariableGetStatistics() should also do validation based on its own knowledge.
    1616
    1717Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
    18 This program and the accompanying materials 
    19 are licensed and made available under the terms and conditions of the BSD License 
    20 which accompanies this distribution.  The full text of the license may be found at 
     18This program and the accompanying materials
     19are licensed and made available under the terms and conditions of the BSD License
     20which accompanies this distribution.  The full text of the license may be found at
    2121http://opensource.org/licenses/bsd-license.php
    2222
    23 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
     23THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    2424WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    2525
     
    119119/**
    120120  Return TRUE if ExitBootServices () has been called.
    121  
     121
    122122  @retval TRUE If ExitBootServices () has been called.
    123123**/
     
    133133  Initializes a basic mutual exclusion lock.
    134134
    135   This function initializes a basic mutual exclusion lock to the released state 
    136   and returns the lock.  Each lock provides mutual exclusion access at its task 
     135  This function initializes a basic mutual exclusion lock to the released state
     136  and returns the lock.  Each lock provides mutual exclusion access at its task
    137137  priority level.  Since there is no preemption or multiprocessor support in EFI,
    138138  acquiring the lock only consists of raising to the locks TPL.
     
    217217  //
    218218  Status = gSmst->SmmLocateProtocol (
    219                     &gEfiSmmFaultTolerantWriteProtocolGuid, 
    220                     NULL, 
     219                    &gEfiSmmFaultTolerantWriteProtocolGuid,
     220                    NULL,
    221221                    FtwProtocol
    222222                    );
     
    256256/**
    257257  Function returns an array of handles that support the SMM FVB protocol
    258   in a buffer allocated from pool. 
     258  in a buffer allocated from pool.
    259259
    260260  @param[out]  NumberHandles    The number of handles returned in Buffer.
     
    327327
    328328  @param[in, out]  InfoEntry    A pointer to the buffer of variable information entry.
    329                                 On input, point to the variable information returned last time. if 
     329                                On input, point to the variable information returned last time. if
    330330                                InfoEntry->VendorGuid is zero, return the first information.
    331331                                On output, point to the next variable information.
     
    334334
    335335  @retval EFI_SUCCESS           The variable information is found and returned successfully.
    336   @retval EFI_UNSUPPORTED       No variable inoformation exists in variable driver. The 
     336  @retval EFI_UNSUPPORTED       No variable inoformation exists in variable driver. The
    337337                                PcdVariableCollectStatistics should be set TRUE to support it.
    338338  @retval EFI_BUFFER_TOO_SMALL  The buffer is too small to hold the next variable information.
     
    351351  CHAR16                                               *InfoName;
    352352  EFI_GUID                                             VendorGuid;
    353  
     353
    354354  if (InfoEntry == NULL) {
    355355    return EFI_INVALID_PARAMETER;
    356356  }
    357  
    358   VariableInfo = gVariableInfo; 
     357
     358  VariableInfo = gVariableInfo;
    359359  if (VariableInfo == NULL) {
    360360    return EFI_UNSUPPORTED;
     
    398398    VariableInfo = VariableInfo->Next;
    399399  };
    400    
     400
    401401  if (VariableInfo == NULL) {
    402402    *InfoSize = 0;
     
    416416  CopyMem (InfoName, VariableInfo->Name, StrSize (VariableInfo->Name));
    417417  *InfoSize = StatisticsInfoSize;
    418  
     418
    419419  return EFI_SUCCESS;
    420420}
     
    428428  Caution: This function may receive untrusted input.
    429429  This variable data and communicate buffer are external input, so this function will do basic validation.
    430   Each sub function VariableServiceGetVariable(), VariableServiceGetNextVariableName(), 
    431   VariableServiceSetVariable(), VariableServiceQueryVariableInfo(), ReclaimForOS(), 
     430  Each sub function VariableServiceGetVariable(), VariableServiceGetNextVariableName(),
     431  VariableServiceSetVariable(), VariableServiceQueryVariableInfo(), ReclaimForOS(),
    432432  SmmVariableGetStatistics() should also do validation based on its own knowledge.
    433433
     
    439439  @param[in, out] CommBufferSize The size of the CommBuffer.
    440440
    441   @retval EFI_SUCCESS                         The interrupt was handled and quiesced. No other handlers 
     441  @retval EFI_SUCCESS                         The interrupt was handled and quiesced. No other handlers
    442442                                              should still be called.
    443   @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED  The interrupt has been quiesced but other handlers should 
     443  @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED  The interrupt has been quiesced but other handlers should
    444444                                              still be called.
    445   @retval EFI_WARN_INTERRUPT_SOURCE_PENDING   The interrupt is still pending and other handlers should still 
     445  @retval EFI_WARN_INTERRUPT_SOURCE_PENDING   The interrupt is still pending and other handlers should still
    446446                                              be called.
    447447  @retval EFI_INTERRUPT_PENDING               The interrupt could not be quiesced.
     
    492492    return EFI_SUCCESS;
    493493  }
    494  
     494
    495495  SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)CommBuffer;
    496    
     496
    497497  switch (SmmVariableFunctionHeader->Function) {
    498498    case SMM_VARIABLE_FUNCTION_GET_VARIABLE:
     
    514514        goto EXIT;
    515515      }
    516       InfoSize = OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) 
     516      InfoSize = OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)
    517517                 + SmmVariableHeader->DataSize + SmmVariableHeader->NameSize;
    518518
     
    543543      CopyMem (SmmVariableFunctionHeader->Data, mVariableBufferPayload, CommBufferPayloadSize);
    544544      break;
    545      
     545
    546546    case SMM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME:
    547547      if (CommBufferPayloadSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name)) {
     
    588588      CopyMem (SmmVariableFunctionHeader->Data, mVariableBufferPayload, CommBufferPayloadSize);
    589589      break;
    590      
     590
    591591    case SMM_VARIABLE_FUNCTION_SET_VARIABLE:
    592592      if (CommBufferPayloadSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)) {
     
    636636                 );
    637637      break;
    638      
     638
    639639    case SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO:
    640640      if (CommBufferPayloadSize < sizeof (SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO)) {
     
    643643      }
    644644      QueryVariableInfo = (SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO *) SmmVariableFunctionHeader->Data;
    645  
     645
    646646      Status = VariableServiceQueryVariableInfo (
    647647                 QueryVariableInfo->Attributes,
     
    661661      Status = EFI_SUCCESS;
    662662      break;
    663  
     663
    664664    case SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE:
    665665      mAtRuntime = TRUE;
     
    672672
    673673      //
    674       // Do not need to check SmmVariableFunctionHeader->Data in SMRAM here. 
    675       // It is covered by previous CommBuffer check 
    676       //
    677      
     674      // Do not need to check SmmVariableFunctionHeader->Data in SMRAM here.
     675      // It is covered by previous CommBuffer check
     676      //
     677
    678678      if (!SmmIsBufferOutsideSmmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBufferSize, sizeof(UINTN))) {
    679679        DEBUG ((EFI_D_ERROR, "GetStatistics: SMM communication buffer in SMRAM!\n"));
    680680        Status = EFI_ACCESS_DENIED;
    681681        goto EXIT;
    682       } 
     682      }
    683683
    684684      Status = SmmVariableGetStatistics (VariableInfo, &InfoSize);
     
    738738  SMM Fault Tolerant Write protocol notification event handler.
    739739
    740   Non-Volatile variable write may needs FTW protocol to reclaim when 
     740  Non-Volatile variable write may needs FTW protocol to reclaim when
    741741  writting variable.
    742  
     742
    743743  @param  Protocol   Points to the protocol's unique identifier
    744744  @param  Interface  Points to the interface instance
     
    747747  @retval EFI_SUCCESS   SmmEventCallback runs successfully
    748748  @retval EFI_NOT_FOUND The Fvb protocol for variable is not found.
    749  
     749
    750750 **/
    751751EFI_STATUS
     
    762762  EFI_PHYSICAL_ADDRESS                    NvStorageVariableBase;
    763763  UINTN                                   FtwMaxBlockSize;
    764  
     764
    765765  if (mVariableModuleGlobal->FvbInstance != NULL) {
    766766    return EFI_SUCCESS;
     
    793793
    794794  mVariableModuleGlobal->FvbInstance = FvbProtocol;
    795  
     795
    796796  Status = VariableWriteServiceInitialize ();
    797797  if (EFI_ERROR (Status)) {
    798798    DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. Status = %r\n", Status));
    799799  }
    800  
     800
    801801  //
    802802  // Notify the variable wrapper driver the variable write service is ready
     
    809809                  );
    810810  ASSERT_EFI_ERROR (Status);
    811  
     811
    812812  return EFI_SUCCESS;
    813813}
     
    816816/**
    817817  Variable Driver main entry point. The Variable driver places the 4 EFI
    818   runtime services in the EFI System Table and installs arch protocols 
     818  runtime services in the EFI System Table and installs arch protocols
    819819  for variable read and write services being available. It also registers
    820820  a notification function for an EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
    821821
    822   @param[in] ImageHandle    The firmware allocated handle for the EFI image. 
     822  @param[in] ImageHandle    The firmware allocated handle for the EFI image.
    823823  @param[in] SystemTable    A pointer to the EFI System Table.
    824  
     824
    825825  @retval EFI_SUCCESS       Variable service successfully initialized.
    826826
     
    872872  Status = gSmst->SmiHandlerRegister (SmmVariableHandler, &gEfiSmmVariableProtocolGuid, &VariableHandle);
    873873  ASSERT_EFI_ERROR (Status);
    874  
     874
    875875  //
    876876  // Notify the variable wrapper driver the variable service is ready
     
    883883                                        );
    884884  ASSERT_EFI_ERROR (Status);
    885  
     885
    886886  //
    887887  // Register EFI_SMM_END_OF_DXE_PROTOCOL_GUID notify function.
     
    896896  //
    897897  // Register FtwNotificationEvent () notify function.
    898   // 
     898  //
    899899  Status = gSmst->SmmRegisterProtocolNotify (
    900900                    &gEfiSmmFaultTolerantWriteProtocolGuid,
     
    905905
    906906  SmmFtwNotificationEvent (NULL, NULL, NULL);
    907  
     907
    908908  return EFI_SUCCESS;
    909909}
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf

    r58459 r58466  
    1212#  Caution: This module requires additional review when modified.
    1313#  This driver will have external input - variable data and communicate buffer in SMM mode.
    14 #  This external input must be validated carefully to avoid security issues such as 
     14#  This external input must be validated carefully to avoid security issues such as
    1515#  buffer overflow or integer overflow.
    1616#    The whole SMM authentication variable design relies on the integrity of flash part and SMM.
    1717#  which is assumed to be protected by platform.  All variable code and metadata in flash/SMM Memory
    18 #  may not be modified without authorization. If platform fails to protect these resources, 
     18#  may not be modified without authorization. If platform fails to protect these resources,
    1919#  the authentication service provided in this driver will be broken, and the behavior is undefined.
    2020#
     
    7777[Protocols]
    7878  gEfiSmmFirmwareVolumeBlockProtocolGuid        ## CONSUMES
    79  
     79
    8080  ## PRODUCES
    8181  ## UNDEFINED     # SmiHandlerRegister
    8282  gEfiSmmVariableProtocolGuid
    83  
     83
    8484  ## CONSUMES
    85   ## NOTIFY 
     85  ## NOTIFY
    8686  gEfiSmmFaultTolerantWriteProtocolGuid
    8787  gEfiSmmEndOfDxeProtocolGuid              ## NOTIFY
     
    9292  ## SOMETIMES_CONSUMES   ## HOB
    9393  gEfiAuthenticatedVariableGuid
    94  
     94
    9595  ## SOMETIMES_CONSUMES   ## Variable:L"PlatformLang"
    9696  ## SOMETIMES_PRODUCES   ## Variable:L"PlatformLang"
     
    108108  ## PRODUCES             ## Variable:L"VendorKeys"
    109109  gEfiGlobalVariableGuid
    110  
     110
    111111  ## SOMETIMES_CONSUMES   ## Variable:L"DB"
    112112  ## SOMETIMES_CONSUMES   ## Variable:L"DBX"
    113113  gEfiImageSecurityDatabaseGuid
    114  
     114
    115115  ## CONSUMES             ## Variable:L"SecureBootEnable"
    116116  ## PRODUCES             ## Variable:L"SecureBootEnable"
    117117  gEfiSecureBootEnableDisableGuid
    118  
     118
    119119  ## CONSUMES             ## Variable:L"CustomMode"
    120120  ## PRODUCES             ## Variable:L"CustomMode"
    121121  gEfiCustomModeEnableGuid
    122  
     122
    123123  ## CONSUMES             ## Variable:L"certdb"
    124124  ## PRODUCES             ## Variable:L"certdb"
     
    128128  ## PRODUCES             ## Variable:L"VendorKeysNv"
    129129  gEfiVendorKeysNvGuid
    130    
     130
    131131  gSmmVariableWriteGuid                    ## PRODUCES               ## GUID        # Install protocol
    132132  gEfiCertTypeRsa2048Sha256Guid            ## SOMETIMES_CONSUMES     ## GUID        # Unique ID for the format of the CertData.
     
    136136  gEfiHardwareErrorVariableGuid            ## SOMETIMES_CONSUMES     ## Variable:L"HwErrRec####"
    137137  gEdkiiFaultTolerantWriteGuid             ## SOMETIMES_CONSUMES     ## HOB
    138  
     138
    139139[Pcd]
    140140  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize       ## CONSUMES
     
    153153[Depex]
    154154  TRUE
    155  
     155
    156156[UserExtensions.TianoCore."ExtraFiles"]
    157157  VariableSmmExtra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.c

    r58459 r58466  
    1515
    1616Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
    17 This program and the accompanying materials 
    18 are licensed and made available under the terms and conditions of the BSD License 
    19 which accompanies this distribution.  The full text of the license may be found at 
     17This program and the accompanying materials
     18are licensed and made available under the terms and conditions of the BSD License
     19which accompanies this distribution.  The full text of the license may be found at
    2020http://opensource.org/licenses/bsd-license.php
    2121
    22 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
     22THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    2323WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    2424
     
    4747#include <Guid/SmmVariableCommon.h>
    4848
    49 EFI_HANDLE                       mHandle                    = NULL; 
     49EFI_HANDLE                       mHandle                    = NULL;
    5050EFI_SMM_VARIABLE_PROTOCOL       *mSmmVariable               = NULL;
    5151EFI_EVENT                        mVirtualAddressChangeEvent = NULL;
     
    128128  @param[in]       DataSize         The data size to send to SMM.
    129129  @param[in]       Function         The function number to initialize the communicate header.
    130                      
     130
    131131  @retval EFI_INVALID_PARAMETER     The data size is too big.
    132132  @retval EFI_SUCCESS               Find the specified variable.
     
    140140  )
    141141{
    142   EFI_SMM_COMMUNICATE_HEADER                *SmmCommunicateHeader; 
    143   SMM_VARIABLE_COMMUNICATE_HEADER           *SmmVariableFunctionHeader; 
    144 
    145  
     142  EFI_SMM_COMMUNICATE_HEADER                *SmmCommunicateHeader;
     143  SMM_VARIABLE_COMMUNICATE_HEADER           *SmmVariableFunctionHeader;
     144
     145
    146146  if (DataSize + SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE > mVariableBufferSize) {
    147147    return EFI_INVALID_PARAMETER;
     
    151151  CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
    152152  SmmCommunicateHeader->MessageLength = DataSize + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
    153    
     153
    154154  SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *) SmmCommunicateHeader->Data;
    155155  SmmVariableFunctionHeader->Function = Function;
     
    168168
    169169  @retval      EFI_SUCCESS            Success is returned from the functin in SMM.
    170   @retval      Others                 Failure is returned from the function in SMM. 
    171  
     170  @retval      Others                 Failure is returned from the function in SMM.
     171
    172172**/
    173173EFI_STATUS
     
    178178  EFI_STATUS                                Status;
    179179  UINTN                                     CommSize;
    180   EFI_SMM_COMMUNICATE_HEADER                *SmmCommunicateHeader; 
     180  EFI_SMM_COMMUNICATE_HEADER                *SmmCommunicateHeader;
    181181  SMM_VARIABLE_COMMUNICATE_HEADER           *SmmVariableFunctionHeader;
    182  
     182
    183183  CommSize = DataSize + SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
    184184  Status = mSmmCommunication->Communicate (mSmmCommunication, mVariableBufferPhysical, &CommSize);
     
    271271                                     data, this value contains the required size.
    272272  @param[out]     Data               Data pointer.
    273                      
     273
    274274  @retval EFI_INVALID_PARAMETER      Invalid parameter.
    275275  @retval EFI_SUCCESS                Find the specified variable.
     
    471471    goto Done;
    472472  }
    473  
     473
    474474  CopyGuid (VendorGuid, &SmmGetNextVariableName->Guid);
    475   CopyMem (VariableName, SmmGetNextVariableName->Name, SmmGetNextVariableName->NameSize); 
     475  CopyMem (VariableName, SmmGetNextVariableName->Name, SmmGetNextVariableName->NameSize);
    476476
    477477Done:
     
    511511{
    512512  EFI_STATUS                                Status;
    513   UINTN                                     PayloadSize; 
     513  UINTN                                     PayloadSize;
    514514  SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE  *SmmVariableHeader;
    515515  UINTN                                     VariableNameSize;
    516    
     516
    517517  //
    518518  // Check input parameters.
     
    520520  if (VariableName == NULL || VariableName[0] == 0 || VendorGuid == NULL) {
    521521    return EFI_INVALID_PARAMETER;
    522   } 
     522  }
    523523
    524524  if (DataSize != 0 && Data == NULL) {
     
    641641  *MaximumVariableSize          = SmmQueryVariableInfo->MaximumVariableSize;
    642642  *MaximumVariableStorageSize   = SmmQueryVariableInfo->MaximumVariableStorageSize;
    643   *RemainingVariableStorageSize = SmmQueryVariableInfo->RemainingVariableStorageSize; 
     643  *RemainingVariableStorageSize = SmmQueryVariableInfo->RemainingVariableStorageSize;
    644644
    645645Done:
     
    669669  // SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE.
    670670  //
    671   InitCommunicateBuffer (NULL, 0, SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE); 
     671  InitCommunicateBuffer (NULL, 0, SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE);
    672672
    673673  //
     
    699699  //
    700700  InitCommunicateBuffer (NULL, 0, SMM_VARIABLE_FUNCTION_READY_TO_BOOT);
    701  
     701
    702702  //
    703703  // Send data to SMM.
     
    734734  @param[in] Event    Event whose notification function is being invoked.
    735735  @param[in] Context  Pointer to the notification function's context.
    736  
     736
    737737**/
    738738VOID
     
    749749    return;
    750750  }
    751  
     751
    752752  Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &mSmmCommunication);
    753753  ASSERT_EFI_ERROR (Status);
    754  
     754
    755755  //
    756756  // Allocate memory for variable communicate buffer.
     
    771771  gRT->SetVariable         = RuntimeServiceSetVariable;
    772772  gRT->QueryVariableInfo   = RuntimeServiceQueryVariableInfo;
    773  
     773
    774774  //
    775775  // Install the Variable Architectural Protocol on a new handle.
     
    777777  Status = gBS->InstallProtocolInterface (
    778778                  &mHandle,
    779                   &gEfiVariableArchProtocolGuid, 
     779                  &gEfiVariableArchProtocolGuid,
    780780                  EFI_NATIVE_INTERFACE,
    781781                  NULL
     
    790790  @param[in] Event    Event whose notification function is being invoked.
    791791  @param[in] Context  Pointer to the notification function's context.
    792  
     792
    793793**/
    794794VOID
     
    809809    return;
    810810  }
    811  
     811
    812812  Status = gBS->InstallProtocolInterface (
    813813                  &mHandle,
    814                   &gEfiVariableWriteArchProtocolGuid, 
     814                  &gEfiVariableWriteArchProtocolGuid,
    815815                  EFI_NATIVE_INTERFACE,
    816816                  NULL
    817817                  );
    818   ASSERT_EFI_ERROR (Status); 
     818  ASSERT_EFI_ERROR (Status);
    819819}
    820820
     
    822822/**
    823823  Variable Driver main entry point. The Variable driver places the 4 EFI
    824   runtime services in the EFI System Table and installs arch protocols 
     824  runtime services in the EFI System Table and installs arch protocols
    825825  for variable read and write services being available. It also registers
    826826  a notification function for an EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
    827827
    828   @param[in] ImageHandle    The firmware allocated handle for the EFI image. 
     828  @param[in] ImageHandle    The firmware allocated handle for the EFI image.
    829829  @param[in] SystemTable    A pointer to the EFI System Table.
    830  
     830
    831831  @retval EFI_SUCCESS       Variable service successfully initialized.
    832832
     
    860860  //
    861861  EfiCreateProtocolNotifyEvent (
    862     &gEfiSmmVariableProtocolGuid, 
    863     TPL_CALLBACK, 
    864     SmmVariableReady, 
    865     NULL, 
     862    &gEfiSmmVariableProtocolGuid,
     863    TPL_CALLBACK,
     864    SmmVariableReady,
     865    NULL,
    866866    &SmmVariableRegistration
    867867    );
     
    871871  //
    872872  EfiCreateProtocolNotifyEvent (
    873     &gSmmVariableWriteGuid, 
    874     TPL_CALLBACK, 
    875     SmmVariableWriteReady, 
    876     NULL, 
     873    &gSmmVariableWriteGuid,
     874    TPL_CALLBACK,
     875    SmmVariableWriteReady,
     876    NULL,
    877877    &SmmVariableWriteRegistration
    878878    );
     
    882882  //
    883883  EfiCreateEventReadyToBootEx (
    884     TPL_NOTIFY, 
    885     OnReadyToBoot, 
    886     NULL, 
     884    TPL_NOTIFY,
     885    OnReadyToBoot,
     886    NULL,
    887887    &OnReadyToBootEvent
    888     );             
     888    );
    889889
    890890  //
     
    898898         &gEfiEventExitBootServicesGuid,
    899899         &ExitBootServiceEvent
    900          ); 
     900         );
    901901
    902902  //
     
    911911         &mVirtualAddressChangeEvent
    912912         );
    913  
     913
    914914  return EFI_SUCCESS;
    915915}
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.inf

    r58459 r58466  
    22#  Runtime DXE part corresponding to SMM authenticated variable module
    33#
    4 #  This module installs variable arch protocol and variable write arch protocol to provide 
    5 #  variable service. This module need work together with SMM authenticated variable module. 
     4#  This module installs variable arch protocol and variable write arch protocol to provide
     5#  variable service. This module need work together with SMM authenticated variable module.
    66#
    77#  Caution: This module requires additional review when modified.
    88#  This driver will have external input - variable data.
    9 #  This external input must be validated carefully to avoid security issues such as 
     9#  This external input must be validated carefully to avoid security issues such as
    1010#  buffer overflow or integer overflow.
    1111#    The whole SMM authentication variable design relies on the integrity of flash part and SMM.
    1212#  which is assumed to be protected by platform.  All variable code and metadata in flash/SMM Memory
    13 #  may not be modified without authorization. If platform fails to protect these resources, 
     13#  may not be modified without authorization. If platform fails to protect these resources,
    1414#  the authentication service provided in this driver will be broken, and the behavior is undefined.
    1515#
     
    5252[LibraryClasses]
    5353  MemoryAllocationLib
    54   BaseLib 
     54  BaseLib
    5555  UefiBootServicesTableLib
    5656  DebugLib
     
    5858  DxeServicesTableLib
    5959  UefiDriverEntryPoint
    60   PcdLib 
     60  PcdLib
    6161  TpmMeasurementLib
    6262
     
    7575  gEfiEventVirtualAddressChangeGuid                                 ## CONSUMES       ## Event
    7676  gEfiEventExitBootServicesGuid                                     ## CONSUMES       ## Event
    77    
     77
    7878  ## CONSUMES ## UNDEFINED # Locate protocol
    7979  ## CONSUMES ## UNDEFINED # Protocol notify
    8080  gSmmVariableWriteGuid
    81  
     81
    8282
    8383  ## SOMETIMES_CONSUMES   ## Variable:L"PK"
     
    8585  ## SOMETIMES_CONSUMES   ## Variable:L"SecureBoot"
    8686  gEfiGlobalVariableGuid
    87  
     87
    8888  ## SOMETIMES_CONSUMES   ## Variable:L"DB"
    8989  ## SOMETIMES_CONSUMES   ## Variable:L"DBX"
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr

    • Property svn:eol-style set to native
    r58459 r58466  
    33
    44Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
    5 This program and the accompanying materials 
    6 are licensed and made available under the terms and conditions of the BSD License 
    7 which accompanies this distribution.  The full text of the license may be found at 
     5This program and the accompanying materials
     6are licensed and made available under the terms and conditions of the BSD License
     7which accompanies this distribution.  The full text of the license may be found at
    88http://opensource.org/licenses/bsd-license.php
    99
    10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
     10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    1111WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    1212
     
    2525    name  = SECUREBOOT_CONFIGURATION,
    2626    guid  = SECUREBOOT_CONFIG_FORM_SET_GUID;
    27  
     27
    2828  //
    2929  // ##1 Form "Secure Boot Configuration"
     
    3838      text   = STRING_TOKEN(STR_SECURE_BOOT_STATE_PROMPT),
    3939        text   = STRING_TOKEN(STR_SECURE_BOOT_STATE_CONTENT);
    40        
     40
    4141    //
    4242    // Define of Check Box: Attempt Secure Boot
     
    4949              flags    = INTERACTIVE,
    5050      endcheckbox;
    51     endif; 
    52    
     51    endif;
     52
    5353    //
    5454    // Display of Check Box: Attempt Secure Boot
     
    6262    endcheckbox;
    6363    endif;
    64    
     64
    6565    //
    6666    // Display of Oneof: 'Secure Boot Mode'
     
    7676    endif;
    7777      oneof name = SecureBootMode,
    78             questionid = KEY_SECURE_BOOT_MODE,     
     78            questionid = KEY_SECURE_BOOT_MODE,
    7979            prompt = STRING_TOKEN(STR_SECURE_BOOT_MODE_PROMPT),
    8080            help   = STRING_TOKEN(STR_SECURE_BOOT_MODE_HELP),
     
    8383            option text = STRING_TOKEN(STR_CUSTOM_MODE),      value = SECURE_BOOT_MODE_CUSTOM,   flags = 0;
    8484      endoneof;
    85    
     85
    8686    //
    8787    //
     
    9898    endif;
    9999  endform;
    100  
     100
    101101  //
    102102  // ##2 Form: 'Custom Secure Boot Options'
     
    104104  form formid = FORMID_SECURE_BOOT_OPTION_FORM,
    105105    title  = STRING_TOKEN(STR_SECURE_BOOT_OPTION_TITLE);
    106    
    107     subtitle text = STRING_TOKEN(STR_NULL);
    108    
     106
     107    subtitle text = STRING_TOKEN(STR_NULL);
     108
    109109    goto FORMID_SECURE_BOOT_PK_OPTION_FORM,
    110110         prompt = STRING_TOKEN(STR_SECURE_BOOT_PK_OPTION),
     
    112112         flags  = INTERACTIVE,
    113113         key    = KEY_SECURE_BOOT_PK_OPTION;
    114        
    115     subtitle text = STRING_TOKEN(STR_NULL);
    116    
     114
     115    subtitle text = STRING_TOKEN(STR_NULL);
     116
    117117    goto FORMID_SECURE_BOOT_KEK_OPTION_FORM,
    118118         prompt = STRING_TOKEN(STR_SECURE_BOOT_KEK_OPTION),
     
    120120         flags  = INTERACTIVE,
    121121         key    = KEY_SECURE_BOOT_KEK_OPTION;
    122        
    123     subtitle text = STRING_TOKEN(STR_NULL);
    124    
     122
     123    subtitle text = STRING_TOKEN(STR_NULL);
     124
    125125    goto FORMID_SECURE_BOOT_DB_OPTION_FORM,
    126126         prompt = STRING_TOKEN(STR_SECURE_BOOT_DB_OPTION),
     
    128128         flags  = INTERACTIVE,
    129129         key    = KEY_SECURE_BOOT_DB_OPTION;
    130    
    131     subtitle text = STRING_TOKEN(STR_NULL);
    132    
     130
     131    subtitle text = STRING_TOKEN(STR_NULL);
     132
    133133    goto FORMID_SECURE_BOOT_DBX_OPTION_FORM,
    134134         prompt = STRING_TOKEN(STR_SECURE_BOOT_DBX_OPTION),
     
    138138
    139139  endform;
    140  
     140
    141141  //
    142142  // ##3 Form: 'PK Options'
     
    144144  form formid = FORMID_SECURE_BOOT_PK_OPTION_FORM,
    145145    title  = STRING_TOKEN(STR_SECURE_BOOT_PK_OPTION);
    146    
    147     subtitle text = STRING_TOKEN(STR_NULL);
    148    
     146
     147    subtitle text = STRING_TOKEN(STR_NULL);
     148
    149149    //
    150150    // Define of Check Box: 'Delete PK'
     
    156156      endcheckbox;
    157157    endif;
    158    
     158
    159159    grayoutif ideqval SECUREBOOT_CONFIGURATION.HasPk == 1;
    160160    goto FORMID_ENROLL_PK_FORM,
     
    164164         key    = KEY_ENROLL_PK;
    165165    endif;
    166    
    167     subtitle text = STRING_TOKEN(STR_NULL);
    168    
    169     //
    170     // Display of Check Box: 'Delete Pk' 
     166
     167    subtitle text = STRING_TOKEN(STR_NULL);
     168
     169    //
     170    // Display of Check Box: 'Delete Pk'
    171171    //
    172172    grayoutif ideqval SECUREBOOT_CONFIGURATION.HideSecureBoot == 1;
    173173    checkbox varid = SECUREBOOT_CONFIGURATION.DeletePk,
    174174          questionid = KEY_SECURE_BOOT_DELETE_PK,
    175           prompt = STRING_TOKEN(STR_DELETE_PK),         
     175          prompt = STRING_TOKEN(STR_DELETE_PK),
    176176          help   = STRING_TOKEN(STR_DELETE_PK_HELP),
    177177          flags  = INTERACTIVE | RESET_REQUIRED,
     
    179179    endif;
    180180  endform;
    181  
     181
    182182  //
    183183  // ##4 Form: 'Enroll PK'
     
    185185  form formid = FORMID_ENROLL_PK_FORM,
    186186    title  = STRING_TOKEN(STR_ENROLL_PK);
    187    
     187
    188188    subtitle text = STRING_TOKEN(STR_NULL);
    189189
     
    194194         key = SECUREBOOT_ADD_PK_FILE_FORM_ID;
    195195  endform;
    196  
     196
    197197  //
    198198  // ##5 Form: 'KEK Options'
     
    202202
    203203    //
    204     // Display of 'Enroll KEK' 
     204    // Display of 'Enroll KEK'
    205205    //
    206206    goto FORMID_ENROLL_KEK_FORM,
     
    208208         help   = STRING_TOKEN(STR_ENROLL_KEK_HELP),
    209209         flags  = INTERACTIVE;
    210    
    211     subtitle text = STRING_TOKEN(STR_NULL);     
    212    
    213     //
    214     // Display of 'Delete KEK' 
     210
     211    subtitle text = STRING_TOKEN(STR_NULL);
     212
     213    //
     214    // Display of 'Delete KEK'
    215215    //
    216216    goto FORMID_DELETE_KEK_FORM,
     
    219219         flags  = INTERACTIVE,
    220220         key    = KEY_DELETE_KEK;
    221  
    222     subtitle text = STRING_TOKEN(STR_NULL);   
    223   endform;
    224 
    225   //
    226   // ##6 Form: 'Enroll KEK' 
     221
     222    subtitle text = STRING_TOKEN(STR_NULL);
     223  endform;
     224
     225  //
     226  // ##6 Form: 'Enroll KEK'
    227227  //
    228228  form formid = FORMID_ENROLL_KEK_FORM,
     
    259259      flags  = INTERACTIVE,
    260260      key    = KEY_VALUE_SAVE_AND_EXIT_KEK;
    261  
     261
    262262    goto FORMID_SECURE_BOOT_OPTION_FORM,
    263263      prompt = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),
     
    270270  //
    271271  // ##7 Form: 'Delete KEK'
    272   // 
     272  //
    273273  form formid = FORMID_DELETE_KEK_FORM,
    274274    title  = STRING_TOKEN(STR_DELETE_KEK_TITLE);
     
    276276    label LABEL_KEK_DELETE;
    277277    label LABEL_END;
    278          
    279     subtitle text = STRING_TOKEN(STR_NULL);
    280    
     278
     279    subtitle text = STRING_TOKEN(STR_NULL);
     280
    281281  endform;
    282282
     
    301301    flags  = INTERACTIVE,
    302302    key    = SECUREBOOT_DELETE_SIGNATURE_FROM_DB;
    303    
     303
    304304  endform;
    305305
     
    336336    label LABEL_END;
    337337    subtitle text = STRING_TOKEN(STR_NULL);
    338    
     338
    339339  endform;
    340340
     
    348348    label LABEL_END;
    349349    subtitle text = STRING_TOKEN(STR_NULL);
    350    
     350
    351351  endform;
    352352
     
    387387         flags  = INTERACTIVE,
    388388         key    = KEY_VALUE_SAVE_AND_EXIT_DB;
    389  
     389
    390390    goto FORMID_SECURE_BOOT_OPTION_FORM,
    391391         prompt = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),
     
    432432         flags  = INTERACTIVE,
    433433         key    = KEY_VALUE_SAVE_AND_EXIT_DBX;
    434  
     434
    435435    goto FORMID_SECURE_BOOT_OPTION_FORM,
    436436         prompt = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),
     
    450450       label LABEL_END;
    451451  endform;
    452  
     452
    453453  //
    454454  // File Explorer for KEK
     
    490490    label SECUREBOOT_ADD_PK_FILE_FORM_ID;
    491491    label LABEL_END;
    492    
     492
    493493    subtitle text = STRING_TOKEN(STR_NULL);
    494494
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDriver.c

    r48674 r58466  
    33
    44Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
    5 This program and the accompanying materials 
    6 are licensed and made available under the terms and conditions of the BSD License 
    7 which accompanies this distribution.  The full text of the license may be found at 
     5This program and the accompanying materials
     6are licensed and made available under the terms and conditions of the BSD License
     7which accompanies this distribution.  The full text of the license may be found at
    88http://opensource.org/licenses/bsd-license.php
    99
    10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
     10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    1111WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    1212
     
    3636  EFI_STATUS                       Status;
    3737  SECUREBOOT_CONFIG_PRIVATE_DATA   *PrivateData;
    38  
     38
    3939  //
    4040  // If already started, return.
     
    5151    return EFI_ALREADY_STARTED;
    5252  }
    53  
     53
    5454  //
    5555  // Create a private data structure.
     
    5959    return EFI_OUT_OF_RESOURCES;
    6060  }
    61    
     61
    6262  //
    6363  // Install SecureBoot configuration form
     
    7070  //
    7171  // Install private GUID.
    72   //   
     72  //
    7373  Status = gBS->InstallMultipleProtocolInterfaces (
    7474                  &ImageHandle,
     
    8787  if (PrivateData != NULL) {
    8888    UninstallSecureBootConfigForm (PrivateData);
    89   } 
    90  
     89  }
     90
    9191  return Status;
    9292}
     
    114114                  &gEfiCallerIdGuid,
    115115                  (VOID **) &PrivateData
    116                   ); 
     116                  );
    117117  if (EFI_ERROR (Status)) {
    118     return Status; 
     118    return Status;
    119119  }
    120  
     120
    121121  ASSERT (PrivateData->Signature == SECUREBOOT_CONFIG_PRIVATE_DATA_SIGNATURE);
    122122
     
    127127         NULL
    128128         );
    129  
     129
    130130  UninstallSecureBootConfigForm (PrivateData);
    131131
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf

    r58459 r58466  
    6363  ## SOMETIMES_PRODUCES      ## Variable:L"CustomMode"
    6464  gEfiCustomModeEnableGuid
    65    
     65
    6666  ## SOMETIMES_CONSUMES      ## Variable:L"SecureBootEnable"
    6767  ## SOMETIMES_PRODUCES      ## Variable:L"SecureBootEnable"
    6868  gEfiSecureBootEnableDisableGuid
    69  
     69
    7070  ## SOMETIMES_CONSUMES      ## GUID            # Unique ID for the type of the signature.
    7171  ## SOMETIMES_PRODUCES      ## GUID            # Unique ID for the type of the signature.
    7272  gEfiCertRsa2048Guid
    73  
     73
    7474  ## SOMETIMES_CONSUMES      ## GUID            # Unique ID for the type of the signature.
    75   ## SOMETIMES_PRODUCES      ## GUID            # Unique ID for the type of the signature.                               
     75  ## SOMETIMES_PRODUCES      ## GUID            # Unique ID for the type of the signature.
    7676  gEfiCertX509Guid
    77  
     77
    7878  ## SOMETIMES_CONSUMES      ## GUID            # Unique ID for the type of the signature.
    79   ## SOMETIMES_PRODUCES      ## GUID            # Unique ID for the type of the signature.   
     79  ## SOMETIMES_PRODUCES      ## GUID            # Unique ID for the type of the signature.
    8080  gEfiCertSha1Guid
    81  
     81
    8282  ## SOMETIMES_CONSUMES      ## GUID            # Unique ID for the type of the signature.
    83   ## SOMETIMES_PRODUCES      ## GUID            # Unique ID for the type of the signature.   
     83  ## SOMETIMES_PRODUCES      ## GUID            # Unique ID for the type of the signature.
    8484  gEfiCertSha256Guid
    85  
     85
    8686  ## SOMETIMES_CONSUMES      ## Variable:L"db"
    8787  ## SOMETIMES_PRODUCES      ## Variable:L"db"
     
    8989  ## SOMETIMES_PRODUCES      ## Variable:L"dbx"
    9090  gEfiImageSecurityDatabaseGuid
    91    
     91
    9292  ## SOMETIMES_CONSUMES      ## Variable:L"SetupMode"
    9393  ## SOMETIMES_PRODUCES      ## Variable:L"PK"
     
    9696  ## SOMETIMES_CONSUMES      ## Variable:L"SecureBoot"
    9797  gEfiGlobalVariableGuid
    98  
     98
    9999  gEfiIfrTianoGuid                              ## PRODUCES            ## GUID       # HII opcode
    100100  ## PRODUCES                ## HII
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c

    r58459 r58466  
    6666
    6767/**
    68   Helper function called as part of the code needed to allocate 
     68  Helper function called as part of the code needed to allocate
    6969  the proper sized buffer for various EFI interfaces.
    7070
     
    123123
    124124/**
    125   Append file name to existing file name, and allocate a new buffer 
     125  Append file name to existing file name, and allocate a new buffer
    126126  to hold the appended result.
    127127
     
    150150  ASSERT (Str != NULL);
    151151
    152   TmpStr = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16)); 
     152  TmpStr = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));
    153153  ASSERT (TmpStr != NULL);
    154154
     
    171171
    172172      //
    173       // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings 
     173      // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings
    174174      // that overlap.
    175175      //
     
    183183
    184184      //
    185       // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings 
     185      // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings
    186186      // that overlap.
    187187      //
     
    197197
    198198  FreePool (TmpStr);
    199  
     199
    200200  return Str;
    201201}
     
    355355
    356356  @param[in, out]  MenuOption        Menu to be freed
    357  
     357
    358358**/
    359359VOID
     
    460460  Attributes is valid only for EFI_FILE_MODE_CREATE.
    461461
    462   @param[in, out]  FilePath        On input, the device path to the file. 
     462  @param[in, out]  FilePath        On input, the device path to the file.
    463463                                   On output, the remaining device path.
    464464  @param[out]      FileHandle      Pointer to the file handle.
     
    496496  EFI_FILE_PROTOCOL               *Handle1;
    497497  EFI_FILE_PROTOCOL               *Handle2;
    498   EFI_HANDLE                      DeviceHandle; 
     498  EFI_HANDLE                      DeviceHandle;
    499499
    500500  if ((FilePath == NULL || FileHandle == NULL)) {
     
    817817    FreePool (SimpleFsHandle);
    818818  }
    819  
     819
    820820  //
    821821  // Remember how many file system options are here
     
    827827
    828828/**
    829   Find files under the current directory. All files and sub-directories 
     829  Find files under the current directory. All files and sub-directories
    830830  in current directory will be stored in DirectoryMenu for future use.
    831831
     
    893893    return EFI_OUT_OF_RESOURCES;
    894894  }
    895  
     895
    896896  //
    897897  // Get all files in current directory
     
    935935                                    );
    936936      NewMenuEntry->HelpString = NULL;
    937      
     937
    938938      NewFileContext->IsDir = (BOOLEAN) ((DirInfo->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY);
    939939      if (NewFileContext->IsDir) {
     
    978978  //
    979979  // Free current updated date
    980   // 
     980  //
    981981  if (mStartOpCodeHandle != NULL) {
    982982    HiiFreeOpCodeHandle (mStartOpCodeHandle);
     
    11191119    FreeMenu (&FsOptionMenu);
    11201120    FindFileSystem ();
    1121    
     1121
    11221122    CreateMenuStringToken (PrivateData->HiiHandle, &FsOptionMenu);
    11231123    UpdateFileExplorePage (PrivateData->HiiHandle, &FsOptionMenu, PrivateData->FeCurrentState);
     
    11631163      PrivateData->MenuEntry = NewMenuEntry;
    11641164      PrivateData->FileContext->FileName = NewFileContext->FileName;
    1165      
     1165
    11661166      TmpDevicePath = NewFileContext->DevicePath;
    11671167      OpenFileByDevicePath (
     
    12011201
    12021202/**
    1203   Clean up the dynamic opcode at label and form specified by both LabelId. 
     1203  Clean up the dynamic opcode at label and form specified by both LabelId.
    12041204
    12051205  @param[in] LabelId         It is both the Form ID and Label ID for opcode deletion.
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c

    r58459 r58466  
    1818
    1919SECUREBOOT_CONFIG_PRIVATE_DATA         mSecureBootConfigPrivateDateTemplate = {
    20   SECUREBOOT_CONFIG_PRIVATE_DATA_SIGNATURE, 
     20  SECUREBOOT_CONFIG_PRIVATE_DATA_SIGNATURE,
    2121  {
    2222    SecureBootExtractConfig,
     
    7272
    7373//
    74 // Variable Definitions 
    75 //                                         
     74// Variable Definitions
     75//
    7676UINT32            mPeCoffHeaderOffset = 0;
    7777WIN_CERTIFICATE   *mCertificate = NULL;
     
    110110)
    111111{
    112   UINTN     Index; 
     112  UINTN     Index;
    113113  for (Index = 0; mDerEncodedSuffix[Index] != NULL; Index++) {
    114114    if (StrCmp (FileSuffix, mDerEncodedSuffix[Index]) == 0) {
     
    148148  Create a time based data payload by concatenating the EFI_VARIABLE_AUTHENTICATION_2
    149149  descriptor with the input data. NO authentication is required in this function.
    150  
     150
    151151  @param[in, out]   DataSize       On input, the size of Data buffer in bytes.
    152152                                   On output, the size of data returned in Data
    153153                                   buffer in bytes.
    154   @param[in, out]   Data           On input, Pointer to data buffer to be wrapped or 
     154  @param[in, out]   Data           On input, Pointer to data buffer to be wrapped or
    155155                                   pointer to NULL to wrap an empty payload.
    156156                                   On output, Pointer to the new payload date buffer allocated from pool,
    157                                    it's caller's responsibility to free the memory when finish using it. 
     157                                   it's caller's responsibility to free the memory when finish using it.
    158158
    159159  @retval EFI_SUCCESS              Create time based payload successfully.
     
    176176  UINTN                            DescriptorSize;
    177177  EFI_TIME                         Time;
    178  
     178
    179179  if (Data == NULL || DataSize == NULL) {
    180180    return EFI_INVALID_PARAMETER;
    181181  }
    182  
    183   //
    184   // In Setup mode or Custom mode, the variable does not need to be signed but the 
     182
     183  //
     184  // In Setup mode or Custom mode, the variable does not need to be signed but the
    185185  // parameters to the SetVariable() call still need to be prepared as authenticated
    186186  // variable. So we create EFI_VARIABLE_AUTHENTICATED_2 descriptor without certificate
     
    189189  Payload     = *Data;
    190190  PayloadSize = *DataSize;
    191  
     191
    192192  DescriptorSize    = OFFSET_OF (EFI_VARIABLE_AUTHENTICATION_2, AuthInfo) + OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData);
    193193  NewData = (UINT8*) AllocateZeroPool (DescriptorSize + PayloadSize);
     
    214214  Time.Pad2       = 0;
    215215  CopyMem (&DescriptorData->TimeStamp, &Time, sizeof (EFI_TIME));
    216  
     216
    217217  DescriptorData->AuthInfo.Hdr.dwLength         = OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData);
    218218  DescriptorData->AuthInfo.Hdr.wRevision        = 0x0200;
    219219  DescriptorData->AuthInfo.Hdr.wCertificateType = WIN_CERT_TYPE_EFI_GUID;
    220220  CopyGuid (&DescriptorData->AuthInfo.CertType, &gEfiCertPkcs7Guid);
    221  
     221
    222222  if (Payload != NULL) {
    223223    FreePool(Payload);
    224224  }
    225  
     225
    226226  *DataSize = DescriptorSize + PayloadSize;
    227227  *Data     = NewData;
     
    288288  @param[in]   SecureBootMode        New secure boot mode: STANDARD_SECURE_BOOT_MODE or
    289289                                     CUSTOM_SECURE_BOOT_MODE.
    290  
     290
    291291  @return EFI_SUCCESS                The platform has switched to the special mode successfully.
    292292  @return other                      Fail to operate the secure boot mode.
    293  
     293
    294294**/
    295295EFI_STATUS
     
    298298  )
    299299{
    300   return gRT->SetVariable (                         
     300  return gRT->SetVariable (
    301301                EFI_CUSTOM_MODE_NAME,
    302302                &gEfiCustomModeEnableGuid,
     
    312312  @param[in]   X509File              FileHandle of X509 Certificate storing file.
    313313  @param[out]  PkCert                Point to the data buffer to store the signature list.
    314  
     314
    315315  @return EFI_UNSUPPORTED            Unsupported Key Length.
    316316  @return EFI_OUT_OF_RESOURCES       There are not enough memory resourses to form the signature list.
    317  
     317
    318318**/
    319319EFI_STATUS
    320320CreatePkX509SignatureList (
    321   IN    EFI_FILE_HANDLE             X509File, 
    322   OUT   EFI_SIGNATURE_LIST          **PkCert 
     321  IN    EFI_FILE_HANDLE             X509File,
     322  OUT   EFI_SIGNATURE_LIST          **PkCert
    323323  )
    324324{
    325   EFI_STATUS              Status; 
     325  EFI_STATUS              Status;
    326326  UINT8                   *X509Data;
    327327  UINTN                   X509DataSize;
     
    330330  X509Data = NULL;
    331331  PkCertData = NULL;
    332   X509DataSize = 0; 
    333  
     332  X509DataSize = 0;
     333
    334334  Status = ReadFileContent (X509File, (VOID**) &X509Data, &X509DataSize, 0);
    335335  if (EFI_ERROR (Status)) {
     
    351351  }
    352352
    353   (*PkCert)->SignatureListSize   = (UINT32) (sizeof(EFI_SIGNATURE_LIST) 
     353  (*PkCert)->SignatureListSize   = (UINT32) (sizeof(EFI_SIGNATURE_LIST)
    354354                                    + sizeof(EFI_SIGNATURE_DATA) - 1
    355355                                    + X509DataSize);
     
    357357  (*PkCert)->SignatureHeaderSize = 0;
    358358  CopyGuid (&(*PkCert)->SignatureType, &gEfiCertX509Guid);
    359   PkCertData                     = (EFI_SIGNATURE_DATA*) ((UINTN)(*PkCert) 
     359  PkCertData                     = (EFI_SIGNATURE_DATA*) ((UINTN)(*PkCert)
    360360                                                          + sizeof(EFI_SIGNATURE_LIST)
    361361                                                          + (*PkCert)->SignatureHeaderSize);
    362   CopyGuid (&PkCertData->SignatureOwner, &gEfiGlobalVariableGuid);   
     362  CopyGuid (&PkCertData->SignatureOwner, &gEfiGlobalVariableGuid);
    363363  //
    364364  // Fill the PK database with PKpub data from X509 certificate file.
    365   // 
     365  //
    366366  CopyMem (&(PkCertData->SignatureData[0]), X509Data, X509DataSize);
    367  
     367
    368368ON_EXIT:
    369  
     369
    370370  if (X509Data != NULL) {
    371371    FreePool (X509Data);
    372372  }
    373  
     373
    374374  if (EFI_ERROR(Status) && *PkCert != NULL) {
    375375    FreePool (*PkCert);
    376376    *PkCert = NULL;
    377377  }
    378  
     378
    379379  return Status;
    380380}
     
    390390  @retval   EFI_INVALID_PARAMETER  The parameter is invalid.
    391391  @retval   EFI_OUT_OF_RESOURCES   Could not allocate needed resources.
    392  
     392
    393393**/
    394394EFI_STATUS
    395395EnrollPlatformKey (
    396396   IN  SECUREBOOT_CONFIG_PRIVATE_DATA*   Private
    397   )                       
     397  )
    398398{
    399399  EFI_STATUS                      Status;
     
    403403  UINT16*                         FilePostFix;
    404404  UINTN                           NameLength;
    405  
     405
    406406  if (Private->FileContext->FileName == NULL) {
    407407    return EFI_INVALID_PARAMETER;
     
    434434  //
    435435  Status = CreatePkX509SignatureList (
    436             Private->FileContext->FHandle, 
    437             &PkCert 
     436            Private->FileContext->FHandle,
     437            &PkCert
    438438            );
    439439  if (EFI_ERROR (Status)) {
     
    441441  }
    442442  ASSERT (PkCert != NULL);
    443                          
     443
    444444  //
    445445  // Set Platform Key variable.
    446   // 
    447   Attr = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS 
     446  //
     447  Attr = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS
    448448          | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
    449449  DataSize = PkCert->SignatureListSize;
     
    453453    goto ON_EXIT;
    454454  }
    455  
     455
    456456  Status = gRT->SetVariable(
    457                   EFI_PLATFORM_KEY_NAME, 
    458                   &gEfiGlobalVariableGuid, 
    459                   Attr, 
    460                   DataSize, 
     457                  EFI_PLATFORM_KEY_NAME,
     458                  &gEfiGlobalVariableGuid,
     459                  Attr,
     460                  DataSize,
    461461                  PkCert
    462462                  );
     
    467467    goto ON_EXIT;
    468468  }
    469  
     469
    470470ON_EXIT:
    471471
     
    473473    FreePool(PkCert);
    474474  }
    475  
     475
    476476  if (Private->FileContext->FHandle != NULL) {
    477477    CloseFile (Private->FileContext->FHandle);
     
    487487  @retval EFI_SUCCESS    Delete PK successfully.
    488488  @retval Others         Could not allow to delete PK.
    489  
     489
    490490**/
    491491EFI_STATUS
     
    533533  EFI_SIGNATURE_DATA              *KEKSigData;
    534534  UINTN                           KekSigListSize;
    535   UINT8                           *KeyBuffer; 
     535  UINT8                           *KeyBuffer;
    536536  UINTN                           KeyLenInBytes;
    537537
     
    545545  KekSigList  = NULL;
    546546  KekSigListSize = 0;
    547  
     547
    548548  //
    549549  // Form the KeKpub certificate list into EFI_SIGNATURE_LIST type.
    550550  // First, We have to parse out public key data from the pbk key file.
    551   //               
     551  //
    552552  Status = ReadFileContent (
    553553             Private->FileContext->FHandle,
     
    566566    goto ON_EXIT;
    567567  }
    568  
     568
    569569  //
    570570  // Convert the Public key to fix octet string format represented in RSA PKCS#1.
    571   // 
     571  //
    572572  KeyLenInBytes = KeyInfo->KeyLengthInBits / 8;
    573573  KeyBuffer = AllocateZeroPool (KeyLenInBytes);
     
    577577  }
    578578  Int2OctStr (
    579     (UINTN*) (KeyBlob + sizeof (CPL_KEY_INFO)), 
    580     KeyLenInBytes / sizeof (UINTN), 
    581     KeyBuffer, 
     579    (UINTN*) (KeyBlob + sizeof (CPL_KEY_INFO)),
     580    KeyLenInBytes / sizeof (UINTN),
     581    KeyBuffer,
    582582    KeyLenInBytes
    583583    );
    584584  CopyMem(KeyBlob + sizeof(CPL_KEY_INFO), KeyBuffer, KeyLenInBytes);
    585  
     585
    586586  //
    587587  // Form an new EFI_SIGNATURE_LIST.
     
    603603  KekSigList->SignatureSize = sizeof(EFI_SIGNATURE_DATA) - 1 + WIN_CERT_UEFI_RSA2048_SIZE;
    604604  CopyGuid (&KekSigList->SignatureType, &gEfiCertRsa2048Guid);
    605  
     605
    606606  KEKSigData = (EFI_SIGNATURE_DATA*)((UINT8*)KekSigList + sizeof(EFI_SIGNATURE_LIST));
    607607  CopyGuid (&KEKSigData->SignatureOwner, Private->SignatureGUID);
     
    611611    WIN_CERT_UEFI_RSA2048_SIZE
    612612    );
    613  
    614   //
    615   // Check if KEK entry has been already existed. 
    616   // If true, use EFI_VARIABLE_APPEND_WRITE attribute to append the 
     613
     614  //
     615  // Check if KEK entry has been already existed.
     616  // If true, use EFI_VARIABLE_APPEND_WRITE attribute to append the
    617617  // new KEK to original variable.
    618   //           
    619   Attr = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS 
     618  //
     619  Attr = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS
    620620         | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
    621621  Status = CreateTimeBasedPayload (&KekSigListSize, (UINT8**) &KekSigList);
     
    626626
    627627  Status = gRT->GetVariable(
    628                   EFI_KEY_EXCHANGE_KEY_NAME, 
    629                   &gEfiGlobalVariableGuid, 
    630                   NULL, 
    631                   &DataSize, 
     628                  EFI_KEY_EXCHANGE_KEY_NAME,
     629                  &gEfiGlobalVariableGuid,
     630                  NULL,
     631                  &DataSize,
    632632                  NULL
    633633                  );
     
    637637    goto ON_EXIT;
    638638  }
    639  
     639
    640640  //
    641641  // Done. Now we have formed the correct KEKpub database item, just set it into variable storage,
    642   //             
     642  //
    643643  Status = gRT->SetVariable(
    644                   EFI_KEY_EXCHANGE_KEY_NAME, 
    645                   &gEfiGlobalVariableGuid, 
    646                   Attr, 
    647                   KekSigListSize, 
     644                  EFI_KEY_EXCHANGE_KEY_NAME,
     645                  &gEfiGlobalVariableGuid,
     646                  Attr,
     647                  KekSigListSize,
    648648                  KekSigList
    649649                  );
     
    651651    goto ON_EXIT;
    652652  }
    653  
     653
    654654ON_EXIT:
    655655
     
    672672    FreePool (KekSigList);
    673673  }
    674  
     674
    675675  return Status;
    676676}
     
    690690EnrollX509ToKek (
    691691  IN SECUREBOOT_CONFIG_PRIVATE_DATA *Private
    692   ) 
     692  )
    693693{
    694694  EFI_STATUS                        Status;
     
    728728  //
    729729  // Fill Certificate Database parameters.
    730   // 
     730  //
    731731  KekSigList->SignatureListSize   = (UINT32) KekSigListSize;
    732732  KekSigList->SignatureHeaderSize = 0;
     
    739739
    740740  //
    741   // Check if KEK been already existed. 
    742   // If true, use EFI_VARIABLE_APPEND_WRITE attribute to append the 
     741  // Check if KEK been already existed.
     742  // If true, use EFI_VARIABLE_APPEND_WRITE attribute to append the
    743743  // new kek to original variable
    744   //   
    745   Attr = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS 
     744  //
     745  Attr = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS
    746746          | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
    747747  Status = CreateTimeBasedPayload (&KekSigListSize, (UINT8**) &KekSigList);
     
    750750    goto ON_EXIT;
    751751  }
    752  
     752
    753753  Status = gRT->GetVariable(
    754                   EFI_KEY_EXCHANGE_KEY_NAME, 
    755                   &gEfiGlobalVariableGuid, 
    756                   NULL, 
    757                   &DataSize, 
     754                  EFI_KEY_EXCHANGE_KEY_NAME,
     755                  &gEfiGlobalVariableGuid,
     756                  NULL,
     757                  &DataSize,
    758758                  NULL
    759759                  );
     
    762762  } else if (Status != EFI_NOT_FOUND) {
    763763    goto ON_EXIT;
    764   } 
     764  }
    765765
    766766  Status = gRT->SetVariable(
    767                   EFI_KEY_EXCHANGE_KEY_NAME, 
    768                   &gEfiGlobalVariableGuid, 
    769                   Attr, 
     767                  EFI_KEY_EXCHANGE_KEY_NAME,
     768                  &gEfiGlobalVariableGuid,
     769                  Attr,
    770770                  KekSigListSize,
    771771                  KekSigList
     
    796796  Enroll new KEK into the System without PK's authentication.
    797797  The SignatureOwner GUID will be Private->SignatureGUID.
    798  
     798
    799799  @param[in] PrivateData     The module's private data.
    800  
     800
    801801  @retval   EFI_SUCCESS            New KEK enrolled successful.
    802802  @retval   EFI_INVALID_PARAMETER  The parameter is invalid.
    803803  @retval   others                 Fail to enroll KEK data.
    804  
     804
    805805**/
    806806EFI_STATUS
    807807EnrollKeyExchangeKey (
    808808  IN SECUREBOOT_CONFIG_PRIVATE_DATA *Private
    809   ) 
     809  )
    810810{
    811811  UINT16*     FilePostFix;
    812812  EFI_STATUS  Status;
    813813  UINTN       NameLength;
    814  
     814
    815815  if ((Private->FileContext->FileName == NULL) || (Private->SignatureGUID == NULL)) {
    816816    return EFI_INVALID_PARAMETER;
     
    823823
    824824  //
    825   // Parse the file's postfix. Supports DER-encoded X509 certificate, 
     825  // Parse the file's postfix. Supports DER-encoded X509 certificate,
    826826  // and .pbk as RSA public key file.
    827827  //
     
    845845
    846846  @param[in] PrivateData     The module's private data.
    847   @param[in] VariableName    Variable name of signature database, must be 
     847  @param[in] VariableName    Variable name of signature database, must be
    848848                             EFI_IMAGE_SECURITY_DATABASE or EFI_IMAGE_SECURITY_DATABASE1.
    849  
     849
    850850  @retval   EFI_SUCCESS            New X509 is enrolled successfully.
    851851  @retval   EFI_OUT_OF_RESOURCES   Could not allocate needed resources.
     
    856856  IN SECUREBOOT_CONFIG_PRIVATE_DATA *Private,
    857857  IN CHAR16                         *VariableName
    858   ) 
     858  )
    859859{
    860860  EFI_STATUS                        Status;
     
    897897  //
    898898  // Fill Certificate Database parameters.
    899   // 
     899  //
    900900  SigDBCert = (EFI_SIGNATURE_LIST*) Data;
    901901  SigDBCert->SignatureListSize   = (UINT32) SigDBSize;
     
    909909
    910910  //
    911   // Check if signature database entry has been already existed. 
    912   // If true, use EFI_VARIABLE_APPEND_WRITE attribute to append the 
     911  // Check if signature database entry has been already existed.
     912  // If true, use EFI_VARIABLE_APPEND_WRITE attribute to append the
    913913  // new signature data to original variable
    914   //   
    915   Attr = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS 
     914  //
     915  Attr = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS
    916916          | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
    917917  Status = CreateTimeBasedPayload (&SigDBSize, (UINT8**) &Data);
     
    922922
    923923  Status = gRT->GetVariable(
    924                   VariableName, 
    925                   &gEfiImageSecurityDatabaseGuid, 
    926                   NULL, 
    927                   &DataSize, 
     924                  VariableName,
     925                  &gEfiImageSecurityDatabaseGuid,
     926                  NULL,
     927                  &DataSize,
    928928                  NULL
    929929                  );
     
    932932  } else if (Status != EFI_NOT_FOUND) {
    933933    goto ON_EXIT;
    934   } 
     934  }
    935935
    936936  Status = gRT->SetVariable(
    937                   VariableName, 
    938                   &gEfiImageSecurityDatabaseGuid, 
    939                   Attr, 
     937                  VariableName,
     938                  &gEfiImageSecurityDatabaseGuid,
     939                  Attr,
    940940                  SigDBSize,
    941941                  Data
     
    977977EFI_STATUS
    978978LoadPeImage (
    979   VOID 
    980   )   
     979  VOID
     980  )
    981981{
    982982  EFI_IMAGE_DOS_HEADER                  *DosHdr;
     
    993993  {
    994994    //
    995     // DOS image header is present, 
     995    // DOS image header is present,
    996996    // So read the PE header after the DOS image header
    997997    //
     
    10181018  // Note the size of FileHeader field is constant for both IA32 and X64 arch
    10191019  //
    1020   if ((NtHeader32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) 
     1020  if ((NtHeader32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32)
    10211021      || (NtHeader32->FileHeader.Machine == EFI_IMAGE_MACHINE_EBC)) {
    10221022    //
     
    10461046
    10471047  @param[in]    HashAlg   Hash algorithm type.
    1048  
     1048
    10491049  @retval TRUE            Successfully hash image.
    10501050  @retval FALSE           Fail in hash image.
    10511051
    10521052**/
    1053 BOOLEAN 
     1053BOOLEAN
    10541054HashPeImage (
    10551055  IN  UINT32                HashAlg
     
    10751075    return FALSE;
    10761076  }
    1077  
     1077
    10781078  //
    10791079  // Initialize context of hash.
     
    10831083  if (HashAlg == HASHALG_SHA1) {
    10841084    mImageDigestSize  = SHA1_DIGEST_SIZE;
    1085     mCertType         = gEfiCertSha1Guid;   
     1085    mCertType         = gEfiCertSha1Guid;
    10861086  } else if (HashAlg == HASHALG_SHA256) {
    10871087    mImageDigestSize  = SHA256_DIGEST_SIZE;
     
    10901090
    10911091  CtxSize   = mHash[HashAlg].GetContextSize();
    1092  
     1092
    10931093  HashCtx = AllocatePool (CtxSize);
    10941094  ASSERT (HashCtx != NULL);
     
    11071107  if (mNtHeader.Pe32->FileHeader.Machine == IMAGE_FILE_MACHINE_IA64 && mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
    11081108    //
    1109     // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value 
    1110     //       in the PE/COFF Header. If the MachineType is Itanium(IA64) and the 
     1109    // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value
     1110    //       in the PE/COFF Header. If the MachineType is Itanium(IA64) and the
    11111111    //       Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
    11121112    //       then override the magic value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
     
    11191119    Magic = mNtHeader.Pe32->OptionalHeader.Magic;
    11201120  }
    1121  
     1121
    11221122  //
    11231123  // 3.  Calculate the distance from the base of the image header to the image checksum address.
     
    11551155    //
    11561156    // Use PE32+ offset.
    1157     //   
     1157    //
    11581158    HashBase = (UINT8 *) &mNtHeader.Pe32Plus->OptionalHeader.CheckSum + sizeof (UINT32);
    11591159    HashSize = (UINTN) ((UINT8 *) (&mNtHeader.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_SECURITY]) - HashBase);
     
    12781278                 mImageSize -
    12791279                 mNtHeader.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_SECURITY].Size -
    1280                  SumOfBytesHashed);     
     1280                 SumOfBytesHashed);
    12811281    }
    12821282
     
    13001300
    13011301/**
    1302   Recognize the Hash algorithm in PE/COFF Authenticode and caculate hash of 
    1303   Pe/Coff image based on the authenticated image hashing in PE/COFF Specification 
     1302  Recognize the Hash algorithm in PE/COFF Authenticode and caculate hash of
     1303  Pe/Coff image based on the authenticated image hashing in PE/COFF Specification
    13041304  8.0 Appendix A
    13051305
     
    13081308
    13091309**/
    1310 EFI_STATUS 
     1310EFI_STATUS
    13111311HashPeImageByType (
    13121312  VOID
     
    13181318  PkcsCertData = (WIN_CERTIFICATE_EFI_PKCS *) (mImageBase + mSecDataDir->Offset);
    13191319
    1320   for (Index = 0; Index < HASHALG_MAX; Index++) { 
     1320  for (Index = 0; Index < HASHALG_MAX; Index++) {
    13211321    //
    13221322    // Check the Hash algorithm in PE/COFF Authenticode.
    1323     //    According to PKCS#7 Definition: 
     1323    //    According to PKCS#7 Definition:
    13241324    //        SignedData ::= SEQUENCE {
    13251325    //            version Version,
     
    13381338    }
    13391339
    1340     //   
     1340    //
    13411341    if (CompareMem (PkcsCertData->CertData + 32, mHash[Index].OidValue, mHash[Index].OidLength) == 0) {
    13421342      break;
     
    13591359
    13601360/**
    1361   Enroll a new executable's signature into Signature Database. 
     1361  Enroll a new executable's signature into Signature Database.
    13621362
    13631363  @param[in] PrivateData     The module's private data.
    1364   @param[in] VariableName    Variable name of signature database, must be 
     1364  @param[in] VariableName    Variable name of signature database, must be
    13651365                             EFI_IMAGE_SECURITY_DATABASE or EFI_IMAGE_SECURITY_DATABASE1.
    13661366
     
    14031403  Status = ReadFileContent(
    14041404             Private->FileContext->FHandle,
    1405              (VOID **) &mImageBase, 
    1406              &mImageSize, 
     1405             (VOID **) &mImageBase,
     1406             &mImageSize,
    14071407             0
    14081408             );
    14091409  if (EFI_ERROR (Status)) {
    14101410    goto ON_EXIT;
    1411   } 
     1411  }
    14121412  ASSERT (mImageBase != NULL);
    14131413
     
    14231423    }
    14241424  } else {
    1425  
     1425
    14261426    //
    14271427    // Read the certificate data
     
    14401440        goto ON_EXIT;;
    14411441      }
    1442    
     1442
    14431443    } else if (mCertificate->wCertificateType == WIN_CERT_TYPE_PKCS_SIGNED_DATA) {
    14441444
     
    14561456  // Create a new SigDB entry.
    14571457  //
    1458   SigDBSize = sizeof(EFI_SIGNATURE_LIST) 
     1458  SigDBSize = sizeof(EFI_SIGNATURE_LIST)
    14591459              + sizeof(EFI_SIGNATURE_DATA) - 1
    14601460              + (UINT32) mImageDigestSize;
     
    14651465    goto ON_EXIT;
    14661466  }
    1467  
     1467
    14681468  //
    14691469  // Adjust the Certificate Database parameters.
    1470   // 
     1470  //
    14711471  SigDBCert = (EFI_SIGNATURE_LIST*) Data;
    14721472  SigDBCert->SignatureListSize   = (UINT32) SigDBSize;
     
    14791479  CopyMem (SigDBCertData->SignatureData, mImageDigest, mImageDigestSize);
    14801480
    1481   Attr = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS 
     1481  Attr = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS
    14821482          | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
    14831483  Status = CreateTimeBasedPayload (&SigDBSize, (UINT8**) &Data);
     
    14861486    goto ON_EXIT;
    14871487  }
    1488  
    1489   //
    1490   // Check if SigDB variable has been already existed. 
    1491   // If true, use EFI_VARIABLE_APPEND_WRITE attribute to append the 
     1488
     1489  //
     1490  // Check if SigDB variable has been already existed.
     1491  // If true, use EFI_VARIABLE_APPEND_WRITE attribute to append the
    14921492  // new signature data to original variable
    1493   //   
     1493  //
    14941494  DataSize = 0;
    14951495  Status = gRT->GetVariable(
    1496                   VariableName, 
    1497                   &gEfiImageSecurityDatabaseGuid, 
    1498                   NULL, 
    1499                   &DataSize, 
     1496                  VariableName,
     1497                  &gEfiImageSecurityDatabaseGuid,
     1498                  NULL,
     1499                  &DataSize,
    15001500                  NULL
    15011501                  );
     
    15041504  } else if (Status != EFI_NOT_FOUND) {
    15051505    goto ON_EXIT;
    1506   } 
     1506  }
    15071507
    15081508  //
     
    15101510  //
    15111511  Status = gRT->SetVariable(
    1512                   VariableName, 
    1513                   &gEfiImageSecurityDatabaseGuid, 
    1514                   Attr, 
    1515                   SigDBSize, 
     1512                  VariableName,
     1513                  &gEfiImageSecurityDatabaseGuid,
     1514                  Attr,
     1515                  SigDBSize,
    15161516                  Data
    15171517                  );
     
    15461546  Enroll signature into DB/DBX without KEK's authentication.
    15471547  The SignatureOwner GUID will be Private->SignatureGUID.
    1548  
     1548
    15491549  @param[in] PrivateData     The module's private data.
    1550   @param[in] VariableName    Variable name of signature database, must be 
     1550  @param[in] VariableName    Variable name of signature database, must be
    15511551                             EFI_IMAGE_SECURITY_DATABASE or EFI_IMAGE_SECURITY_DATABASE1.
    1552  
     1552
    15531553  @retval   EFI_SUCCESS            New signature enrolled successfully.
    15541554  @retval   EFI_INVALID_PARAMETER  The parameter is invalid.
    15551555  @retval   others                 Fail to enroll signature data.
    1556  
     1556
    15571557**/
    15581558EFI_STATUS
     
    15601560  IN SECUREBOOT_CONFIG_PRIVATE_DATA     *Private,
    15611561  IN CHAR16                             *VariableName
    1562   ) 
     1562  )
    15631563{
    15641564  UINT16*      FilePostFix;
     
    15741574    return Status;
    15751575  }
    1576  
    1577   //
    1578   // Parse the file's postfix. 
     1576
     1577  //
     1578  // Parse the file's postfix.
    15791579  //
    15801580  NameLength = StrLen (Private->FileContext->FileName);
     
    16061606  @retval   EFI_SUCCESS             Success to update the signature list page
    16071607  @retval   EFI_OUT_OF_RESOURCES    Unable to allocate required resources.
    1608  
     1608
    16091609**/
    16101610EFI_STATUS
     
    16251625  VOID                        *EndOpCodeHandle;
    16261626  EFI_IFR_GUID_LABEL          *StartLabel;
    1627   EFI_IFR_GUID_LABEL          *EndLabel; 
     1627  EFI_IFR_GUID_LABEL          *EndLabel;
    16281628  UINTN                       DataSize;
    16291629  UINT8                       *Data;
     
    16411641  StartOpCodeHandle = NULL;
    16421642  EndOpCodeHandle   = NULL;
    1643  
     1643
    16441644  //
    16451645  // Initialize the container for dynamic opcodes.
     
    16481648  if (StartOpCodeHandle == NULL) {
    16491649    Status = EFI_OUT_OF_RESOURCES;
    1650     goto ON_EXIT; 
     1650    goto ON_EXIT;
    16511651  }
    16521652
     
    16541654  if (EndOpCodeHandle == NULL) {
    16551655    Status = EFI_OUT_OF_RESOURCES;
    1656     goto ON_EXIT; 
     1656    goto ON_EXIT;
    16571657  }
    16581658
     
    16821682  //
    16831683  DataSize = 0;
    1684   Status = gRT->GetVariable (VariableName, VendorGuid, NULL, &DataSize, Data); 
     1684  Status = gRT->GetVariable (VariableName, VendorGuid, NULL, &DataSize, Data);
    16851685  if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
    16861686    goto ON_EXIT;
     
    17321732    CertCount  = (CertList->SignatureListSize - sizeof (EFI_SIGNATURE_LIST) - CertList->SignatureHeaderSize) / CertList->SignatureSize;
    17331733    for (Index = 0; Index < CertCount; Index++) {
    1734       Cert = (EFI_SIGNATURE_DATA *) ((UINT8 *) CertList 
    1735                                               + sizeof (EFI_SIGNATURE_LIST) 
    1736                                               + CertList->SignatureHeaderSize 
     1734      Cert = (EFI_SIGNATURE_DATA *) ((UINT8 *) CertList
     1735                                              + sizeof (EFI_SIGNATURE_LIST)
     1736                                              + CertList->SignatureHeaderSize
    17371737                                              + Index * CertList->SignatureSize);
    17381738      //
    1739       // Display GUID and help 
     1739      // Display GUID and help
    17401740      //
    17411741      GuidToString (&Cert->SignatureOwner, GuidStr, 100);
     
    17441744        StartOpCodeHandle,
    17451745        (EFI_QUESTION_ID) (QuestionIdBase + GuidIndex++),
    1746         0, 
    1747         0, 
    1748         GuidID, 
     1746        0,
     1747        0,
     1748        GuidID,
    17491749        Help,
    17501750        EFI_IFR_FLAG_CALLBACK,
    17511751        0,
    17521752        NULL
    1753         );       
     1753        );
    17541754    }
    17551755
     
    17741774    HiiFreeOpCodeHandle (EndOpCodeHandle);
    17751775  }
    1776  
     1776
    17771777  if (Data != NULL) {
    17781778    FreePool (Data);
     
    17871787
    17881788/**
    1789   Delete a KEK entry from KEK database. 
     1789  Delete a KEK entry from KEK database.
    17901790
    17911791  @param[in]    PrivateData         Module's private data.
     
    17941794  @retval   EFI_SUCCESS            Delete kek item successfully.
    17951795  @retval   EFI_OUT_OF_RESOURCES   Could not allocate needed resources.
    1796  
     1796
    17971797**/
    17981798EFI_STATUS
     
    18221822  CertList        = NULL;
    18231823  Cert            = NULL;
    1824   Attr            = 0;   
     1824  Attr            = 0;
    18251825  DeleteKekIndex  = QuestionId - OPTION_DEL_KEK_QUESTION_ID;
    18261826
     
    18291829    return Status;
    18301830  }
    1831  
     1831
    18321832  //
    18331833  // Get original KEK variable.
    1834   //                           
    1835   DataSize = 0; 
     1834  //
     1835  DataSize = 0;
    18361836  Status = gRT->GetVariable (EFI_KEY_EXCHANGE_KEY_NAME, &gEfiGlobalVariableGuid, NULL, &DataSize, NULL);
    18371837  if (EFI_ERROR(Status) && Status != EFI_BUFFER_TOO_SMALL) {
     
    18411841  OldData = (UINT8*)AllocateZeroPool(DataSize);
    18421842  if (OldData == NULL) {
    1843     Status = EFI_OUT_OF_RESOURCES; 
     1843    Status = EFI_OUT_OF_RESOURCES;
    18441844    goto ON_EXIT;
    18451845  }
     
    18511851
    18521852  //
    1853   // Allocate space for new variable. 
     1853  // Allocate space for new variable.
    18541854  //
    18551855  Data = (UINT8*) AllocateZeroPool (DataSize);
     
    18811881          //
    18821882          NewCertList->SignatureListSize -= CertList->SignatureSize;
    1883           IsKEKItemFound = TRUE;         
     1883          IsKEKItemFound = TRUE;
    18841884        } else {
    18851885          //
     
    18991899      Offset += CertList->SignatureListSize;
    19001900    }
    1901      
     1901
    19021902    KekDataSize -= CertList->SignatureListSize;
    19031903    CertList = (EFI_SIGNATURE_LIST*) ((UINT8*) CertList + CertList->SignatureListSize);
     
    19251925      CopyMem (OldData + Offset, CertList, CertList->SignatureListSize);
    19261926      Offset += CertList->SignatureListSize;
    1927     }   
     1927    }
    19281928    KekDataSize -= CertList->SignatureListSize;
    19291929    CertList = (EFI_SIGNATURE_LIST *) ((UINT8 *) CertList + CertList->SignatureListSize);
     
    19401940
    19411941  Status = gRT->SetVariable(
    1942                   EFI_KEY_EXCHANGE_KEY_NAME, 
    1943                   &gEfiGlobalVariableGuid, 
    1944                   Attr, 
    1945                   DataSize, 
     1942                  EFI_KEY_EXCHANGE_KEY_NAME,
     1943                  &gEfiGlobalVariableGuid,
     1944                  Attr,
     1945                  DataSize,
    19461946                  OldData
    19471947                  );
     
    19501950    goto ON_EXIT;
    19511951  }
    1952  
     1952
    19531953ON_EXIT:
    19541954  if (Data != NULL) {
     
    19611961
    19621962  return UpdateDeletePage (
    1963            PrivateData, 
     1963           PrivateData,
    19641964           EFI_KEY_EXCHANGE_KEY_NAME,
    19651965           &gEfiGlobalVariableGuid,
     
    19801980  @param[in]    QuestionIdBase      Base question id of the signature list.
    19811981  @param[in]    DeleteIndex         Signature index to delete.
    1982  
     1982
    19831983  @retval   EFI_SUCCESS             Delete siganture successfully.
    19841984  @retval   EFI_NOT_FOUND           Can't find the signature item,
     
    20152015  CertList        = NULL;
    20162016  Cert            = NULL;
    2017   Attr            = 0; 
     2017  Attr            = 0;
    20182018
    20192019  Status = SetSecureBootMode(CUSTOM_SECURE_BOOT_MODE);
     
    20242024  //
    20252025  // Get original signature list data.
    2026   //                           
     2026  //
    20272027  DataSize = 0;
    20282028  Status = gRT->GetVariable (VariableName, VendorGuid, NULL, &DataSize, NULL);
     
    20332033  OldData = (UINT8 *) AllocateZeroPool (DataSize);
    20342034  if (OldData == NULL) {
    2035     Status = EFI_OUT_OF_RESOURCES; 
     2035    Status = EFI_OUT_OF_RESOURCES;
    20362036    goto ON_EXIT;
    20372037  }
     
    20402040  if (EFI_ERROR(Status)) {
    20412041    goto ON_EXIT;
    2042   } 
    2043 
    2044   //
    2045   // Allocate space for new variable. 
     2042  }
     2043
     2044  //
     2045  // Allocate space for new variable.
    20462046  //
    20472047  Data = (UINT8*) AllocateZeroPool (DataSize);
     
    20792079          //
    20802080          NewCertList->SignatureListSize -= CertList->SignatureSize;
    2081           IsItemFound = TRUE;         
     2081          IsItemFound = TRUE;
    20822082        } else {
    20832083          //
     
    20972097      Offset += CertList->SignatureListSize;
    20982098    }
    2099      
     2099
    21002100    ItemDataSize -= CertList->SignatureListSize;
    21012101    CertList = (EFI_SIGNATURE_LIST *) ((UINT8 *) CertList + CertList->SignatureListSize);
     
    21232123      CopyMem (OldData + Offset, (UINT8*)(CertList), CertList->SignatureListSize);
    21242124      Offset += CertList->SignatureListSize;
    2125     }   
     2125    }
    21262126    ItemDataSize -= CertList->SignatureListSize;
    21272127    CertList = (EFI_SIGNATURE_LIST *) ((UINT8 *) CertList + CertList->SignatureListSize);
     
    21382138
    21392139  Status = gRT->SetVariable(
    2140                   VariableName, 
    2141                   VendorGuid, 
    2142                   Attr, 
    2143                   DataSize, 
     2140                  VariableName,
     2141                  VendorGuid,
     2142                  Attr,
     2143                  DataSize,
    21442144                  OldData
    21452145                  );
     
    21482148    goto ON_EXIT;
    21492149  }
    2150  
     2150
    21512151ON_EXIT:
    21522152  if (Data != NULL) {
     
    21592159
    21602160  return UpdateDeletePage (
    2161            PrivateData, 
     2161           PrivateData,
    21622162           VariableName,
    21632163           VendorGuid,
     
    21702170/**
    21712171  This function extracts configuration from variable.
    2172  
     2172
    21732173  @param[in, out]  ConfigData   Point to SecureBoot configuration private data.
    21742174
     
    21772177SecureBootExtractConfigFromVariable (
    21782178  IN OUT SECUREBOOT_CONFIGURATION    *ConfigData
    2179   ) 
     2179  )
    21802180{
    21812181  UINT8   *SecureBootEnable;
     
    21862186  SetupMode        = NULL;
    21872187  SecureBootMode   = NULL;
    2188  
     2188
    21892189  //
    21902190  // If the SecureBootEnable Variable doesn't exist, hide the SecureBoot Enable/Disable
     
    22012201    }
    22022202  }
    2203  
     2203
    22042204  //
    22052205  // If it is Physical Presence User, set the PhysicalPresent to true.
     
    22102210    ConfigData->PhysicalPresent = FALSE;
    22112211  }
    2212  
     2212
    22132213  //
    22142214  // If there is no PK then the Delete Pk button will be gray.
     
    22902290    return EFI_INVALID_PARAMETER;
    22912291  }
    2292  
     2292
    22932293  AllocatedRequest = FALSE;
    22942294  ConfigRequestHdr = NULL;
     
    22962296  Size             = 0;
    22972297  SecureBoot       = NULL;
    2298  
     2298
    22992299  ZeroMem (&Configuration, sizeof (Configuration));
    23002300  PrivateData      = SECUREBOOT_CONFIG_PRIVATE_FROM_THIS (This);
    23012301  *Progress        = Request;
    2302  
     2302
    23032303  if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &gSecureBootConfigFormSetGuid, mSecureBootStorageName)) {
    23042304    return EFI_NOT_FOUND;
     
    23222322    FreePool (SecureBoot);
    23232323  }
    2324  
     2324
    23252325  BufferSize = sizeof (SECUREBOOT_CONFIGURATION);
    23262326  ConfigRequest = Request;
     
    24002400  UINTN                      BufferSize;
    24012401  EFI_STATUS                 Status;
    2402  
     2402
    24032403  if (Configuration == NULL || Progress == NULL) {
    24042404    return EFI_INVALID_PARAMETER;
     
    24812481{
    24822482  EFI_INPUT_KEY                   Key;
    2483   EFI_STATUS                      Status; 
     2483  EFI_STATUS                      Status;
    24842484  SECUREBOOT_CONFIG_PRIVATE_DATA  *Private;
    24852485  UINTN                           BufferSize;
     
    25062506    return EFI_SUCCESS;
    25072507  }
    2508  
     2508
    25092509  if (Action == EFI_BROWSER_ACTION_RETRIEVE) {
    25102510    Status = EFI_UNSUPPORTED;
     
    25172517    return Status;
    25182518  }
    2519  
     2519
    25202520  if ((Action != EFI_BROWSER_ACTION_CHANGED) &&
    25212521      (Action != EFI_BROWSER_ACTION_CHANGING) &&
     
    25242524    return EFI_UNSUPPORTED;
    25252525  }
    2526  
     2526
    25272527  Private = SECUREBOOT_CONFIG_PRIVATE_FROM_THIS (This);
    25282528
     
    25392539
    25402540  HiiGetBrowserData (&gSecureBootConfigFormSetGuid, mSecureBootStorageName, BufferSize, (UINT8 *) IfrNvData);
    2541  
     2541
    25422542  if (Action == EFI_BROWSER_ACTION_CHANGING) {
    25432543
     
    25962596      // Refresh selected file.
    25972597      //
    2598       CleanUpPage (LabelId, Private);   
     2598      CleanUpPage (LabelId, Private);
    25992599      break;
    2600  
     2600
    26012601    case SECUREBOOT_ADD_PK_FILE_FORM_ID:
    26022602    case FORMID_ENROLL_KEK_FORM:
     
    26182618      break;
    26192619
    2620     case KEY_SECURE_BOOT_DELETE_PK: 
     2620    case KEY_SECURE_BOOT_DELETE_PK:
    26212621      if (Value->u8) {
    26222622        CreatePopUp (
     
    26432643    case KEY_DELETE_KEK:
    26442644      UpdateDeletePage (
    2645         Private, 
     2645        Private,
    26462646        EFI_KEY_EXCHANGE_KEY_NAME,
    26472647        &gEfiGlobalVariableGuid,
    26482648        LABEL_KEK_DELETE,
    26492649        FORMID_DELETE_KEK_FORM,
    2650         OPTION_DEL_KEK_QUESTION_ID         
     2650        OPTION_DEL_KEK_QUESTION_ID
    26512651        );
    26522652      break;
    26532653
    2654     case SECUREBOOT_DELETE_SIGNATURE_FROM_DB:       
     2654    case SECUREBOOT_DELETE_SIGNATURE_FROM_DB:
    26552655      UpdateDeletePage (
    26562656        Private,
     
    27262726          EFI_IMAGE_SECURITY_DATABASE,
    27272727          &gEfiImageSecurityDatabaseGuid,
    2728           LABEL_DB_DELETE,   
     2728          LABEL_DB_DELETE,
    27292729          SECUREBOOT_DELETE_SIGNATURE_FROM_DB,
    27302730          OPTION_DEL_DB_QUESTION_ID,
     
    27372737          EFI_IMAGE_SECURITY_DATABASE1,
    27382738          &gEfiImageSecurityDatabaseGuid,
    2739           LABEL_DBX_DELETE,   
     2739          LABEL_DBX_DELETE,
    27402740          SECUREBOOT_DELETE_SIGNATURE_FROM_DBX,
    27412741          OPTION_DEL_DBX_QUESTION_ID,
     
    27492749    case KEY_SECURE_BOOT_ENABLE:
    27502750      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
    2751       break; 
     2751      break;
    27522752    case KEY_VALUE_SAVE_AND_EXIT_PK:
    27532753      Status = EnrollPlatformKey (Private);
     
    27672767          );
    27682768      } else {
    2769         *ActionRequest = EFI_BROWSER_ACTION_REQUEST_RESET; 
    2770       }       
     2769        *ActionRequest = EFI_BROWSER_ACTION_REQUEST_RESET;
     2770      }
    27712771      break;
    27722772
     
    27802780        Private->FileContext->FileName = NULL;
    27812781      }
    2782    
     2782
    27832783      if (Private->SignatureGUID != NULL) {
    27842784        FreePool (Private->SignatureGUID);
     
    27872787      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;
    27882788      break;
    2789      
     2789
    27902790    case KEY_SECURE_BOOT_MODE:
    27912791      mIsEnterSecureBootForm = FALSE;
     
    28552855    }
    28562856  }
    2857  
     2857
    28582858  if (!EFI_ERROR (Status)) {
    28592859    BufferSize = sizeof (SECUREBOOT_CONFIGURATION);
     
    28612861  }
    28622862  FreePool (IfrNvData);
    2863  
     2863
    28642864  return EFI_SUCCESS;
    28652865}
     
    29272927  PrivateData->FileContext = AllocateZeroPool (sizeof (SECUREBOOT_FILE_CONTEXT));
    29282928  PrivateData->MenuEntry   = AllocateZeroPool (sizeof (SECUREBOOT_MENU_ENTRY));
    2929  
     2929
    29302930  if (PrivateData->FileContext == NULL || PrivateData->MenuEntry == NULL) {
    29312931    UninstallSecureBootConfigForm (PrivateData);
    29322932    return EFI_OUT_OF_RESOURCES;
    29332933  }
    2934  
     2934
    29352935  PrivateData->FeCurrentState = FileExplorerStateInActive;
    29362936  PrivateData->FeDisplayContext = FileExplorerDisplayUnknown;
    2937  
     2937
    29382938  InitializeListHead (&FsOptionMenu.Head);
    29392939  InitializeListHead (&DirectoryMenu.Head);
     
    29762976  mEndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
    29772977  mEndLabel->Number       = LABEL_END;
    2978  
     2978
    29792979  return EFI_SUCCESS;
    29802980}
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.h

    r58459 r58466  
    317317  CHAR16                   *Name;           ///< Name for Hash Algorithm
    318318  UINTN                    DigestLength;    ///< Digest Length
    319   UINT8                    *OidValue;       ///< Hash Algorithm OID ASN.1 Value 
     319  UINT8                    *OidValue;       ///< Hash Algorithm OID ASN.1 Value
    320320  UINTN                    OidLength;       ///< Length of Hash OID Value
    321321  HASH_GET_CONTEXT_SIZE    GetContextSize;  ///< Pointer to Hash GetContentSize function
     
    472472
    473473/**
    474   Clean up the dynamic opcode at label and form specified by both LabelId. 
     474  Clean up the dynamic opcode at label and form specified by both LabelId.
    475475
    476476  @param[in] LabelId         It is both the Form ID and Label ID for opcode deletion.
     
    506506
    507507  @param[in, out]  MenuOption        Menu to be freed
    508  
     508
    509509**/
    510510VOID
     
    515515
    516516/**
    517   Read file content into BufferPtr, the size of the allocate buffer 
     517  Read file content into BufferPtr, the size of the allocate buffer
    518518  is *FileSize plus AddtionAllocateSize.
    519519
     
    521521  @param[in, out]  BufferPtr             Pointers to the pointer of allocated buffer.
    522522  @param[out]      FileSize              Size of input file
    523   @param[in]       AddtionAllocateSize   Addtion size the buffer need to be allocated. 
     523  @param[in]       AddtionAllocateSize   Addtion size the buffer need to be allocated.
    524524                                         In case the buffer need to contain others besides the file content.
    525  
     525
    526526  @retval   EFI_SUCCESS                  The file was read into the buffer.
    527527  @retval   EFI_INVALID_PARAMETER        A parameter was invalid.
     
    543543
    544544  @param[in] FileHandle           The file handle to close.
    545  
     545
    546546**/
    547547VOID
     
    556556  @param[in]   Integer          Pointer to the nonnegative integer to be converted
    557557  @param[in]   IntSizeInWords   Length of integer buffer in words
    558   @param[out]  OctetString      Converted octet string of the specified length 
     558  @param[out]  OctetString      Converted octet string of the specified length
    559559  @param[in]   OSSizeInBytes    Intended length of resulting octet string in bytes
    560560
     
    588588EFI_STATUS
    589589StringToGuid (
    590   IN   CHAR16           *Str, 
    591   IN   UINTN            StrLen, 
     590  IN   CHAR16           *Str,
     591  IN   UINTN            StrLen,
    592592  OUT  EFI_GUID         *Guid
    593593  );
     
    600600  @param[in]     Buffer        Buffer to print Guid into.
    601601  @param[in]     BufferSize    Size of Buffer.
    602  
     602
    603603  @retval    Number of characters printed.
    604604
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigMisc.c

    r48674 r58466  
    1616
    1717/**
    18   Read file content into BufferPtr, the size of the allocate buffer 
     18  Read file content into BufferPtr, the size of the allocate buffer
    1919  is *FileSize plus AddtionAllocateSize.
    2020
     
    2222  @param[in, out]  BufferPtr             Pointers to the pointer of allocated buffer.
    2323  @param[out]      FileSize              Size of input file
    24   @param[in]       AddtionAllocateSize   Addtion size the buffer need to be allocated. 
     24  @param[in]       AddtionAllocateSize   Addtion size the buffer need to be allocated.
    2525                                         In case the buffer need to contain others besides the file content.
    26  
     26
    2727  @retval   EFI_SUCCESS                  The file was read into the buffer.
    2828  @retval   EFI_INVALID_PARAMETER        A parameter was invalid.
     
    6363    goto ON_EXIT;
    6464  }
    65  
     65
    6666  Status = FileHandle->SetPosition (FileHandle, 0);
    6767  if (EFI_ERROR (Status)) {
     
    8787
    8888ON_EXIT:
    89  
     89
    9090  *BufferPtr = Buffer;
    9191  return Status;
     
    9696
    9797  @param[in] FileHandle           The file handle to close.
    98  
     98
    9999**/
    100100VOID
     
    104104{
    105105  if (FileHandle != NULL) {
    106     FileHandle->Close (FileHandle); 
     106    FileHandle->Close (FileHandle);
    107107  }
    108108}
     
    113113  @param[in]   Integer          Pointer to the nonnegative integer to be converted
    114114  @param[in]   IntSizeInWords   Length of integer buffer in words
    115   @param[out]  OctetString      Converted octet string of the specified length 
     115  @param[out]  OctetString      Converted octet string of the specified length
    116116  @param[in]   OSSizeInBytes    Intended length of resulting octet string in bytes
    117117
     
    139139    *Ptr2 = *Ptr1;
    140140  }
    141        
     141
    142142  for (; Ptr1 < (CONST UINT8 *)(Integer + IntSizeInWords) && *Ptr1 == 0; Ptr1++);
    143  
     143
    144144  if (Ptr1 < (CONST UINT8 *)(Integer + IntSizeInWords)) {
    145145    return EFI_BUFFER_TOO_SMALL;
    146146  }
    147  
     147
    148148  if (Ptr2 >= OctetString) {
    149149    ZeroMem (OctetString, Ptr2 - OctetString + 1);
    150150  }
    151  
     151
    152152  return EFI_SUCCESS;
    153153}
     
    168168EFI_STATUS
    169169StringToGuid (
    170   IN   CHAR16           *Str, 
    171   IN   UINTN            StrLen, 
     170  IN   CHAR16           *Str,
     171  IN   UINTN            StrLen,
    172172  OUT  EFI_GUID         *Guid
    173173  )
     
    191191  //
    192192  PtrBuffer       = Buffer;
    193   PtrPosition     = PtrBuffer; 
     193  PtrPosition     = PtrBuffer;
    194194  while (*PtrBuffer != L'\0') {
    195195    if (*PtrBuffer == L'-') {
     
    288288
    289289  FreePool (Buffer);
    290  
     290
    291291  return EFI_SUCCESS;
    292292}
     
    298298  @param[in]     Buffer        Buffer to print Guid into.
    299299  @param[in]     BufferSize    Size of Buffer.
    300  
     300
    301301  @retval    Number of characters printed.
    302302
     
    313313  Size = UnicodeSPrint (
    314314            Buffer,
    315             BufferSize, 
     315            BufferSize,
    316316            L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
    317             (UINTN)Guid->Data1,                   
     317            (UINTN)Guid->Data1,
    318318            (UINTN)Guid->Data2,
    319319            (UINTN)Guid->Data3,
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigNvData.h

    r58459 r58466  
    33
    44Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
    5 This program and the accompanying materials 
    6 are licensed and made available under the terms and conditions of the BSD License 
    7 which accompanies this distribution.  The full text of the license may be found at 
     5This program and the accompanying materials
     6are licensed and made available under the terms and conditions of the BSD License
     7which accompanies this distribution.  The full text of the license may be found at
    88http://opensource.org/licenses/bsd-license.php
    99
    10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
     10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    1111WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    1212
     
    9494// Question ID 0x4000 ~ 0x4FFF is for DBX
    9595//
    96 #define OPTION_DEL_DBX_QUESTION_ID            0x4000 
     96#define OPTION_DEL_DBX_QUESTION_ID            0x4000
    9797
    9898#define FILE_OPTION_GOTO_OFFSET               0xC000
     
    113113  BOOLEAN PhysicalPresent; //If a Physical Present User;
    114114  UINT8   SecureBootMode;  //Secure Boot Mode: Standard Or Custom
    115   BOOLEAN DeletePk; 
     115  BOOLEAN DeletePk;
    116116  BOOLEAN HasPk;           //If Pk is existed it is true;
    117117} SECUREBOOT_CONFIGURATION;
  • trunk/src/VBox/Devices/EFI/Firmware/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigStrings.uni

    • Property svn:mime-type changed from application/octet-stream to text/plain;encoding=UTF-16LE
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette