From nobody Wed May 15 16:01:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+88319+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+88319+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1648793354; cv=none; d=zohomail.com; s=zohoarc; b=huV8rzOCT17v7gySrTUWOxHo9mjIm58KjcAQiRJTMq89yKG0F389WYCiz2olxO32cxkPhXNWk+iKba9/rxjB6v2Kb0yWrPHUEwHA9ArbCa+ZZ1NMUsPrwLIKRDgbm4pIvOuuQAsmFCJm4D0I9u28bTZW4z6xfkEl+AGoKnj8p3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648793354; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=RYNKYOLe0uFCZh45qhvFbyo8mN8jTMA+QM8ZNo3EDyE=; b=C1eQzQRZX32SKFT06/BfKot4PTi12IpcnRY3I1shqVy0Ja8IKzLaaXtlFMvVU2nyIhYfiH1c7eTSK7m92EBMvWkJ/LvvgsoGHIP270tiDpcLGspzVyn5EJe61t/6uHQCQCb7RexL4jte8lfb0+DAwtsqEEDG2TwugDn8mK+L2Gw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+88319+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1648793354956162.04746958928604; Thu, 31 Mar 2022 23:09:14 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id VE8xYY1788612x2hYd6ptBbj; Thu, 31 Mar 2022 23:09:14 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web09.7206.1648793352687340022 for ; Thu, 31 Mar 2022 23:09:13 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10303"; a="239987820" X-IronPort-AV: E=Sophos;i="5.90,226,1643702400"; d="scan'208";a="239987820" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 23:09:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,226,1643702400"; d="scan'208";a="547665028" X-Received: from shbiosbuild1001.sh.intel.com ([10.239.133.29]) by orsmga007.jf.intel.com with ESMTP; 31 Mar 2022 23:09:08 -0700 From: "Chen Lin Z" To: jian.j.wang@intel.com, gaoliming@byosoft.com.cn, dandan.bi@intel.com, eric.dong@intel.com, devel@edk2.groups.io Cc: zhuangzhi.li@intel.com, di.zhang@intel.com, Chen Lin Z Subject: [edk2-devel] [PATCH-V2] Fix Setup numeric default value incorrect issue Date: Fri, 1 Apr 2022 14:09:05 +0800 Message-Id: <20220401060905.841569-1-lin.z.chen@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lin.z.chen@intel.com X-Gm-Message-State: kh7NPGDrN0v2xo56fdX5PapTx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1648793354; bh=+KWJ36TB1IF6b0DLPGxcYYymSl3CuWIu/kV9b6QVdWE=; h=Cc:Date:From:Reply-To:Subject:To; b=Dp+W2lOjtIfYKO3RRXECTR0IeTPYXloWrBMGkZXZMrlc+HJLa74vOFjxTEGeNxzz5UX xBgVJ7IHlewkLX5pOdSL/tEAqeoPprnN7CxBHdAYK656lv9VITAFTo8LEAQlFacrQmN7n 1/B/fudi23ZOnbkdDMXPdQ9/l3z/0qPfiI4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1648793357115100003 Content-Type: text/plain; charset="utf-8" When default/manufacturing flag get removed from numeric varid, it can't get default value from StructurePcd in 'UpdateDefaultSettingInFormPackage' function since there is no EFI_IFR_DEFAULT_OP opcode in IFR file. Add a chance to get numeric default value from StructurePcd in the case that numeric minimum value will be used as default value. Signed-off-by: Chen Lin Z Signed-off-by: Dandan Bi Reviewed-by: Liming Gao --- .../Universal/HiiDatabaseDxe/ConfigRouting.c | 22 ++++++++++++++++++ .../Universal/HiiDatabaseDxe/HiiDatabase.h | 23 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeMod= ulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index 2f792d2965..1c6af853b3 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -2171,6 +2171,7 @@ ParseIfrData ( UINTN PackageOffset; EFI_IFR_VARSTORE *IfrVarStore; EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; + EFI_IFR_VARSTORE_EFI *IfrEfiVarStoreTmp; EFI_IFR_OP_HEADER *IfrOpHdr; EFI_IFR_ONE_OF *IfrOneOf; EFI_IFR_REF4 *IfrRef; @@ -2187,6 +2188,7 @@ ParseIfrData ( IFR_BLOCK_DATA *BlockData; CHAR16 *VarStoreName; UINTN NameSize; + UINTN NvDefaultStoreSize; UINT16 VarWidth; UINT16 VarDefaultId; BOOLEAN FirstOneOfOption; @@ -2212,6 +2214,7 @@ ParseIfrData ( SmallestDefaultId =3D 0xFFFF; FromOtherDefaultOpcode =3D FALSE; QuestionReferBitField =3D FALSE; + IfrEfiVarStoreTmp =3D NULL; =20 // // Go through the form package to parse OpCode one by one. @@ -2303,6 +2306,17 @@ ParseIfrData ( } =20 AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName= , NameSize); + if (IfrEfiVarStoreTmp !=3D NULL) { + FreePool (IfrEfiVarStoreTmp); + } + IfrEfiVarStoreTmp =3D AllocatePool (IfrEfiVarStore->Header.Length = + AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name)); + if (IfrEfiVarStoreTmp =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + CopyMem (IfrEfiVarStoreTmp, IfrEfiVarStore, IfrEfiVarStore->Header= .Length); + AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, (CHAR16 *)&(= IfrEfiVarStoreTmp->Name[0]), AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) *= sizeof (CHAR16)); =20 if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, ConfigHdr= )) { // @@ -2502,9 +2516,13 @@ ParseIfrData ( // // Set default value base on the DefaultId list get from IFR dat= a. // + NvDefaultStoreSize =3D PcdGetSize (PcdNvStoreDefaultValueBuffer); for (LinkData =3D DefaultIdArray->Entry.ForwardLink; LinkData != =3D &DefaultIdArray->Entry; LinkData =3D LinkData->ForwardLink) { DefaultDataPtr =3D BASE_CR (LinkData, IFR_DEFAULT_DATA,= Entry); DefaultData.DefaultId =3D DefaultDataPtr->DefaultId; + if (NvDefaultStoreSize > sizeof (PCD_NV_STORE_DEFAULT_BUFFER_H= EADER)) { + FindQuestionDefaultSetting (DefaultData.DefaultId, IfrEfiVar= StoreTmp, &(IfrOneOf->Question), &DefaultData.Value, VarWidth, QuestionRefe= rBitField); + } InsertDefaultValue (BlockData, &DefaultData); } } @@ -3192,6 +3210,10 @@ Done: } } =20 + if (IfrEfiVarStoreTmp !=3D NULL) { + FreePool (IfrEfiVarStoreTmp); + } + return Status; } =20 diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h b/MdeModul= ePkg/Universal/HiiDatabaseDxe/HiiDatabase.h index c4ca6ad6ee..421c293cfc 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h @@ -2308,6 +2308,29 @@ HiiGetConfigRespInfo ( IN CONST EFI_HII_DATABASE_PROTOCOL *This ); =20 +/** + Find question default value from PcdNvStoreDefaultValueBuffer + + @param DefaultId Default store ID + @param EfiVarStore Point to EFI VarStore header + @param IfrQuestionHdr Point to Question header + @param ValueBuffer Point to Buffer includes the found default set= ting + @param Width Width of the default value + @param BitFieldQuestion Whether the Question is stored in Bit field. + + @retval EFI_SUCCESS Question default value is found. + @retval EFI_NOT_FOUND Question default value is not found. +**/ +EFI_STATUS +FindQuestionDefaultSetting ( + IN UINT16 DefaultId, + IN EFI_IFR_VARSTORE_EFI *EfiVarStore, + IN EFI_IFR_QUESTION_HEADER *IfrQuestionHdr, + OUT VOID *ValueBuffer, + IN UINTN Width, + IN BOOLEAN BitFieldQuestion + ); + // // Global variables // --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#88319): https://edk2.groups.io/g/devel/message/88319 Mute This Topic: https://groups.io/mt/90172134/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-