From nobody Mon Feb 9 11:33:13 2026 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+106758+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+106758+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1688959039; cv=none; d=zohomail.com; s=zohoarc; b=ZbF1XqLcMCDyt/d0sO6rdAG6sK+sPvnQ+YNccjyDr4Ydv/48F40lLT8LmVmy752KtL1R0cVVzApY4Ow2/s+qs18kZCQzNG/Lx1L3dKSRNLvDvrR3yOa2P4uMnrRUkQm1WX861gcImQDp2WazEBoAG/6rn/uAT0mmG/VLrcZ4ipI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688959039; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=IzH2ozoBSm6TCyIqhpFk9NbeHIEC0iJBsTOsU10JApo=; b=e1KjpB2F0j+ERhDcjaE7f3DLkzK489TrdLMfo3n3rljkO0pEAkBIH4SU5va5jxyhJRhNs2RB88EYhQE7EEfibZ5/JGZGl9WkbNVo2utdXZrOSEuIM/sPSdbJvHIw58Jd3PyXSHB9vo1cy3WKGWedgRRSJ9V+fqUx8WGtfLwioCE= 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+106758+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 1688959038976763.3878008761368; Sun, 9 Jul 2023 20:17:18 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id F7rbYY1788612xr52yE7iVda; Sun, 09 Jul 2023 20:17:18 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web10.32065.1688959036830470108 for ; Sun, 09 Jul 2023 20:17:18 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10766"; a="430319054" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="430319054" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jul 2023 20:17:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10766"; a="834113157" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="834113157" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.151]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jul 2023 20:17:15 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Zhiguang Liu , Rebecca Cran , Liming Gao , Bob Feng , Yuwei Chen Subject: [edk2-devel] [PATCH 1/4] BaseTools: Remove logic to create AP waking vector in GenFv Date: Mon, 10 Jul 2023 11:17:03 +0800 Message-Id: <20230710031706.1329-2-zhiguang.liu@intel.com> In-Reply-To: <20230710031706.1329-1-zhiguang.liu@intel.com> References: <20230710031706.1329-1-zhiguang.liu@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,zhiguang.liu@intel.com X-Gm-Message-State: dpfGCs9Lpoh6lJElysmwloXFx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1688959038; bh=hbbjXyRZcEDS2H5HZvanV4cUBNfXnqG9fV9eK6PBuHQ=; h=Cc:Date:From:Reply-To:Subject:To; b=GxF8QqxQuYHM9XYNXfHw5q4v5aGPzP5GEVgBcN/8/ZHXluGRxdaALUoi3jpE2bd4ZxD a7fOw/9HsQRVaB18eCoZzGiNyXrdwMKh+uipArxG8JBZoX8nk72dDjSAPmspc+d9e6aTw na4QmErPvOqcvvKNGtIo9atHH8MDjN0VAmo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1688959040270100005 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4494 Today for SEC core(not VTF-0), GenFv finds free 4K aligned space in FV for AP waking vector and JMP to 4G-30h in the waking vector. There is no usage of this today. Remove the logic to avoid confusing and save spaces in reset vector. Cc: Rebecca Cran Cc: Liming Gao Cc: Bob Feng Cc: Yuwei Chen Signed-off-by: Zhiguang Liu Reviewed-by: Liming Gao --- BaseTools/Source/C/GenFv/GenFvInternalLib.c | 199 -------------------- 1 file changed, 199 deletions(-) diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source= /C/GenFv/GenFvInternalLib.c index f466324d61..29c3363a50 100644 --- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c +++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c @@ -116,63 +116,6 @@ CHAR8 *mFvbAlignmentName[] =3D { EFI_FVB2_ALIGNMENT_2G_STRING }; =20 -// -// This data array will be located at the base of the Firmware Volume Head= er (FVH) -// in the boot block. It must not exceed 14 bytes of code. The last 2 by= tes -// will be used to keep the FVH checksum consistent. -// This code will be run in response to a startup IPI for HT-enabled syste= ms. -// -#define SIZEOF_STARTUP_DATA_ARRAY 0x10 - -UINT8 m128kRecoveryStartupApDataArray[SI= ZEOF_STARTUP_DATA_ARRAY] =3D { - // - // EA D0 FF 00 F0 ; far jmp F000:FFD0 - // 0, 0, 0, 0, 0, 0, 0, 0, 0, ; Reserved bytes - // 0, 0 ; Checksum Padding - // - 0xEA, - 0xD0, - 0xFF, - 0x0, - 0xF0, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 -}; - -UINT8 m64kRecoveryStartupApDataArray[SIZ= EOF_STARTUP_DATA_ARRAY] =3D { - // - // EB CE ; jmp short ($-0x30) - // ; (from offset 0x0 to offset 0xFFD0) - // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ; Reserved bytes - // 0, 0 ; Checksum Padding - // - 0xEB, - 0xCE, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 -}; - FV_INFO mFvDataInfo; CAP_INFO mCapDataInfo; BOOLEAN mIsLargeFfs =3D FALSE; @@ -1568,12 +1511,6 @@ Returns: EFI_PHYSICAL_ADDRESS SecCorePhysicalAddress; INT32 Ia32SecEntryOffset; UINT32 *Ia32ResetAddressPtr; - UINT8 *BytePointer; - UINT8 *BytePointer2; - UINT16 *WordPointer; - UINT16 CheckSum; - UINT32 IpiVector; - UINTN Index; EFI_FFS_FILE_STATE SavedState; BOOLEAN Vtf0Detected; UINT32 FfsHeaderSize; @@ -1745,65 +1682,6 @@ if (MachineType =3D=3D IMAGE_FILE_MACHINE_I386 || Ma= chineType =3D=3D IMAGE_FILE_MACHINE_ Ia32ResetAddressPtr =3D (UINT32 *) ((UINTN) FvImage->Eof - 4); *Ia32ResetAddressPtr =3D (UINT32) (FvInfo->BaseAddress); DebugMsg (NULL, 0, 9, "update BFV base address in the top FV image", "= BFV base address =3D 0x%llX.", (unsigned long long) FvInfo->BaseAddress); - - // - // Update the Startup AP in the FVH header block ZeroVector region. - // - BytePointer =3D (UINT8 *) ((UINTN) FvImage->FileImage); - if (FvInfo->Size <=3D 0x10000) { - BytePointer2 =3D m64kRecoveryStartupApDataArray; - } else if (FvInfo->Size <=3D 0x20000) { - BytePointer2 =3D m128kRecoveryStartupApDataArray; - } else { - BytePointer2 =3D m128kRecoveryStartupApDataArray; - // - // Find the position to place Ap reset vector, the offset - // between the position and the end of Fvrecovery.fv file - // should not exceed 128kB to prevent Ap reset vector from - // outside legacy E and F segment - // - Status =3D FindApResetVectorPosition (FvImage, &BytePointer); - if (EFI_ERROR (Status)) { - Error (NULL, 0, 3000, "Invalid", "FV image does not have enough sp= ace to place AP reset vector. The FV image needs to reserve at least 4KB of= unused space."); - return EFI_ABORTED; - } - } - - for (Index =3D 0; Index < SIZEOF_STARTUP_DATA_ARRAY; Index++) { - BytePointer[Index] =3D BytePointer2[Index]; - } - // - // Calculate the checksum - // - CheckSum =3D 0x0000; - WordPointer =3D (UINT16 *) (BytePointer); - for (Index =3D 0; Index < SIZEOF_STARTUP_DATA_ARRAY / 2; Index++) { - CheckSum =3D (UINT16) (CheckSum + ((UINT16) *WordPointer)); - WordPointer++; - } - // - // Update the checksum field - // - WordPointer =3D (UINT16 *) (BytePointer + SIZEOF_STARTUP_DATA_ARRAY = - 2); - *WordPointer =3D (UINT16) (0x10000 - (UINT32) CheckSum); - - // - // IpiVector at the 4k aligned address in the top 2 blocks in the PEI = FV. - // - IpiVector =3D (UINT32) (FV_IMAGES_TOP_ADDRESS - ((UINTN) FvImage->Eof= - (UINTN) BytePointer)); - DebugMsg (NULL, 0, 9, "Startup AP Vector address", "IpiVector at 0x%X"= , (unsigned) IpiVector); - if ((IpiVector & 0xFFF) !=3D 0) { - Error (NULL, 0, 3000, "Invalid", "Startup AP Vector address are not = 4K aligned, because the FV size is not 4K aligned"); - return EFI_ABORTED; - } - IpiVector =3D IpiVector >> 12; - IpiVector =3D IpiVector & 0xFF; - - // - // Write IPI Vector at Offset FvrecoveryFileSize - 8 - // - Ia32ResetAddressPtr =3D (UINT32 *) ((UINTN) FvImage->Eof - 8); - *Ia32ResetAddressPtr =3D IpiVector; } else if (MachineType =3D=3D IMAGE_FILE_MACHINE_ARMTHUMB_MIXED) { // // Since the ARM reset vector is in the FV Header you really don't nee= d a @@ -4190,83 +4068,6 @@ Returns: return EFI_SUCCESS; } =20 -EFI_STATUS -FindApResetVectorPosition ( - IN MEMORY_FILE *FvImage, - OUT UINT8 **Pointer - ) -/*++ - -Routine Description: - - Find the position in this FvImage to place Ap reset vector. - -Arguments: - - FvImage Memory file for the FV memory image. - Pointer Pointer to pointer to position. - -Returns: - - EFI_NOT_FOUND - No satisfied position is found. - EFI_SUCCESS - The suitable position is return. - ---*/ -{ - EFI_FFS_FILE_HEADER *PadFile; - UINT32 Index; - EFI_STATUS Status; - UINT8 *FixPoint; - UINT32 FileLength; - - for (Index =3D 1; ;Index ++) { - // - // Find Pad File to add ApResetVector info - // - Status =3D GetFileByType (EFI_FV_FILETYPE_FFS_PAD, Index, &PadFile); - if (EFI_ERROR (Status) || (PadFile =3D=3D NULL)) { - // - // No Pad file to be found. - // - break; - } - // - // Get Pad file size. - // - FileLength =3D GetFfsFileLength(PadFile); - FileLength =3D (FileLength + EFI_FFS_FILE_HEADER_ALIGNMENT - 1) & ~(EF= I_FFS_FILE_HEADER_ALIGNMENT - 1); - // - // FixPoint must be align on 0x1000 relative to FvImage Header - // - FixPoint =3D (UINT8*) PadFile + GetFfsHeaderLength(PadFile); - FixPoint =3D FixPoint + 0x1000 - (((UINTN) FixPoint - (UINTN) FvImage-= >FileImage) & 0xFFF); - // - // FixPoint be larger at the last place of one fv image. - // - while (((UINTN) FixPoint + SIZEOF_STARTUP_DATA_ARRAY - (UINTN) PadFile= ) <=3D FileLength) { - FixPoint +=3D 0x1000; - } - FixPoint -=3D 0x1000; - - if ((UINTN) FixPoint < ((UINTN) PadFile + GetFfsHeaderLength(PadFile))= ) { - // - // No alignment FixPoint in this Pad File. - // - continue; - } - - if ((UINTN) FvImage->Eof - (UINTN)FixPoint <=3D 0x20000) { - // - // Find the position to place ApResetVector - // - *Pointer =3D FixPoint; - return EFI_SUCCESS; - } - } - - return EFI_NOT_FOUND; -} - EFI_STATUS ParseCapInf ( IN MEMORY_FILE *InfFile, --=20 2.31.1.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 (#106758): https://edk2.groups.io/g/devel/message/106758 Mute This Topic: https://groups.io/mt/100051788/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-