From nobody Fri Apr 19 23:36:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+42055+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42055+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1560144043; cv=none; d=zoho.com; s=zohoarc; b=EVeJ5nFlUKEmByeDpAkXdwWpRo3Fr/NgBFvHsVjmHYgB1XmGYxBkdEU9B9vOYB4YYIjoD+edwQYdgQAckKiv+qoHRTqJOM4Qgh85VVaZHs7JIBezS1JBiR2JTt9ukr3wkt2vuyo8m6rzzX1zorypRY+uvO0wlmD7jpDqxj+IG1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560144043; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=ewUcmyrqSwT0xJe7bVg7kbC1LCMj8zDVAzuA1UM0GyM=; b=TqX9N+nmUvEozNZ61OVMX6OXpFTejMoofUeuLaV84tcLNvAWbBItF2pHcEyRMeENehMiFwzDwK+OSBuwe/U89RDbSNmh+3qHHsfRxF421zmD+r6IIhcsybp4LSz2RyUT76Q7rC4SHhff5kx3QNn5PLOcFk3l/fhrH8/SYCK8FBc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42055+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 15601440436051002.0985175700476; Sun, 9 Jun 2019 22:20:43 -0700 (PDT) Return-Path: X-Received: from mga01.intel.com (mga01.intel.com []) by groups.io with SMTP; Sun, 09 Jun 2019 22:20:42 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jun 2019 22:20:42 -0700 X-ExtLoop1: 1 X-Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga006.fm.intel.com with ESMTP; 09 Jun 2019 22:20:40 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Bret Barkelew , Jian J Wang , Hao A Wu , Ray Ni , Star Zeng , Liming Gao , Sean Brogan , Michael Turner , Leif Lindholm , Zhichao gao Subject: [edk2-devel] [PATCH v5 1/5] MdeModulePkg/CapsulePei: Optimize the CapsulePei Date: Mon, 10 Jun 2019 13:20:32 +0800 Message-Id: <20190610052036.11924-2-zhichao.gao@intel.com> In-Reply-To: <20190610052036.11924-1-zhichao.gao@intel.com> References: <20190610052036.11924-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,zhichao.gao@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1560144043; bh=eGcCWrsu5qhhtZlYpjoqtO2UcaTwKrglV1kCvdJedT0=; h=Cc:Date:From:Reply-To:Subject:To; b=kZ8J0uPp1IkXatr9hmnxh3QlykDkWq/7nandMRXTA10L3zSU5lP8JdXUR+UnFG5D/be Rsb4LTc9W9ywJ2AJ2RzH8sHCShIC6ALyrF6Czs85ZOsxL27lgLuGtVtkt/KCjbZp20m5Z 6BoFe9PdwF8Otrkbmbvh2jQRI9j/hln6wEU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Bret Barkelew REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1853 Code change form Mu project: https://github.com/microsoft/mu_basecore/blob/release/201903/ MdeModulePkg/Universal/CapsulePei/UefiCapsule.c#L801 Separate the capsule check function from GetCapsuleDescriptors to AreCapsulesStaged. The original one is unclear. Avoid querying the capsule variable twice. Use a fixed array to cache the SG list during count the number of SG list. Then allocate memory buffer to save the SG list from array. Using MemoryAllocationLib instead of memory function in Pei services. Cc: Jian J Wang Cc: Hao A Wu Cc: Ray Ni Cc: Star Zeng Cc: Liming Gao Cc: Sean Brogan Cc: Michael Turner Cc: Bret Barkelew Cc: Leif Lindholm Signed-off-by: Zhichao gao Reviewed-by: Hao A Wu --- MdeModulePkg/Universal/CapsulePei/Capsule.h | 1 + .../Universal/CapsulePei/CapsulePei.inf | 1 + .../Universal/CapsulePei/UefiCapsule.c | 325 +++++++++--------- 3 files changed, 172 insertions(+), 155 deletions(-) diff --git a/MdeModulePkg/Universal/CapsulePei/Capsule.h b/MdeModulePkg/Uni= versal/CapsulePei/Capsule.h index baf40423af..3d9cab02c4 100644 --- a/MdeModulePkg/Universal/CapsulePei/Capsule.h +++ b/MdeModulePkg/Universal/CapsulePei/Capsule.h @@ -30,6 +30,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include "Common/CommonHeader.h" =20 diff --git a/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf b/MdeModulePk= g/Universal/CapsulePei/CapsulePei.inf index 5d43df3075..786c411633 100644 --- a/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf +++ b/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf @@ -43,6 +43,7 @@ BaseLib HobLib BaseMemoryLib + MemoryAllocationLib PeiServicesLib PeimEntryPoint DebugLib diff --git a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c b/MdeModulePkg= /Universal/CapsulePei/UefiCapsule.c index e967599e96..7c8c7a0f45 100644 --- a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c +++ b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c @@ -791,18 +791,84 @@ BuildMemoryResourceDescriptor ( } =20 /** - Checks for the presence of capsule descriptors. - Get capsule descriptors from variable CapsuleUpdateData, CapsuleUpdateDa= ta1, CapsuleUpdateData2... - and save to DescriptorBuffer. + Check if the capsules are staged. =20 - @param DescriptorBuffer Pointer to the capsule descriptors + @param UpdateCapsules A pointer to return the check result. + + @retval EFI_INVALID_PARAMETER The parameter is null. + @retval EFI_SUCCESS The Capsules are staged. =20 - @retval EFI_SUCCESS a valid capsule is present - @retval EFI_NOT_FOUND if a valid capsule is not present **/ EFI_STATUS -GetCapsuleDescriptors ( - IN EFI_PHYSICAL_ADDRESS *DescriptorBuffer +EFIAPI +AreCapsulesStaged( + OUT BOOLEAN *UpdateCapsules + ) +{ + EFI_STATUS Status; + UINTN Size; + EFI_PEI_READ_ONLY_VARIABLE2_PPI *PPIVariableServices; + EFI_PHYSICAL_ADDRESS CapsuleDataPtr64 =3D 0; + + if (UpdateCapsules =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a Invalid parameters. Inputs can't be NULL\n",= __FUNCTION__)); + ASSERT (UpdateCapsules !=3D NULL); + return EFI_INVALID_PARAMETER; + } + + *UpdateCapsules =3D FALSE; + + Status =3D PeiServicesLocatePpi( + &gEfiPeiReadOnlyVariable2PpiGuid, + 0, + NULL, + (VOID **)&PPIVariableServices + ); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to find ReadOnlyVariable2PPI\n")); + return Status; + } + + // + // Check for Update capsule + // + Size =3D sizeof (CapsuleDataPtr64); + Status =3D PPIVariableServices->GetVariable ( + PPIVariableServices, + EFI_CAPSULE_VARIABLE_NAME, + &gEfiCapsuleVendorGuid, + NULL, + &Size, + (VOID *)&CapsuleDataPtr64 + ); + + if (!EFI_ERROR (Status)) { + *UpdateCapsules =3D TRUE; + } + + return EFI_SUCCESS; +} + +#define MAX_SG_LIST_HEADS (20) + +/** + Check all the variables for SG list heads and get the count and addresse= s. + + @param ListLength A pointer would return the SG list lengt= h. + @param HeadList A ponter to the capsule SG list. + + @retval EFI_SUCCESS a valid capsule is present + @retval EFI_NOT_FOUND if a valid capsule is not present + @retval EFI_INVALID_PARAMETER the input parameter is invalid + @retval EFI_OUT_OF_RESOURCES fail to allocate memory + +**/ +EFI_STATUS +EFIAPI +GetScatterGatherHeadEntries( + OUT UINTN *ListLength, + OUT EFI_PHYSICAL_ADDRESS **HeadList ) { EFI_STATUS Status; @@ -815,6 +881,7 @@ GetCapsuleDescriptors ( CHAR16 *TempVarName; EFI_PHYSICAL_ADDRESS CapsuleDataPtr64; EFI_PEI_READ_ONLY_VARIABLE2_PPI *PPIVariableServices; + EFI_PHYSICAL_ADDRESS TempList[MAX_SG_LIST_HEADS]; =20 Index =3D 0; TempVarName =3D NULL; @@ -822,87 +889,96 @@ GetCapsuleDescriptors ( ValidIndex =3D 0; CapsuleDataPtr64 =3D 0; =20 + if ((ListLength =3D=3D NULL) || (HeadList =3D=3D NULL)) { + DEBUG ((DEBUG_ERROR, "%a Invalid parameters. Inputs can't be NULL\n",= __FUNCTION__)); + ASSERT (ListLength !=3D NULL); + ASSERT (HeadList !=3D NULL); + return EFI_INVALID_PARAMETER; + } + + *ListLength =3D 0; + *HeadList =3D NULL; + Status =3D PeiServicesLocatePpi ( &gEfiPeiReadOnlyVariable2PpiGuid, 0, NULL, - (VOID **) &PPIVariableServices + (VOID **)&PPIVariableServices ); - if (Status =3D=3D EFI_SUCCESS) { - StrCpyS (CapsuleVarName, sizeof(CapsuleVarName)/sizeof(CHAR16), EFI_CA= PSULE_VARIABLE_NAME); - TempVarName =3D CapsuleVarName + StrLen (CapsuleVarName); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to find ReadOnlyVariable2PPI\n")); + return Status; + } + + // + // setup var name buffer for update capsules + // + StrCpyS (CapsuleVarName, sizeof (CapsuleVarName) / sizeof (CHAR16), EFI_= CAPSULE_VARIABLE_NAME); + TempVarName =3D CapsuleVarName + StrLen (CapsuleVarName); + while (ValidIndex < MAX_SG_LIST_HEADS) { + if (Index !=3D 0) { + UnicodeValueToStringS ( + TempVarName, + (sizeof (CapsuleVarName) - ((StrLen (CapsuleVarName) + 1) * sizeof= (CHAR16))), + 0, + Index, + 0 + ); + } Size =3D sizeof (CapsuleDataPtr64); - while (1) { - if (Index =3D=3D 0) { - // - // For the first Capsule Image - // - Status =3D PPIVariableServices->GetVariable ( - PPIVariableServices, - CapsuleVarName, - &gEfiCapsuleVendorGuid, - NULL, - &Size, - (VOID *) &CapsuleDataPtr64 - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "Capsule -- capsule variable not set\n")); - return EFI_NOT_FOUND; - } - // - // We have a chicken/egg situation where the memory init code need= s to - // know the boot mode prior to initializing memory. For this case,= our - // validate function will fail. We can detect if this is the case = if blocklist - // pointer is null. In that case, return success since we know tha= t the - // variable is set. - // - if (DescriptorBuffer =3D=3D NULL) { - return EFI_SUCCESS; - } - } else { - UnicodeValueToStringS ( - TempVarName, - sizeof (CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVa= rName), - 0, - Index, - 0 - ); - Status =3D PPIVariableServices->GetVariable ( - PPIVariableServices, - CapsuleVarName, - &gEfiCapsuleVendorGuid, - NULL, - &Size, - (VOID *) &CapsuleDataPtr64 - ); - if (EFI_ERROR (Status)) { - break; - } + Status =3D PPIVariableServices->GetVariable ( + PPIVariableServices, + CapsuleVarName, + &gEfiCapsuleVendorGuid, + NULL, + &Size, + (VOID *)&CapsuleDataPtr64 + ); =20 - // - // If this BlockList has been linked before, skip this variable - // - Flag =3D FALSE; - for (TempIndex =3D 0; TempIndex < ValidIndex; TempIndex++) { - if (DescriptorBuffer[TempIndex] =3D=3D CapsuleDataPtr64) { - Flag =3D TRUE; - break; - } - } - if (Flag) { - Index ++; - continue; - } + if (EFI_ERROR (Status)) { + if (Status !=3D EFI_NOT_FOUND) { + DEBUG ((DEBUG_ERROR, "Unexpected error getting Capsule Update vari= able. Status =3D %r\n")); } + break; + } =20 - // - // Cache BlockList which has been processed - // - DescriptorBuffer[ValidIndex++] =3D CapsuleDataPtr64; - Index ++; + // + // If this BlockList has been linked before, skip this variable + // + Flag =3D FALSE; + for (TempIndex =3D 0; TempIndex < ValidIndex; TempIndex++) { + if (TempList[TempIndex] =3D=3D CapsuleDataPtr64) { + Flag =3D TRUE; + break; + } } + if (Flag) { + Index++; + continue; + } + + // + // add it to the cached list + // + TempList[ValidIndex++] =3D CapsuleDataPtr64; + Index++; + } + + if (ValidIndex =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a didn't find any SG lists in variables\n", __F= UNCTION__)); + return EFI_NOT_FOUND; } =20 + *HeadList =3D AllocateZeroPool ((ValidIndex + 1) * sizeof (EFI_PHYSICAL_= ADDRESS)); + if (*HeadList =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "Failed to allocate memory\n")); + return EFI_OUT_OF_RESOURCES; + } + + CopyMem (*HeadList, TempList, (ValidIndex) * sizeof (EFI_PHYSICAL_ADDRES= S)); + *ListLength =3D ValidIndex; + return EFI_SUCCESS; } =20 @@ -937,15 +1013,9 @@ CapsuleCoalesce ( IN OUT UINTN *MemorySize ) { - UINTN Index; - UINTN Size; - UINTN VariableCount; - CHAR16 CapsuleVarName[30]; - CHAR16 *TempVarName; - EFI_PHYSICAL_ADDRESS CapsuleDataPtr64; EFI_STATUS Status; EFI_BOOT_MODE BootMode; - EFI_PEI_READ_ONLY_VARIABLE2_PPI *PPIVariableServices; + UINTN ListLength; EFI_PHYSICAL_ADDRESS *VariableArrayAddress; MEMORY_RESOURCE_DESCRIPTOR *MemoryResource; #ifdef MDE_CPU_IA32 @@ -955,10 +1025,8 @@ CapsuleCoalesce ( EFI_CAPSULE_LONG_MODE_BUFFER LongModeBuffer; #endif =20 - Index =3D 0; - VariableCount =3D 0; - CapsuleVarName[0] =3D 0; - CapsuleDataPtr64 =3D 0; + ListLength =3D 0; + VariableArrayAddress =3D NULL; =20 // // Someone should have already ascertained the boot mode. If it's not @@ -972,74 +1040,11 @@ CapsuleCoalesce ( } =20 // - // User may set the same ScatterGatherList with several different variab= les, - // so cache all ScatterGatherList for check later. + // Get SG list entries // - Status =3D PeiServicesLocatePpi ( - &gEfiPeiReadOnlyVariable2PpiGuid, - 0, - NULL, - (VOID **) &PPIVariableServices - ); + Status =3D GetScatterGatherHeadEntries (&ListLength, &VariableArrayAddre= ss); if (EFI_ERROR (Status)) { - goto Done; - } - Size =3D sizeof (CapsuleDataPtr64); - StrCpyS (CapsuleVarName, sizeof(CapsuleVarName)/sizeof(CHAR16), EFI_CAPS= ULE_VARIABLE_NAME); - TempVarName =3D CapsuleVarName + StrLen (CapsuleVarName); - while (TRUE) { - if (Index > 0) { - UnicodeValueToStringS ( - TempVarName, - sizeof (CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVarN= ame), - 0, - Index, - 0 - ); - } - Status =3D PPIVariableServices->GetVariable ( - PPIVariableServices, - CapsuleVarName, - &gEfiCapsuleVendorGuid, - NULL, - &Size, - (VOID *) &CapsuleDataPtr64 - ); - if (EFI_ERROR (Status)) { - // - // There is no capsule variables, quit - // - DEBUG ((DEBUG_INFO,"Capsule variable Index =3D %d\n", Index)); - break; - } - VariableCount++; - Index++; - } - - DEBUG ((DEBUG_INFO,"Capsule variable count =3D %d\n", VariableCount)); - - // - // The last entry is the end flag. - // - Status =3D PeiServicesAllocatePool ( - (VariableCount + 1) * sizeof (EFI_PHYSICAL_ADDRESS), - (VOID **)&VariableArrayAddress - ); - - if (Status !=3D EFI_SUCCESS) { - DEBUG ((DEBUG_ERROR, "AllocatePages Failed!, Status =3D %x\n", Status)= ); - goto Done; - } - - ZeroMem (VariableArrayAddress, (VariableCount + 1) * sizeof (EFI_PHYSICA= L_ADDRESS)); - - // - // Find out if we actually have a capsule. - // GetCapsuleDescriptors depends on variable PPI, so it should run in 32= -bit environment. - // - Status =3D GetCapsuleDescriptors (VariableArrayAddress); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Fail to find capsule variables.\n")); + DEBUG ((DEBUG_ERROR, "%a failed to get Scatter Gather List Head Entrie= s. Status =3D %r\n", __FUNCTION__, Status)); goto Done; } =20 @@ -1118,7 +1123,17 @@ CheckCapsuleUpdate ( ) { EFI_STATUS Status; - Status =3D GetCapsuleDescriptors (NULL); + BOOLEAN Update; + + Status =3D AreCapsulesStaged (&Update); + + if (!EFI_ERROR (Status)) { + if (Update) { + Status =3D EFI_SUCCESS; + } else { + Status =3D EFI_NOT_FOUND; + } + } return Status; } /** --=20 2.21.0.windows.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 (#42055): https://edk2.groups.io/g/devel/message/42055 Mute This Topic: https://groups.io/mt/32001192/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- From nobody Fri Apr 19 23:36:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+42056+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42056+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1560144045; cv=none; d=zoho.com; s=zohoarc; b=PB7w20gbc9CqyI0lGMmGJvSPTpJxGIO5VCfgGS+OSIRh/sa+3/Xz8UOzq3jM8hcVpHJfZwv/YB9xyUotKs0gzt3Atrm7EIzJUT5Msq6AEYWNvsha3NHZHuXMOAe6kRKKCs+I0EmsUjyFB+PN3klrm1KU/YsqWDa4EJtS71mTEvQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560144045; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=AGkLEyn9gORQt/uwNzQUKNaHiYF9c5guj3WwLeVGtss=; b=QSv1BCM2EnyLddZwXcnp5vrOE5FDrvr/B+h6zELmdhMxN+AFOoFZRxogl3hYCJCHuHq4piyqJTxd9s7vD61yNf+uwi7B9S4HyhZz8Jjd09uitBqD0FF9MLI31z6kJACzZdDwnbnYpgLhV/dkVvcN3LRMMWPBAJ7+dj+jJUyfAjY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42056+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1560144045390961.7072904421292; Sun, 9 Jun 2019 22:20:45 -0700 (PDT) Return-Path: X-Received: from mga01.intel.com (mga01.intel.com []) by groups.io with SMTP; Sun, 09 Jun 2019 22:20:44 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jun 2019 22:20:44 -0700 X-ExtLoop1: 1 X-Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga006.fm.intel.com with ESMTP; 09 Jun 2019 22:20:42 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Ray Ni , Star Zeng , Liming Gao , Sean Brogan , Michael Turner , Bret Barkelew , Leif Lindholm , Zhichao gao Subject: [edk2-devel] [PATCH v5 2/5] MdeMoudlePkg/CapsulePei: Fix coding style issue Date: Mon, 10 Jun 2019 13:20:33 +0800 Message-Id: <20190610052036.11924-3-zhichao.gao@intel.com> In-Reply-To: <20190610052036.11924-1-zhichao.gao@intel.com> References: <20190610052036.11924-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,zhichao.gao@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1560144045; bh=6enKJY+PkKgaWeZNVanz2uulu9gBWv2zUPqO676yeew=; h=Cc:Date:From:Reply-To:Subject:To; b=Frx7Do/bEG7CksnXf1wLC1y9fieGWKJuPYU2YTKbodgxKk1Q7S+IiQaU6ZrLSXk/4lY XxCq51kJn8ov9mXi5qn1UWzgeTSIEcnPlC3F/rukQr9ay7mjtSJm3gGvLwuTHgUsL/SyE nel+P8DNf/HW5vJPGJo5YtmaPE5InfqBXDE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1853 Remove API specifier AreCapsulesStaged and GetScatterGatherHeadEntries because they are internal used. Add space between function name and bracket. Cc: Jian J Wang Cc: Hao A Wu Cc: Ray Ni Cc: Star Zeng Cc: Liming Gao Cc: Sean Brogan Cc: Michael Turner Cc: Bret Barkelew Cc: Leif Lindholm Signed-off-by: Zhichao gao Reviewed-by: Hao A Wu --- MdeModulePkg/Universal/CapsulePei/UefiCapsule.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c b/MdeModulePkg= /Universal/CapsulePei/UefiCapsule.c index 7c8c7a0f45..b224e200fe 100644 --- a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c +++ b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c @@ -1,7 +1,7 @@ /** @file Capsule update PEIM for UEFI2.0 =20 -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Incorporated. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -800,8 +800,7 @@ BuildMemoryResourceDescriptor ( =20 **/ EFI_STATUS -EFIAPI -AreCapsulesStaged( +AreCapsulesStaged ( OUT BOOLEAN *UpdateCapsules ) { @@ -865,8 +864,7 @@ AreCapsulesStaged( =20 **/ EFI_STATUS -EFIAPI -GetScatterGatherHeadEntries( +GetScatterGatherHeadEntries ( OUT UINTN *ListLength, OUT EFI_PHYSICAL_ADDRESS **HeadList ) --=20 2.21.0.windows.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 (#42056): https://edk2.groups.io/g/devel/message/42056 Mute This Topic: https://groups.io/mt/32001193/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- From nobody Fri Apr 19 23:36:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+42057+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42057+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1560144047; cv=none; d=zoho.com; s=zohoarc; b=WttLMyG2C23qzIe7juXOGrSZoyU/z+DgA1wK7DOIxMUiuo3+lTufJai1x4X4X4Zb9HZtzGRPjg8LsX6Fbh8stGcM+OFnpjr9Yn6AxdU7vIr5c1x6SP91zLkTYGXGqFWM7DHJ9eyvakrTdpldHmErI61MD3HjQ/ObA0rVVJDmYDQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560144047; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=dFWoqR+yVgWT2qTxxiVLX+9kC6qwI1/bjrzoh3bjAug=; b=GAIhNTI0hz6Jt6lRwBsao9ZFzVcO5hxBryTMMiceWmBfmZ6DFVeRrhwyO4A7e1tmKIzJYXPQ8OVuGwFBKG3v7ynK+hoRZlrCOv/V/gVNN0tdqmwSEBlVjHTqJEAONW9dF4C8rCNp6J6UMMprdf1DNv7UWLKTuMYHkbNcjMh+5CI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42057+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1560144047345357.57291480991285; Sun, 9 Jun 2019 22:20:47 -0700 (PDT) Return-Path: X-Received: from mga01.intel.com (mga01.intel.com []) by groups.io with SMTP; Sun, 09 Jun 2019 22:20:46 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jun 2019 22:20:46 -0700 X-ExtLoop1: 1 X-Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga006.fm.intel.com with ESMTP; 09 Jun 2019 22:20:44 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Ray Ni , Star Zeng , Liming Gao , Sean Brogan , Michael Turner , Bret Barkelew , Leif Lindholm , Zhichao gao Subject: [edk2-devel] [PATCH v5 3/5] MdeMoudlePkg/CapsulePei: Optimize AreCapsulesStaged Date: Mon, 10 Jun 2019 13:20:34 +0800 Message-Id: <20190610052036.11924-4-zhichao.gao@intel.com> In-Reply-To: <20190610052036.11924-1-zhichao.gao@intel.com> References: <20190610052036.11924-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,zhichao.gao@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1560144046; bh=hZvpMQTIZDcRitVEOftG3dUABk4m9JEHjb8BxvcIVSY=; h=Cc:Date:From:Reply-To:Subject:To; b=l70zWIJm4FZaqjuIxpMTzm3Uk3SUjxZSspFq/jhaWTuAKmcdjMD4Erl6og0RQ+MUiJy K+xL0OUPK/PiHxeI4hHrZh9dH4IAab9Ws5cxTBXzmZFqiXcL24FBvnLKfaIzmIOAXg5X6 CvkID0GmTeW1gEmKY1YoDfs8gFrtKD0f4IY= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1853 AreCapsulesStaged do not need to return the status, only boolean result is useful. So directly return a boolean value. Cannot initialize the variable at its definition. Cc: Jian J Wang Cc: Hao A Wu Cc: Ray Ni Cc: Star Zeng Cc: Liming Gao Cc: Sean Brogan Cc: Michael Turner Cc: Bret Barkelew Cc: Leif Lindholm Signed-off-by: Zhichao gao Reviewed-by: Hao A Wu --- .../Universal/CapsulePei/UefiCapsule.c | 42 ++++++------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c b/MdeModulePkg= /Universal/CapsulePei/UefiCapsule.c index b224e200fe..ce6d95a786 100644 --- a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c +++ b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c @@ -793,29 +793,21 @@ BuildMemoryResourceDescriptor ( /** Check if the capsules are staged. =20 - @param UpdateCapsules A pointer to return the check result. - - @retval EFI_INVALID_PARAMETER The parameter is null. - @retval EFI_SUCCESS The Capsules are staged. + @retval TRUE The capsules are staged. + @retval FALSE The capsules are not staged. =20 **/ -EFI_STATUS +BOOLEAN AreCapsulesStaged ( - OUT BOOLEAN *UpdateCapsules + VOID ) { EFI_STATUS Status; UINTN Size; EFI_PEI_READ_ONLY_VARIABLE2_PPI *PPIVariableServices; - EFI_PHYSICAL_ADDRESS CapsuleDataPtr64 =3D 0; - - if (UpdateCapsules =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a Invalid parameters. Inputs can't be NULL\n",= __FUNCTION__)); - ASSERT (UpdateCapsules !=3D NULL); - return EFI_INVALID_PARAMETER; - } + EFI_PHYSICAL_ADDRESS CapsuleDataPtr64; =20 - *UpdateCapsules =3D FALSE; + CapsuleDataPtr64 =3D 0; =20 Status =3D PeiServicesLocatePpi( &gEfiPeiReadOnlyVariable2PpiGuid, @@ -826,7 +818,7 @@ AreCapsulesStaged ( =20 if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "Failed to find ReadOnlyVariable2PPI\n")); - return Status; + return FALSE; } =20 // @@ -843,10 +835,10 @@ AreCapsulesStaged ( ); =20 if (!EFI_ERROR (Status)) { - *UpdateCapsules =3D TRUE; + return TRUE; } =20 - return EFI_SUCCESS; + return FALSE; } =20 #define MAX_SG_LIST_HEADS (20) @@ -1120,19 +1112,11 @@ CheckCapsuleUpdate ( IN EFI_PEI_SERVICES **PeiServices ) { - EFI_STATUS Status; - BOOLEAN Update; - - Status =3D AreCapsulesStaged (&Update); - - if (!EFI_ERROR (Status)) { - if (Update) { - Status =3D EFI_SUCCESS; - } else { - Status =3D EFI_NOT_FOUND; - } + if (AreCapsulesStaged ()) { + return EFI_SUCCESS; + } else { + return EFI_NOT_FOUND; } - return Status; } /** This function will look at a capsule and determine if it's a test patter= n. --=20 2.21.0.windows.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 (#42057): https://edk2.groups.io/g/devel/message/42057 Mute This Topic: https://groups.io/mt/32001194/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- From nobody Fri Apr 19 23:36:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+42058+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42058+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1560144049; cv=none; d=zoho.com; s=zohoarc; b=bs30Xw6zARlhr6EGoYn7iXIgxKAjUO/D1v6Nd8i8lSxRvmPdt7f0DSJYsQYKo7K3zZXdcL7J75x5fNnYim1rZvtnMu4Q4CroPQSQtCpCX7kTaJ8RxeEMTuyFwR1UxrHASKyMR8kbUWB1la2iMKoRqmkC2QAg610C54job3kp/8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560144049; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=JWgJKxxZXzanfXIKYLo26z5cmJNsoCEem2/mLJ/bG4k=; b=c3J54ERzKf00Y30HRLsheu46FhEbq1zh6zaMFt4lrIKcjr45/trEuYvydzLQ0HRWbg3HLlfydT/qXOn7RIREW/HEPFTgixtoXbtdHuQtnNwMV4bC5NSVUML67ASuZdc2VaLGpQwe06sTYqJP3Y4iUGodWaFiKtIOIrqrxeJ4qek= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42058+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1560144049398503.7814165932731; Sun, 9 Jun 2019 22:20:49 -0700 (PDT) Return-Path: X-Received: from mga01.intel.com (mga01.intel.com []) by groups.io with SMTP; Sun, 09 Jun 2019 22:20:48 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jun 2019 22:20:48 -0700 X-ExtLoop1: 1 X-Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga006.fm.intel.com with ESMTP; 09 Jun 2019 22:20:46 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Ray Ni , Star Zeng , Liming Gao , Sean Brogan , Michael Turner , Bret Barkelew , Leif Lindholm , Zhichao gao Subject: [edk2-devel] [PATCH v5 4/5] MdeMoudlePkg/CapsulePei: Optimize GetScatterGatherHeadEntries Date: Mon, 10 Jun 2019 13:20:35 +0800 Message-Id: <20190610052036.11924-5-zhichao.gao@intel.com> In-Reply-To: <20190610052036.11924-1-zhichao.gao@intel.com> References: <20190610052036.11924-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,zhichao.gao@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1560144049; bh=BrAGEjCUQBMsezJi/VgV5v8y1HEh+hyJA7E7250Pwq0=; h=Cc:Date:From:Reply-To:Subject:To; b=BlurdYlbhMPGEPDqQ+0tdSpm2v6mZk2cPH0w2+bPgIxmbOxpVbHPMw2HurbLF2y9IBc 7e+sDfUfmFNeWHdiCn7i/pcce+X1E4O3Xtpj4NZQpqRWTr0NR3SAhjhJBbn8GBfdcI5aW 54pzX0JT/AFHd//+Vbdv1UY7ceNOusNcjgA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1853 Rename the MACRO from MAX_SG_LIST_HEADS to DEFAULT_SG_LIST_HEADS. GetScatterGatherHeadEntries: use allocated buffer instead of fixed array to handle the condition which the SG list is larger then the array size. Cc: Jian J Wang Cc: Hao A Wu Cc: Ray Ni Cc: Star Zeng Cc: Liming Gao Cc: Sean Brogan Cc: Michael Turner Cc: Bret Barkelew Cc: Leif Lindholm Signed-off-by: Zhichao gao Reviewed-by: Hao A Wu --- .../Universal/CapsulePei/UefiCapsule.c | 51 ++++++++++++++----- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c b/MdeModulePkg= /Universal/CapsulePei/UefiCapsule.c index ce6d95a786..3ac95b7be6 100644 --- a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c +++ b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c @@ -10,6 +10,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #include "Capsule.h" =20 +#define DEFAULT_SG_LIST_HEADS (20) + #ifdef MDE_CPU_IA32 // // Global Descriptor Table (GDT) @@ -841,8 +843,6 @@ AreCapsulesStaged ( return FALSE; } =20 -#define MAX_SG_LIST_HEADS (20) - /** Check all the variables for SG list heads and get the count and addresse= s. =20 @@ -861,17 +861,19 @@ GetScatterGatherHeadEntries ( OUT EFI_PHYSICAL_ADDRESS **HeadList ) { - EFI_STATUS Status; - UINTN Size; - UINTN Index; - UINTN TempIndex; - UINTN ValidIndex; - BOOLEAN Flag; - CHAR16 CapsuleVarName[30]; - CHAR16 *TempVarName; - EFI_PHYSICAL_ADDRESS CapsuleDataPtr64; - EFI_PEI_READ_ONLY_VARIABLE2_PPI *PPIVariableServices; - EFI_PHYSICAL_ADDRESS TempList[MAX_SG_LIST_HEADS]; + EFI_STATUS Status; + UINTN Size; + UINTN Index; + UINTN TempIndex; + UINTN ValidIndex; + BOOLEAN Flag; + CHAR16 CapsuleVarName[30]; + CHAR16 *TempVarName; + EFI_PHYSICAL_ADDRESS CapsuleDataPtr64; + EFI_PEI_READ_ONLY_VARIABLE2_PPI *PPIVariableServices; + EFI_PHYSICAL_ADDRESS *TempList; + EFI_PHYSICAL_ADDRESS *EnlargedTempList; + UINTN TempListLength; =20 Index =3D 0; TempVarName =3D NULL; @@ -901,12 +903,22 @@ GetScatterGatherHeadEntries ( return Status; } =20 + // + // Allocate memory for sg list head + // + TempListLength =3D DEFAULT_SG_LIST_HEADS * sizeof (EFI_PHYSICAL_ADDRESS); + TempList =3D AllocateZeroPool (TempListLength); + if (TempList =3D=3D NULL) { + DEBUG((DEBUG_ERROR, "Failed to allocate memory\n")); + return EFI_OUT_OF_RESOURCES; + } + // // setup var name buffer for update capsules // StrCpyS (CapsuleVarName, sizeof (CapsuleVarName) / sizeof (CHAR16), EFI_= CAPSULE_VARIABLE_NAME); TempVarName =3D CapsuleVarName + StrLen (CapsuleVarName); - while (ValidIndex < MAX_SG_LIST_HEADS) { + while (TRUE) { if (Index !=3D 0) { UnicodeValueToStringS ( TempVarName, @@ -948,6 +960,17 @@ GetScatterGatherHeadEntries ( continue; } =20 + // + // The TempList is full, enlarge it + // + if ((ValidIndex + 1) >=3D TempListLength) { + EnlargedTempList =3D AllocateZeroPool (TempListLength * 2); + CopyMem (EnlargedTempList, TempList, TempListLength); + FreePool (TempList); + TempList =3D EnlargedTempList; + TempListLength *=3D 2; + } + // // add it to the cached list // --=20 2.21.0.windows.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 (#42058): https://edk2.groups.io/g/devel/message/42058 Mute This Topic: https://groups.io/mt/32001195/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- From nobody Fri Apr 19 23:36:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+42059+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42059+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1560144051; cv=none; d=zoho.com; s=zohoarc; b=O1NwwN2e1Z2F8jk5ZkQwgNBjy17OF6aCzkZAZkW5rzD3JvlCDGqX8rpan1f4m+2b+hAE5p9t304ukLmHXgSdWJEEfQmQkVvse0IQ5bUS+L8aDRhFg94IFlH57byEKYwXIMITnAnbw20RGWSuADg3XY2qwbd4uQazd81EwLHZ/uY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560144051; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=nKlVswdqkRbWajPWzWMlw8PPGmcKgKoKWH2/yE+yd70=; b=Nt+IEBuU9btQkIJltPIiSEebW7tqRe77gMQA2XMq2JNr8G5gpqwwXa2m6P7QP09gVzkdowwkwJ1ErSGlGdzaSqc8NQz11HtJCePVeQDOVUAh4vUWR7cJo+83JGFTeoBh3N+OiXEhwbbZqRPGUwiH3MYXl+Y1OutZ8JnWZTCQRK4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42059+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1560144051327363.92925434637186; Sun, 9 Jun 2019 22:20:51 -0700 (PDT) Return-Path: X-Received: from mga01.intel.com (mga01.intel.com []) by groups.io with SMTP; Sun, 09 Jun 2019 22:20:50 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jun 2019 22:20:50 -0700 X-ExtLoop1: 1 X-Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga006.fm.intel.com with ESMTP; 09 Jun 2019 22:20:48 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Ray Ni , Star Zeng , Liming Gao , Sean Brogan , Michael Turner , Bret Barkelew , Leif Lindholm , Zhichao gao Subject: [edk2-devel] [PATCH v5 5/5] MdeMoudlePkg/CapsulePei: No need to remain space for null-terminate Date: Mon, 10 Jun 2019 13:20:36 +0800 Message-Id: <20190610052036.11924-6-zhichao.gao@intel.com> In-Reply-To: <20190610052036.11924-1-zhichao.gao@intel.com> References: <20190610052036.11924-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,zhichao.gao@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1560144050; bh=Q7cEJXy5WrlOFmKNVEK5MFntn+sPqitQqKyA01YGU38=; h=Cc:Date:From:Reply-To:Subject:To; b=bntHPWUVdl99XcCNo1qqr5JdBwYXfWW6o3MztCFJt2j8PfSjoeGIAzcITYC+TPjvNJr 9shM3JkKvbVpaabhSYqMu+9UDXBi6FaFs+u48n77tAeCxchx0RG0rZYZ8PX++uhD0KNLl vaZk93w5mfLZMdC1s3y59CFAlYvJm4rtWLc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1853 UnicodeValueToStringS would remain two bytes for the first parameter to set the null- terminate. So remove this change in Mu. Cc: Jian J Wang Cc: Hao A Wu Cc: Ray Ni Cc: Star Zeng Cc: Liming Gao Cc: Sean Brogan Cc: Michael Turner Cc: Bret Barkelew Cc: Leif Lindholm Signed-off-by: Zhichao gao Reviewed-by: Hao A Wu Reviewed-by: Leif Lindholm --- MdeModulePkg/Universal/CapsulePei/UefiCapsule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c b/MdeModulePkg= /Universal/CapsulePei/UefiCapsule.c index 3ac95b7be6..fabf30926c 100644 --- a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c +++ b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c @@ -922,7 +922,7 @@ GetScatterGatherHeadEntries ( if (Index !=3D 0) { UnicodeValueToStringS ( TempVarName, - (sizeof (CapsuleVarName) - ((StrLen (CapsuleVarName) + 1) * sizeof= (CHAR16))), + (sizeof(CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVarN= ame)), 0, Index, 0 --=20 2.21.0.windows.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 (#42059): https://edk2.groups.io/g/devel/message/42059 Mute This Topic: https://groups.io/mt/32001196/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-