From nobody Mon Apr 29 01:34:13 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1498459710504676.3984163307156; Sun, 25 Jun 2017 23:48:30 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 01F242095A6A6; Sun, 25 Jun 2017 23:46:59 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 49E7F21AE2627 for ; Sun, 25 Jun 2017 23:46:57 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jun 2017 23:48:25 -0700 Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga001.fm.intel.com with ESMTP; 25 Jun 2017 23:48:25 -0700 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 25 Jun 2017 23:48:25 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 25 Jun 2017 23:48:24 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.116]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.197]) with mapi id 14.03.0319.002; Mon, 26 Jun 2017 14:48:22 +0800 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,394,1493708400"; d="dat'59?scan'59,208,59";a="1164626267" From: "Guo, Mang" To: "edk2-devel@lists.01.org" Thread-Topic: [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017] Security of Setup Variable Thread-Index: AdLuSDOLggYGc+1gQ6+1Mz4ZuDN0Bg== Date: Mon, 26 Jun 2017 06:48:22 +0000 Message-ID: <22D2C85ED001C54AA20BFE3B0E4751D15251D2E5@SHSMSX103.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: <22D2C85ED001C54AA20BFE3B0E4751D15251D2E5@SHSMSX103.ccr.corp.intel.com> x-originating-ip: [10.239.127.40] MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 Subject: [edk2] [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017] Security of Setup Variable X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "liming.guo@intel.com" , "Wei, David" Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" System can still boot to shell and OS successfully after EFI variable delet= ion/corruption. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang --- Platform/BroxtonPlatformPkg/BuildBios.bat | 11 +- .../PlatformPreMemPei/MultiPlatSupport.h | 201 +++++++++++++++++= +++ .../PlatformPreMemPei/PlatformInitPreMem.c | 207 +++++++++++++++++= ++++ .../PlatformPreMemPei/PlatformInitPreMem.h | 4 + .../PlatformSetupDxe/PlatformSetupDxe.c | 38 ++++ .../PlatformSettings/PlatformSetupDxe/Vfr.vfr | 10 +- 6 files changed, 465 insertions(+), 6 deletions(-) create mode 100644 Platform/BroxtonPlatformPkg/Common/PlatformSettings/Pla= tformPreMemPei/MultiPlatSupport.h diff --git a/Platform/BroxtonPlatformPkg/BuildBios.bat b/Platform/BroxtonPl= atformPkg/BuildBios.bat index f656876..2ecc28d 100644 --- a/Platform/BroxtonPlatformPkg/BuildBios.bat +++ b/Platform/BroxtonPlatformPkg/BuildBios.bat @@ -387,10 +387,15 @@ if not exist "%AutoGenPath%" ( findstr /L "_PCD_VALUE_" %AutoGenPath% > %STITCH_PATH%\FlashMap.h =20 echo Running FCE... +copy /b %BUILD_PATH%\FV\FvIBBM.fv + /b %BUILD_PATH%\FV\Soc.fd /b %BUILD_PA= TH%\FV\Temp.fd :: Extract Hii data from build and store a copy in HiiDefaultData.txt -fce.exe read -i %BUILD_PATH%\FV\Soc.fd > %BUILD_PATH%\FV\HiiDefaultData.tx= t 2>>EDK2.log +:: UQI 0006 005C 0078 0030 0031 0030 0031 is for question prompt(STR_IPU_E= NABLED) +:: First 0006 is the length of string; Next six byte values are mapped to = STR_IPU_ENABLED string value defined in Platform\BroxtonPlatformPkg\Common\= PlatformSettings\PlatformSetupDxe\VfrStrings.uni. +fce.exe read -i %BUILD_PATH%\FV\Temp.fd 0006 005C 0078 0030 0031 0030 0031= > %BUILD_PATH%\FV\HiiDefaultData.txt 2>>EDK2.log :: Generate the Setup variable and save changes to BxtXXX.fd -fce.exe update -i %BUILD_PATH%\FV\Soc.fd -s %BUILD_PATH%\FV\HiiDefaultData= .txt -o %BUILD_PATH%\FV\Bxt%Arch%.fd 1>>EDK2.log 2>&1 +:: B73FE497-B92E-416e-8326-45AD0D270091 is the GUID of IBBM FV +fce.exe update -i %BUILD_PATH%\FV\Temp.fd -s %BUILD_PATH%\FV\HiiDefaultDat= a.txt -o %BUILD_PATH%\FV\Bxt%Arch%.fd -g B73FE497-B92E-416e-8326-45AD0D270= 091 -a 1>>EDK2.log 2>&1 +split -f %BUILD_PATH%\FV\Bxt%Arch%.fd -s 0x35000 -o %BUILD_PATH%\FV\FvIBBM= .fv =20 if ErrorLevel 1 goto BldFail =20 @@ -401,7 +406,7 @@ if "%BUILD_TYPE%"=3D=3D"R" set BUILD_TYPE=3DR =20 echo Copy BIOS... set BIOS_Name=3D%BOARD_ID%_%Arch%_%BUILD_TYPE%_%VERSION_MAJOR%_%VERSION_MI= NOR% -copy /y/b %BUILD_PATH%\FV\Bxt%Arch%.fd %STITCH_PATH%\%BIOS_Name%.ROM >nul +copy /y/b %BUILD_PATH%\FV\Soc.fd %STITCH_PATH%\%BIOS_Name%.ROM >n= ul copy /y %STITCH_PATH%\FlashMap.h %STITCH_PATH%\%BIOS_Name%.map >n= ul =20 set Storage_Folder=3D%STITCH_PATH%\%BIOS_Name% diff --git a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformPr= eMemPei/MultiPlatSupport.h b/Platform/BroxtonPlatformPkg/Common/PlatformSet= tings/PlatformPreMemPei/MultiPlatSupport.h new file mode 100644 index 0000000..7f21da2 --- /dev/null +++ b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformPreMemPei= /MultiPlatSupport.h @@ -0,0 +1,201 @@ +/**@file + +Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD = License +which accompanies this distribution. The full text of the license may be = found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. + +**/ + +#ifndef __MULTI_PLATFORM_SUPPORT_H__ +#define __MULTI_PLATFORM_SUPPORT_H__ + +extern EFI_GUID gDefaultDataOptSizeFileGuid; + +/// +/// Alignment of variable name and data, according to the architecture: +/// * For IA-32 and Intel(R) 64 architectures: 1. +/// * For IA-64 architecture: 8. +/// +#if defined (MDE_CPU_IPF) +#define ALIGNMENT 8 +#else +#define ALIGNMENT 1 +#endif + +// +// GET_PAD_SIZE calculates the miminal pad bytes needed to make the curren= t pad size satisfy the alignment requirement. +// +#if (ALIGNMENT =3D=3D 1) +#define GET_PAD_SIZE(a) (0) +#else +#define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1)) +#endif + +/// +/// Alignment of Variable Data Header in Variable Store region. +/// +#define HEADER_ALIGNMENT 4 +#define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) &= (~(HEADER_ALIGNMENT - 1))) + +/// +/// Status of Variable Store Region. +/// +/*typedef enum { + EfiRaw, + EfiValid, + EfiInvalid, + EfiUnknown +} VARIABLE_STORE_STATUS;*/ + +#pragma pack(1) + +/// +/// Variable Store Header Format and State. +/// +#define VARIABLE_STORE_FORMATTED 0x5a +#define VARIABLE_STORE_HEALTHY 0xfe + +/// +/// Variable Store region header. +/// +/*typedef struct { + /// + /// Variable store region signature. + /// + EFI_GUID Signature; + /// + /// Size of entire variable store,=20 + /// including size of variable store header but not including the size o= f FvHeader. + /// + UINT32 Size; + /// + /// Variable region format state. + /// + UINT8 Format; + /// + /// Variable region healthy state. + /// + UINT8 State; + UINT16 Reserved; + UINT32 Reserved1; +} VARIABLE_STORE_HEADER;*/ + +/// +/// Variable data start flag. +/// +#define VARIABLE_DATA 0x55AA + +/// +/// Variable State flags. +/// +#define VAR_IN_DELETED_TRANSITION 0xfe ///< Variable is in obsolete t= ransition. +#define VAR_DELETED 0xfd ///< Variable is obsolete. +#define VAR_HEADER_VALID_ONLY 0x7f ///< Variable header has been = valid. +#define VAR_ADDED 0x3f ///< Variable has been complet= ely added. + +/// +/// Single Variable Data Header Structure. +/// +/*typedef struct { + /// + /// Variable Data Start Flag. + /// + UINT16 StartId; + /// + /// Variable State defined above. + /// + UINT8 State; + UINT8 Reserved; + /// + /// Attributes of variable defined in UEFI specification. + /// + UINT32 Attributes; + /// + /// Size of variable null-terminated Unicode string name. + /// + UINT32 NameSize; + /// + /// Size of the variable data without this header. + /// + UINT32 DataSize; + /// + /// A unique identifier for the vendor that produces and consumes this v= araible. + /// + EFI_GUID VendorGuid; +} VARIABLE_HEADER;*/ + +/// +/// Single Variable Data Header Structure for Auth variable. +/// +/*typedef struct { + /// + /// Variable Data Start Flag. + /// + UINT16 StartId; + /// + /// Variable State defined above. + /// + UINT8 State; + UINT8 Reserved; + /// + /// Attributes of variable defined in UEFI specification. + /// + UINT32 Attributes; + /// + /// Associated monotonic count value against replay attack. + /// + UINT64 MonotonicCount; + /// + /// Associated TimeStamp value against replay attack.=20 + /// + EFI_TIME TimeStamp; + /// + /// Index of associated public key in database. + /// + UINT32 PubKeyIndex; + /// + /// Size of variable null-terminated Unicode string name. + /// + UINT32 NameSize; + /// + /// Size of the variable data without this header. + /// + UINT32 DataSize; + /// + /// A unique identifier for the vendor that produces and consumes this v= araible. + /// + EFI_GUID VendorGuid; +} AUTHENTICATED_VARIABLE_HEADER;*/ + +typedef struct { + UINT16 DefaultId; + UINT16 BoardId; +} DEFAULT_INFO; + +typedef struct { + UINT16 Offset; + UINT8 Value; +} DATA_DELTA; + +typedef struct { + // + // HeaderSize includes HeaderSize fields and DefaultInfo arrays + // + UINT16 HeaderSize; + // + // DefaultInfo arrays those have the same default setting. + // + DEFAULT_INFO DefaultInfo[1]; + // + // Default data is stored as variable storage or the array of DATA_DELTA= .=20 + // +} DEFAULT_DATA; + +#pragma pack() + +#endif diff --git a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformPr= eMemPei/PlatformInitPreMem.c b/Platform/BroxtonPlatformPkg/Common/PlatformS= ettings/PlatformPreMemPei/PlatformInitPreMem.c index fe454bf..49121ae 100644 --- a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformPreMemPei= /PlatformInitPreMem.c +++ b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformPreMemPei= /PlatformInitPreMem.c @@ -75,6 +75,15 @@ #include #include =20 +#include +#include +#include + +// +// GUID used in FCE. FCE generate ffs file with this GUID. +// +EFI_GUID gDefaultDataOptSizeFileGuid =3D { 0x003e7b41, 0x98a2, 0x4be2, { 0= xb2, 0x7a, 0x6c, 0x30, 0xc7, 0x65, 0x52, 0x25 }}; + #if (ENBDT_PF_ENABLE =3D=3D 1) // //SSC @@ -913,6 +922,7 @@ PlatformInitPreMemEntryPoint ( PEI_BOARD_PRE_MEM_INIT_PPI *BoardPreMemInitPpi; UINTN Instance; UINT64 AcpiVariableSetCompatibility; + UINTN VarSize; =20 Status =3D (*PeiServices)->RegisterForShadow (FileHandle); =20 @@ -1116,6 +1126,29 @@ PlatformInitPreMemEntryPoint ( Tick =3D CarMap->IbblPerfRecord4; PERF_END_EX (NULL, "IBBMVer", "IBBL", Tick, 0x1041); =20 + + VarSize =3D sizeof (SYSTEM_CONFIGURATION); + Status =3D VariableServices->GetVariable ( + VariableServices, + L"Setup", + &gEfiSetupVariableGuid, + NULL, + &VarSize, + &SystemConfiguration + ); + if (EFI_ERROR (Status) || VarSize !=3D sizeof(SYSTEM_CONFIGURATION)) { + Status =3D PlatformCreateDefaultVariableHob (EFI_HII_DEFAULT_CLASS_S= TANDARD); + ASSERT_EFI_ERROR (Status); + } + Status =3D VariableServices->GetVariable ( + VariableServices, + L"Setup", + &gEfiSetupVariableGuid, + NULL, + &VarSize, + &SystemConfiguration + ); + ASSERT_EFI_ERROR (Status); // // Normal boot - build Hob for SEC performance data. // @@ -1372,3 +1405,177 @@ ReadBxtIPlatformIds ( return EFI_SUCCESS; } =20 + +/** +Description: + + This function finds the matched default data and create GUID hob for it.=20 + +Arguments: + + DefaultId - Specifies the type of defaults to retrieve. + +Returns: + + EFI_SUCCESS - The matched default data is found. + EFI_NOT_FOUND - The matched default data is not found. + EFI_OUT_OF_RESOURCES - No enough resource to create HOB. + +**/ +EFI_STATUS +PlatformCreateDefaultVariableHob ( + IN UINT16 DefaultId + ) + +{ + UINTN FvInstance; + EFI_FIRMWARE_VOLUME_HEADER *FvHeader; + EFI_FFS_FILE_HEADER *FfsHeader; + UINT32 FileSize; + EFI_COMMON_SECTION_HEADER *Section; + UINT32 SectionLength; + BOOLEAN DefaultSettingIsFound; + DEFAULT_DATA *DefaultData; + DEFAULT_INFO *DefaultInfo; + VARIABLE_STORE_HEADER *VarStoreHeader; + VARIABLE_STORE_HEADER *VarStoreHeaderHob; + UINT8 *VarHobPtr; + UINT8 *VarPtr; + UINT32 VarDataOffset; + UINT32 VarHobDataOffset; + BOOLEAN IsFirstSection; + DATA_DELTA *DataDelta; + UINTN DataDeltaSize; + UINTN Index; + CONST EFI_PEI_SERVICES **PeiServices; + + // + // Get PeiService pointer + // + PeiServices =3D GetPeiServicesTablePointer (); + + // + // Find the FFS file that stores all default data. + // + DefaultSettingIsFound =3D FALSE; + FvInstance =3D 0; + FfsHeader =3D NULL; + while (((*PeiServices)->FfsFindNextVolume (PeiServices, FvInstance, (VOI= D **) &FvHeader) =3D=3D EFI_SUCCESS) && + (!DefaultSettingIsFound)) { + FfsHeader =3D NULL; + while ((*PeiServices)->FfsFindNextFile (PeiServices, EFI_FV_FILETYPE_F= REEFORM, FvHeader, (VOID **) &FfsHeader) =3D=3D EFI_SUCCESS) { + if (CompareGuid ((EFI_GUID *) FfsHeader, &gDefaultDataOptSizeFileGui= d)) { + DefaultSettingIsFound =3D TRUE; + break; + } + } + FvInstance ++; + } + + // + // FFS file is not found. + // + if (!DefaultSettingIsFound) { + return EFI_NOT_FOUND; + } + + // + // Find the matched default data for the input default ID and plat ID. + // + DefaultSettingIsFound =3D FALSE; + VarStoreHeaderHob =3D NULL; + VarHobPtr =3D NULL; + DataDelta =3D NULL; + DataDeltaSize =3D 0; + IsFirstSection =3D TRUE; + VarStoreHeader =3D NULL; + Section =3D (EFI_COMMON_SECTION_HEADER *)(FfsHeader + 1); + FileSize =3D *(UINT32 *)(FfsHeader->Size) & 0x00FFFFFF; + while (((UINTN) Section < (UINTN) FfsHeader + FileSize) && !DefaultSetti= ngIsFound) { + DefaultData =3D (DEFAULT_DATA *) (Section + 1); + DefaultInfo =3D &(DefaultData->DefaultInfo[0]); + SectionLength =3D *(UINT32 *)Section->Size & 0x00FFFFFF; + + if (IsFirstSection) { + // + // Create HOB to store default data so that Variable driver can use = it. + // Allocate more data for header alignment. + // + VarStoreHeader =3D (VARIABLE_STORE_HEADER *) ((UINT8 *) DefaultData = + DefaultData->HeaderSize); + VarStoreHeaderHob =3D (VARIABLE_STORE_HEADER *) BuildGuidHob (&VarSt= oreHeader->Signature, VarStoreHeader->Size + HEADER_ALIGNMENT - 1); + if (VarStoreHeaderHob =3D=3D NULL) { + // + // No enough hob resource. + // + return EFI_OUT_OF_RESOURCES; + } + + // + // Copy variable storage header. + // + CopyMem (VarStoreHeaderHob, VarStoreHeader, sizeof (VARIABLE_STORE_H= EADER)); + // + // Copy variable data. + // + VarPtr =3D (UINT8 *) HEADER_ALIGN ((UINTN) (VarStoreHeader= + 1)); + VarDataOffset =3D (UINT32) ((UINTN) VarPtr - (UINTN) VarStoreHead= er); + VarHobPtr =3D (UINT8 *) HEADER_ALIGN ((UINTN) (VarStoreHeader= Hob + 1)); + VarHobDataOffset =3D (UINT32) ((UINTN) VarHobPtr - (UINTN) VarStoreH= eaderHob); + CopyMem (VarHobPtr, VarPtr, VarStoreHeader->Size - VarDataOffset); + // + // Update variable size. + // + VarStoreHeaderHob->Size =3D VarStoreHeader->Size - VarDataOffset + V= arHobDataOffset; + + // + // Update Delta Data + // + VarHobPtr =3D (UINT8 *) VarStoreHeaderHob - VarDataOffset + VarHobDa= taOffset; + } else { + // + // Apply delta setting + // + DataDelta =3D (DATA_DELTA *) ((UINT8 *) DefaultData + DefaultDat= a->HeaderSize); + DataDeltaSize =3D SectionLength - sizeof (EFI_COMMON_SECTION_HEADER)= - DefaultData->HeaderSize; + for (Index =3D 0; Index < DataDeltaSize / sizeof (DATA_DELTA); Index= ++) { + *((UINT8 *) VarHobPtr + DataDelta[Index].Offset) =3D DataDelta[Ind= ex].Value; + } + } + + // + // Find the matched DefaultId + // + while ((UINTN) DefaultInfo < (UINTN) DefaultData + DefaultData->Header= Size) { + if (DefaultInfo->DefaultId =3D=3D DefaultId) { + DefaultSettingIsFound =3D TRUE; + break; + } + DefaultInfo ++; + } + // + // Size is 24 bits wide so mask upper 8 bits.=20 + // SectionLength is adjusted it is 4 byte aligned. + // Go to the next section + // + SectionLength =3D (SectionLength + 3) & (~3); + ASSERT (SectionLength !=3D 0); + Section =3D (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLe= ngth); + IsFirstSection =3D FALSE; + } + // + // Matched default data is not found. + // + if (!DefaultSettingIsFound) { + // + // Change created HOB type to be unused. + // + if (VarStoreHeaderHob !=3D NULL) { + ((EFI_HOB_GUID_TYPE *)((UINT8 *) VarStoreHeaderHob - sizeof (EFI_HOB= _GUID_TYPE)))->Header.HobType =3D EFI_HOB_TYPE_UNUSED; + } + return EFI_NOT_FOUND; + } + + + return EFI_SUCCESS; +} + diff --git a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformPr= eMemPei/PlatformInitPreMem.h b/Platform/BroxtonPlatformPkg/Common/PlatformS= ettings/PlatformPreMemPei/PlatformInitPreMem.h index 17b4dad..3aa5033 100644 --- a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformPreMemPei= /PlatformInitPreMem.h +++ b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformPreMemPei= /PlatformInitPreMem.h @@ -139,5 +139,9 @@ InstallMonoStatusCode ( IN CONST EFI_PEI_SERVICES **PeiServices ); =20 +EFI_STATUS=20 +PlatformCreateDefaultVariableHob ( +IN UINT16 DefaultId +); #endif =20 diff --git a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformSe= tupDxe/PlatformSetupDxe.c b/Platform/BroxtonPlatformPkg/Common/PlatformSett= ings/PlatformSetupDxe/PlatformSetupDxe.c index 54c751f..ff59496 100644 --- a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformSetupDxe/= PlatformSetupDxe.c +++ b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformSetupDxe/= PlatformSetupDxe.c @@ -402,6 +402,8 @@ SystemConfigCallback ( CHAR16 *StringBuffer2; EFI_STATUS Status; SEC_OPERATION_PROTOCOL *SeCOp; + UINTN VariableSize; + UINT32 VariableAttributes; =20 StringBuffer1 =3D AllocateZeroPool (200 * sizeof (CHAR16)); ASSERT (StringBuffer1 !=3D NULL); @@ -412,7 +414,43 @@ SystemConfigCallback ( return EFI_OUT_OF_RESOURCES; } =20 + Private =3D EFI_CALLBACK_INFO_FROM_THIS (This); + FakeNvData =3D &Private->FakeNvData; + switch (Action) { + case EFI_BROWSER_ACTION_FORM_OPEN: + { + if (KeyValue =3D=3D 0x1003) { + if (!HiiGetBrowserData (&mSystemConfigGuid, mVariableName, sizeof = (SYSTEM_CONFIGURATION), (UINT8 *) FakeNvData)) { + return EFI_NOT_FOUND; + } + + CheckSystemConfigLoad (FakeNvData); + + // + // Pass changed uncommitted data back to Form Browser + // + HiiSetBrowserData (&mSystemConfigGuid, mVariableName, sizeof (SYST= EM_CONFIGURATION), (UINT8 *) FakeNvData, NULL); + } + break; + } + case EFI_BROWSER_ACTION_SUBMITTED: + { + if (KeyValue =3D=3D 0x1002) { + VariableSize =3D sizeof (SYSTEM_CONFIGURATION); + Status =3D gRT->GetVariable ( + L"Setup", + &gEfiSetupVariableGuid, + &VariableAttributes, + &VariableSize, + FakeNvData + ); + if (!EFI_ERROR (Status)) { + CheckSystemConfigSave (FakeNvData); + } + } + break; + } case EFI_BROWSER_ACTION_CHANGING: case EFI_BROWSER_ACTION_CHANGED: { diff --git a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformSe= tupDxe/Vfr.vfr b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/Platfo= rmSetupDxe/Vfr.vfr index 4b10a49..5e5b4fa 100644 --- a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformSetupDxe/= Vfr.vfr +++ b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformSetupDxe/= Vfr.vfr @@ -16,6 +16,9 @@ #include "PlatformSetupDxeStrDefs.h" #include "Guid/SetupVariable.h" =20 +#define EFI_VARIABLE_NON_VOLATILE 0x00000001 +#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002 +#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004 =20 formset guid =3D SYSTEM_CONFIGURATION_GUID, @@ -24,8 +27,7 @@ formset class =3D 1, subclass =3D 0, =20 - - varstore SYSTEM_CONFIGURATION, name =3D Setup, guid =3D SYSTEM_CONFIGURA= TION_GUID; + efivarstore SYSTEM_CONFIGURATION, attribute =3D EFI_VARIABLE_BOOTSERVICE= _ACCESS | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS, name =3D= Setup, guid =3D SYSTEM_CONFIGURATION_GUID; form formid =3D ROOT_FORM_ID, title =3D STRING_TOKEN(STR_SYSTEM_SETUP_TITLE); =20 @@ -34,7 +36,9 @@ formset // goto ROOT_MAIN_FORM_ID, prompt =3D STRING_TOKEN(STR_MAIN_TITLE), - help =3D STRING_TOKEN(STR_MAIN_HELP); + help =3D STRING_TOKEN(STR_MAIN_HELP), + flags =3D INTERACTIVE, // INTERACTIVE indicate= it's marked with EFI_IFR_FLAG_CALLBACK + key =3D 0x1003; // Question ID which wi= ll be passed-in in COnfigAccess.Callback() =20 // // Jump to 2)CPU Configuration Form=20 --=20 2.10.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel