From nobody Sun Feb 8 18:09:30 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+88467+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+88467+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1649264646; cv=none; d=zohomail.com; s=zohoarc; b=cZ6m6FzI3ye7bP8kF6I9fnpZJB6XWFJqQDisb0zWjNYxKsmzKcz5csfX94XPcLTboe3NrvumRwTYkRdNeJq9HHbte1jXKnvWCEE7N3DwFlmwmjVzCBVd9xseW3fIlJuMxzoOOyHzC60PH9guy6RVDsLsoCIraVMrdbXTd2zgy3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649264646; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=qyo2quX8rLFAVxh42/bhRzZQ8S/ltUvz8zs0IOU0hCs=; b=g3Labg4L1OWR8g9HxsnAOzix5Ri4uQltONt1pS1bJk1qBJwdCyVZTBbnsR8h/rCt83nufiQza4hA9428WGNKK/YTEMiwc9C2EqsZixfIrRSckhp2wArdJCaeNpImXObvfkaYn6RxqXAdxszGk41gf5iFj+6ikl2EOaNF35uJAOQ= 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+88467+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 1649264646231392.62914570803923; Wed, 6 Apr 2022 10:04:06 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id VXSPYY1788612xgDrzebaFIq; Wed, 06 Apr 2022 10:04:05 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.431.1649264644096687714 for ; Wed, 06 Apr 2022 10:04:04 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10309"; a="347548602" X-IronPort-AV: E=Sophos;i="5.90,240,1643702400"; d="scan'208";a="347548602" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2022 10:02:55 -0700 X-IronPort-AV: E=Sophos;i="5.90,240,1643702400"; d="scan'208";a="642137730" X-Received: from tedkuo1-win10.gar.corp.intel.com ([10.5.215.13]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2022 10:02:54 -0700 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Star Zeng , Ashraf Ali S Subject: [edk2-devel][PATCH v3 1/8] IntelFsp2Pkg: X64 compatible changes to support PEI in 64bit Date: Thu, 7 Apr 2022 01:02:32 +0800 Message-Id: In-Reply-To: References: In-Reply-To: References: 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,ted.kuo@intel.com X-Gm-Message-State: 2DjZZYMqXf4FIbhHWZOxma82x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1649264645; bh=+5J8Eh6n8r+pUzaRM7g71o7AYg/Y1J1LkxVb/9AeL/E=; h=Cc:Date:From:Reply-To:Subject:To; b=HsPWwbqQyKkxb3dFn4r2EB72PkmksxSJEA+t1vbUyuAt45aRHLVK3xGyPfm1IVsI9U3 ksP2ik2MlQEur+gBiQ/5cOprGx/Czs6cM2cSL76CKeZi/Z3JdpOOCD/JUHHHDg5p5C94Z JP2J7TMfuQTMbf7rLkpNtJSk1CFdMweMQLw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1649264647065100007 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3893 1.Added EFIAPI to FspNotifyPhasePeimEntryPoint. 2.Changed AsmReadEsp to AsmReadStackPointer. 3.Changed the type of the return value of AsmReadStackPointer from UINT32 to UINTN. 4.Changed the type of TemporaryMemoryBase, PermenentMemoryBase and BootLoaderStack from UINT32 to UINTN. 5.Some type casting to pointers are UINT32. Changed them to UINTN to accommodate both IA32 and X64. 6.Corrected some typos. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Ashraf Ali S Signed-off-by: Ted Kuo --- IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c | 1 + IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm | 8 ++++--= -- IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm | 10 +++++-= ---- IntelFsp2Pkg/FspSecCore/SecFsp.c | 8 ++++--= -- IntelFsp2Pkg/FspSecCore/SecFsp.h | 2 +- IntelFsp2Pkg/FspSecCore/SecFspApiChk.c | 8 ++++--= -- IntelFsp2Pkg/FspSecCore/SecMain.c | 8 ++++--= -- IntelFsp2Pkg/FspSecCore/SecMain.h | 10 +++++-= ---- IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm | 2 +- 9 files changed, 29 insertions(+), 28 deletions(-) diff --git a/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c b/IntelFsp2Pk= g/FspNotifyPhase/FspNotifyPhasePeim.c index 88f5540fef..66d39cc70c 100644 --- a/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c +++ b/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c @@ -112,6 +112,7 @@ WaitForNotify ( @retval EFI_OUT_OF_RESOURCES Insufficient resources to create databa= se **/ EFI_STATUS +EFIAPI FspNotifyPhasePeimEntryPoint ( IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm b/IntelFsp2Pkg/FspSe= cCore/Ia32/ReadEsp.nasm index 8046b43745..d40dad5a52 100644 --- a/IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm +++ b/IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm @@ -9,14 +9,14 @@ SECTION .text =20 ;-------------------------------------------------------------------------= ----- -; UINT32 +; UINTN ; EFIAPI -; AsmReadEsp ( +; AsmReadStackPointer ( ; VOID ; ); ;-------------------------------------------------------------------------= ----- -global ASM_PFX(AsmReadEsp) -ASM_PFX(AsmReadEsp): +global ASM_PFX(AsmReadStackPointer) +ASM_PFX(AsmReadStackPointer): mov eax, esp ret =20 diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm b/IntelFsp2Pkg/FspSecC= ore/Ia32/Stack.nasm index 5a7e27c240..ce20639890 100644 --- a/IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm +++ b/IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm @@ -9,20 +9,20 @@ ; ;-------------------------------------------------------------------------= ----- =20 -SECTION .text + SECTION .text =20 ;-------------------------------------------------------------------------= ----- ; VOID ; EFIAPI ; SecSwitchStack ( ; UINT32 TemporaryMemoryBase, -; UINT32 PermenentMemoryBase +; UINT32 PermanentMemoryBase ; ); ;-------------------------------------------------------------------------= ----- global ASM_PFX(SecSwitchStack) ASM_PFX(SecSwitchStack): ; - ; Save three register: eax, ebx, ecx + ; Save four register: eax, ebx, ecx, edx ; push eax push ebx @@ -55,7 +55,7 @@ ASM_PFX(SecSwitchStack): mov dword [eax + 12], edx mov edx, dword [esp + 16] ; Update this function's return address= into permanent memory mov dword [eax + 16], edx - mov esp, eax ; From now, esp is pointed to perma= nent memory + mov esp, eax ; From now, esp is pointed to permanent= memory =20 ; ; Fixup the ebp point to permanent memory @@ -63,7 +63,7 @@ ASM_PFX(SecSwitchStack): mov eax, ebp sub eax, ebx add eax, ecx - mov ebp, eax ; From now, ebp is pointed to permanent = memory + mov ebp, eax ; From now, ebp is pointed to permanent= memory =20 pop edx pop ecx diff --git a/IntelFsp2Pkg/FspSecCore/SecFsp.c b/IntelFsp2Pkg/FspSecCore/Sec= Fsp.c index 68e588dd41..85fbc7664c 100644 --- a/IntelFsp2Pkg/FspSecCore/SecFsp.c +++ b/IntelFsp2Pkg/FspSecCore/SecFsp.c @@ -26,7 +26,7 @@ FspGetExceptionHandler ( IA32_IDT_GATE_DESCRIPTOR *IdtGateDescriptor; FSP_INFO_HEADER *FspInfoHeader; =20 - FspInfoHeader =3D (FSP_INFO_HEADER *)AsmGetFspInfoH= eader (); + FspInfoHeader =3D (FSP_INFO_HEADER *)(UINTN)AsmGetF= spInfoHeader (); ExceptionHandler =3D IdtEntryTemplate; IdtGateDescriptor =3D (IA32_IDT_GATE_DESCRIPTOR *)&Exce= ptionHandler; Entry =3D (IdtGateDescriptor->Bits.OffsetHi= gh << 16) | IdtGateDescriptor->Bits.OffsetLow; @@ -115,7 +115,7 @@ SecGetPlatformData ( VOID FspGlobalDataInit ( IN OUT FSP_GLOBAL_DATA *PeiFspData, - IN UINT32 BootLoaderStack, + IN UINTN BootLoaderStack, IN UINT8 ApiIdx ) { @@ -141,7 +141,7 @@ FspGlobalDataInit ( // Get FSP Header offset // It may have multiple FVs, so look into the last one for FSP header // - PeiFspData->FspInfoHeader =3D (FSP_INFO_HEADER *)AsmGetFspInfoHeader (); + PeiFspData->FspInfoHeader =3D (FSP_INFO_HEADER *)(UINTN)AsmGetFspInfoHea= der (); SecGetPlatformData (PeiFspData); =20 // @@ -154,7 +154,7 @@ FspGlobalDataInit ( // FspmUpdDataPtr =3D (VOID *)GetFspApiParameter (); if (FspmUpdDataPtr =3D=3D NULL) { - FspmUpdDataPtr =3D (VOID *)(PeiFspData->FspInfoHeader->ImageBase + Pei= FspData->FspInfoHeader->CfgRegionOffset); + FspmUpdDataPtr =3D (VOID *)(UINTN)(PeiFspData->FspInfoHeader->ImageBas= e + PeiFspData->FspInfoHeader->CfgRegionOffset); } =20 SetFspUpdDataPointer (FspmUpdDataPtr); diff --git a/IntelFsp2Pkg/FspSecCore/SecFsp.h b/IntelFsp2Pkg/FspSecCore/Sec= Fsp.h index 7c9be85fe0..7fb31c3f87 100644 --- a/IntelFsp2Pkg/FspSecCore/SecFsp.h +++ b/IntelFsp2Pkg/FspSecCore/SecFsp.h @@ -48,7 +48,7 @@ FspGetExceptionHandler ( VOID FspGlobalDataInit ( IN OUT FSP_GLOBAL_DATA *PeiFspData, - IN UINT32 BootLoaderStack, + IN UINTN BootLoaderStack, IN UINT8 ApiIdx ); =20 diff --git a/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c b/IntelFsp2Pkg/FspSecCo= re/SecFspApiChk.c index 7d6ef11fe7..a746e8b64e 100644 --- a/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c +++ b/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c @@ -31,7 +31,7 @@ FspApiCallingCheck ( // // NotifyPhase check // - if ((FspData =3D=3D NULL) || ((UINT32)FspData =3D=3D 0xFFFFFFFF)) { + if ((FspData =3D=3D NULL) || ((UINTN)FspData =3D=3D 0xFFFFFFFF)) { Status =3D EFI_UNSUPPORTED; } else { if (FspData->Signature !=3D FSP_GLOBAL_DATA_SIGNATURE) { @@ -42,7 +42,7 @@ FspApiCallingCheck ( // // FspMemoryInit check // - if ((UINT32)FspData !=3D 0xFFFFFFFF) { + if ((UINTN)FspData !=3D 0xFFFFFFFF) { Status =3D EFI_UNSUPPORTED; } else if (EFI_ERROR (FspUpdSignatureCheck (ApiIdx, ApiParam))) { Status =3D EFI_INVALID_PARAMETER; @@ -51,7 +51,7 @@ FspApiCallingCheck ( // // TempRamExit check // - if ((FspData =3D=3D NULL) || ((UINT32)FspData =3D=3D 0xFFFFFFFF)) { + if ((FspData =3D=3D NULL) || ((UINTN)FspData =3D=3D 0xFFFFFFFF)) { Status =3D EFI_UNSUPPORTED; } else { if (FspData->Signature !=3D FSP_GLOBAL_DATA_SIGNATURE) { @@ -62,7 +62,7 @@ FspApiCallingCheck ( // // FspSiliconInit check // - if ((FspData =3D=3D NULL) || ((UINT32)FspData =3D=3D 0xFFFFFFFF)) { + if ((FspData =3D=3D NULL) || ((UINTN)FspData =3D=3D 0xFFFFFFFF)) { Status =3D EFI_UNSUPPORTED; } else { if (FspData->Signature !=3D FSP_GLOBAL_DATA_SIGNATURE) { diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.c b/IntelFsp2Pkg/FspSecCore/Se= cMain.c index d376fb8361..9e9332ffcd 100644 --- a/IntelFsp2Pkg/FspSecCore/SecMain.c +++ b/IntelFsp2Pkg/FspSecCore/SecMain.c @@ -54,7 +54,7 @@ SecStartup ( IN UINT32 TempRamBase, IN VOID *BootFirmwareVolume, IN PEI_CORE_ENTRY PeiCore, - IN UINT32 BootLoaderStack, + IN UINTN BootLoaderStack, IN UINT32 ApiIdx ) { @@ -233,7 +233,7 @@ SecTemporaryRamSupport ( GetFspGlobalDataPointer ()->OnSeparateStack =3D 1; =20 if (PcdGet8 (PcdFspHeapSizePercentage) =3D=3D 0) { - CurrentStack =3D AsmReadEsp (); + CurrentStack =3D AsmReadStackPointer (); FspStackBase =3D (UINTN)GetFspEntryStack (); =20 StackSize =3D FspStackBase - CurrentStack; @@ -292,8 +292,8 @@ SecTemporaryRamSupport ( // permanent memory. // SecSwitchStack ( - (UINT32)(UINTN)OldStack, - (UINT32)(UINTN)NewStack + (UINTN)OldStack, + (UINTN)NewStack ); =20 return EFI_SUCCESS; diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.h b/IntelFsp2Pkg/FspSecCore/Se= cMain.h index 7794255af1..3c60b15f01 100644 --- a/IntelFsp2Pkg/FspSecCore/SecMain.h +++ b/IntelFsp2Pkg/FspSecCore/SecMain.h @@ -51,8 +51,8 @@ typedef struct _SEC_IDT_TABLE { VOID EFIAPI SecSwitchStack ( - IN UINT32 TemporaryMemoryBase, - IN UINT32 PermenentMemoryBase + IN UINTN TemporaryMemoryBase, + IN UINTN PermenentMemoryBase ); =20 /** @@ -104,7 +104,7 @@ SecStartup ( IN UINT32 TempRamBase, IN VOID *BootFirmwareVolume, IN PEI_CORE_ENTRY PeiCore, - IN UINT32 BootLoaderStack, + IN UINTN BootLoaderStack, IN UINT32 ApiIdx ); =20 @@ -127,9 +127,9 @@ ProcessLibraryConstructorList ( @return value of esp. =20 **/ -UINT32 +UINTN EFIAPI -AsmReadEsp ( +AsmReadStackPointer ( VOID ); =20 diff --git a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm= b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm index aef7f96d1d..7be570c4e5 100644 --- a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm +++ b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm @@ -16,7 +16,7 @@ SECTION .text =20 %macro RET_ESI 0 =20 - movd esi, mm7 ; restore ESP from MM7 + movd esi, mm7 ; restore EIP from MM7 jmp esi =20 %endmacro --=20 2.16.2.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 (#88467): https://edk2.groups.io/g/devel/message/88467 Mute This Topic: https://groups.io/mt/90294483/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-