From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from walk.intel-email.com (walk.intel-email.com [101.227.64.242]) by mx.groups.io with SMTP id smtpd.web10.37391.1688989149475477815 for ; Mon, 10 Jul 2023 04:39:10 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@byosoft.com.cn header.s=cloud-union header.b=kj3wl82K; spf=pass (domain: byosoft.com.cn, ip: 101.227.64.242, mailfrom: gaoliming@byosoft.com.cn) Received: from walk.intel-email.com (localhost [127.0.0.1]) by walk.intel-email.com (Postfix) with ESMTP id B1156CD1F6CE for ; Mon, 10 Jul 2023 19:39:04 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=byosoft.com.cn; s=cloud-union; t=1688989144; bh=d1WUPKRzrSZLAR0MaR7M3UlT4+jKoyrNNr8nHYM7HEs=; h=From:To:Cc:References:In-Reply-To:Subject:Date; b=kj3wl82K7v8ex5ZDjdoo36IRgb4Cze2kwS1n+EGRQIx9uiY744y/QvWLgHGev6wyc MXNoLVhBRWiFYZUNY+bJt0wL2WSm7S1JziFIMyd+b/iaQ7Fw5v5FjJt4D8Wf8aLimP oopslUnJNZxa/vUtRW7CP6GdE2hVDGbIvBOdQMYc= Received: from localhost (localhost [127.0.0.1]) by walk.intel-email.com (Postfix) with ESMTP id AC876CD1F6CD for ; Mon, 10 Jul 2023 19:39:04 +0800 (CST) Received: from walk.intel-email.com (localhost [127.0.0.1]) by walk.intel-email.com (Postfix) with ESMTP id 796F9CD1F715 for ; Mon, 10 Jul 2023 19:39:04 +0800 (CST) Authentication-Results: walk.intel-email.com; none Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by walk.intel-email.com (Postfix) with SMTP id 152EDCD1F6EB for ; Mon, 10 Jul 2023 19:39:01 +0800 (CST) Received: from DESKTOPS6D0PVI ([172.16.100.8]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Mon, 10 Jul 2023 19:38:49 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-Originating-IP: 172.16.100.8 X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: , Cc: "'Rebecca Cran'" , "'Bob Feng'" , "'Yuwei Chen'" References: <20230710031706.1329-1-zhiguang.liu@intel.com> <20230710031706.1329-2-zhiguang.liu@intel.com> In-Reply-To: <20230710031706.1329-2-zhiguang.liu@intel.com> Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF0gW1BBVENIIDEvNF0gQmFzZVRvb2xzOiBSZW1vdmUgbG9naWMgdG8gY3JlYXRlIEFQIHdha2luZyB2ZWN0b3IgaW4gR2VuRnY=?= Date: Mon, 10 Jul 2023 19:38:56 +0800 Message-ID: <013f01d9b323$1cd37e30$567a7a90$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQIcPYyVquv7S8grFk/HMkC6WJbBoAHDQkgurx+wxtA= Sender: "gaoliming" Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Zhiguang: If there is no such usage any more, I agree to remove this logic. Reviewed-by: Liming Gao Thanks Liming > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: devel@edk2.groups.io =B4=FA=B1= =ED Zhiguang Liu > =B7=A2=CB=CD=CA=B1=BC=E4: 2023=C4=EA7=D4=C210=C8=D5 11:17 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io > =B3=AD=CB=CD: Zhiguang Liu ; Rebecca Cran > ; Liming Gao ; Bob Feng > ; Yuwei Chen > =D6=F7=CC=E2: [edk2-devel] [PATCH 1/4] BaseTools: Remove logic to create = AP waking > vector in GenFv >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4494 >=20 > 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. >=20 > Cc: Rebecca Cran > Cc: Liming Gao > Cc: Bob Feng > Cc: Yuwei Chen > Signed-off-by: Zhiguang Liu > --- > BaseTools/Source/C/GenFv/GenFvInternalLib.c | 199 -------------------- > 1 file changed, 199 deletions(-) >=20 > 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 Header > (FVH) > -// in the boot block. It must not exceed 14 bytes of code. The last 2 bytes > -// will be used to keep the FVH checksum consistent. > -// This code will be run in response to a startup IPI for HT-enabled systems. > -// > -#define SIZEOF_STARTUP_DATA_ARRAY 0x10 > - > -UINT8 > m128kRecoveryStartupApDataArray[SIZEOF_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[SIZEOF_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 > || MachineType =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 > space to place AP reset vector. The FV image needs to reserve at least 4K= B 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 PE= I 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 no= t 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 need > 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) & > ~(EFI_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, > -- > 2.31.1.windows.1 >=20 >=20 >=20 >=20 >=20